/** * Filter the DPS shortcode output's opening outer wrapper element. * * @since 0.1.1 * @access public * @uses WP_Bootstrap_Carousel::enqueue() * @uses WP_Bootstrap_Carousel_DPS::$found_posts * @uses WP_Bootstrap_Carousel_DPS::is_bootstrap() * @uses wp_bc_bool() * @param string $output HTML markup for the opening outer wrapper element. * @param array $original_atts Original attributes passed to the shortcode. * @return string Modified HTML markup for the opening outer wrapper element. */ public function display_posts_shortcode_wrapper_open($output, $original_atts) { // check bootstrap attribute if (!$this->is_bootstrap($original_atts)) { return $output; } // static iterator static $it = 1; $it++; // handle feed if (is_feed()) { /** * Determine what is displayed in RSS feeds * * @param string $html The default HTML */ return apply_filters('wp_bootstrap_carousel_dps_feed', '<p><a href="' . apply_filters('the_permalink', get_permalink($GLOBALS['post']->ID)) . '#wp-bootstrap-carousel-dps-' . $it . '">' . __('Click here to view the embedded slideshow.', 'wp_bootstrap_carousel') . '</a></p>'); } // sanitize variables $max_width = isset($original_atts['width']) ? intval(str_replace(array('%', 'px'), '', trim($original_atts['width']))) : false; $max_width = !empty($max_width) ? "max-width:{$max_width}px;" : ''; $controls = isset($original_atts['controls']) ? wp_bc_bool($original_atts['controls']) : 1; $slide = isset($original_atts['slide']) ? wp_bc_bool($original_atts['slide']) : 1; $interval = isset($original_atts['interval']) ? intval($original_atts['interval']) : 5000; $pause = isset($original_atts['pause']) ? sanitize_text_field($original_atts['pause']) : 'hover'; $wrap = isset($original_atts['wrap']) ? wp_bc_bool($original_atts['wrap']) : 1; $keyboard = isset($original_atts['keyboard']) ? wp_bc_bool($original_atts['keyboard']) : 1; $thickbox = isset($original_atts['thickbox']) ? wp_bc_bool($original_atts['thickbox']) : 0; $title = isset($original_atts['title']) ? sanitize_text_field($original_atts['title']) : 0; // enqueue scripts WP_Bootstrap_Carousel::enqueue($thickbox); // start building output $output = ''; // carousel title if ($title) { /** * Filter the title tag element. * * @since 0.4.0 * @param string $tag Type of element to use for the output title tag. Default 'h2'. * @param array $original_atts Original attributes passed to the DPS shortcode. */ $title_tag = apply_filters('wp_bootstrap_carousel_dps_title', 'h2', $original_atts); $output .= '<' . $title_tag . ' class="display-posts-title wpbc-dps-title">' . $title . '</' . $title_tag . '>' . "\n"; } // open carousel outer div $output .= '<div style="width:100%;' . $max_width . '" id="wp-bootstrap-carousel-dps-' . $it . '" class="carousel carousel-dps' . ($slide ? " slide" : "") . '" data-interval="' . $interval . '" data-pause="' . $pause . '" data-wrap="' . $wrap . '" data-keyboard="' . $keyboard . '">'; // carousel indicators if ($controls) { $output .= '<ol class="carousel-indicators">'; for ($i = 0; $i < self::$found_posts; $i++) { $output .= '<li data-target="#wp-bootstrap-carousel-dps-' . $it . '" data-slide-to="' . $i . '" class="' . ($i == 0 ? "active" : "") . '"></li>'; } $output .= '</ol>'; } // open carousel inner div $output .= '<div class="carousel-inner carousel-inner-dps" role="listbox">'; // return output return $output; }
/** * Main WP_Bootstrap_Carousel instance * * Ensures only one instance of WP Bootstrap Carousel is loaded or can be loaded. * * @since 0.5.0 * @static * @return WP_Bootstrap_Carousel, main instance */ public static function instance() { if (is_null(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }