/**
  * Locates and renders the album based on the template
  * Will look in the following locations
  *  wp-content/themes/{child-theme}/foogallery/album-{template}.php
  *    wp-content/themes/{theme}/foogallery/album-{template}.php
  *  wp-content/plugins/foogallery/templates/album-{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_album;
     global $current_foogallery_album_arguments;
     global $current_foogallery_album_template;
     //set the arguments
     $current_foogallery_album_arguments = $args;
     //load our album
     $current_foogallery_album = $this->find_album($args);
     if (false === $current_foogallery_album) {
         _e('Could not load the album!', 'foogallery');
         return;
     }
     //find the gallery template we will use to render the gallery
     $current_foogallery_album_template = $this->get_arg($args, 'template', $current_foogallery_album->album_template);
     //set a default if we have no gallery template
     if (empty($current_foogallery_album_template)) {
         $current_foogallery_album_template = foogallery_get_default('album_template');
     }
     //if we still have not default, then use the first one we can find
     if (empty($current_foogallery_album_template)) {
         $available_templates = foogallery_album_templates();
         $current_foogallery_album_template = $available_templates[0]['slug'];
     }
     //check if we have any galleries
     if (!$current_foogallery_album->has_galleries()) {
         //no galleries!
         do_action("foogallery_album_template_no_galleries-({$current_foogallery_album_template})", $current_foogallery_album);
     } else {
         //create locator instance
         $instance_name = FOOGALLERY_SLUG . '_album_templates';
         $loader = new Foo_Plugin_File_Locator_v1($instance_name, FOOGALLERY_FILE, 'templates', FOOGALLERY_SLUG);
         //allow extensions to very easily add pickup locations for their files
         $this->add_extension_pickup_locations($loader, apply_filters($instance_name . '_files', array()));
         if (false !== ($template_location = $loader->locate_file("album-{$current_foogallery_album_template}.php"))) {
             //we have found a template!
             do_action('foogallery_located_album_template', $current_foogallery_album);
             do_action("foogallery_located_album_template-{$current_foogallery_album_template}", $current_foogallery_album);
             //try to include some JS
             if (false !== ($js_location = $loader->locate_file("album-{$current_foogallery_album_template}.js"))) {
                 wp_enqueue_script("foogallery-album-template-{$current_foogallery_album_template}", $js_location['url']);
             }
             //try to include some CSS
             if (false !== ($css_location = $loader->locate_file("album-{$current_foogallery_album_template}.css"))) {
                 wp_enqueue_style("foogallery-album-template-{$current_foogallery_album_template}", $css_location['url']);
             }
             //finally include the actual php template!
             if ($template_location) {
                 load_template($template_location['path'], false);
             }
             //we have loaded all files, now let extensions do some stuff
             do_action("foogallery_loaded_album_template", $current_foogallery_album);
             do_action("foogallery_loaded_album_template-({$current_foogallery_album_template})", $current_foogallery_album);
         } else {
             //we could not find a template!
             _e('No album template found!', 'foogallery');
         }
     }
 }
 /**
  * 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');
             }
         }
     }
 }
 /**
  * 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
             $instance_name = FOOGALLERY_SLUG . '_gallery_templates';
             $loader = new Foo_Plugin_File_Locator_v1($instance_name, FOOGALLERY_FILE, 'templates', FOOGALLERY_SLUG);
             //allow extensions to very easily add pickup locations for their files
             $this->add_extension_pickup_locations($loader, apply_filters($instance_name . '_files', array()));
             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']);
                 }
                 //try to include some CSS
                 if (false !== ($css_location = $loader->locate_file("gallery-{$current_foogallery_template}.css"))) {
                     wp_enqueue_style("foogallery-template-{$current_foogallery_template}", $css_location['url']);
                 }
                 //finally include the actual php template!
                 if ($template_location) {
                     load_template($template_location['path'], false);
                 }
                 //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');
             }
         }
     }
 }
 function create_settings()
 {
     //region General Tab
     $tabs['general'] = __('General', 'foogallery');
     $gallery_templates = foogallery_gallery_templates();
     $gallery_templates_choices = array();
     foreach ($gallery_templates as $template) {
         $gallery_templates_choices[$template['slug']] = $template['name'];
     }
     $settings[] = array('id' => 'gallery_template', 'title' => __('Default Gallery Template', 'foogallery'), 'desc' => __('The default gallery template to use for new galleries', 'foogallery'), 'default' => foogallery_get_default('gallery_template'), 'type' => 'select', 'choices' => $gallery_templates_choices, 'tab' => 'general');
     $settings[] = array('id' => 'gallery_sorting', 'title' => __('Default Gallery Sorting', 'foogallery'), 'desc' => __('The default attachment sorting to use for new galleries', 'foogallery'), 'default' => '', 'type' => 'select', 'choices' => foogallery_sorting_options(), 'tab' => 'general');
     $settings[] = array('id' => 'hide_gallery_template_help', 'title' => __('Hide Gallery Template Help', 'foogallery'), 'desc' => __('Some gallery templates show helpful tips, which are useful for new users. You can choose to hide these tips.', 'foogallery'), 'type' => 'checkbox', 'tab' => 'general');
     $galleries = foogallery_get_all_galleries();
     $gallery_choices = array();
     foreach ($galleries as $gallery) {
         $gallery_choices[$gallery->ID] = $gallery->name;
     }
     $settings[] = array('id' => 'default_gallery_settings', 'title' => __('Default Gallery Settings', 'foogallery'), 'desc' => __('When creating a new gallery, it can use the settings from an existing gallery as the default settings. This will save you time when creating many galleries that all have the same look and feel.', 'foogallery'), 'type' => 'select', 'choices' => $gallery_choices, 'tab' => 'general');
     //endregion General
     //region Extensions Tab
     $tabs['extensions'] = __('Extensions', 'foogallery');
     $settings[] = array('id' => 'use_future_endpoint', 'title' => __('Use Beta Endpoint', 'foogallery'), 'desc' => __('The list of available extensions are pulled from an external URL. You can also pull from a "beta" endpoint which will sometimes contain beta extensions that are not publicly available.', 'foogallery'), 'type' => 'checkbox', 'tab' => 'extensions');
     //region Thumbnail Tab
     $tabs['thumb'] = __('Thumbnails', 'foogallery');
     $settings[] = array('id' => 'thumb_jpeg_quality', 'title' => __('JPEG Quality', 'foogallery'), 'desc' => __('The image quality to be used when resizing JPEG images.', 'foogallery'), 'type' => 'text', 'default' => '80', 'tab' => 'thumb');
     $settings[] = array('id' => 'thumb_resize_animations', 'title' => __('Resize Animated GIFs', 'foogallery'), 'desc' => __('Should animated gifs be resized or not. If enabled, only the first frame is used in the resize.', 'foogallery'), 'type' => 'checkbox', 'tab' => 'thumb');
     //endregion Thumbnail Tab
     //	        //region Advanced Tab
     //	        $tabs['advanced'] = __( 'Advanced', 'foogallery' );
     //
     //	        $example_url = '<code>' . trailingslashit( site_url() ) . foogallery_permalink() . '/my-cool-gallery</code>';
     //
     //	        $settings[] = array(
     //		        'id'      => 'gallery_permalinks_enabled',
     //		        'title'   => __( 'Enable Friendly URL\'s', 'foogallery' ),
     //		        'desc'    => sprintf( __( 'If enabled, you will be able to access your galleries from a friendly URL e.g. %s', 'foogallery' ), $example_url ),
     //		        'default' => foogallery_get_default( 'gallery_permalinks_enabled' ),
     //		        'type'    => 'checkbox',
     //		        'tab'     => 'advanced',
     //	        );
     //
     //	        $settings[] = array(
     //		        'id'      => 'gallery_permalink',
     //		        'title'   => __( 'Gallery Permalink', 'foogallery' ),
     //		        'desc'    => __( 'If friendly URL\'s are enabled, this is used in building up a friendly URL', 'foogallery' ),
     //		        'default' => foogallery_get_default( 'gallery_permalink' ),
     //		        'type'    => 'text',
     //		        'tab'     => 'advanced',
     //	        );
     //	        //endregion Advanced
     return apply_filters('foogallery_admin_settings_override', array('tabs' => $tabs, 'sections' => array(), 'settings' => $settings));
 }
/**
 * Return the FooGallery saved setting, or a default value
 *
 * @param string $key The key for the setting
 *
 * @param bool $default The default if no value is saved or found
 *
 * @return mixed
 */
function foogallery_get_setting($key, $default = false)
{
    $foogallery = FooGallery_Plugin::get_instance();
    return $foogallery->options()->get($key, foogallery_get_default($key, $default));
}
Beispiel #6
0
 function create_settings()
 {
     //region General Tab
     $tabs['general'] = __('General', 'foogallery');
     $gallery_templates = foogallery_gallery_templates();
     $gallery_templates_choices = array();
     foreach ($gallery_templates as $template) {
         $gallery_templates_choices[$template['slug']] = $template['name'];
     }
     $settings[] = array('id' => 'gallery_template', 'title' => __('Default Gallery Template', 'foogallery'), 'desc' => __('The default gallery template to use for new galleries', 'foogallery'), 'default' => foogallery_get_default('gallery_template'), 'type' => 'select', 'choices' => $gallery_templates_choices, 'tab' => 'general', 'section' => __('Gallery Defaults', 'foogallery'));
     $settings[] = array('id' => 'gallery_sorting', 'title' => __('Default Gallery Sorting', 'foogallery'), 'desc' => __('The default attachment sorting to use for new galleries', 'foogallery'), 'default' => '', 'type' => 'select', 'choices' => foogallery_sorting_options(), 'tab' => 'general', 'section' => __('Gallery Defaults', 'foogallery'));
     $galleries = foogallery_get_all_galleries();
     $gallery_choices = array();
     foreach ($galleries as $gallery) {
         $gallery_choices[$gallery->ID] = $gallery->name;
     }
     $settings[] = array('id' => 'default_gallery_settings', 'title' => __('Default Gallery Settings', 'foogallery'), 'desc' => __('When creating a new gallery, it can use the settings from an existing gallery as the default settings. This will save you time when creating many galleries that all have the same look and feel.', 'foogallery'), 'type' => 'select', 'choices' => $gallery_choices, 'tab' => 'general', 'section' => __('Gallery Defaults', 'foogallery'));
     $settings[] = array('id' => 'hide_gallery_template_help', 'title' => __('Hide Gallery Template Help', 'foogallery'), 'desc' => __('Some gallery templates show helpful tips, which are useful for new users. You can choose to hide these tips.', 'foogallery'), 'type' => 'checkbox', 'tab' => 'general', 'section' => __('Admin', 'foogallery'));
     $settings[] = array('id' => 'hide_editor_button', 'title' => __('Hide WYSIWYG Editor Button', 'foogallery'), 'desc' => sprintf(__('If enabled, this will hide the "Add %s" button in the WYSIWYG editor.', 'foogallery'), foogallery_plugin_name()), 'type' => 'checkbox', 'tab' => 'general', 'section' => __('Admin', 'foogallery'));
     //endregion General
     //region Extensions Tab
     $tabs['extensions'] = __('Extensions', 'foogallery');
     $settings[] = array('id' => 'use_future_endpoint', 'title' => __('Use Beta Endpoint', 'foogallery'), 'desc' => __('The list of available extensions are pulled from an external URL. You can also pull from a "beta" endpoint which will sometimes contain beta extensions that are not publicly available.', 'foogallery'), 'type' => 'checkbox', 'tab' => 'extensions');
     //endregion Extensions Tab
     //region Images Tab
     $tabs['thumb'] = __('Images', 'foogallery');
     $settings[] = array('id' => 'thumb_jpeg_quality', 'title' => __('Thumbnail JPEG Quality', 'foogallery'), 'desc' => __('The image quality to be used when resizing JPEG images.', 'foogallery'), 'type' => 'text', 'default' => '80', 'tab' => 'thumb');
     $settings[] = array('id' => 'clear_css_optimizations', 'title' => __('Clear CSS Cache', 'foogallery'), 'desc' => sprintf(__('%s optimizes the way it loads gallery stylesheets to improve page performance. This can lead to the incorrect CSS being loaded in some cases. Use this button to clear all the CSS optimizations that have been cached across all galleries.', 'foogallery'), foogallery_plugin_name()), 'type' => 'clear_optimization_button', 'tab' => 'thumb');
     $settings[] = array('id' => 'thumb_resize_animations', 'title' => __('Resize Animated GIFs', 'foogallery'), 'desc' => __('Should animated gifs be resized or not. If enabled, only the first frame is used in the resize.', 'foogallery'), 'type' => 'checkbox', 'tab' => 'thumb');
     //endregion Thumbnail Tab
     //	        //region Advanced Tab
     //	        $tabs['advanced'] = __( 'Advanced', 'foogallery' );
     //
     //	        $example_url = '<code>' . trailingslashit( site_url() ) . foogallery_permalink() . '/my-cool-gallery</code>';
     //
     //	        $settings[] = array(
     //		        'id'      => 'gallery_permalinks_enabled',
     //		        'title'   => __( 'Enable Friendly URL\'s', 'foogallery' ),
     //		        'desc'    => sprintf( __( 'If enabled, you will be able to access your galleries from a friendly URL e.g. %s', 'foogallery' ), $example_url ),
     //		        'default' => foogallery_get_default( 'gallery_permalinks_enabled' ),
     //		        'type'    => 'checkbox',
     //		        'tab'     => 'advanced',
     //	        );
     //
     //	        $settings[] = array(
     //		        'id'      => 'gallery_permalink',
     //		        'title'   => __( 'Gallery Permalink', 'foogallery' ),
     //		        'desc'    => __( 'If friendly URL\'s are enabled, this is used in building up a friendly URL', 'foogallery' ),
     //		        'default' => foogallery_get_default( 'gallery_permalink' ),
     //		        'type'    => 'text',
     //		        'tab'     => 'advanced',
     //	        );
     //	        //endregion Advanced
     //region Language Tab
     $tabs['language'] = __('Language', 'foogallery');
     $settings[] = array('id' => 'language_images_count_none_text', 'title' => __('Image Count None Text', 'foogallery'), 'type' => 'text', 'default' => __('No images', 'foogallery'), 'tab' => 'language');
     $settings[] = array('id' => 'language_images_count_single_text', 'title' => __('Image Count Single Text', 'foogallery'), 'type' => 'text', 'default' => __('1 image', 'foogallery'), 'tab' => 'language');
     $settings[] = array('id' => 'language_images_count_plural_text', 'title' => __('Image Count Many Text', 'foogallery'), 'type' => 'text', 'default' => __('%s images', 'foogallery'), 'tab' => 'language');
     //endregion Language Tab
     return apply_filters('foogallery_admin_settings_override', array('tabs' => $tabs, 'sections' => array(), 'settings' => $settings));
 }