Exemple #1
0
 static function loadBaseURL()
 {
     $absolute_plugin_folder = RealPath(self::$plugin_folder);
     if (StrPos($absolute_plugin_folder, ABSPATH) === 0) {
         self::$base_url = Get_Bloginfo('wpurl') . '/' . SubStr($absolute_plugin_folder, Strlen(ABSPATH));
     } else {
         self::$base_url = Plugins_Url(BaseName(self::$plugin_folder));
     }
     self::$base_url = Str_Replace("\\", '/', self::$base_url);
     # Windows Workaround
 }
<?php

/*
Fancy Gallery Template: Thumbnails / Image Title with Share buttons
Description: This template displays the thumbnail images and the image title with share buttons.
Version: 1.0.1
Author: Dennis Hoppe
Author URI: http://DennisHoppe.de
*/
// Read base url
$base_url = SPrintF('%s/%s', Get_Bloginfo('wpurl'), SubStr(RealPath(DirName(__FILE__)), Strlen(ABSPATH)));
$base_url = Str_Replace("\\", '/', $base_url);
// Windows Workaround
?>
<div class="gallery fancy-gallery <?php 
echo BaseName(__FILE__, '.php');
?>
" id="gallery_<?php 
echo $this->gallery->id;
?>
"><?php 
foreach ($this->gallery->images as $image) {
    // Build <img> Tags
    $img_code = '<img';
    foreach ($image->attributes as $attribute => $value) {
        $img_code .= SPrintF(' %s="%s"', $attribute, HTMLSpecialChars(Strip_Tags($value)));
    }
    $img_code .= '>';
    // Build FB share button
    $fb_code = SPrintF('<a href="%1$s" title="%2$s" class="%3$s" target="_blank">%4$s</a>', SPrintF('https://www.facebook.com/sharer/sharer.php?u=%s', $image->href), HTMLSpecialChars($image->title), $this->gallery->attributes->link_class, SPrintF('<img src="%s/facebook-button.png" alt="Share it" height="20">', $base_url));
    // Build Pintarest share button
Exemple #3
0
 public function Get_Template_Files()
 {
     $arr_template = Array_Unique(Array_Merge((array) Glob(DirName(__FILE__) . '/templates/*.php'), (array) Glob(DirName(__FILE__) . '/templates/*/*.php'), (array) Glob(Get_StyleSheet_Directory() . '/*.php'), (array) Glob(Get_StyleSheet_Directory() . '/*/*.php'), Is_Child_Theme() ? (array) Glob(Get_Template_Directory() . '/*.php') : array(), Is_Child_Theme() ? (array) Glob(Get_Template_Directory() . '/*/*.php') : array(), (array) Glob($this->template_dir . '/*.php'), (array) Glob($this->template_dir . '/*/*.php')));
     # Filter to add template files - you can use this filter to add template files to the user interface
     $arr_template = Apply_Filters('fancy_gallery_template_files', $arr_template);
     # Check if there template files
     if (empty($arr_template)) {
         return False;
     }
     $arr_result = array();
     $arr_sort = array();
     foreach ($arr_template as $index => $template_file) {
         # Read meta data from the template
         if ($arr_properties = $this->Get_Template_Properties($template_file)) {
             $stylesheet_file = SubStr($template_file, 0, -4) . '.css';
             $stylesheet_url = Is_File($stylesheet_file);
             if ($stylesheet_url) {
                 if (StrPos($stylesheet_file, DirName(__FILE__)) === 0) {
                     # the template is inside the plugin folder
                     $stylesheet_url = $this->base_url . SubStr($stylesheet_file, StrLen(DirName(__FILE__)));
                 } elseif (StrPos($stylesheet_file, ABSPATH) === 0) {
                     # the template is inside the wordpress folder
                     $stylesheet_url = Get_Bloginfo('wpurl') . '/' . SubStr($stylesheet_file, Strlen(ABSPATH));
                 } else {
                     $stylesheet_url = $stylesheet_file = False;
                 }
             }
             $arr_result[$arr_properties['name']] = Array_Merge($arr_properties, array('file' => $template_file, 'stylesheet_file' => Is_File($stylesheet_file) ? $stylesheet_file : False, 'stylesheet_uri' => $stylesheet_url));
             $arr_sort[$arr_properties['name']] = StrToLower($arr_properties['name']);
         } else {
             continue;
         }
     }
     Array_MultiSort($arr_sort, SORT_STRING, SORT_ASC, $arr_result);
     return $arr_result;
 }
 function Enqueue_Frontend_Scripts()
 {
     WP_Enqueue_Script('jquery.mousewheel', $this->base_url . '/js/jquery.mousewheel.js', array('jquery'), '3.0.6', $this->get_option('script_position') != 'header');
     WP_Enqueue_Script('fancybox', $this->base_url . '/fancybox/jquery.fancybox.js', array('jquery'), '2.1.4', $this->get_option('script_position') != 'header');
     WP_Enqueue_Style('fancybox', $this->base_url . '/fancybox/fancybox.css', Null, '2.1.4');
     WP_Enqueue_Script('fancybox-buttons', $this->base_url . '/fancybox/jquery.fancybox-buttons.js', array('jquery', 'fancybox'), '1.0.5', $this->get_option('script_position') != 'header');
     WP_Enqueue_Script('fancybox-media', $this->base_url . '/fancybox/jquery.fancybox-media.js', array('jquery', 'fancybox'), '1.0.5', $this->get_option('script_position') != 'header');
     WP_Enqueue_Script('fancybox-thumbs', $this->base_url . '/fancybox/jquery.fancybox-thumbs.js', array('jquery', 'fancybox'), '1.0.7', $this->get_option('script_position') != 'header');
     WP_Enqueue_Script('fancy-gallery', $this->base_url . '/js/fancy-gallery.js', array('jquery', 'fancybox'), $this->version, $this->get_option('script_position') != 'header');
     // Add image descriptions as title if required
     if ($this->get_option('use_as_image_title') == 'description') {
         // Collect image titles
         $arr_image_titles = array();
         foreach (Get_Posts(array('post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => -1, 'order' => 'ASC', 'orderby' => 'ID')) as $i => $image) {
             $arr_image_titles[$image->ID] = $this->get_image_title($image);
         }
         // Add image title to the images
         WP_Localize_Script('fancy-gallery', 'IMAGETITLES', $arr_image_titles);
     }
     // Add the plugin options to the JS front end
     $arr_options = $this->Get_Option();
     unset($arr_options['disable_update_notification']);
     unset($arr_options['update_username']);
     unset($arr_options['update_password']);
     WP_Localize_Script('fancy-gallery', 'FANCYGALLERY', $arr_options);
     // Enqueue Template Stylesheets
     foreach ($this->Get_Template_Files() as $template_name => $template_properties) {
         $style_sheet_name = BaseName($template_properties['file'], '.php') . '.css';
         $style_sheet_file = DirName($template_properties['file']) . '/' . $style_sheet_name;
         if (!Is_File($style_sheet_file)) {
             continue;
         }
         $template_dir = DirName($style_sheet_file);
         $style_sheet_id = 'fancy-gallery-template-' . Sanitize_Title($template_name);
         $template_base_url = Get_Bloginfo('wpurl') . '/' . SubStr($template_dir, Strlen(ABSPATH));
         $template_base_url = Str_Replace("\\", '/', $template_base_url);
         // Windows workaround
         WP_Enqueue_Style($style_sheet_id, $template_base_url . '/' . $style_sheet_name);
     }
 }