/**
  * Function slideshowDeploy adds a bookmark to where ever a shortcode
  * is found and adds the postId to an array, it then is loaded after
  * WordPress has done its HTML checks.
  *
  * @since 1.2.0
  * @param mixed $attributes
  * @return String $output
  */
 static function slideshowDeploy($attributes)
 {
     $postId = '';
     if (isset($attributes['id'])) {
         $postId = $attributes['id'];
     }
     $settings = SlideshowPluginSlideshowSettingsHandler::getSettings($postId);
     if ($settings['avoidFilter'] == 'true' && strlen(current_filter()) > 0) {
         // Avoid current filter, call function to replace the bookmark with the slideshow
         add_filter(current_filter(), array(__CLASS__, 'insertSlideshow'), 999);
         // Save post id
         self::$postIds[] = $postId;
         // Set output
         $output = self::$bookmark;
     } else {
         // Just output the slideshow, without filtering
         $output = SlideshowPlugin::prepare($postId);
     }
     // Return output
     return $output;
 }
 /**
  * Function slideshowDeploy adds a bookmark to where ever a shortcode
  * is found and adds the postId to an array, it then is loaded after
  * Wordpress has done its HTML checks.
  *
  * @since 1.2.0
  * @param mixed $atts
  * @return String $output
  */
 static function slideshowDeploy($atts)
 {
     $postId = '';
     if (isset($atts['id'])) {
         $postId = $atts['id'];
     }
     $output = '';
     $settings = SlideshowPluginSlideshowSettingsHandler::getSettings($postId);
     if ($settings['avoidFilter'] == 'true') {
         // Filter content after all Wordpress HTML parsers are done, then replace bookmarks with raw HTML
         add_filter('the_content', array(__CLASS__, 'insertSlideshow'), 999);
         add_filter('the_excerpt', array(__CLASS__, 'insertSlideshow'), 999);
         // Save post id
         self::$postIds[] = $postId;
         // Set output
         $output = self::$bookmark;
     } else {
         // Just output the slideshow, without filtering
         $output = SlideshowPlugin::prepare($postId);
     }
     // Return output
     return $output;
 }
Example #3
0
            }
            ?>
		<tr
			<?php 
            echo !empty($value['group']) ? 'class="group-' . strtolower(str_replace(' ', '-', $value['group'])) . '"' : '';
            ?>
			<?php 
            echo !empty($value['dependsOn']) ? 'style="display:none;"' : '';
            ?>
		>
			<td><?php 
            echo $value['description'];
            ?>
</td>
			<td><?php 
            echo SlideshowPluginSlideshowSettingsHandler::getInputField(SlideshowPluginSlideshowSettingsHandler::$settingsKey, htmlspecialchars($key), $value);
            ?>
</td>
			<td><?php 
            _e('Default', 'slideshow-jquery-image-gallery');
            ?>
: &#39;<?php 
            echo isset($value['options']) ? $value['options'][$value['default']] : $value['default'];
            ?>
&#39;</td>
		</tr>

		<?php 
        }
        ?>
		<?php 
</h4>

		<table>

			<?php 
    foreach ($defaultStyleSettings as $defaultStyleSettingKey => $defaultStyleSettingValue) {
        ?>

			<tr>
				<td>
					<?php 
        echo $defaultStyleSettingValue['description'];
        ?>
				</td>
				<td>
					<?php 
        echo SlideshowPluginSlideshowSettingsHandler::getInputField(SlideshowPluginGeneralSettings::$defaultStyleSettings, $defaultStyleSettingKey, $defaultStyleSettingValue, false);
        ?>
				</td>
			</tr>

			<?php 
    }
    ?>

		</table>
	</div>

	<div style="clear: both;"></div>
<?php 
}
 /**
  * Returns an array of SlideshowPluginSlideshowView objects if $returnAsObjects is true, otherwise returns an array
  * of view arrays that contain slide properties.
  *
  * To prevent the result from being cached set $enableCache to false. It's set to true by default.
  *
  * @since 2.2.0
  * @param int $slideshowId
  * @param bool $returnAsObjects (optional, defaults to true)
  * @param bool $enableCache (optional, defaults to true)
  * @return mixed $views
  */
 static function getViews($slideshowId, $returnAsObjects = true, $enableCache = true)
 {
     // Get slides
     $slides = self::getSlides($slideshowId, $enableCache);
     // Get settings. Since in version 2.2.X slides aren't put into views yet, this has to be done manually
     $settings = SlideshowPluginSlideshowSettingsHandler::getSettings($slideshowId, false, $enableCache);
     $slidesPerView = 1;
     if (isset($settings['slidesPerView'])) {
         $slidesPerView = $settings['slidesPerView'];
     }
     // Loop through slides, forcing them into views
     $i = 0;
     $viewId = -1;
     $views = array();
     if (is_array($slides)) {
         foreach ($slides as $slide) {
             // Create new view when view is full or not yet created
             if ($i % $slidesPerView == 0) {
                 $viewId++;
                 if ($returnAsObjects) {
                     $views[$viewId] = new SlideshowPluginSlideshowView();
                 } else {
                     $views[$viewId] = array();
                 }
             }
             // Add slide to view
             if ($returnAsObjects) {
                 $views[$viewId]->addSlide($slide);
             } else {
                 $views[$viewId][] = $slide;
             }
             $i++;
         }
     }
     return $views;
 }
 /**
  * Shows settings for particular slideshow
  *
  * @since 1.0.0
  */
 static function settingsMetaBox()
 {
     global $post;
     // Nonce
     wp_nonce_field(SlideshowPluginSlideshowSettingsHandler::$nonceAction, SlideshowPluginSlideshowSettingsHandler::$nonceName);
     $data = new stdClass();
     $data->settings = SlideshowPluginSlideshowSettingsHandler::getSettings($post->ID, true);
     SlideshowPluginMain::outputView(__CLASS__ . DIRECTORY_SEPARATOR . 'settings.php', $data);
 }
 /**
  * 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 issues to be able to track them on the page.
     $log = array();
     // Get views
     $views = SlideshowPluginSlideshowSettingsHandler::getViews($post->ID);
     if (!is_array($views) || count($views) <= 0) {
         $log[] = 'No views were found';
     }
     // Get settings
     $settings = SlideshowPluginSlideshowSettingsHandler::getSettings($post->ID);
     $styleSettings = SlideshowPluginSlideshowSettingsHandler::getStyleSettings($post->ID);
     // The slideshow's session ID, allows JavaScript and CSS to distinguish between multiple slideshows
     $sessionID = self::$sessionCounter++;
     // Try to get a custom stylesheet
     if (isset($styleSettings['style'])) {
         // Try to get the custom style's version
         $customStyle = get_option($styleSettings['style'], false);
         $customStyleVersion = false;
         if ($customStyle) {
             $customStyleVersion = get_option($styleSettings['style'] . '_version', false);
         }
         // Style name and version
         if ($customStyle && $customStyleVersion) {
             $styleName = $styleSettings['style'];
             $styleVersion = $customStyleVersion;
         } else {
             $styleName = str_replace('.css', '', $styleSettings['style']);
             $styleVersion = SlideshowPluginMain::$version;
         }
     } else {
         $styleName = 'style-light';
         $styleVersion = SlideshowPluginMain::$version;
     }
     // Register function stylesheet
     wp_enqueue_style('slideshow-jquery-image-gallery-stylesheet_functional', SlideshowPluginMain::getPluginUrl() . '/style/' . __CLASS__ . '/functional.css', array(), SlideshowPluginMain::$version);
     // Enqueue stylesheet
     wp_enqueue_style('slideshow-jquery-image-gallery-ajax-stylesheet_' . $styleName, admin_url('admin-ajax.php?action=slideshow_jquery_image_gallery_load_stylesheet&style=' . $styleName), array(), $styleVersion);
     // Include output file to store output in $output.
     $output = '';
     ob_start();
     include SlideshowPluginMain::getPluginPath() . '/views/' . __CLASS__ . '/slideshow.php';
     $output .= ob_get_clean();
     // Enqueue slideshow script
     wp_enqueue_script('slideshow-jquery-image-gallery-script', SlideshowPluginMain::getPluginUrl() . '/js/' . __CLASS__ . '/slideshow.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;
         }
     }
     // Include slideshow settings by localizing them
     wp_localize_script('slideshow-jquery-image-gallery-script', 'SlideshowPluginSettings_' . $sessionID, $settings);
     // Return output
     return $output;
 }
 /**
  * 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 issues to be able to track them on the page.
     $log = array();
     // Get views
     $views = SlideshowPluginSlideshowSettingsHandler::getViews($post->ID);
     if (!is_array($views) || count($views) <= 0) {
         $log[] = 'No views 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']);
     // Include output file to store output in $output.
     $output = '';
     ob_start();
     include SlideshowPluginMain::getPluginPath() . '/views/' . __CLASS__ . '/slideshow.php';
     $output .= ob_get_clean();
     // 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;
         }
     }
     // 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());
     self::$sessionCounter++;
     // Return output
     return $output;
 }
 /**
  * Shows settings for particular slideshow
  *
  * @since 1.0.0
  */
 static function settingsMetaBox()
 {
     global $post;
     // Nonce
     wp_nonce_field(SlideshowPluginSlideshowSettingsHandler::$nonceAction, SlideshowPluginSlideshowSettingsHandler::$nonceName);
     // Get settings
     $settings = SlideshowPluginSlideshowSettingsHandler::getSettings($post->ID, true);
     // Include
     include SlideshowPluginMain::getPluginPath() . '/views/' . __CLASS__ . '/settings.php';
 }