コード例 #1
0
 /**
  * The form shown on the admins widget page. Here settings can be changed.
  *
  * @since 1.2.0
  * @param mixed array $instance
  * @return string
  */
 function form($instance)
 {
     // Defaults
     $defaults = array('title' => __(self::$widgetName, 'slideshow-plugin'), 'slideshowId' => -1);
     // Merge database settings with defaults
     $instance = wp_parse_args((array) $instance, $defaults);
     // Get slideshows
     $slideshows = get_posts(array('numberposts' => -1, 'offset' => 0, 'post_type' => SlideshowPluginPostType::$postType));
     // Include form
     include SlideshowPluginMain::getPluginPath() . '/views/' . __CLASS__ . '/form.php';
 }
コード例 #2
0
 /**
  * The form shown on the admins widget page. Here settings can be changed.
  *
  * @since 1.2.0
  * @param mixed array $instance
  * @return string
  */
 function form($instance)
 {
     // Defaults
     $defaults = array('title' => __(self::$widgetName, 'slideshow-jquery-image-gallery'), 'slideshowId' => -1);
     // Merge database settings with defaults
     $instance = wp_parse_args((array) $instance, $defaults);
     // Get slideshows
     $slideshows = get_posts(array('numberposts' => -1, 'offset' => 0, 'post_type' => SlideshowPluginPostType::$postType));
     $data = new stdClass();
     $data->widget = $this;
     $data->instance = $instance;
     $data->slideshows = $slideshows;
     // Include form
     SlideshowPluginMain::outputView(__CLASS__ . DIRECTORY_SEPARATOR . 'form.php', $data);
 }
 /**
  * Loads the stylesheet with the parsed style name, then returns it.
  *
  * @since 2.2.8
  * @param string $styleName
  * @return string $stylesheet
  */
 public static function loadStylesheet($styleName)
 {
     // Get custom stylesheet, of the default stylesheet if the custom stylesheet does not exist
     $stylesheet = get_option($styleName, '');
     if (strlen($stylesheet) <= 0) {
         $stylesheetFile = SlideshowPluginMain::getPluginPath() . DIRECTORY_SEPARATOR . 'style' . DIRECTORY_SEPARATOR . 'SlideshowPlugin' . DIRECTORY_SEPARATOR . $styleName . '.css';
         if (!file_exists($stylesheetFile)) {
             $stylesheetFile = SlideshowPluginMain::getPluginPath() . DIRECTORY_SEPARATOR . 'style' . DIRECTORY_SEPARATOR . 'SlideshowPlugin' . DIRECTORY_SEPARATOR . 'style-light.css';
         }
         // Get contents of stylesheet
         ob_start();
         include $stylesheetFile;
         $stylesheet .= ob_get_clean();
     }
     // Replace the '%plugin-url%' tag with the actual URL and add a unique identifier to separate stylesheets
     $stylesheet = str_replace('%plugin-url%', SlideshowPluginMain::getPluginUrl(), $stylesheet);
     $stylesheet = str_replace('.slideshow_container', '.slideshow_container_' . $styleName, $stylesheet);
     return $stylesheet;
 }
コード例 #4
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 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;
 }
コード例 #5
0
ファイル: slideshow.php プロジェクト: watsonad/gpoa
			<div class="slideshow_loading_icon"></div>
		<?php 
    }
    ?>

		<div class="slideshow_content" style="display: none;">

			<?php 
    if (is_array($data->slides) && count($data->slides) > 0) {
        $i = 0;
        for ($i; $i < count($data->slides); $i++) {
            echo '<div class="slideshow_view">';
            for ($i; $i < count($data->slides); $i++) {
                $slideData = new stdClass();
                $slideData->properties = $data->slides[$i];
                SlideshowPluginMain::outputView('SlideshowPluginSlideshowSlide' . DIRECTORY_SEPARATOR . 'frontend_' . $data->slides[$i]['type'] . '.php', $slideData);
                if (($i + 1) % $data->settings['slidesPerView'] == 0) {
                    break;
                }
            }
            echo '<div style="clear: both;"></div></div>';
        }
    }
    ?>

		</div>

		<div class="slideshow_controlPanel slideshow_transparent" style="display: none;"><ul><li class="slideshow_togglePlay" data-play-text="<?php 
    _e('Play', 'slideshow-jquery-image-gallery');
    ?>
" data-pause-text="<?php 
コード例 #6
0
<?php

// Get default stylesheets
$defaultStyles = array();
$defaultStylesheets = array('style-light.css' => __('Light', 'slideshow-plugin'), 'style-dark.css' => __('Dark', 'slideshow-plugin'));
$stylesheetsFilePath = SlideshowPluginMain::getPluginPath() . DIRECTORY_SEPARATOR . 'style' . DIRECTORY_SEPARATOR . 'SlideshowPlugin';
foreach ($defaultStylesheets as $fileName => $name) {
    if (file_exists($stylesheetsFilePath . DIRECTORY_SEPARATOR . $fileName)) {
        ob_start();
        include $stylesheetsFilePath . DIRECTORY_SEPARATOR . $fileName;
        $defaultStyles[$fileName] = array('name' => $name, 'style' => ob_get_clean());
    }
}
// Get custom styles
$customStyleValues = array();
$customStyleKeys = get_option(SlideshowPluginGeneralSettings::$customStyles, array());
if (is_array($customStyleKeys)) {
    foreach ($customStyleKeys as $customStyleKey => $customStyleKeyName) {
        // Get custom style value from custom style key
        $customStyleValues[$customStyleKey] = get_option($customStyleKey);
    }
}
?>

<div class="custom-styles-tab feature-filter" style="float: left; display: none;">
	<div class="styles-list">

		<p>
			<b><?php 
_e('Default stylesheets', 'slideshow-plugin');
?>
コード例 #7
0
 /**
  * Enqueues styles and scripts necessary for the media upload button.
  *
  * @since 2.0.0
  */
 static function enqueueFiles()
 {
     // Return if function doesn't exist
     if (!function_exists('get_current_screen')) {
         return;
     }
     // Return when not on a slideshow edit page, or files have already been included.
     $currentScreen = get_current_screen();
     if ($currentScreen->post_type != SlideshowPluginPostType::$postType || self::$enqueuedFiles) {
         return;
     }
     // Enqueue style
     wp_enqueue_style('slideshow-slide-inserter', SlideshowPluginMain::getPluginUrl() . '/style/' . __CLASS__ . '/slide-inserter.css', null, SlideshowPluginMain::$version);
     // Enqueue insert button script
     wp_enqueue_script('slideshow-slide-inserter', SlideshowPluginMain::getPluginUrl() . '/js/' . __CLASS__ . '/slide-inserter.js', array('jquery'), SlideshowPluginMain::$version);
     wp_localize_script('slideshow-slide-inserter', 'SlideInserterTranslations', array('confirmMessage' => __('Are you sure you want to delete this slide?', 'slideshow-plugin')));
     // Set enqueued to true
     self::$enqueuedFiles = true;
 }
コード例 #8
0
 /**
  * Enqueues the shortcode inserter script
  *
  * @since 2.1.16
  */
 static function shortcodeInserterScript()
 {
     wp_enqueue_script('slideshow-shortcode-inserter', SlideshowPluginMain::getPluginUrl() . '/js/' . __CLASS__ . '/shortcode-inserter.js', array('jquery'), SlideshowPluginMain::$version);
     wp_localize_script('slideshow-shortcode-inserter', 'SlideshowShortcodeInserter', array('undefinedSlideshowMessage' => __('No slideshow selected.', 'slideshow-plugin'), 'shortcode' => SlideshowPluginShortcode::$shortCode));
 }
コード例 #9
0
 /**
  * Returns an array of stylesheets with its keys and respective names.
  *
  * Gets the version number for each stylesheet when $withVersion is set to true.
  *
  * When the $separateDefaultFromCustom boolean is set to true, the default stylesheets will be returned separately
  * from the custom stylesheets.
  *
  * The data returned with both parameters set to 'false' will look like the following:
  *
  * [$stylesheetKey => $stylesheetName]
  *
  * With both parameters set to 'true' the returned data will be formed like this:
  *
  * [
  *  default => [$stylesheetKey => [name => $stylesheetName, version => $versionNumber]],
  *  custom => [$stylesheetKey => [name => $stylesheetName, version => $versionNumber]]
  * ]
  *
  * @since 2.1.23
  * @param boolean $withVersion (optional, defaults to false)
  * @param boolean $separateDefaultFromCustom (optional, defaults to false)
  * @return array $stylesheets
  */
 static function getStylesheets($withVersion = false, $separateDefaultFromCustom = false)
 {
     // Default styles
     $defaultStyles = array('style-light.css' => __('Light', 'slideshow-plugin'), 'style-dark.css' => __('Dark', 'slideshow-plugin'));
     // Loop through default stylesheets
     $stylesheetsFilePath = SlideshowPluginMain::getPluginPath() . DIRECTORY_SEPARATOR . 'style' . DIRECTORY_SEPARATOR . 'SlideshowPlugin';
     foreach ($defaultStyles as $fileName => $name) {
         // Check if stylesheet exists on server, don't offer it when it does not exist.
         if (!file_exists($stylesheetsFilePath . DIRECTORY_SEPARATOR . $fileName)) {
             unset($defaultStyles[$fileName]);
             continue;
         }
         // Add version if $withVersion is true
         if ($withVersion) {
             $defaultStyles[$fileName] = array('name' => $name, 'version' => SlideshowPluginMain::$version);
         }
     }
     // Get custom styles
     $customStyles = get_option(SlideshowPluginGeneralSettings::$customStyles, array());
     // Add version to the custom styles if $withVersion is true
     if ($withVersion) {
         foreach ($customStyles as $customStylesKey => $customStylesName) {
             $customStylesVersion = get_option($customStylesKey . '_version', false);
             if (!$customStylesVersion) {
                 $customStylesVersion = time();
             }
             $customStyles[$customStylesKey] = array('name' => $customStylesName, 'version' => $customStylesVersion);
         }
     }
     // Return
     if ($separateDefaultFromCustom) {
         return array('default' => $defaultStyles, 'custom' => $customStyles);
     }
     return array_merge($defaultStyles, $customStyles);
 }
コード例 #10
0
 /**
  * Hooked on the admin's 'media_buttons' hook, outputs the shortcode inserter media button
  *
  * @since 2.1.16
  */
 static function shortcodeInserter()
 {
     $data = new stdClass();
     $data->slideshows = new WP_Query(array('post_type' => SlideshowPluginPostType::$postType, 'orderby' => 'post_date', 'posts_per_page' => -1, 'order' => 'DESC'));
     SlideshowPluginMain::outputView(__CLASS__ . DIRECTORY_SEPARATOR . 'shortcode-inserter.php', $data);
 }
コード例 #11
0
 /**
  * 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';
 }
コード例 #12
0
ファイル: backend_attachment.php プロジェクト: recca004/JAS
    }
    // Prepare image
    $image = wp_get_attachment_image_src($attachment->ID);
    $imageSrc = '';
    $displaySlide = true;
    if (!is_array($image) || !$image) {
        if (!empty($attachment->guid)) {
            $imageSrc = $attachment->guid;
        } else {
            $displaySlide = false;
        }
    } else {
        $imageSrc = $image[0];
    }
    if (!$imageSrc || empty($imageSrc)) {
        $imageSrc = SlideshowPluginMain::getPluginUrl() . '/images/' . __CLASS__ . '/no-img.png';
    }
    $editUrl = admin_url() . '/media.php?attachment_id=' . $attachment->ID . '&amp;action=edit';
    if ($displaySlide) {
        ?>


		<li class="widefat sortable-slides-list-item">

			<h3 class="hndle">
				<span>
					<?php 
        _e('Image slide', 'slideshow-plugin');
        ?>

				</span>
コード例 #13
0
 /**
  * Returns an array of stylesheets with its keys and respective names.
  *
  * When the $separateDefaultFromCustom boolean is set to true, the default stylesheets will be returned separately
  * from the custom stylesheets as: array('default' => array(), 'custom' => array()) respectively.
  *
  * @since 2.1.23
  * @param boolean $separateDefaultFromCustom (optional, defaults to false)
  * @return array $stylesheets
  */
 static function getStylesheets($separateDefaultFromCustom = false)
 {
     // Default styles
     $defaultStyles = array('style-light.css' => __('Light', 'slideshow-plugin'), 'style-dark.css' => __('Dark', 'slideshow-plugin'));
     // Loop through default stylesheets
     $stylesheetsFilePath = SlideshowPluginMain::getPluginPath() . DIRECTORY_SEPARATOR . 'style' . DIRECTORY_SEPARATOR . 'SlideshowPlugin';
     foreach ($defaultStyles as $fileName => $name) {
         // Check if stylesheet exists on server, don't offer it when it does not exist.
         if (!file_exists($stylesheetsFilePath . DIRECTORY_SEPARATOR . $fileName)) {
             unset($defaultStyles[$fileName]);
         }
     }
     // Get custom styles
     $customStyles = get_option(SlideshowPluginGeneralSettings::$customStyles, array());
     // Return
     if ($separateDefaultFromCustom) {
         return array('default' => $defaultStyles, 'custom' => $customStyles);
     }
     return array_merge($defaultStyles, $customStyles);
 }
コード例 #14
0
ファイル: general-settings.php プロジェクト: watsonad/gpoa
    _e('Default Slideshow Settings', 'slideshow-jquery-image-gallery');
    ?>
</a>
				<a href="#custom-styles-tab" class="nav-tab"><?php 
    _e('Custom Styles', 'slideshow-jquery-image-gallery');
    ?>
</a>

				<?php 
    submit_button(null, 'primary', null, false, 'style="float: right;"');
    ?>
			</h2>

			<?php 
    // General Settings
    SlideshowPluginMain::outputView('SlideshowPluginGeneralSettings' . DIRECTORY_SEPARATOR . 'general-settings-tab.php');
    // Default slideshow settings
    SlideshowPluginMain::outputView('SlideshowPluginGeneralSettings' . DIRECTORY_SEPARATOR . 'default-slideshow-settings-tab.php');
    // Custom styles
    SlideshowPluginMain::outputView('SlideshowPluginGeneralSettings' . DIRECTORY_SEPARATOR . 'custom-styles-tab.php');
    ?>

			<p>
				<?php 
    submit_button(null, 'primary', null, false);
    ?>
			</p>
		</form>
	</div>
<?php 
}
コード例 #15
0
 /**
  * Hooked on the admin's 'media_buttons' hook, outputs the shortcode inserter media button
  *
  * @since 2.1.16
  */
 static function shortcodeInserter()
 {
     // Get slideshows
     $slideshows = new WP_Query(array('post_type' => SlideshowPluginPostType::$postType, 'orderby' => 'post_date', 'posts_per_page' => -1, 'order' => 'DESC'));
     include SlideshowPluginMain::getPluginPath() . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . __CLASS__ . DIRECTORY_SEPARATOR . 'shortcode-inserter.php';
 }
コード例 #16
0
ファイル: slides.php プロジェクト: narabikke/wordpress
		<p><?php 
        _e('Add slides to this slideshow by using one of the buttons above.', 'slideshow-jquery-image-gallery');
        ?>
</p>
	<?php 
    }
    ?>

	<div class="sortable-slides-list">

		<?php 
    if (is_array($data->slides)) {
        $i = 0;
        foreach ($data->slides as $slide) {
            $data = new stdClass();
            $data->name = SlideshowPluginSlideshowSettingsHandler::$slidesKey . '[' . $i . ']';
            $data->properties = $slide;
            SlideshowPluginMain::outputView('SlideshowPluginSlideshowSlide' . DIRECTORY_SEPARATOR . 'backend_' . $slide['type'] . '.php', $data);
            $i++;
        }
    }
    ?>

	</div>

	<?php 
    SlideshowPluginMain::outputView('SlideshowPluginSlideshowSlide' . DIRECTORY_SEPARATOR . 'backend_templates.php');
    ?>

<?php 
}
コード例 #17
0
 /**
  * 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);
 }
コード例 #18
0
 /**
  * Build templates for back-end slides.
  *
  * Returns when $return is true, prints when $return is false.
  *
  * @since 2.2.0
  * @param boolean $return (optional, defaults to true)
  * @return String $backEndTemplates
  */
 static function getBackEndTemplates($return = true)
 {
     // Start output buffering if output needs to be returned
     if ($return) {
         ob_start();
     }
     include SlideshowPluginMain::getPluginPath() . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . __CLASS__ . DIRECTORY_SEPARATOR . 'backend_templates.php';
     // Return output
     if ($return) {
         return ob_get_clean();
     }
     return '';
 }
コード例 #19
0
 /**
  * Gets the stylesheet with the parsed style name, then returns it.
  *
  * @since 2.2.8
  * @param string $styleName
  * @return string $stylesheet
  */
 public static function getStylesheet($styleName)
 {
     // Check if $styleName is a custom stylesheet
     if (self::isCustomStylesheet($styleName)) {
         // Get custom stylesheet
         $stylesheet = get_option($styleName, '');
     } else {
         $stylesheetFile = SlideshowPluginMain::getPluginPath() . DIRECTORY_SEPARATOR . 'style' . DIRECTORY_SEPARATOR . 'SlideshowPlugin' . DIRECTORY_SEPARATOR . $styleName . '.css';
         if (!file_exists($stylesheetFile)) {
             $stylesheetFile = SlideshowPluginMain::getPluginPath() . DIRECTORY_SEPARATOR . 'style' . DIRECTORY_SEPARATOR . 'SlideshowPlugin' . DIRECTORY_SEPARATOR . 'style-light.css';
         }
         // Get contents of stylesheet
         ob_start();
         include $stylesheetFile;
         $stylesheet = ob_get_clean();
     }
     // Replace the URL placeholders with actual URLs and add a unique identifier to separate stylesheets
     $stylesheet = str_replace('%plugin-url%', SlideshowPluginMain::getPluginUrl(), $stylesheet);
     $stylesheet = str_replace('%site-url%', get_bloginfo('url'), $stylesheet);
     $stylesheet = str_replace('%stylesheet-url%', get_stylesheet_directory_uri(), $stylesheet);
     $stylesheet = str_replace('%template-url%', get_template_directory_uri(), $stylesheet);
     $stylesheet = str_replace('.slideshow_container', '.slideshow_container_' . $styleName, $stylesheet);
     return $stylesheet;
 }
コード例 #20
0
 /**
  * Include popup, needs to be called in the footer
  *
  * @since 2.0.0
  */
 static function includePopup()
 {
     include SlideshowPluginMain::getPluginPath() . '/views/' . __CLASS__ . '/search-popup.php';
 }
コード例 #21
0
<a
	href="#TB_inline?width=450&inlineId=insertSlideshowShortcode"
	class="button thickbox"
	title="<?php 
_e('Insert a Slideshow', 'slideshow-jquery-image-gallery');
?>
"
    style="padding-left: .4em;"
>
	<img
		src="<?php 
echo SlideshowPluginMain::getPluginUrl() . '/images/SlideshowPluginPostType/adminIcon.png';
?>
"
		alt="<?php 
_e('Insert a Slideshow', 'slideshow-jquery-image-gallery');
?>
"
	    style="vertical-align: text-top;"
	/>
	<?php 
_e('Insert Slideshow', 'slideshow-jquery-image-gallery');
?>
</a>

<div id="insertSlideshowShortcode" style="display: none;">

	<h3 style="padding: 10px 0; color: #5a5a5a;">
		<?php 
_e('Insert a Slideshow', 'slideshow-jquery-image-gallery');
?>
コード例 #22
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 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;
 }