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 = SlideshowSEPlugin::prepare($postId); } // Return output return $output; } /** * Function insertSlideshow uses the prepare method of class SlideshowSEPlugin * to insert the code for the slideshow on the location a bookmark was found. * * @since 2.1.8 * @param String $content * @return String $content */ static function insertSlideshow($content) { // Loop through post ids if (is_array(self::$postIds) && count(self::$postIds) > 0) { foreach (self::$postIds as $postId) { $updatedContent = preg_replace("/" . self::$bookmark . "/", SlideshowSEPlugin::prepare($postId), $content, 1); if (is_string($updatedContent)) { $content = $updatedContent; } } } // Reset postIds, so a shortcode in a next post can be used self::$postIds = array(); return $content; } /** * 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' => SlideshowSEPluginPostType::$postType, 'orderby' => 'post_date', 'posts_per_page' => -1, 'order' => 'DESC' )); SlideshowSEPluginMain::outputView(__CLASS__ . DIRECTORY_SEPARATOR . 'shortcode-inserter.php', $data); } /** * Enqueues the shortcode inserter script * * @since 2.1.16 */ static function localizeScript() { wp_localize_script( 'slideshow-jquery-image-gallery-backend-script', 'slideshow_jquery_image_gallery_backend_script_shortcode', array( 'data' => array('shortcode' => SlideshowSEPluginShortcode::$shortCode), 'localization' => array('undefinedSlideshow' => __('No slideshow selected.', 'slideshow-se')) ) ); } }