/**
  * Enqueues a stylesheet based on the stylesheet's name. This can either be a default stylesheet or a custom one.
  * If the name parameter is left unset, the default stylesheet will be used.
  *
  * Returns the name and version number of the stylesheet that's been enqueued, as this can be different from the
  * name passed. This can be this case if a stylesheet does not exist and a default stylesheet is enqueued.
  *
  * @param string $name (optional, defaults to null)
  * @return array [$name, $version]
  */
 public static function enqueueStylesheet($name = null)
 {
     $enqueueDynamicStylesheet = true;
     $version = SlideshowPluginMain::$version;
     if (isset($name)) {
         // Try to get the custom style's version
         $customStyle = get_option($name, false);
         $customStyleVersion = false;
         if ($customStyle) {
             $customStyleVersion = get_option($name . '_version', false);
         }
         // Style name and version
         if ($customStyle && $customStyleVersion) {
             $version = $customStyleVersion;
         } else {
             $enqueueDynamicStylesheet = false;
             $name = str_replace('.css', '', $name);
         }
     } else {
         $enqueueDynamicStylesheet = false;
         $name = 'style-light';
     }
     // Enqueue stylesheet
     if (SlideshowPluginGeneralSettings::getStylesheetLocation() == 'footer') {
         add_filter('style_loader_tag', array(__CLASS__, 'filterStyleLoaderTag'), 10, 3);
         if ($enqueueDynamicStylesheet) {
             wp_enqueue_style('slideshow-jquery-image-gallery-ajax-stylesheet_' . $name, admin_url('admin-ajax.php?action=slideshow_jquery_image_gallery_load_stylesheet&style=' . $name, 'admin'), array(), $version);
         } else {
             wp_enqueue_style('slideshow-jquery-image-gallery-stylesheet_' . $name, SlideshowPluginMain::getPluginUrl() . '/css/' . $name . '.css', array(), $version);
         }
     }
     return array($name, $version);
 }
Esempio n. 2
0
 /**
  * Enqueues frontend scripts and styles.
  *
  * Should always be called on the wp_enqueue_scripts hook.
  *
  * @since 2.3.0
  */
 static function enqueueFrontendScripts()
 {
     // Enqueue slideshow script if lazy loading is enabled
     if (SlideshowPluginGeneralSettings::getEnableLazyLoading()) {
         wp_enqueue_script('slideshow-jquery-image-gallery-script', self::getPluginUrl() . '/js/min/all.frontend.min.js', array('jquery'), self::$version);
         wp_localize_script('slideshow-jquery-image-gallery-script', 'slideshow_jquery_image_gallery_script_adminURL', admin_url());
     }
 }
 /**
  * Initializes the slideshow post type's general settings.
  *
  * @since 2.1.22
  */
 static function init()
 {
     // Only initialize in admin
     if (!is_admin()) {
         return;
     }
     if (isset($_GET['post_type']) && $_GET['post_type'] == 'slideshow' && isset($_GET['page']) && $_GET['page'] == 'general_settings') {
         self::$isCurrentPage = true;
     }
     // Register settings
     add_action('admin_init', array(__CLASS__, 'registerSettings'));
     // Add sub menu
     add_action('admin_menu', array(__CLASS__, 'addSubMenuPage'));
     // Localize
     add_action('admin_enqueue_scripts', array(__CLASS__, 'localizeScript'), 11);
 }
Esempio n. 4
0
 /**
  * Bootstraps the application by assigning the right functions to
  * the right action hooks.
  *
  * @since 1.0.0
  */
 static function bootStrap()
 {
     self::autoInclude();
     // Initialize localization on init
     add_action('init', array(__CLASS__, 'localize'));
     // For ajax requests
     SlideshowPluginAjax::init();
     // Register slideshow post type
     SlideshowPluginPostType::init();
     // Add general settings page
     SlideshowPluginGeneralSettings::init();
     // Deploy slideshow on do_action('slideshow_deploy'); hook.
     add_action('slideshow_deploy', array('SlideshowPlugin', 'deploy'));
     // Initialize shortcode
     SlideshowPluginShortcode::init();
     // Register widget
     add_action('widgets_init', array('SlideshowPluginWidget', 'registerWidget'));
     // Initialize plugin updater
     SlideshowPluginInstaller::init();
 }
Esempio n. 5
0
 /**
  * Bootstraps the application by assigning the right functions to
  * the right action hooks.
  *
  * @since 1.0.0
  */
 static function bootStrap()
 {
     self::autoInclude();
     // Initialize localization on init
     add_action('init', array(__CLASS__, 'localize'));
     // Include backend scripts and styles
     add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueueBackendScripts'));
     // Ajax requests
     SlideshowPluginAJAX::init();
     // Register slideshow post type
     SlideshowPluginPostType::init();
     // Add general settings page
     SlideshowPluginGeneralSettings::init();
     // Initialize stylesheet builder
     SlideshowPluginSlideshowStylesheet::init();
     // Deploy slideshow on do_action('slideshow_deploy'); hook.
     add_action('slideshow_deploy', array('SlideshowPlugin', 'deploy'));
     // Initialize shortcode
     SlideshowPluginShortcode::init();
     // Register widget
     add_action('widgets_init', array('SlideshowPluginWidget', 'registerWidget'));
     // Initialize plugin updater
     SlideshowPluginInstaller::init();
 }
 /**
  * Enqueue stylesheet
  */
 public static function enqueueFrontendStylesheets()
 {
     if (SlideshowPluginGeneralSettings::getStylesheetLocation() === 'head') {
         // Register functional stylesheet
         wp_enqueue_style('slideshow-jquery-image-gallery-stylesheet_functional', SlideshowPluginMain::getPluginUrl() . '/style/SlideshowPlugin/functional.css', array(), SlideshowPluginMain::$version);
         // Get default and custom stylesheets
         $stylesheets = SlideshowPluginGeneralSettings::getStylesheets(true, true);
         $defaultStylesheets = $stylesheets['default'];
         $customStylesheets = $stylesheets['custom'];
         // Clean the '.css' extension from the default stylesheets
         foreach ($defaultStylesheets as $defaultStylesheetKey => $defaultStylesheetValue) {
             $newDefaultStylesheetKey = str_replace('.css', '', $defaultStylesheetKey);
             $defaultStylesheets[$newDefaultStylesheetKey] = $defaultStylesheetValue;
             if ($defaultStylesheetKey !== $newDefaultStylesheetKey) {
                 unset($defaultStylesheets[$defaultStylesheetKey]);
             }
         }
         // Enqueue stylesheets
         foreach (array_merge($defaultStylesheets, $customStylesheets) as $stylesheetKey => $stylesheetValue) {
             wp_enqueue_style('slideshow-jquery-image-gallery-ajax-stylesheet_' . $stylesheetKey, admin_url('admin-ajax.php?action=slideshow_jquery_image_gallery_load_stylesheet&style=' . $stylesheetKey, 'admin'), array(), $stylesheetValue['version']);
         }
         self::$allStylesheetsRegistered = true;
     }
 }
 /**
  * Returns an array of style setting defaults.
  *
  * For a full description of the parameters, see getAllDefaults().
  *
  * @since 2.1.20
  * @param boolean $fullDefinition (optional, defaults to false)
  * @param boolean $fromDatabase (optional, defaults to true)
  * @return mixed $data
  */
 static function getDefaultStyleSettings($fullDefinition = false, $fromDatabase = true)
 {
     // Default style settings
     $data = array('style' => 'style-light.css');
     // Read defaults from database and merge with $data, when $fromDatabase is set to true
     if ($fromDatabase) {
         $data = array_merge($data, $customData = get_option(SlideshowPluginGeneralSettings::$defaultStyleSettings, array()));
     }
     // Full definition
     if ($fullDefinition) {
         $data = array('style' => array('type' => 'select', 'default' => $data['style'], 'description' => __('The style used for this slideshow', 'slideshow-plugin'), 'options' => SlideshowPluginGeneralSettings::getStylesheets()));
     }
     // Return
     return $data;
 }
<?php

// General settings
$stylesheetLocation = SlideshowPluginGeneralSettings::getStylesheetLocation();
// Roles
global $wp_roles;
// Capabilities
$capabilities = array(SlideshowPluginGeneralSettings::$capabilities['addSlideshows'] => __('Add slideshows', 'slideshow-plugin'), SlideshowPluginGeneralSettings::$capabilities['editSlideshows'] => __('Edit slideshows', 'slideshow-plugin'), SlideshowPluginGeneralSettings::$capabilities['deleteSlideshows'] => __('Delete slideshows', 'slideshow-plugin'));
?>

<div class="general-settings-tab feature-filter">

	<h4><?php 
_e('User Capabilities', 'slideshow-plugin');
?>
</h4>

	<p><?php 
_e('Select the user roles that will able to perform certain actions.', 'slideshow-plugin');
?>
</p>

	<table>

		<?php 
foreach ($capabilities as $capability => $capabilityName) {
    ?>

		<tr valign="top">
			<th><?php 
    echo $capabilityName;
Esempio n. 9
0
    echo isset($data->settings['preserveSlideshowDimensions']) && $data->settings['preserveSlideshowDimensions'] == 'false' && isset($data->settings['height']) && $data->settings['height'] > 0 ? 'height: ' . $data->settings['height'] . 'px;' : '';
    ?>
 <?php 
    echo isset($data->settings['maxWidth']) && $data->settings['maxWidth'] > 0 ? 'max-width: ' . $data->settings['maxWidth'] . 'px;' : '';
    ?>
" data-slideshow-id="<?php 
    echo htmlspecialchars($data->post->ID);
    ?>
" data-style-name="<?php 
    echo htmlspecialchars($data->styleName);
    ?>
" data-style-version="<?php 
    echo htmlspecialchars($data->styleVersion);
    ?>
" <?php 
    if (SlideshowPluginGeneralSettings::getEnableLazyLoading()) {
        ?>
data-settings="<?php 
        echo htmlspecialchars(json_encode($data->settings));
        ?>
"<?php 
    }
    ?>
>

		<?php 
    if (isset($data->settings['showLoadingIcon']) && $data->settings['showLoadingIcon'] === 'true') {
        ?>
			<div class="slideshow_loading_icon"></div>
		<?php 
    }
Esempio n. 10
0
 /**
  * Function prepare returns the required html and enqueues
  * the scripts and stylesheets necessary for displaying the slideshow
  *
  * Passing this function no parameter or passing it a negative one will
  * result in a random pick of slideshow
  *
  * @since 2.1.0
  * @param int $postId
  * @return String $output
  */
 static function prepare($postId = null)
 {
     $post = null;
     // Get post by its ID, if the ID is not a negative value
     if (is_numeric($postId) && $postId >= 0) {
         $post = get_post($postId);
     }
     // Get slideshow by slug when it's a non-empty string
     if ($post === null && is_string($postId) && !is_numeric($postId) && !empty($postId)) {
         $query = new WP_Query(array('post_type' => SlideshowPluginPostType::$postType, 'name' => $postId, 'orderby' => 'post_date', 'order' => 'DESC', 'suppress_filters' => true));
         if ($query->have_posts()) {
             $post = $query->next_post();
         }
     }
     // When no slideshow is found, get one at random
     if ($post === null) {
         $post = get_posts(array('numberposts' => 1, 'offset' => 0, 'orderby' => 'rand', 'post_type' => SlideshowPluginPostType::$postType, 'suppress_filters' => true));
         if (is_array($post)) {
             $post = $post[0];
         }
     }
     // Exit on error
     if ($post === null) {
         return '<!-- WordPress Slideshow - No slideshows available -->';
     }
     // Log slideshow's problems to be able to track them on the page.
     $log = array();
     // Get slides
     $slides = SlideshowPluginSlideshowSettingsHandler::getSlides($post->ID);
     if (!is_array($slides) || count($slides) <= 0) {
         $log[] = 'No slides were found';
     }
     // Get settings
     $settings = SlideshowPluginSlideshowSettingsHandler::getSettings($post->ID);
     $styleSettings = SlideshowPluginSlideshowSettingsHandler::getStyleSettings($post->ID);
     // Only enqueue the functional stylesheet when the 'allStylesheetsRegistered' flag is false
     if (!SlideshowPluginSlideshowStylesheet::$allStylesheetsRegistered) {
         wp_enqueue_style('slideshow-jquery-image-gallery-stylesheet_functional', SlideshowPluginMain::getPluginUrl() . '/style/' . __CLASS__ . '/functional.css', array(), SlideshowPluginMain::$version);
     }
     // Check if requested style is available. If not, use the default
     list($styleName, $styleVersion) = SlideshowPluginSlideshowStylesheet::enqueueStylesheet($styleSettings['style']);
     $data = new stdClass();
     $data->log = $log;
     $data->post = $post;
     $data->slides = $slides;
     $data->settings = $settings;
     $data->styleName = $styleName;
     $data->styleVersion = $styleVersion;
     // Include output file to store output in $output.
     $output = SlideshowPluginMain::getView(__CLASS__ . DIRECTORY_SEPARATOR . 'slideshow.php', $data);
     // Enqueue slideshow script
     wp_enqueue_script('slideshow-jquery-image-gallery-script', SlideshowPluginMain::getPluginUrl() . '/js/min/all.frontend.min.js', array('jquery'), SlideshowPluginMain::$version);
     // Set dimensionWidth and dimensionHeight if dimensions should be preserved
     if (isset($settings['preserveSlideshowDimensions']) && $settings['preserveSlideshowDimensions'] == 'true') {
         $aspectRatio = explode(':', $settings['aspectRatio']);
         // Width
         if (isset($aspectRatio[0]) && is_numeric($aspectRatio[0])) {
             $settings['dimensionWidth'] = $aspectRatio[0];
         } else {
             $settings['dimensionWidth'] = 1;
         }
         // Height
         if (isset($aspectRatio[1]) && is_numeric($aspectRatio[1])) {
             $settings['dimensionHeight'] = $aspectRatio[1];
         } else {
             $settings['dimensionHeight'] = 1;
         }
     }
     if (!SlideshowPluginGeneralSettings::getEnableLazyLoading()) {
         // Include slideshow settings by localizing them
         wp_localize_script('slideshow-jquery-image-gallery-script', 'SlideshowPluginSettings_' . $post->ID, $settings);
         // Include the location of the admin-ajax.php file
         wp_localize_script('slideshow-jquery-image-gallery-script', 'slideshow_jquery_image_gallery_script_adminURL', admin_url());
     }
     // Return output
     return $output;
 }