s->get_image_src( $id, $item, $data, 'mobile' ); return $attr . ' data-soliloquy-src-mobile="' . esc_url( $mobile_image ) . '"'; } /** * Shuffles and randomizes images in a slider. * * @since 1.0.0 * * @param array $data The slider data to use for retrieval. * @return array $data Shuffled slider data. */ public function shuffle( $data ) { // Return early there are no items to shuffle. if ( ! is_array( $data['slider'] ) ) { return $data; } // Prepare variables. $random = []; $keys = array_keys( $data['slider'] ); // Shuffle the keys and loop through them to create a new, randomized array of images. shuffle( $keys ); foreach ( $keys as $key ) { $random[ $key ] = $data['slider'][ $key ]; } // Return the randomized image array. $data['slider'] = $random; return $data; } /** * Helper method for retrieving config values. * * @since 1.0.0 * * @param string $key The config key to retrieve. * @param array $data The slider data to use for retrieval. * @return string Key value on success, default if not set. */ public function get_config( $key, $data ) { $instance = Soliloquy_Common_Lite::get_instance(); return isset( $data['config'][ $key ] ) ? $data['config'][ $key ] : $instance->get_config_default( $key ); } /** * Helper method to minify a string of data. * * @since 1.0.4 * * @param string $string String of data to minify. * @return string $string Minified string of data. */ public function minify( $string ) { $clean = preg_replace( '/((?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:\/\/.*))/', '', $string ); $clean = str_replace( [ "\r\n", "\r", "\t", "\n", ' ', ' ', ' ' ], '', $clean ); return apply_filters( 'soliloquy_minified_string', $clean, $string ); } /** * Outputs only the first image of the slider inside a regular
tag * to avoid styling issues with feeds. * * @since 1.0.0 * * @param array $data Array of slider data. * @return string $slider Custom slider output for feeds. */ public function do_feed_output( $data ) { $slider = '
'; foreach ( $data['slider'] as $id => $item ) { // Skip over images that are pending (ignore if in Preview mode). if ( isset( $item['status'] ) && 'pending' === $item['status'] && ! is_preview() ) { continue; } $imagesrc = $this->get_image_src( $id, $item, $data ); $slider .= '' . esc_attr( $item['alt'] ) . ''; break; } $slider .= '
'; return apply_filters( 'soliloquy_feed_output', $slider, $data ); } /** * Returns the query args to be passed to YouTube videos. * * @since 1.0.0 * * @param array $data Array of slider data. */ public function get_youtube_args( $data ) { return apply_filters( 'soliloquy_youtube_args', [ 'enablejsapi' => 1, 'version' => 3, 'wmode' => 'transparent', 'rel' => 0, 'showinfo' => 0, 'modestbranding' => 1, 'autoplay' => 1, 'origin' => get_home_url(), ], $data ); } /** * Returns the query args to be passed to Vimeo videos. * * @since 1.0.0 * * @param array $data Array of slider data. */ public function get_vimeo_args( $data ) { return apply_filters( 'soliloquy_vimeo_args', [ 'api' => 1, 'wmode' => 'transparent', 'byline' => 0, 'title' => 0, 'portrait' => 0, 'autoplay' => 1, 'badge' => 0, 'fullscreen' => 1, ], $data ); } /** * Returns the query args to be passed to Wistia videos. * * @since 1.0.0 * * @param array $data Array of slider data. */ public function get_wistia_args( $data ) { return apply_filters( 'soliloquy_wistia_args', [ 'version' => 'v1', 'wmode' => 'opaque', 'volumeControl' => 1, 'controlsVisibleOnLoad' => 1, 'videoFoam' => 1, ], $data ); } /** * Flag for detecting a mobile device server-side. * * @since 1.0.0 * * @return bool True if on a mobile device, false otherwise. */ public function is_mobile() { // Return wp_is_mobile for the final check. return wp_is_mobile(); } /** * Returns the singleton instance of the class. * * @since 1.0.0 * * @return object The Soliloquy_Shortcode_Lite object. */ public static function get_instance() { if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Soliloquy_Shortcode_Lite ) ) { self::$instance = new Soliloquy_Shortcode_Lite(); } return self::$instance; } } // Load the shortcode class. $soliloquy_shortcode_lite = Soliloquy_Shortcode_Lite::get_instance();