/**
  * Locates and renders the gallery based on the template
  * Will look in the following locations
  *  wp-content/themes/{child-theme}/foogallery/gallery-{template}.php
  *    wp-content/themes/{theme}/foogallery/gallery-{template}.php
  *  wp-content/plugins/foogallery/templates/gallery-{template}.php
  *
  * @param $args array       Arguments passed in from the shortcode
  */
 public function render_template($args)
 {
     //do some work before we locate the template
     global $current_foogallery;
     global $current_foogallery_arguments;
     global $current_foogallery_template;
     //set the arguments
     $current_foogallery_arguments = $args;
     //load our gallery
     $current_foogallery = $this->find_gallery($args);
     if (false === $current_foogallery) {
         //we could not find the gallery!
         _e('The gallery was not found!', 'foogallery');
     } else {
         //find the gallery template we will use to render the gallery
         $current_foogallery_template = $this->get_arg($args, 'template', $current_foogallery->gallery_template);
         //set a default if we have no gallery template
         if (empty($current_foogallery_template)) {
             $current_foogallery_template = foogallery_get_default('gallery_template');
         }
         //check if we have any attachments
         if (!$current_foogallery->has_attachments()) {
             //no attachments!
             do_action("foogallery_template_no_attachments-({$current_foogallery_template})", $current_foogallery);
         } else {
             //create locator instance
             $loader = $this->create_locator_instance();
             if (false !== ($template_location = $loader->locate_file("gallery-{$current_foogallery_template}.php"))) {
                 //we have found a template!
                 do_action('foogallery_located_template', $current_foogallery);
                 do_action("foogallery_located_template-{$current_foogallery_template}", $current_foogallery);
                 //try to include some JS
                 if (false !== ($js_location = $loader->locate_file("gallery-{$current_foogallery_template}.js"))) {
                     wp_enqueue_script("foogallery-template-{$current_foogallery_template}", $js_location['url']);
                     do_action('foogallery_template_enqueue_script', $current_foogallery_template, $js_location['url']);
                 }
                 //try to include some CSS
                 if (false !== ($css_location = $loader->locate_file("gallery-{$current_foogallery_template}.css"))) {
                     foogallery_enqueue_style("foogallery-template-{$current_foogallery_template}", $css_location['url'], array(), FOOGALLERY_VERSION);
                 }
                 //finally include the actual php template!
                 if ($template_location) {
                     load_template($template_location['path'], false);
                 }
                 //cater for lightbox extensions needing to add styles and javascript
                 $lightbox = foogallery_gallery_template_setting('lightbox');
                 if (!empty($lightbox)) {
                     do_action("foogallery_template_lightbox-{$lightbox}", $current_foogallery);
                 }
                 //we have loaded all files, now let extensions do some stuff
                 do_action("foogallery_loaded_template", $current_foogallery);
                 do_action("foogallery_loaded_template-({$current_foogallery_template})", $current_foogallery);
             } else {
                 //we could not find a template!
                 _e('No gallery template found!', 'foogallery');
             }
         }
     }
 }
示例#2
0
 /**
  * Handle a gallery that has a lightbox. This allows us to include any scripts or CSS that is needed for the lightbox
  *
  * @param $gallery FooGallery
  */
 function handle_lightbox_field($gallery)
 {
     if ($gallery->gallery_template_has_field_of_type('lightbox')) {
         $lightbox = foogallery_gallery_template_setting('lightbox');
         if (false != $lightbox) {
             do_action("foogallery_template_lightbox-{$lightbox}", $gallery);
         }
     }
 }
 * FooGallery justufued gallery template
 */
global $current_foogallery;
global $current_foogallery_arguments;
$height = foogallery_gallery_template_setting('thumb_height', '250');
$row_height = foogallery_gallery_template_setting('row_height', '150');
$max_row_height = foogallery_gallery_template_setting('max_row_height', '200%');
if (strpos($max_row_height, '%') !== false) {
    $max_row_height = '"' . $max_row_height . '"';
}
$margins = foogallery_gallery_template_setting('margins', '1');
$captions = foogallery_gallery_template_setting('captions', '') == 'on';
$gutter_width = foogallery_gallery_template_setting('gutter_width', '10');
$args = array('height' => $height, 'link' => foogallery_gallery_template_setting('thumbnail_link', 'image'));
$lightbox = foogallery_gallery_template_setting('lightbox', 'unknown');
$caption_source = foogallery_gallery_template_setting('caption_source', 'title');
?>
<div data-justified-options='{ "rowHeight": <?php 
echo $row_height;
?>
, "maxRowHeight": <?php 
echo $max_row_height;
?>
, "margins": <?php 
echo $margins;
?>
, "captions": <?php 
echo $captions ? 'true' : 'false';
?>
 }' id="foogallery-gallery-<?php 
echo $current_foogallery->ID;
/**
 * FooGallery single thumbnail gallery template
 */
global $current_foogallery;
global $current_foogallery_arguments;
$args = foogallery_gallery_template_setting('thumbnail_dimensions', array());
$lightbox = foogallery_gallery_template_setting('lightbox', 'unknown');
$position = foogallery_gallery_template_setting('position', 'position-block');
$caption_style = foogallery_gallery_template_setting('caption_style', 'caption-simple');
$caption_title = foogallery_gallery_template_setting('caption_title', '');
$caption_desc = foogallery_gallery_template_setting('caption_description', '');
$caption_bgcolor = foogallery_gallery_template_setting('caption_bgcolor', 'rgba(0, 0, 0, 0.8)');
$caption_color = foogallery_gallery_template_setting('caption_color', '#fff');
$featured_attachment = $current_foogallery->featured_attachment($args);
$thumb_url = $featured_attachment->url;
if (foogallery_gallery_template_setting('link_custom_url', '') == 'on') {
    if (!empty($featured_attachment->custom_url)) {
        $thumb_url = $featured_attachment->custom_url;
    }
    $args['link'] = 'custom';
}
$args['link_attributes'] = array('rel' => 'foobox[' . $current_foogallery->ID . ']');
?>
<div id="foogallery-gallery-<?php 
echo $current_foogallery->ID;
?>
" class="<?php 
echo foogallery_build_class_attribute($current_foogallery, 'foogallery-lightbox-' . $lightbox, $caption_style, $position);
?>
">
    <?php 
<?php

/**
 * FooGallery portfolio gallery template
 */
global $current_foogallery;
global $current_foogallery_arguments;
$args = foogallery_gallery_template_setting('thumbnail_dimensions', array());
$args['link'] = foogallery_gallery_template_setting('thumbnail_link', 'image');
$args['image_attributes'] = array('class' => 'bf-img', 'height' => $args['height']);
$lightbox = foogallery_gallery_template_setting('lightbox', 'unknown');
$gutter = foogallery_gallery_template_setting('gutter', 40);
?>
<div data-brickfolio-gutter="<?php 
echo $gutter;
?>
" id="foogallery-gallery-<?php 
echo $current_foogallery->ID;
?>
" class="<?php 
echo foogallery_build_class_attribute($current_foogallery, 'foogallery-lightbox-' . $lightbox, 'brickfolio');
?>
">
<?php 
foreach ($current_foogallery->attachments() as $attachment) {
    echo '<div class="bf-item" style="width:' . $args['width'] . 'px">';
    echo $attachment->html($args);
    if ($attachment->caption) {
        echo '<h4>' . $attachment->caption . '</h4>';
    }
    if ($attachment->description) {
示例#6
0
<?php

/**
 * FooGallery default responsive gallery template
 */
global $current_foogallery;
global $current_foogallery_arguments;
$args = foogallery_gallery_template_setting('thumbnail_dimensions', array());
$link = foogallery_gallery_template_setting('thumbnail_link', 'image');
$args['link'] = $link;
$lightbox = foogallery_gallery_template_setting('lightbox', 'unknown');
$spacing = foogallery_gallery_template_setting('spacing', '');
$hover_effect = foogallery_gallery_template_setting('hover-effect', 'hover-effect-zoom');
$border_style = foogallery_gallery_template_setting('border-style', 'border-style-square-white');
$alignment = foogallery_gallery_template_setting('alignment', 'alignment-center');
?>
<div id="foogallery-gallery-<?php 
echo $current_foogallery->ID;
?>
" class="<?php 
echo foogallery_build_class_attribute($current_foogallery, 'foogallery-link-' . $link, 'foogallery-lightbox-' . $lightbox, $spacing, $hover_effect, $border_style, $alignment);
?>
">
	<?php 
foreach ($current_foogallery->attachments() as $attachment) {
    echo $attachment->html($args);
}
?>
	<div style="clear:both"></div>
</div>
<?php

/**
 * FooGallery justufued gallery template
 */
global $current_foogallery;
global $current_foogallery_arguments;
$height = foogallery_gallery_template_setting('row_height', '150');
$margins = foogallery_gallery_template_setting('margins', '1');
$captions = foogallery_gallery_template_setting('captions', 'on') == 'on';
$gutter_width = foogallery_gallery_template_setting('gutter_width', '10');
$args = array('height' => $height, 'link' => foogallery_gallery_template_setting('thumbnail_link', 'image'));
$lightbox = foogallery_gallery_template_setting('lightbox', 'unknown');
?>
<div id="foogallery-gallery-<?php 
echo $current_foogallery->ID;
?>
" class="<?php 
echo foogallery_build_class_attribute($current_foogallery, 'foogallery-lightbox-' . $lightbox);
?>
">
	<?php 
foreach ($current_foogallery->attachments() as $attachment) {
    echo $attachment->html($args, true, false);
    if ($captions) {
        echo '<div class="caption">' . $attachment->caption . '</div>';
    }
    echo '</a>';
}
?>
</div>
示例#8
0
 * FooGallery default responsive gallery template
 */
global $current_foogallery;
global $current_foogallery_arguments;
$args = foogallery_gallery_template_setting('thumbnail_dimensions', array());
$link = foogallery_gallery_template_setting('thumbnail_link', 'image');
$args['link'] = $link;
$lightbox = foogallery_gallery_template_setting('lightbox', 'unknown');
$spacing = foogallery_gallery_template_setting('spacing', '');
$hover_effect = foogallery_gallery_template_setting('hover-effect', 'hover-effect-zoom');
$border_style = foogallery_gallery_template_setting('border-style', 'border-style-square-white');
$alignment = foogallery_gallery_template_setting('alignment', 'alignment-center');
$hover_effect_type = foogallery_gallery_template_setting('hover-effect-type', '');
$caption_hover_effect = foogallery_gallery_template_setting('caption-hover-effect', 'hover-caption-simple');
$caption_content = foogallery_gallery_template_setting('caption-content', 'title');
$loading_animation = 'yes' === foogallery_gallery_template_setting('loading_animation', 'yes') ? 'foogallery-default-loading' : '';
if ('hover-effect-caption' === $hover_effect_type) {
    $hover_effect = '';
}
?>
<div id="foogallery-gallery-<?php 
echo $current_foogallery->ID;
?>
" class="<?php 
echo foogallery_build_class_attribute($current_foogallery, 'foogallery-link-' . $link, 'foogallery-lightbox-' . $lightbox, $spacing, $hover_effect, $hover_effect_type, $border_style, $alignment, $caption_hover_effect, $loading_animation);
?>
">
	<?php 
foreach ($current_foogallery->attachments() as $attachment) {
    echo $attachment->html($args, true, false);
    if ('hover-effect-caption' === $hover_effect_type) {
<?php

/**
 * FooGallery single thumbnail gallery template
 */
global $current_foogallery;
global $current_foogallery_arguments;
$args = foogallery_gallery_template_setting('thumbnail_dimensions', array());
$lightbox = foogallery_gallery_template_setting('lightbox', 'unknown');
$position = foogallery_gallery_template_setting('position', 'position-block');
$caption_style = foogallery_gallery_template_setting('caption_style', 'caption-simple');
$caption_title = foogallery_gallery_template_setting('caption_title', '');
$caption_desc = foogallery_gallery_template_setting('caption_description', '');
$caption_bgcolor = foogallery_gallery_template_setting('caption_bgcolor', 'rgba(0, 0, 0, 0.8)');
$caption_color = foogallery_gallery_template_setting('caption_color', '#fff');
$featured_attachment = $current_foogallery->featured_attachment($args);
?>
<div id="foogallery-gallery-<?php 
echo $current_foogallery->ID;
?>
" class="<?php 
echo foogallery_build_class_attribute($current_foogallery, 'foogallery-lightbox-' . $lightbox, $caption_style, $position);
?>
">
    <a href="<?php 
echo $featured_attachment->url;
?>
">
        <?php 
echo $featured_attachment->html_img($args);
?>
示例#10
0
<?php

/**
 * FooGallery default responsive gallery template
 */
global $current_foogallery;
global $current_foogallery_arguments;
$args = foogallery_gallery_template_setting('thumbnail_dimensions', array());
$link = foogallery_gallery_template_setting('thumbnail_link', 'image');
$args['link'] = $link;
$lightbox = foogallery_gallery_template_setting('lightbox', 'unknown');
$spacing = foogallery_gallery_template_setting('spacing', '');
$hover_effect = foogallery_gallery_template_setting('hover-effect', 'hover-effect-zoom');
$border_style = foogallery_gallery_template_setting('border-style', 'border-style-square-white');
$alignment = foogallery_gallery_template_setting('alignment', 'alignment-center');
$hover_effect_type = foogallery_gallery_template_setting('hover-effect-type', '');
?>
<div id="foogallery-gallery-<?php 
echo $current_foogallery->ID;
?>
" class="<?php 
echo foogallery_build_class_attribute($current_foogallery, 'foogallery-link-' . $link, 'foogallery-lightbox-' . $lightbox, $spacing, $hover_effect, $hover_effect_type, $border_style, $alignment, 'foogallery-default-loading');
?>
">
	<?php 
foreach ($current_foogallery->attachments() as $attachment) {
    echo $attachment->html($args);
}
?>
</div>
$autoplay = foogallery_gallery_template_setting('autoplay', 'true');
$hash = foogallery_gallery_template_setting('hash', 'true');
$pause = foogallery_gallery_template_setting('pause', 'true');
$seconds = foogallery_gallery_template_setting('seconds', '4000');
$loop = foogallery_gallery_template_setting('loop', 'true');
$margin = foogallery_gallery_template_setting('margin', '10');
$hover_effect = foogallery_gallery_template_setting('hover-effect', 'hover-effect-zoom');
$border_style = foogallery_gallery_template_setting('border-style', 'border-style-square-white');
$animation = foogallery_gallery_template_setting('animation', false);
$showdesc = foogallery_gallery_template_setting('showdesc', false);
$advanced = foogallery_gallery_template_setting('enable_advanced', 'no');
$responsive = foogallery_gallery_template_setting('enable-responsive', 'no');
$itemsat0 = foogallery_gallery_template_setting('items-at-0', false);
$itemsat480 = foogallery_gallery_template_setting('items-at-480', false);
$itemsat960 = foogallery_gallery_template_setting('items-at-960', false);
$autowidth = foogallery_gallery_template_setting('autowidth', false);
if ($border_style == '' || $border_style == 'border-style-rounded') {
    $hasborder = '';
} else {
    $hasborder = 'hasborder';
}
//general FooGallery settings that are useful for owl
if ($hasborder == 'hasborder') {
    $height = $args['height'] + 20;
} else {
    $height = $args['height'];
}
$width = $args['width'];
//image width
$gallid = $current_foogallery->ID;
// current FooGallery ID
.fiv-custom > .fiv-inner > .fiv-ctrls > .fiv-next {
		border-color: <?php 
    echo foogallery_gallery_template_setting('theme_custom_bordercolor', '#e6e6e6');
    ?>
;
	}
	#foogallery-gallery-<?php 
    echo $current_foogallery->ID;
    ?>
.fiv-custom > .fiv-inner > .fiv-ctrls > .fiv-prev:hover,
	#foogallery-gallery-<?php 
    echo $current_foogallery->ID;
    ?>
.fiv-custom > .fiv-inner > .fiv-ctrls > .fiv-next:hover {
		background-color: <?php 
    echo foogallery_gallery_template_setting('theme_custom_hovercolor', '#F2F2F2');
    ?>
;
	}
</style>
<?php 
}
?>
<div id="foogallery-gallery-<?php 
echo $current_foogallery->ID;
?>
" class="<?php 
echo foogallery_build_class_attribute($current_foogallery, 'foogallery-link-' . $link, 'foogallery-lightbox-' . $lightbox, $theme, $hover_effect, $hover_effect_type, $alignment);
?>
">
	<div class="fiv-inner">
    $max_row_height = '"' . $max_row_height . '"';
}
$margins = foogallery_gallery_template_setting('margins', '1');
$caption_source = foogallery_gallery_template_setting('caption_source', 'title');
if (foogallery_gallery_template_setting('caption_source', '') == 'none') {
    $captions = false;
} else {
    $captions = true;
}
$thumb_size = foogallery_gallery_template_setting('thumbnail_size', 'dynamic');
$thumb_link = foogallery_gallery_template_setting('thumbnail_link', 'image');
$lightbox = foogallery_gallery_template_setting('lightbox', 'unknown');
$page_mode = foogallery_gallery_template_setting('advance-page-mode', 'page');
$first_page = foogallery_gallery_template_setting('first_page', '10');
$per_page = foogallery_gallery_template_setting('per_page', '10');
$footer_offset = foogallery_gallery_template_setting('footer_offset', '300');
$total_count = sizeof($current_foogallery->attachments());
// Set the args to be used to generate the html code (image links, etc.)
$args = array('height' => $height, 'link' => $thumb_link, 'thumb_size' => $thumb_size);
//future enhancement to allow setting this parameter...hard code for now.
$last_row = "justify";
$last_row = '"' . $last_row . '"';
?>
<div data-justified-options='{ "rowHeight": <?php 
echo $height;
?>
, 
	"maxRowHeight": <?php 
echo $max_row_height;
?>
, "margins": <?php