?> <h2><?php echo esc_html($title); ?> </h2> <?php } ?> <?php if ($description) { ?> <h4><?php echo esc_html($description); ?> </h4> <?php } ?> <?php if ($buttons) { while (has_sub_field('buttons')) { GRAV_BLOCKS::get_link_html('button', 'button'); } } ?> </div> </div> </div> <?php }
<div class="block-inner num-col-<?php echo $cols_count; ?> "> <div class="<?php echo GRAV_BLOCKS::css()->row()->get(); ?> "> <?php if (have_rows('content_column')) { while (have_rows('content_column')) { the_row(); ?> <div class="<?php echo GRAV_BLOCKS::css()->col(12, $cols_count < 3 ? $cols_span : 12, $cols_count >= 3 ? $cols_span : 12)->get(); ?> "> <?php the_sub_field('column'); ?> </div> <?php } } ?> </div> </div> <?php }
<?php if ($link = GRAV_BLOCKS::get_link_url('link')) { ?> <a class="block-link-<?php echo esc_attr(get_sub_field('link_type')); ?> " href="<?php echo esc_url($link); ?> "> <?php } ?> <?php echo GRAV_BLOCKS::image(get_sub_field('image')); ?> <?php if ($link) { ?> </a> <?php } ?> </div> <div class="<?php echo $bottom_classes; ?> "> <?php
<?php /* * * Gravitate Content Block * * Available Variables: * $block = Name of Block Folder * $block_backgrounds = Array for Background Options * $block_background_image = Array for Background Image Option * * This file must return an array(); * */ $block_fields = array($block_backgrounds, $block_background_image, array('key' => 'field_' . $block . '_1', 'label' => 'Gallery Title', 'name' => 'gallery_title', 'type' => 'text', 'column_width' => '', 'default_value' => '', 'instructions' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', 'formatting' => 'none', 'maxlength' => ''), array('key' => 'field_' . $block . '_11', 'label' => 'Place Item Titles Below Image', 'name' => 'move_title', 'type' => 'true_false', 'instructions' => 'By default, individual gallery item titles show above their respective images.', 'message' => '', 'default_value' => 0), array('key' => 'field_' . $block . '_2', 'label' => 'Gallery Items', 'name' => 'gallery_items', 'type' => 'repeater', 'column_width' => '', 'instructions' => '', 'sub_fields' => array(array('key' => 'field_' . $block . '_8', 'label' => 'Item Title', 'name' => 'item_title', 'type' => 'text', 'column_width' => '', 'default_value' => '', 'instructions' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', 'formatting' => 'none', 'maxlength' => ''), array('key' => 'field_' . $block . '_9', 'label' => 'Image', 'name' => 'item_image', 'instructions' => '', 'type' => 'image', 'column_width' => '', 'save_format' => 'object', 'library' => 'all', 'preview_size' => 'medium'), GRAV_BLOCKS::get_link_fields('link', '', false), array('key' => 'field_' . $block . '_10', 'label' => 'Content', 'name' => 'item_content', 'type' => 'textarea', 'column_width' => '', 'default_value' => '')), 'min' => '', 'max' => '', 'layout' => 'row', 'button_label' => 'Add Gallery Item')); $sub_fields = array_merge(GRAV_BLOCKS::get_additional_fields(), $block_fields); return array('name' => $block, 'label' => 'Media Gallery', 'display' => 'block', 'sub_fields' => $sub_fields, 'min' => '', 'max' => '', 'grav_blocks_settings' => array('icon' => 'gravicon-gallery', 'description' => '<div class="row"> <div class="columns medium-6"> <img src="' . plugins_url() . '/gravitate-blocks/grav-blocks/media-gallery/gallery.svg"> </div> <div class="columns medium-6"> <p>When you want to display more than one image, this flexible block is the way to go. It allows for multiple gallery items each with an ability for a title, image, link and description. Each image will also display in a gallery modal if no link is clicked.</p> <p><strong>Available Fields:</strong></p> <ul> <li>Background</li> <li>Gallery Title</li> <li>Gallery Item <ul> <li>Item Title</li> <li>Image</li> <li>Link <em>( Page, URL, File, Video )</em></li>
<?php if ($image) { ?> <img src="<?php echo esc_attr($image['sizes']['thumbnail']); ?> " alt="<?php echo esc_attr($image['alt']); ?> "> <?php } ?> </div> <div class="<?php echo GRAV_BLOCKS::css()->col(12, 10)->get(); ?> "> <blockquote class="testimonial">“<?php the_sub_field('testimonial'); ?> ” <footer> <cite><?php the_sub_field('attribution'); ?> </cite> </footer> </blockquote> </div> </div>
<?php if ($link = GRAV_BLOCKS::get_link_url('link')) { ?> <a class="block-link-<?php echo esc_attr(get_sub_field('link_type')); ?> " href="<?php echo esc_url($link); ?> "> <?php } ?> <?php echo GRAV_BLOCKS::image($image); ?> <?php if ($link) { ?> </a> <?php } ?> <?php if ($padding) { ?> </div><?php } ?>
/** * Outputs the Grav Blocks * * @param string $args - Currently the two options for the array are 'section' and 'object' * * @return type */ public static function display($args = array()) { // Check $args array if it exists and what is set. $section = !empty($args) && isset($args['section']) ? $args['section'] : 'grav_blocks'; $object = !empty($args) && isset($args['object']) ? $args['object'] : false; $query_target = $object ? $object : (($query = get_queried_object()) && !empty($query->term_id) ? $query : ''); if (self::is_viewable()) { $handler_file = self::get_path('handler.php'); self::$block_index = 0; if ($handler_file && get_field($section, $query_target)) { while (the_flexible_field($section, $query_target)) { self::$block_index++; $block_class_prefix = 'block'; $unique_id = GRAV_BLOCKS_PLUGIN_SETTINGS::is_setting_checked('advanced_options', 'add_unique_id') && ($uid = get_sub_field('unique_id')) ? 'id=' . sanitize_title($uid) . '' : ''; self::$current_block_name = strtolower(str_replace('_', '-', get_row_layout())); $block_background = ($block_bg = get_sub_field('block_background')) ? $block_bg : 'block-bg-none'; if (!empty(self::$settings['background_colors'])) { foreach (self::$settings['background_colors'] as $color_key => $color_params) { $use_css_variable = !empty($color_params['class']) && GRAV_BLOCKS_PLUGIN_SETTINGS::is_setting_checked('css_options', 'add_custom_color_class'); if (!empty($color_params['_repeater_id']) && $block_background === 'block-bg-' . $color_params['_repeater_id'] && $use_css_variable) { if (!GRAV_BLOCKS_PLUGIN_SETTINGS::is_setting_checked('css_options', 'enqueue_css')) { $block_background = ''; } $block_background .= ' ' . $color_params['class']; } } } $block_background_image = get_sub_field('block_background_image'); $block_background_image_url = $block_background_image['url']; $block_section_attributes = ''; $block_background_style = $block_background === 'block-bg-image' && $block_background_image ? ' background-image: url(\'' . $block_background_image_url . '\'); ' : ''; if (GRAV_BLOCKS_PLUGIN_SETTINGS::is_setting_checked('advanced_options', 'add_responsive_img')) { if ($block_background === 'block-bg-image') { $block_section_attributes = GRAV_BLOCKS::image_sources($block_background_image); $block_background_style = ''; } } include $handler_file; } } } }
$block_section_attributes $block_index $unique_id = if activated */ $classes = array($block_class_prefix . '-container', $block_class_prefix . '-' . GRAV_BLOCKS::$current_block_name, $block_background, 'block-index-' . GRAV_BLOCKS::$block_index); $block_style_attr = apply_filters('grav_block_background_style', $block_background_style); ?> <section <?php echo esc_attr($unique_id); ?> <?php echo $block_section_attributes; ?> class="<?php echo GRAV_BLOCKS::css()->add($classes)->get(); ?> " <?php if ($block_style_attr) { echo ' style="' . $block_style_attr . '"'; } ?> > <?php GRAV_BLOCKS::get_block(GRAV_BLOCKS::$current_block_name); ?> </section>