diff options
Diffstat (limited to 'plugins/jetpack/modules/shortcodes')
86 files changed, 0 insertions, 12833 deletions
diff --git a/plugins/jetpack/modules/shortcodes/archiveorg-book.php b/plugins/jetpack/modules/shortcodes/archiveorg-book.php deleted file mode 100644 index 88ac328c..00000000 --- a/plugins/jetpack/modules/shortcodes/archiveorg-book.php +++ /dev/null @@ -1,130 +0,0 @@ -<?php -/** - * Archive.org Shortcode - * - * Usage: - * [archiveorg-book goodytwoshoes00newyiala] - * [archiveorg-book http://www.archive.org/stream/goodytwoshoes00newyiala] - * [archiveorg id=goodytwoshoes00newyiala width=480 height=430] - - * <iframe src='https://www.archive.org/stream/goodytwoshoes00newyiala?ui=embed#mode/1up' width='480px' height='430px' frameborder='0' ></iframe> - * - * @package Jetpack - */ - -/** - * Get ID of requested archive.org book embed. - * - * @since 4.5.0 - * - * @param array $atts Shortcode attributes. - * - * @return int|string - */ -function jetpack_shortcode_get_archiveorg_book_id( $atts ) { - if ( isset( $atts[0] ) ) { - $atts[0] = trim( $atts[0], '=' ); - if ( preg_match( '#archive.org/stream/(.+)/?$#i', $atts[0], $match ) ) { - $id = $match[1]; - } else { - $id = $atts[0]; - } - return $id; - } - return 0; -} - -/** - * Convert an archive.org book shortcode into an embed code. - * - * @since 4.5.0 - * - * @param array $atts An array of shortcode attributes. - * @return string The embed code for the Archive.org book - */ -function jetpack_archiveorg_book_shortcode( $atts ) { - global $content_width; - - if ( isset( $atts[0] ) && empty( $atts['id'] ) ) { - $atts['id'] = jetpack_shortcode_get_archiveorg_book_id( $atts ); - } - - $atts = shortcode_atts( - array( - 'id' => '', - 'width' => 480, - 'height' => 430, - ), - $atts - ); - - if ( ! $atts['id'] ) { - return '<!-- error: missing archive.org book ID -->'; - } - - $id = $atts['id']; - - if ( ! $atts['width'] ) { - $width = absint( $content_width ); - } else { - $width = intval( $atts['width'] ); - } - - if ( ! $atts['height'] ) { - $height = round( ( $width / 640 ) * 360 ); - } else { - $height = intval( $atts['height'] ); - } - - $url = esc_url( set_url_scheme( "http://archive.org/stream/{$id}?ui=embed#mode/1up" ) ); - - $html = "<div class='embed-archiveorg-book' style='text-align:center;'><iframe src='$url' width='$width' height='$height' style='border:0;' webkitallowfullscreen='true' mozallowfullscreen='true' allowfullscreen></iframe></div>"; - return $html; -} - -add_shortcode( 'archiveorg-book', 'jetpack_archiveorg_book_shortcode' ); - -/** - * Compose shortcode from archive.org book iframe. - * - * @since 4.5.0 - * - * @param string $content Post content. - * - * @return mixed - */ -function jetpack_archiveorg_book_embed_to_shortcode( $content ) { - if ( ! is_string( $content ) || false === stripos( $content, 'archive.org/stream/' ) ) { - return $content; - } - - $regexp = '!<iframe\s+src=[\'"](http|https)://(www.archive|archive)\.org/stream/([^\'"]+)[\'"]((?:\s+\w+(=[\'"][^\'"]*[\'"])?)*)\s></iframe>!i'; - - if ( ! preg_match_all( $regexp, $content, $matches, PREG_SET_ORDER ) ) { - return $content; - } - - foreach ( $matches as $match ) { - $url = explode( '?', $match[3] ); - $id = $url[0]; - - $params = $match[4]; - - $params = wp_kses_hair( $params, array( 'http' ) ); - - $width = isset( $params['width'] ) ? absint( $params['width']['value'] ) : 0; - $height = isset( $params['height'] ) ? absint( $params['height']['value'] ) : 0; - - $wh = ''; - if ( $width && $height ) { - $wh = ' width=' . $width . ' height=' . $height; - } - - $shortcode = '[archiveorg-book ' . $id . $wh . ']'; - $content = str_replace( $match[0], $shortcode, $content ); - } - - return $content; -} - -add_filter( 'pre_kses', 'jetpack_archiveorg_book_embed_to_shortcode' ); diff --git a/plugins/jetpack/modules/shortcodes/archiveorg.php b/plugins/jetpack/modules/shortcodes/archiveorg.php deleted file mode 100644 index 4a335b32..00000000 --- a/plugins/jetpack/modules/shortcodes/archiveorg.php +++ /dev/null @@ -1,160 +0,0 @@ -<?php -/** - * Archive.org book shortcode. - * - * Usage: - * [archiveorg Experime1940] - * [archiveorg http://archive.org/details/Experime1940 poster=http://archive.org/images/map.png] - * [archiveorg id=Experime1940 width=640 height=480 autoplay=1] - - * <iframe src="http://archive.org/embed/Experime1940&autoplay=1&poster=http://archive.org/images/map.png" width="640" height="480" frameborder="0" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen></iframe> - * - * @package Jetpack - */ - -/** - * Get ID of requested archive.org embed. - * - * @since 4.5.0 - * - * @param array $atts Shortcode attributes. - * - * @return int|string - */ -function jetpack_shortcode_get_archiveorg_id( $atts ) { - if ( isset( $atts[0] ) ) { - $atts[0] = trim( $atts[0], '=' ); - if ( preg_match( '#archive.org/(details|embed)/(.+)/?$#i', $atts[0], $match ) ) { - $id = $match[2]; - } else { - $id = $atts[0]; - } - return $id; - } - return 0; -} - -/** - * Convert an archive.org shortcode into an embed code. - * - * @since 4.5.0 - * - * @param array $atts An array of shortcode attributes. - * @return string The embed code for the archive.org video. - */ -function jetpack_archiveorg_shortcode( $atts ) { - global $content_width; - - if ( isset( $atts[0] ) && empty( $atts['id'] ) ) { - $atts['id'] = jetpack_shortcode_get_archiveorg_id( $atts ); - } - - $atts = shortcode_atts( - array( - 'id' => '', - 'width' => 640, - 'height' => 480, - 'autoplay' => 0, - 'poster' => '', - ), - $atts - ); - - if ( ! $atts['id'] ) { - return '<!-- error: missing archive.org ID -->'; - } - - $id = $atts['id']; - - if ( ! $atts['width'] ) { - $width = absint( $content_width ); - } else { - $width = intval( $atts['width'] ); - } - - if ( ! $atts['height'] ) { - $height = round( ( $width / 640 ) * 360 ); - } else { - $height = intval( $atts['height'] ); - } - - if ( $atts['autoplay'] ) { - $autoplay = '&autoplay=1'; - } else { - $autoplay = ''; - } - - if ( $atts['poster'] ) { - $poster = '&poster=' . $atts['poster']; - } else { - $poster = ''; - } - - $url = esc_url( set_url_scheme( "https://archive.org/embed/{$id}{$autoplay}{$poster}" ) ); - - $html = "<div class='embed-archiveorg' style='text-align:center;'><iframe src='$url' width='$width' height='$height' style='border:0;' webkitallowfullscreen='true' mozallowfullscreen='true' allowfullscreen></iframe></div>"; - - return $html; -} - -add_shortcode( 'archiveorg', 'jetpack_archiveorg_shortcode' ); - -/** - * Compose shortcode from archive.org iframe. - * - * @since 4.5.0 - * - * @param string $content Post content. - * - * @return mixed - */ -function jetpack_archiveorg_embed_to_shortcode( $content ) { - if ( ! is_string( $content ) || false === stripos( $content, 'archive.org/embed/' ) ) { - return $content; - } - - $regexp = '!<iframe\s+src=[\'"]https?://archive\.org/embed/([^\'"]+)[\'"]((?:\s+\w+(=[\'"][^\'"]*[\'"])?)*)></iframe>!i'; - - if ( ! preg_match_all( $regexp, $content, $matches, PREG_SET_ORDER ) ) { - return $content; - } - - foreach ( $matches as $match ) { - $url = explode( '&', $match[1] ); - $id = 'id=' . $url[0]; - - $autoplay = ''; - $poster = ''; - $url_count = count( $url ); - - for ( $ii = 1; $ii < $url_count; $ii++ ) { - if ( 'autoplay=1' === $url[ $ii ] ) { - $autoplay = ' autoplay="1"'; - } - - $map_matches = array(); - if ( preg_match( '/^poster=(.+)$/', $url[ $ii ], $map_matches ) ) { - $poster = " poster=\"{$map_matches[1]}\""; - } - } - - $params = $match[2]; - - $params = wp_kses_hair( $params, array( 'http' ) ); - - $width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0; - $height = isset( $params['height'] ) ? (int) $params['height']['value'] : 0; - - $wh = ''; - if ( $width && $height ) { - $wh = ' width=' . $width . ' height=' . $height; - } - - $shortcode = '[archiveorg ' . $id . $wh . $autoplay . $poster . ']'; - $content = str_replace( $match[0], $shortcode, $content ); - } - - return $content; -} - -add_filter( 'pre_kses', 'jetpack_archiveorg_embed_to_shortcode' ); diff --git a/plugins/jetpack/modules/shortcodes/archives.php b/plugins/jetpack/modules/shortcodes/archives.php deleted file mode 100644 index 173bbbb1..00000000 --- a/plugins/jetpack/modules/shortcodes/archives.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php - -/* - * Archives shortcode - * @author bubel & nickmomrik - * [archives limit=10] - */ - -add_shortcode( 'archives', 'archives_shortcode' ); - -function archives_shortcode( $atts ) { - if ( is_feed() ) { - return '[archives]'; - } - - global $allowedposttags; - - $default_atts = array( - 'type' => 'postbypost', - 'limit' => '', - 'format' => 'html', - 'showcount' => false, - 'before' => '', - 'after' => '', - 'order' => 'desc', - ); - - $attr = shortcode_atts( $default_atts, $atts, 'archives' ); - - if ( ! in_array( $attr['type'], array( 'yearly', 'monthly', 'daily', 'weekly', 'postbypost' ) ) ) { - $attr['type'] = 'postbypost'; - } - - if ( ! in_array( $attr['format'], array( 'html', 'option', 'custom' ) ) ) { - $attr['format'] = 'html'; - } - - $limit = intval( $attr['limit'] ); - // A Limit of 0 makes no sense so revert back to the default. - if ( empty( $limit ) ) { - $limit = ''; - } - - $showcount = ( false !== $attr['showcount'] && 'false' !== $attr['showcount'] ) ? true : false; - $before = wp_kses( $attr['before'], $allowedposttags ); - $after = wp_kses( $attr['after'], $allowedposttags ); - - // Get the archives - $archives = wp_get_archives( - array( - 'type' => $attr['type'], - 'limit' => $limit, - 'format' => $attr['format'], - 'echo' => false, - 'show_post_count' => $showcount, - 'before' => $before, - 'after' => $after, - ) - ); - - if ( 'asc' === $attr['order'] ) { - $archives = implode( "\n", array_reverse( explode( "\n", $archives ) ) ); - } - - // Check to see if there are any archives - if ( empty( $archives ) ) { - $archives = '<p>' . __( 'Your blog does not currently have any published posts.', 'jetpack' ) . '</p>'; - } elseif ( 'option' === $attr['format'] ) { - $archives = '<select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;"><option value="' . get_permalink() . '">--</option>' . $archives . '</select>'; - } elseif ( 'html' === $attr['format'] ) { - $archives = '<ul>' . $archives . '</ul>'; - } - - return $archives; -} diff --git a/plugins/jetpack/modules/shortcodes/audio.php b/plugins/jetpack/modules/shortcodes/audio.php deleted file mode 100644 index 88c13090..00000000 --- a/plugins/jetpack/modules/shortcodes/audio.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php -/** - * Deprecated. No longer needed. - * - * @package Jetpack - */ diff --git a/plugins/jetpack/modules/shortcodes/bandcamp.php b/plugins/jetpack/modules/shortcodes/bandcamp.php deleted file mode 100644 index 312418f7..00000000 --- a/plugins/jetpack/modules/shortcodes/bandcamp.php +++ /dev/null @@ -1,229 +0,0 @@ -<?php -// shortcode handler for [bandcamp], which inserts a bandcamp.com -// music player (iframe, html5) -// -// [bandcamp album=119385304] -// [bandcamp album=3462839126 bgcol=FFFFFF linkcol=4285BB size=venti] -// [bandcamp track=2446959313] -// -function shortcode_handler_bandcamp( $atts ) { - // there are no default values, but specify here anyway - // to explicitly list supported atts - $attributes = shortcode_atts( - array( - 'album' => null, // integer album id - 'track' => null, // integer track id - 'video' => null, // integer track id for video player - 'size' => 'venti', // one of the supported sizes - 'bgcol' => 'FFFFFF', // hex, no '#' prefix - 'linkcol' => null, // hex, no '#' prefix - 'layout' => null, // encoded layout url - 'width' => null, // integer with optional "%" - 'height' => null, // integer with optional "%" - 'notracklist' => null, // may be string "true" (defaults false) - 'tracklist' => null, // may be string "false" (defaults true) - 'artwork' => null, // may be string "false" (alternately: "none") or "small" (default is large) - 'minimal' => null, // may be string "true" (defaults false) - 'theme' => null, // may be theme identifier string ("light"|"dark" so far) - 'package' => null, // integer package id - 't' => null, // integer track number - 'tracks' => null, // comma separated list of allowed tracks - 'esig' => null, // hex, no '#' prefix - ), - $atts, - 'bandcamp' - ); - - $sizes = array( - 'venti' => array( - 'width' => 400, - 'height' => 100, - ), - 'grande' => array( - 'width' => 300, - 'height' => 100, - ), - 'grande2' => array( - 'width' => 300, - 'height' => 355, - ), - 'grande3' => array( - 'width' => 300, - 'height' => 415, - ), - 'tall_album' => array( - 'width' => 150, - 'height' => 295, - ), - 'tall_track' => array( - 'width' => 150, - 'height' => 270, - ), - 'tall2' => array( - 'width' => 150, - 'height' => 450, - ), - 'short' => array( - 'width' => 46, - 'height' => 23, - ), - 'large' => array( - 'width' => 350, - 'height' => 470, - ), - 'medium' => array( - 'width' => 450, - 'height' => 120, - ), - 'small' => array( - 'width' => 350, - 'height' => 42, - ), - ); - - $sizekey = $attributes['size']; - $height = null; - $width = null; - - $isVideo = false; - - // Build iframe url. For audio players, args are appended as - // extra path segments for historical reasons having to - // do with an IE-only flash bug which required this URL - // to contain no querystring. Delay the actual joining - // of args into a string until after we decide if it's - // a video player or an audio player - $argparts = array(); - - if ( ! isset( $attributes['album'] ) && ! isset( $attributes['track'] ) && ! isset( $attributes['video'] ) ) { - return "[bandcamp: shortcode must include 'track', 'album', or 'video' param]"; - } - - if ( isset( $attributes['track'] ) && is_numeric( $attributes['track'] ) ) { - $track = esc_attr( $attributes['track'] ); - array_push( $argparts, "track={$track}" ); - } elseif ( isset( $attributes['video'] ) && is_numeric( $attributes['video'] ) ) { - $track = esc_attr( $attributes['video'] ); // videos are referenced by track id - $urlbase = '//bandcamp.com/EmbeddedPlayer/v=2'; - $isVideo = true; - array_push( $argparts, "track={$track}" ); - } - if ( isset( $attributes['album'] ) && is_numeric( $attributes['album'] ) ) { - $album = esc_attr( $attributes['album'] ); - array_push( $argparts, "album={$album}" ); - } - - if ( $sizekey == 'tall' ) { - if ( isset( $attributes['album'] ) ) { - $sizekey .= '_album'; - } else { - $sizekey .= '_track'; - } - } - - // if size specified that we don't recognize, fall back on venti - if ( empty( $sizes[ $sizekey ] ) ) { - $sizekey = 'venti'; - $attributes['size'] = 'venti'; - } - - // use strict regex for digits + optional % instead of absint for height/width - // 'width' and 'height' params in the iframe url get the exact string from the shortcode - // args, whereas the inline style attribute must have "px" added to it if it has no "%" - if ( isset( $attributes['width'] ) && preg_match( '|^([0-9]+)(%)?$|', $attributes['width'], $matches ) ) { - $width = $csswidth = $attributes['width']; - if ( sizeof( $matches ) < 3 ) { - $csswidth .= 'px'; - } - } - if ( isset( $attributes['height'] ) && preg_match( '|^([0-9]+)(%)?$|', $attributes['height'], $matches ) ) { - $height = $cssheight = $attributes['height']; - if ( sizeof( $matches ) < 3 ) { - $cssheight .= 'px'; - } - } - - if ( ! $height ) { - $height = $sizes[ $sizekey ]['height']; - $cssheight = $height . 'px'; - } - - if ( ! $width ) { - $width = $sizes[ $sizekey ]['width']; - $csswidth = $width . 'px'; - } - - if ( isset( $attributes['layout'] ) ) { - array_push( $argparts, "layout={$attributes['layout']}" ); - } elseif ( isset( $attributes['size'] ) && preg_match( '|^[a-zA-Z0-9]+$|', $attributes['size'] ) ) { - array_push( $argparts, "size={$attributes['size']}" ); - } - - if ( isset( $attributes['bgcol'] ) && preg_match( '|^[0-9A-Fa-f]+$|', $attributes['bgcol'] ) ) { - array_push( $argparts, "bgcol={$attributes['bgcol']}" ); - } - - if ( isset( $attributes['linkcol'] ) && preg_match( '|^[0-9A-Fa-f]+$|', $attributes['linkcol'] ) ) { - array_push( $argparts, "linkcol={$attributes['linkcol']}" ); - } - - if ( isset( $attributes['package'] ) && preg_match( '|^[0-9]+$|', $attributes['package'] ) ) { - array_push( $argparts, "package={$attributes['package']}" ); - } - - if ( isset( $attributes['t'] ) && preg_match( '|^[0-9]+$|', $attributes['t'] ) ) { - array_push( $argparts, "t={$attributes['t']}" ); - } - - if ( $attributes['notracklist'] == 'true' ) { - array_push( $argparts, 'notracklist=true' ); - } - - // 'tracklist' arg deprecates 'notracklist=true' to be less weird. note, behavior - // if both are specified is undefined - switch ( $attributes['tracklist'] ) { - case 'false': - case 'none': - array_push( $argparts, 'tracklist=false' ); - break; - } - - switch ( $attributes['artwork'] ) { - case 'false': - case 'none': - case 'small': - array_push( $argparts, 'artwork=' . $attributes['artwork'] ); - break; - } - - if ( $attributes['minimal'] == 'true' ) { - array_push( $argparts, 'minimal=true' ); - } - - if ( isset( $attributes['theme'] ) && preg_match( '|^[a-zA-Z_]+$|', $attributes['theme'] ) ) { - array_push( $argparts, "theme={$attributes['theme']}" ); - } - - // param 'tracks' is signed digest param 'esig' - if ( isset( $attributes['tracks'] ) && preg_match( '|^[0-9\,]+$|', $attributes['tracks'] ) ) { - if ( isset( $attributes['esig'] ) && preg_match( '|^[0-9A-Fa-f]+$|', $attributes['esig'] ) ) { - array_push( $argparts, "tracks={$attributes['tracks']}" ); - array_push( $argparts, "esig={$attributes['esig']}" ); - } - } - - if ( $isVideo ) { - $url = '//bandcamp.com/VideoEmbed?' . join( '&', $argparts ); - $extraAttrs = " mozallowfullscreen='1' webkitallowfullscreen='1' allowfullscreen='1'"; - } else { - $url = '//bandcamp.com/EmbeddedPlayer/v=2/' . join( '/', $argparts ) . '/'; - $extraAttrs = ''; - } - - $iframe = '<iframe width="%s" height="%s" style="position: relative; display: block; width: %s; height: %s;" src="%s" allowtransparency="true" frameborder="0"%s></iframe>'; - $iframe = sprintf( $iframe, esc_attr( $width ), esc_attr( $height ), esc_attr( $csswidth ), esc_attr( $cssheight ), esc_url( $url ), $extraAttrs ); - - return $iframe; -} - -add_shortcode( 'bandcamp', 'shortcode_handler_bandcamp' ); diff --git a/plugins/jetpack/modules/shortcodes/brightcove.php b/plugins/jetpack/modules/shortcodes/brightcove.php deleted file mode 100644 index 5eca5293..00000000 --- a/plugins/jetpack/modules/shortcodes/brightcove.php +++ /dev/null @@ -1,295 +0,0 @@ -<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName - -/** - * Brightcove shortcode. - * - * Brighcove had renovated their video player embedding code since they introduced their "new studio". - * See https://support.brightcove.com/en/video-cloud/docs. - * The new code is not 100% backward compatible, as long as a customized player is used. - * By the time I wrote this, there were about 150000+ posts embedded legacy players, so it would be a bad - * idea either to introduce a new brightcove shortcode, or to break those posts completely. - * - * That's why we introduce a less aggressive way: leaving the old embedding code untouched, and - * introduce a new set of shortcode parameters which are translated to the latest Brightcove embedding code. - * - * e.g. - * [brightcove video_id="12345" account_id="99999"] will be translated to the latest embedding code. - * [brightcove exp=627045696&vid=1415670151] or [brightcove exp=1463233149&vref=1601200825] will be translated - * to the legacy code. - */ -class Jetpack_Brightcove_Shortcode { - /** - * Shortcode name. - * - * @var string - */ - public static $shortcode = 'brightcove'; - - /** - * Parse shortcode arguments and render its output. - * - * @since 4.5.0 - * - * @param array $atts Shortcode parameters. - * - * @return string - */ - public static function convert( $atts ) { - $normalized_atts = self::normalize_attributes( $atts ); - - if ( empty( $atts ) ) { - return '<!-- Missing Brightcove parameters -->'; - } - - return self::has_legacy_atts( $normalized_atts ) - ? self::convert_to_legacy_studio( $normalized_atts ) - : self::convert_to_new_studio( $normalized_atts ); - } - - /** - * We need to take care of two kinds of shortcode format here. - * The latest: [shortcode a=1 b=2] and the legacy: [shortcode a=1&b=2] - * For an old shortcode: [shortcode a=1&b=2&c=3], it would be parsed into array( 'a' => 1&b=2&c=3' ), which is useless. - * However, since we want to determine whether to call convert_to_legacy_studio() or convert_to_new_studio() via passed parameters, we still need to parse the two properly. - * See http://jetpack.wp-a2z.org/oik_api/shortcode_new_to_old_params/ - * - * @since 4.5.0 - * - * @param array $atts Shortcode parameters. - * - * @return array - */ - public static function normalize_attributes( $atts ) { - if ( is_array( $atts ) && 1 === count( $atts ) ) { // this is the case we need to take care of. - $parsed_atts = array(); - $params = shortcode_new_to_old_params( $atts ); - - /** - * Filter the Brightcove shortcode parameters. - * - * @module shortcodes - * - * @since 4.5.0 - * - * @param string $params String of shortcode parameters. - */ - $params = apply_filters( 'brightcove_dimensions', $params ); - parse_str( $params, $parsed_atts ); - - return $parsed_atts; - } else { - return $atts; - } - } - - /** - * Check that it has legacy attributes. - * - * @since 4.5.0 - * - * @param array $atts Shortcode parameters. - * - * @return bool - */ - public static function has_legacy_atts( $atts ) { - return ( isset( $atts['vid'] ) || isset( $atts['vref'] ) ) - && ( isset( $atts['exp'] ) || isset( $atts['exp3'] ) ); - } - - /** - * Convert to latest player format. - * - * @since 4.5.0 - * - * @param array $atts Shortcode parameters. - * - * @return string - */ - public static function convert_to_new_studio( $atts ) { - $defaults = array( - 'account_id' => '', - 'video_id' => '', - 'player_id' => 'default', - 'width' => '100%', - 'height' => '100%', - ); - - $atts_applied = shortcode_atts( $defaults, $atts, self::$shortcode ); - - $player_url = sprintf( - '//players.brightcove.net/%s/%s_default/index.html?videoId=%s', - esc_attr( $atts_applied['account_id'] ), - esc_attr( $atts_applied['player_id'] ), - esc_attr( $atts_applied['video_id'] ) - ); - - $output_html = sprintf( - '<iframe src="' . esc_url( $player_url ) . '" allowfullscreen webkitallowfullscreen mozallowfullscreen style="width: %spx; height: %spx;"></iframe>', - esc_attr( $atts_applied['width'] ), - esc_attr( $atts_applied['height'] ) - ); - - return $output_html; - } - - /** - * Convert to legacy player format. - * - * [brightcove exp=627045696&vid=1415670151] for the older player and backward compatibility - * [brightcove exp=1463233149&vref=1601200825] for the new player - * - * @since 4.5.0 - * - * @param array $atts Shortcode parameters. - * - * @return string - */ - public static function convert_to_legacy_studio( $atts ) { - $attr = shortcode_atts( - array( - 'bg' => '', - 'exp' => '', - 'exp3' => '', - 'h' => '', - 'lbu' => '', - 'pk' => '', - 'pubid' => '', - 's' => '', - 'surl' => '', - 'vid' => '', - 'vref' => '', - 'w' => '', - ), - $atts - ); - - if ( isset( $attr['pk'] ) ) { - $attr['pk'] = rawurlencode( preg_replace( '/[^a-zA-Z0-9!*\'();:@&=+$,\/?#\[\]\-_.~ ]/', '', $attr['pk'] ) ); - } - - if ( isset( $attr['bg'] ) ) { - $attr['bg'] = preg_replace( '![^-a-zA-Z0-9#]!', '', $attr['bg'] ); - } - - $fv = array( - 'viewerSecureGatewayURL' => 'https://services.brightcove.com/services/amfgateway', - 'servicesURL' => 'http://services.brightcove.com/services', - 'cdnURL' => 'http://admin.brightcove.com', - 'autoStart' => 'false', - ); - - $js_tld = 'com'; - $src = ''; - $name = 'flashObj'; - $html5 = false; - - if ( isset( $attr['exp3'] ) ) { - if ( isset( $attr['surl'] ) && strpos( $attr['surl'], 'brightcove.co.jp' ) ) { - $js_tld = 'co.jp'; - } - if ( ! isset( $attr['surl'] ) || ! preg_match( '#^https?://(?:[a-z\d-]+\.)*brightcove\.(?:com|co\.jp)/#', $attr['surl'] ) ) { - $attr['surl'] = 'http://c.brightcove.com/services'; - } - - $attr['exp3'] = intval( $attr['exp3'] ); - $attr['pubid'] = intval( $attr['pubid'] ); - $attr['vid'] = intval( $attr['vid'] ); - - $fv['servicesURL'] = $attr['surl']; - $fv['playerID'] = $attr['exp3']; - $fv['domain'] = 'embed'; - $fv['videoID'] = intval( $attr['vid'] ); - - $src = sprintf( - '%s/viewer/federated_f9/%s?isVid=1&isUI=1&publisherID=%s', - $attr['surl'], - $attr['exp3'], - $attr['pubid'] - ); - $html5 = true; - } elseif ( isset( $attr['exp'] ) ) { - $attr['exp'] = intval( $attr['exp'] ); - $src = 'http://services.brightcove.com/services/viewer/federated_f8/' . $attr['exp']; - if ( $attr['vid'] ) { - $fv['videoId'] = $attr['vid']; - } elseif ( $attr['vref'] ) { - $fv['videoRef'] = $attr['vref']; - } - - $fv['playerId'] = $attr['exp']; - $fv['domain'] = 'embed'; - } else { - return '<small>brightcove error: missing required parameter exp or exp3</small>'; - } - - if ( ! empty( $attr['lbu'] ) ) { - $fv['linkBaseURL'] = $attr['lbu']; - } - - $flashvars = trim( add_query_arg( array_map( 'urlencode', $fv ), '' ), '?' ); - - $width = null; - $height = null; - - if ( ! empty( $attr['w'] ) && ! empty( $attr['h'] ) ) { - $w = abs( (int) $attr['w'] ); - $h = abs( (int) $attr['h'] ); - if ( $w && $h ) { - $width = $w; - $height = $h; - } - } elseif ( empty( $attr['s'] ) || 'l' === $attr['s'] ) { - $width = '480'; - $height = '360'; - } - - if ( empty( $width ) || empty( $height ) ) { - $width = '280'; - $height = '210'; - } - - if ( $html5 ) { - wp_enqueue_script( - 'brightcove-loader', - Jetpack::get_file_url_for_environment( '_inc/build/shortcodes/js/brightcove.min.js', 'modules/shortcodes/js/brightcove.js' ), - array( 'jquery' ), - 20121127, - false - ); - wp_localize_script( - 'brightcove-loader', - 'brightcoveData', - array( - 'tld' => esc_js( $js_tld ), - ) - ); - - return ' - <object id="myExperience" class="BrightcoveExperience"> - <param name="bgcolor" value="' . esc_attr( $attr['bg'] ) . '" /> - <param name="width" value="' . esc_attr( $width ) . '" /> - <param name="height" value="' . esc_attr( $height ) . '" /> - <param name="playerID" value="' . esc_attr( $attr['exp3'] ) . '" /> - <param name="@videoPlayer" value="' . esc_attr( $attr['vid'] ) . '" /> - <param name="playerKey" value="' . esc_attr( $attr['pk'] ) . '" /> - <param name="isVid" value="1" /> - <param name="isUI" value="1" /> - <param name="dynamicStreaming" value="true" /> - <param name="autoStart" value="false" /> - <param name="secureConnections" value="true" /> - <param name="secureHTMLConnections" value="true" /> - </object>'; - } - - return sprintf( - '<embed src="%s" bgcolor="#FFFFFF" flashvars="%s" base="http://admin.brightcove.com" name="%s" width="%s" height="%s" allowFullScreen="true" seamlesstabbing="false" type="application/x-shockwave-flash" swLiveConnect="true" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" />', - esc_url( $src ), - $flashvars, - esc_attr( $name ), - esc_attr( $width ), - esc_attr( $height ) - ); - } -} - -add_shortcode( Jetpack_Brightcove_Shortcode::$shortcode, array( 'Jetpack_Brightcove_Shortcode', 'convert' ) ); diff --git a/plugins/jetpack/modules/shortcodes/cartodb.php b/plugins/jetpack/modules/shortcodes/cartodb.php deleted file mode 100644 index 82c925d8..00000000 --- a/plugins/jetpack/modules/shortcodes/cartodb.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - - -/* - * Carto (formerly CartoDB) - * - * example URL: http://osm2.carto.com/viz/08aef918-94da-11e4-ad83-0e0c41326911/public_map - * - * possible patterns: - * [username].carto.com/viz/[map-id]/public_map - * [username].carto.com/viz/[map-id]/embed_map - * [username].carto.com/viz/[map-id]/map - * [organization].carto.com/u/[username]/viz/[map-id]/public_map - * [organization].carto.com/u/[username]/viz/[map-id]/embed_map - * [organization].carto.com/u/[username]/viz/[map-id]/map - * - * On July 8th, 2016 CartoDB changed its primary domain from cartodb.com to carto.com - * So this shortcode still supports the cartodb.com domain for oembeds. -*/ - -wp_oembed_add_provider( '#https?://(?:www\.)?[^/^\.]+\.carto(db)?\.com/\S+#i', 'https://services.carto.com/oembed', true ); diff --git a/plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php b/plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php deleted file mode 100644 index d5cfb956..00000000 --- a/plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php +++ /dev/null @@ -1,294 +0,0 @@ -<?php -/** - * The companion file to shortcodes.php - * - * This file contains the code that converts HTML embeds into shortcodes - * for when the user copy/pastes in HTML. - */ - -add_filter( 'pre_kses', array( 'Filter_Embedded_HTML_Objects', 'filter' ), 11 ); -add_filter( 'pre_kses', array( 'Filter_Embedded_HTML_Objects', 'maybe_create_links' ), 100 ); // See WPCom_Embed_Stats::init() - -/** - * Helper class for identifying and parsing known HTML blocks - * - * @since 4.5.0 - * - * @author mdawaffe - * - * Not completely done, but seems to work okay - * Stolen from Mike's Seaside presentation: - * @link http://mdawaffepresents.wordpress.com/?p=36 - */ - -class Filter_Embedded_HTML_Objects { - static public $strpos_filters = array(); - static public $regexp_filters = array(); - static public $current_element = false; - static public $html_strpos_filters = array(); - static public $html_regexp_filters = array(); - static public $failed_embeds = array(); - - /** - * Store tokens found in Syntax Highlighter. - * - * @since 4.5.0 - * - * @var array - */ - static private $sh_unfiltered_content_tokens; - - /** - * Capture tokens found in Syntax Highlighter and collect them in self::$sh_unfiltered_content_tokens. - * - * @since 4.5.0 - * - * @param array $match - * - * @return string - */ - public static function sh_regexp_callback( $match ) { - $token = '[prekses-filter-token-' . mt_rand() . '-' . md5( $match[0] ) . '-' . mt_rand() . ']'; - self::$sh_unfiltered_content_tokens[ $token ] = $match[0]; - return $token; - } - - public static function filter( $html ) { - if ( ! $html || ! is_string( $html ) ) { - return $html; - } - - $regexps = array( - 'object' => '%<object[^>]*+>(?>[^<]*+(?><(?!/object>)[^<]*+)*)</object>%i', - 'embed' => '%<embed[^>]*+>(?:\s*</embed>)?%i', - 'iframe' => '%<iframe[^>]*+>(?>[^<]*+(?><(?!/iframe>)[^<]*+)*)</iframe>%i', - 'div' => '%<div[^>]*+>(?>[^<]*+(?><(?!/div>)[^<]*+)*+)(?:</div>)+%i', - 'script' => '%<script[^>]*+>(?>[^<]*+(?><(?!/script>)[^<]*+)*)</script>%i', - ); - - $unfiltered_content_tokens = array(); - self::$sh_unfiltered_content_tokens = array(); - - // Check here to make sure that SyntaxHighlighter is still used. (Just a little future proofing) - if ( class_exists( 'SyntaxHighlighter' ) ) { - // Replace any "code" shortcode blocks with a token that we'll later replace with its original text. - // This will keep the contents of the shortcode from being filtered - global $SyntaxHighlighter; - - // Check to see if the $SyntaxHighlighter object has been created and is ready for use - if ( isset( $SyntaxHighlighter ) && is_array( $SyntaxHighlighter->shortcodes ) ) { - $shortcode_regex = implode( '|', array_map( 'preg_quote', $SyntaxHighlighter->shortcodes ) ); - $html = preg_replace_callback( - '/\[(' . $shortcode_regex . ')(\s[^\]]*)?\][\s\S]*?\[\/\1\]/m', - array( __CLASS__, 'sh_regexp_callback' ), - $html - ); - $unfiltered_content_tokens = self::$sh_unfiltered_content_tokens; - } - } - - foreach ( $regexps as $element => $regexp ) { - self::$current_element = $element; - - if ( false !== stripos( $html, "<$element" ) ) { - if ( $new_html = preg_replace_callback( $regexp, array( __CLASS__, 'dispatch' ), $html ) ) { - $html = $new_html; - } - } - - if ( false !== stripos( $html, "<$element" ) ) { - $regexp_entities = self::regexp_entities( $regexp ); - if ( $new_html = preg_replace_callback( $regexp_entities, array( __CLASS__, 'dispatch_entities' ), $html ) ) { - $html = $new_html; - } - } - } - - if ( count( $unfiltered_content_tokens ) > 0 ) { - // Replace any tokens generated earlier with their original unfiltered text - $html = str_replace( array_keys( $unfiltered_content_tokens ), $unfiltered_content_tokens, $html ); - } - - return $html; - } - - public static function regexp_entities( $regexp ) { - return preg_replace( - '/\[\^&([^\]]+)\]\*\+/', - '(?>[^&]*+(?>&(?!\1)[^&])*+)*+', - str_replace( '?>', '?' . '>', htmlspecialchars( $regexp, ENT_NOQUOTES ) ) - ); - } - - public static function register( $match, $callback, $is_regexp = false, $is_html_filter = false ) { - if ( $is_html_filter ) { - if ( $is_regexp ) { - self::$html_regexp_filters[ $match ] = $callback; - } else { - self::$html_strpos_filters[ $match ] = $callback; - } - } else { - if ( $is_regexp ) { - self::$regexp_filters[ $match ] = $callback; - } else { - self::$strpos_filters[ $match ] = $callback; - } - } - } - - public static function unregister( $match ) { - // Allow themes/plugins to remove registered embeds - unset( self::$regexp_filters[ $match ] ); - unset( self::$strpos_filters[ $match ] ); - unset( self::$html_regexp_filters[ $match ] ); - unset( self::$html_strpos_filters[ $match ] ); - } - - static function dispatch_entities( $matches ) { - $matches[0] = html_entity_decode( $matches[0] ); - - return self::dispatch( $matches ); - } - - static function dispatch( $matches ) { - $html = preg_replace( '%�*58;//%', '://', $matches[0] ); - $attrs = self::get_attrs( $html ); - if ( isset( $attrs['src'] ) ) { - $src = $attrs['src']; - } elseif ( isset( $attrs['movie'] ) ) { - $src = $attrs['movie']; - } else { - // no src found, search html - foreach ( self::$html_strpos_filters as $match => $callback ) { - if ( false !== strpos( $html, $match ) ) { - return call_user_func( $callback, $attrs ); - } - } - - foreach ( self::$html_regexp_filters as $match => $callback ) { - if ( preg_match( $match, $html ) ) { - return call_user_func( $callback, $attrs ); - } - } - - return $matches[0]; - } - - $src = trim( $src ); - - // check source filter - foreach ( self::$strpos_filters as $match => $callback ) { - if ( false !== strpos( $src, $match ) ) { - return call_user_func( $callback, $attrs ); - } - } - - foreach ( self::$regexp_filters as $match => $callback ) { - if ( preg_match( $match, $src ) ) { - return call_user_func( $callback, $attrs ); - } - } - - // check html filters - foreach ( self::$html_strpos_filters as $match => $callback ) { - if ( false !== strpos( $html, $match ) ) { - return call_user_func( $callback, $attrs ); - } - } - - foreach ( self::$html_regexp_filters as $match => $callback ) { - if ( preg_match( $match, $html ) ) { - return call_user_func( $callback, $attrs ); - } - } - - // Log the strip - if ( function_exists( 'wp_kses_reject' ) ) { - wp_kses_reject( sprintf( __( '<code>%s</code> HTML tag removed as it is not allowed', 'jetpack' ), '<' . self::$current_element . '>' ), array( self::$current_element => $attrs ) ); - } - - // Keep the failed match so we can later replace it with a link, - // but return the original content to give others a chance too. - self::$failed_embeds[] = array( - 'match' => $matches[0], - 'src' => esc_url( $src ), - ); - - return $matches[0]; - } - - /** - * Failed embeds are stripped, so let's convert them to links at least. - * - * @param string $string Failed embed string. - * - * @return string $string Linkified string. - */ - public static function maybe_create_links( $string ) { - if ( empty( self::$failed_embeds ) ) { - return $string; - } - - foreach ( self::$failed_embeds as $entry ) { - $html = sprintf( '<a href="%s">%s</a>', esc_url( $entry['src'] ), esc_url( $entry['src'] ) ); - // Check if the string doesn't contain iframe, before replace. - if ( ! preg_match( '/<iframe /', $string ) ) { - $string = str_replace( $entry['match'], $html, $string ); - } - } - - self::$failed_embeds = array(); - - return $string; - } - - static function get_attrs( $html ) { - if ( ! ( class_exists( 'DOMDocument' ) && function_exists( 'libxml_use_internal_errors' ) && function_exists( 'simplexml_load_string' ) ) ) { - trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) ); - return array(); - } - // We have to go through DOM, since it can load non-well-formed XML (i.e. HTML). SimpleXML cannot. - $dom = new DOMDocument(); - // The @ is not enough to suppress errors when dealing with libxml, - // we have to tell it directly how we want to handle errors. - libxml_use_internal_errors( true ); - @$dom->loadHTML( $html ); // suppress parser warnings - libxml_use_internal_errors( false ); - $xml = false; - foreach ( $dom->childNodes as $node ) { - // find the root node (html) - if ( XML_ELEMENT_NODE == $node->nodeType ) { - // Use simplexml_load_string rather than simplexml_import_dom as the later doesn't cope well if the XML is malformmed in the DOM See #1688-wpcom - libxml_use_internal_errors( true ); - $xml = simplexml_load_string( $dom->saveXML( $node->firstChild->firstChild ) ); // html->body->object - libxml_clear_errors(); - break; - } - } - if ( ! $xml ) { - return array(); - } - - $attrs = array(); - $attrs['_raw_html'] = $html; - - // <param> elements - foreach ( $xml->param as $param ) { - $attrs[ (string) $param['name'] ] = (string) $param['value']; - } - - // <object> attributes - foreach ( $xml->attributes() as $name => $attr ) { - $attrs[ $name ] = (string) $attr; - } - - // <embed> attributes - if ( $xml->embed ) { - foreach ( $xml->embed->attributes() as $name => $attr ) { - $attrs[ $name ] = (string) $attr; - } - } - - return $attrs; - } -} diff --git a/plugins/jetpack/modules/shortcodes/codepen.php b/plugins/jetpack/modules/shortcodes/codepen.php deleted file mode 100644 index 45efa774..00000000 --- a/plugins/jetpack/modules/shortcodes/codepen.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -/* - * CodePen embed - * - * example URL: http://codepen.io/css-tricks/pen/wFeaG -*/ - -// Register oEmbed provider -wp_oembed_add_provider( '#https?://codepen.io/([^/]+)/pen/([^/]+)/?#', 'https://codepen.io/api/oembed', true ); diff --git a/plugins/jetpack/modules/shortcodes/crowdsignal.php b/plugins/jetpack/modules/shortcodes/crowdsignal.php deleted file mode 100644 index e2078a68..00000000 --- a/plugins/jetpack/modules/shortcodes/crowdsignal.php +++ /dev/null @@ -1,610 +0,0 @@ -<?php - -// Keep compatibility with polldaddy-plugin -if ( ! class_exists( 'CrowdsignalShortcode' ) && ! class_exists( 'PolldaddyShortcode' ) ) { - -/** -* Class wrapper for Crowdsignal shortcodes -*/ - -class CrowdsignalShortcode { - - static $add_script = false; - static $scripts = false; - - /** - * Add all the actions & resgister the shortcode - */ - function __construct() { - if ( defined( 'GLOBAL_TAGS' ) == false ) { - add_shortcode( 'crowdsignal', array( $this, 'crowdsignal_shortcode' ) ); - add_shortcode( 'polldaddy', array( $this, 'crowdsignal_shortcode' ) ); - - add_filter( 'pre_kses', array( $this, 'crowdsignal_embed_to_shortcode' ) ); - } - add_action( 'wp_enqueue_scripts', array( $this, 'check_infinite' ) ); - add_action( 'infinite_scroll_render', array( $this, 'crowdsignal_shortcode_infinite' ), 11 ); - } - - private function get_async_code( array $settings, $survey_link ) { - $include = <<<CONTAINER -( function( d, c, j ) { - if ( !d.getElementById( j ) ) { - var pd = d.createElement( c ), s; - pd.id = j; - pd.src = 'https://polldaddy.com/survey.js'; - s = d.getElementsByTagName( c )[0]; - s.parentNode.insertBefore( pd, s ); - } -}( document, 'script', 'pd-embed' ) ); -CONTAINER; - - // Compress it a bit - $include = $this->compress_it( $include ); - - $placeholder = - '<div class="cs-embed pd-embed" data-settings="' - . esc_attr( json_encode( $settings ) ) - . '"></div>'; - if ( 'button' === $settings['type'] ) { - $placeholder = - '<a class="cs-embed pd-embed" href="' - . esc_attr( $survey_link ) - . '" data-settings="' - . esc_attr( json_encode( $settings ) ) - . '">' - . esc_html( $settings['title'] ) - . '</a>'; - } - - $js_include = $placeholder . "\n"; - $js_include .= '<script type="text/javascript"><!--//--><![CDATA[//><!--' . "\n"; - $js_include .= $include . "\n"; - $js_include .= "//--><!]]></script>\n"; - - if ( 'button' !== $settings['type'] ) { - $js_include .= '<noscript>' . $survey_link . "</noscript>\n"; - } - - return $js_include; - } - - private function compress_it( $js ) { - $js = str_replace( array( "\n", "\t", "\r" ), '', $js ); - $js = preg_replace( '/\s*([,:\?\{;\-=\(\)])\s*/', '$1', $js ); - return $js; - } - - /* - * Crowdsignal Poll Embed script - transforms code that looks like that: - * <script type="text/javascript" charset="utf-8" async src="http://static.polldaddy.com/p/123456.js"></script> - * <noscript><a href="http://polldaddy.com/poll/123456/">What is your favourite color?</a></noscript> - * into the [crowdsignal poll=...] shortcode format - */ - function crowdsignal_embed_to_shortcode( $content ) { - - if ( ! is_string( $content ) || false === strpos( $content, 'polldaddy.com/p/' ) ) { - return $content; - } - - $regexes = array(); - - $regexes[] = '#<script[^>]+?src="https?://(secure|static)\.polldaddy\.com/p/([0-9]+)\.js"[^>]*+>\s*?</script>\r?\n?(<noscript>.*?</noscript>)?#i'; - - $regexes[] = '#<script(?:[^&]|&(?!gt;))+?src="https?://(secure|static)\.polldaddy\.com/p/([0-9]+)\.js"(?:[^&]|&(?!gt;))*+>\s*?</script>\r?\n?(<noscript>.*?</noscript>)?#i'; - - foreach ( $regexes as $regex ) { - if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) { - continue; - } - - foreach ( $matches as $match ) { - if ( ! isset( $match[2] ) ) { - continue; - } - - $id = (int) $match[2]; - - if ( $id > 0 ) { - $content = str_replace( $match[0], " [crowdsignal poll=$id]", $content ); - /** This action is documented in modules/shortcodes/youtube.php */ - do_action( 'jetpack_embed_to_shortcode', 'crowdsignal', $id ); - } - } - } - - return $content; - } - - /** - * Shortcode for polldadddy - * [crowdsignal poll|survey|rating="123456"] - */ - function crowdsignal_shortcode( $atts ) { - global $post; - global $content_width; - - /** - * Variables extracted from $atts. - * - * @var string $survey - * @var string $link_text - * @var string $poll - * @var string $rating - * @var string $unique_id - * @var string $item_id - * @var string $title - * @var string $permalink - * @var int $cb - * @var string $type - * @var string $body - * @var string $button - * @var string $text_color - * @var string $back_color - * @var string $align - * @var string $style - * @var int $width - * @var int $height - * @var int $delay - * @var string $visit - * @var string $domain - * @var string $id - */ - extract( shortcode_atts( array( - 'survey' => null, - 'link_text' => 'Take Our Survey', - 'poll' => 'empty', - 'rating' => 'empty', - 'unique_id' => null, - 'item_id' => null, - 'title' => null, - 'permalink' => null, - 'cb' => 0, - 'type' => 'button', - 'body' => '', - 'button' => '', - 'text_color' => '000000', - 'back_color' => 'FFFFFF', - 'align' => '', - 'style' => '', - 'width' => $content_width, - 'height' => floor( $content_width * 3 / 4 ), - 'delay' => 100, - 'visit' => 'single', - 'domain' => '', - 'id' => '', - ), $atts, 'crowdsignal' ) ); - - if ( ! is_array( $atts ) ) { - return '<!-- Crowdsignal shortcode passed invalid attributes -->'; - } - - $inline = ! in_the_loop(); - $no_script = false; - $infinite_scroll = false; - - if ( is_home() && current_theme_supports( 'infinite-scroll' ) ) { - $infinite_scroll = true; - } - - if ( defined( 'PADPRESS_LOADED' ) ) { - $inline = true; - } - - if ( function_exists( 'get_option' ) && get_option( 'polldaddy_load_poll_inline' ) ) { - $inline = true; - } - - if ( is_feed() || ( defined( 'DOING_AJAX' ) && ! $infinite_scroll ) ) { - $no_script = false; - } - - self::$add_script = $infinite_scroll; - - if ( intval( $rating ) > 0 && ! $no_script ) { //rating embed - - if ( empty( $unique_id ) ) { - $unique_id = is_page() ? 'wp-page-' . $post->ID : 'wp-post-' . $post->ID; - } - - if ( empty( $item_id ) ) { - $item_id = is_page() ? '_page_' . $post->ID : '_post_' . $post->ID; - } - - if ( empty( $title ) ) { - /** This filter is documented in core/src/wp-includes/general-template.php */ - $title = apply_filters( 'wp_title', $post->post_title, '', '' ); - } - - if ( empty( $permalink ) ) { - $permalink = get_permalink( $post->ID ); - } - - $rating = intval( $rating ); - $unique_id = preg_replace( '/[^\-_a-z0-9]/i', '', wp_strip_all_tags( $unique_id ) ); - $item_id = wp_strip_all_tags( $item_id ); - $item_id = preg_replace( '/[^_a-z0-9]/i', '', $item_id ); - - $settings = json_encode( array( - 'id' => $rating, - 'unique_id' => $unique_id, - 'title' => rawurlencode( trim( $title ) ), - 'permalink' => esc_url( $permalink ), - 'item_id' => $item_id, - ) ); - - $item_id = esc_js( $item_id ); - - if ( Jetpack_AMP_Support::is_amp_request() ) { - return sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $permalink ), esc_html( trim( $title ) ) ); - } elseif ( $inline ) { - return <<<SCRIPT -<div class="cs-rating pd-rating" id="pd_rating_holder_{$rating}{$item_id}"></div> -<script type="text/javascript" charset="UTF-8"><!--//--><![CDATA[//><!-- -PDRTJS_settings_{$rating}{$item_id}={$settings}; -//--><!]]></script> -<script type="text/javascript" charset="UTF-8" async src="https://polldaddy.com/js/rating/rating.js"></script> -SCRIPT; - } else { - if ( false === self::$scripts ) { - self::$scripts = array(); - } - - $data = array( 'id' => $rating, 'item_id' => $item_id, 'settings' => $settings ); - - self::$scripts['rating'][] = $data; - - add_action( 'wp_footer', array( $this, 'generate_scripts' ) ); - - $data = esc_attr( json_encode( $data ) ); - - if ( $infinite_scroll ) { - return <<<CONTAINER -<div class="cs-rating pd-rating" id="pd_rating_holder_{$rating}{$item_id}" data-settings="{$data}"></div> -CONTAINER; - } else { - return <<<CONTAINER -<div class="cs-rating pd-rating" id="pd_rating_holder_{$rating}{$item_id}"></div> -CONTAINER; - } - } - } elseif ( intval( $poll ) > 0 ) { //poll embed - - if ( empty( $title ) ) { - $title = __( 'Take Our Poll', 'jetpack' ); - } - - $poll = intval( $poll ); - $poll_url = sprintf( 'https://poll.fm/%d', $poll ); - $poll_js = sprintf( 'https://secure.polldaddy.com/p/%d.js', $poll ); - $poll_link = sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $poll_url ), esc_html( $title ) ); - - if ( $no_script || Jetpack_AMP_Support::is_amp_request() ) { - return $poll_link; - } else { - if ( $type == 'slider' && !$inline ) { - - if ( ! in_array( $visit, array( 'single', 'multiple' ) ) ) { - $visit = 'single'; - } - - $settings = array( - 'type' => 'slider', - 'embed' => 'poll', - 'delay' => intval( $delay ), - 'visit' => $visit, - 'id' => intval( $poll ) - ); - - return $this->get_async_code( $settings, $poll_link ); - } else { - $cb = ( $cb == 1 ? '?cb='.mktime() : false ); - $margins = ''; - $float = ''; - - if ( in_array( $align, array( 'right', 'left' ) ) ) { - $float = sprintf( 'float: %s;', $align ); - - if ( $align == 'left') - $margins = 'margin: 0px 10px 0px 0px;'; - elseif ( $align == 'right' ) - $margins = 'margin: 0px 0px 0px 10px'; - } - - // Force the normal style embed on single posts/pages otherwise it's not rendered on infinite scroll themed blogs ('infinite_scroll_render' isn't fired) - if ( is_singular() ) { - $inline = true; - } - - if ( false === $cb && ! $inline ) { - if ( false === self::$scripts ) { - self::$scripts = array(); - } - - $data = array( 'url' => $poll_js ); - - self::$scripts['poll'][intval( $poll )] = $data; - - add_action( 'wp_footer', array( $this, 'generate_scripts' ) ); - - $data = esc_attr( json_encode( $data ) ); - - $script_url = esc_url_raw( plugins_url( 'js/polldaddy-shortcode.js', __FILE__ ) ); - $str = <<<CONTAINER -<a name="pd_a_{$poll}"></a> -<div class="CSS_Poll PDS_Poll" id="PDI_container{$poll}" data-settings="{$data}" style="display:inline-block;{$float}{$margins}"></div> -<div id="PD_superContainer"></div> -<noscript>{$poll_link}</noscript> -CONTAINER; - -$loader = <<<SCRIPT -( function( d, c, j ) { - if ( ! d.getElementById( j ) ) { - var pd = d.createElement( c ), s; - pd.id = j; - pd.src = '{$script_url}'; - s = d.getElementsByTagName( c )[0]; - s.parentNode.insertBefore( pd, s ); - } else if ( typeof jQuery !== 'undefined' ) { - jQuery( d.body ).trigger( 'pd-script-load' ); - } -} ( document, 'script', 'pd-polldaddy-loader' ) ); -SCRIPT; - - $loader = $this->compress_it( $loader ); - $loader = "<script type='text/javascript'>\n" . $loader . "\n</script>"; - - return $str . $loader; - } else { - if ( $inline ) { - $cb = ''; - } - - return <<<CONTAINER -<a id="pd_a_{$poll}"></a> -<div class="CSS_Poll PDS_Poll" id="PDI_container{$poll}" style="display:inline-block;{$float}{$margins}"></div> -<div id="PD_superContainer"></div> -<script type="text/javascript" charset="UTF-8" async src="{$poll_js}{$cb}"></script> -<noscript>{$poll_link}</noscript> -CONTAINER; - } - } - } - } elseif ( ! empty( $survey ) ) { //survey embed - - if ( in_array( $type, array( 'iframe', 'button', 'banner', 'slider' ) ) ) { - - if ( empty( $title ) ) { - $title = __( 'Take Our Survey', 'jetpack' ); - if( ! empty( $link_text ) ) { - $title = $link_text; - } - } - - if ( $type == 'banner' || $type == 'slider' ) - $inline = false; - - $survey = preg_replace( '/[^a-f0-9]/i', '', $survey ); - $survey_url = esc_url( "https://survey.fm/{$survey}" ); - $survey_link = sprintf( '<a href="%s" target="_blank">%s</a>', $survey_url, esc_html( $title ) ); - - $settings = array(); - - // Do we want a full embed code or a link? - if ( $no_script || $inline || $infinite_scroll || Jetpack_AMP_Support::is_amp_request() ) { - return $survey_link; - } - - if ( $type == 'iframe' ) { - if ( $height != 'auto' ) { - if ( isset( $content_width ) && is_numeric( $width ) && $width > $content_width ) { - $width = $content_width; - } - - if ( ! $width ) { - $width = '100%'; - } else { - $width = (int) $width; - } - - if ( ! $height ) { - $height = '600'; - } else { - $height = (int) $height; - } - - return <<<CONTAINER -<iframe src="{$survey_url}?iframe=1" frameborder="0" width="{$width}" height="{$height}" scrolling="auto" allowtransparency="true" marginheight="0" marginwidth="0">{$survey_link}</iframe> -CONTAINER; - } elseif ( ! empty( $domain ) && ! empty( $id ) ) { - - $domain = preg_replace( '/[^a-z0-9\-]/i', '', $domain ); - $id = preg_replace( '/[\/\?&\{\}]/', '', $id ); - - $auto_src = esc_url( "https://{$domain}.survey.fm/{$id}" ); - $auto_src = parse_url( $auto_src ); - - if ( ! is_array( $auto_src ) || count( $auto_src ) == 0 ) { - return '<!-- no crowdsignal output -->'; - } - - if ( ! isset( $auto_src['host'] ) || ! isset( $auto_src['path'] ) ) { - return '<!-- no crowdsignal output -->'; - } - - $domain = $auto_src['host'] . '/'; - $id = ltrim( $auto_src['path'], '/' ); - - $settings = array( - 'type' => $type, - 'auto' => true, - 'domain' => $domain, - 'id' => $id - ); - } - } else { - $text_color = preg_replace( '/[^a-f0-9]/i', '', $text_color ); - $back_color = preg_replace( '/[^a-f0-9]/i', '', $back_color ); - - if ( - ! in_array( - $align, - array( - 'right', - 'left', - 'top-left', - 'top-right', - 'middle-left', - 'middle-right', - 'bottom-left', - 'bottom-right' - ) - ) - ) { - $align = ''; - } - - if ( - ! in_array( - $style, - array( - 'inline', - 'side', - 'corner', - 'rounded', - 'square' - ) - ) - ) { - $style = ''; - } - - $title = wp_strip_all_tags( $title ); - $body = wp_strip_all_tags( $body ); - $button = wp_strip_all_tags( $button ); - - $settings = array_filter( array( - 'title' => $title, - 'type' => $type, - 'body' => $body, - 'button' => $button, - 'text_color' => $text_color, - 'back_color' => $back_color, - 'align' => $align, - 'style' => $style, - 'id' => $survey, - ) ); - } - - if ( empty( $settings ) ) { - return '<!-- no crowdsignal output -->'; - } - - return $this->get_async_code( $settings, $survey_link ); - } - } else { - return '<!-- no crowdsignal output -->'; - } - } - - function generate_scripts() { - $script = ''; - - if ( is_array( self::$scripts ) ) { - if ( isset( self::$scripts['rating'] ) ) { - $script = "<script type='text/javascript' charset='UTF-8' id='polldaddyRatings'><!--//--><![CDATA[//><!--\n"; - foreach( self::$scripts['rating'] as $rating ) { - $script .= "PDRTJS_settings_{$rating['id']}{$rating['item_id']}={$rating['settings']}; if ( typeof PDRTJS_RATING !== 'undefined' ){if ( typeof PDRTJS_{$rating['id']}{$rating['item_id']} == 'undefined' ){PDRTJS_{$rating['id']}{$rating['item_id']} = new PDRTJS_RATING( PDRTJS_settings_{$rating['id']}{$rating['item_id']} );}}"; - } - $script .= "\n//--><!]]></script><script type='text/javascript' charset='UTF-8' async src='https://polldaddy.com/js/rating/rating.js'></script>"; - - } - - if ( isset( self::$scripts['poll'] ) ) { - foreach( self::$scripts['poll'] as $poll ) { - $script .= "<script type='text/javascript' charset='UTF-8' async src='{$poll['url']}'></script>"; - } - } - } - - self::$scripts = false; - echo $script; - } - - /** - * If the theme uses infinite scroll, include jquery at the start - */ - function check_infinite() { - if ( - current_theme_supports( 'infinite-scroll' ) - && class_exists( 'The_Neverending_Home_Page' ) - && The_Neverending_Home_Page::archive_supports_infinity() - ) { - wp_enqueue_script( 'jquery' ); - } - } - - /** - * Dynamically load the .js, if needed - * - * This hooks in late (priority 11) to infinite_scroll_render to determine - * a posteriori if a shortcode has been called. - */ - function crowdsignal_shortcode_infinite() { - // only try to load if a shortcode has been called and theme supports infinite scroll - if( self::$add_script ) { - $script_url = esc_url_raw( plugins_url( 'js/polldaddy-shortcode.js', __FILE__ ) ); - - // if the script hasn't been loaded, load it - // if the script loads successfully, fire an 'pd-script-load' event - echo <<<SCRIPT - <script type='text/javascript'> - //<![CDATA[ - ( function( d, c, j ) { - if ( !d.getElementById( j ) ) { - var pd = d.createElement( c ), s; - pd.id = j; - pd.async = true; - pd.src = '{$script_url}'; - s = d.getElementsByTagName( c )[0]; - s.parentNode.insertBefore( pd, s ); - } else if ( typeof jQuery !== 'undefined' ) { - jQuery( d.body ).trigger( 'pd-script-load' ); - } - } ( document, 'script', 'pd-polldaddy-loader' ) ); - //]]> - </script> -SCRIPT; - - } - } -} - -// kick it all off -new CrowdsignalShortcode(); - -if ( ! function_exists( 'crowdsignal_link' ) ) { - // http://polldaddy.com/poll/1562975/?view=results&msg=voted - function crowdsignal_link( $content ) { - if ( Jetpack_AMP_Support::is_amp_request() ) { - return $content; - } - - return preg_replace( '!(?:\n|\A)https?://(polldaddy\.com/poll|poll\.fm)/([0-9]+?)(/.*)?(?:\n|\Z)!i', "\n<script type='text/javascript' charset='utf-8' src='//static.polldaddy.com/p/$2.js'></script><noscript> <a href='https://poll.fm/$2'>View Poll</a></noscript>\n", $content ); - } - - // higher priority because we need it before auto-link and autop get to it - add_filter( 'the_content', 'crowdsignal_link', 1 ); - add_filter( 'the_content_rss', 'crowdsignal_link', 1 ); -} - - /** - * Note that Core has the oembed of '#https?://survey\.fm/.*#i' as of 5.1. - * This should be removed after Core has the current regex is in our minimum version. - * - * @see https://core.trac.wordpress.org/ticket/46467 - * @todo Confirm patch landed and remove once 5.2 is the minimum version. - */ -wp_oembed_add_provider( '#https?://.+\.survey\.fm/.*#i', 'https://api.crowdsignal.com/oembed', true ); - -} diff --git a/plugins/jetpack/modules/shortcodes/css/quiz.css b/plugins/jetpack/modules/shortcodes/css/quiz.css deleted file mode 100644 index e2a0b36b..00000000 --- a/plugins/jetpack/modules/shortcodes/css/quiz.css +++ /dev/null @@ -1,56 +0,0 @@ -div.jetpack-quiz { - border: 1px solid #deede3; - background-color: #f3f3f3; - padding: 1em; - line-height: 1.3em; - margin-bottom: 2em; - border-radius: .2em; -} - -div.jetpack-quiz div.jetpack-quiz-question { - margin-bottom: .5em; - font-weight: bold; -} - -div.jetpack-quiz div.jetpack-quiz-answer { - cursor: pointer; - margin-bottom: .5em; - padding: 1em 0 1em 1em; - border-bottom: 1px dotted #999; -} -div.jetpack-quiz div.jetpack-quiz-answer.last { - padding-bottom: 0; - margin-bottom: 0; - border-bottom: 0; -} - -div.jetpack-quiz div.jetpack-quiz-answer.correct { - color: green; -} - -div.jetpack-quiz div.jetpack-quiz-answer.wrong { - color: red; -} - -div.jetpack-quiz div.jetpack-quiz-answer div.jetpack-quiz-explanation { - display: none; -} - -div.jetpack-quiz div.jetpack-quiz-answer.correct div.jetpack-quiz-explanation, div.jetpack-quiz div.jetpack-quiz-answer.wrong div.jetpack-quiz-explanation { - display: block; - color: black; - font-size: 90%; - margin-top: 1em; -} - -div.jetpack-quiz div.jetpack-quiz-answer.correct div.jetpack-quiz-explanation tt, div.jetpack-quiz div.jetpack-quiz-answer.wrong div.jetpack-quiz-explanation tt { - font-size: 85%; -} - -div.jetpack-quiz pre { - font: 15px Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; - background: transparent; - margin: 0; - padding: 0; -} - diff --git a/plugins/jetpack/modules/shortcodes/css/recipes-print-rtl.css b/plugins/jetpack/modules/shortcodes/css/recipes-print-rtl.css deleted file mode 100644 index bbea4bf2..00000000 --- a/plugins/jetpack/modules/shortcodes/css/recipes-print-rtl.css +++ /dev/null @@ -1 +0,0 @@ -.jetpack-recipe-meta li.jetpack-recipe-print{display:none}.jetpack-recipe-title{font-size:16pt}.jetpack-recipe-content img{display:inline-block!important;max-width:100%}.jetpack-recipe-image{display:none!important}.jetpack-recipe-content .aligncenter{display:block!important;margin:0 auto 1em!important;text-align:center!important}.jetpack-recipe-content .alignright{float:left!important;margin:0 1em .5em 0!important}.jetpack-recipe-content .alignleft{float:right!important;margin:0 0 .5em 1em!important}.jetpack-recipe-content .alignnone{display:inline-block}
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/css/recipes-print-rtl.min.css b/plugins/jetpack/modules/shortcodes/css/recipes-print-rtl.min.css deleted file mode 100644 index bbea4bf2..00000000 --- a/plugins/jetpack/modules/shortcodes/css/recipes-print-rtl.min.css +++ /dev/null @@ -1 +0,0 @@ -.jetpack-recipe-meta li.jetpack-recipe-print{display:none}.jetpack-recipe-title{font-size:16pt}.jetpack-recipe-content img{display:inline-block!important;max-width:100%}.jetpack-recipe-image{display:none!important}.jetpack-recipe-content .aligncenter{display:block!important;margin:0 auto 1em!important;text-align:center!important}.jetpack-recipe-content .alignright{float:left!important;margin:0 1em .5em 0!important}.jetpack-recipe-content .alignleft{float:right!important;margin:0 0 .5em 1em!important}.jetpack-recipe-content .alignnone{display:inline-block}
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/css/recipes-print.css b/plugins/jetpack/modules/shortcodes/css/recipes-print.css deleted file mode 100644 index 48e05179..00000000 --- a/plugins/jetpack/modules/shortcodes/css/recipes-print.css +++ /dev/null @@ -1,36 +0,0 @@ -.jetpack-recipe-meta li.jetpack-recipe-print { - display: none; -} - -.jetpack-recipe-title { - font-size: 16pt; -} - -.jetpack-recipe-content img { - display: inline-block !important; - max-width: 100%; -} - -.jetpack-recipe-image { - display: none !important; -} - -.jetpack-recipe-content .aligncenter { - display: block !important; - margin: 0 auto 1em !important; - text-align: center !important; -} - -.jetpack-recipe-content .alignright { - float: right !important; - margin: 0 0 .5em 1em !important; -} - -.jetpack-recipe-content .alignleft { - float: left !important; - margin: 0 1em .5em 0 !important; -} - -.jetpack-recipe-content .alignnone { - display: inline-block; -} diff --git a/plugins/jetpack/modules/shortcodes/css/recipes-print.min.css b/plugins/jetpack/modules/shortcodes/css/recipes-print.min.css deleted file mode 100644 index 52cf81bf..00000000 --- a/plugins/jetpack/modules/shortcodes/css/recipes-print.min.css +++ /dev/null @@ -1,2 +0,0 @@ -/* Do not modify this file directly. It is concatenated from individual module CSS files. */ -.jetpack-recipe-meta li.jetpack-recipe-print{display:none}.jetpack-recipe-title{font-size:16pt}.jetpack-recipe-content img{display:inline-block!important;max-width:100%}.jetpack-recipe-image{display:none!important}.jetpack-recipe-content .aligncenter{display:block!important;margin:0 auto 1em!important;text-align:center!important}.jetpack-recipe-content .alignright{float:right!important;margin:0 0 .5em 1em!important}.jetpack-recipe-content .alignleft{float:left!important;margin:0 1em .5em 0!important}.jetpack-recipe-content .alignnone{display:inline-block}
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/css/recipes-rtl.css b/plugins/jetpack/modules/shortcodes/css/recipes-rtl.css deleted file mode 100644 index a0492b5f..00000000 --- a/plugins/jetpack/modules/shortcodes/css/recipes-rtl.css +++ /dev/null @@ -1 +0,0 @@ -.jetpack-recipe{border:1px solid #f2f2f2;border-radius:1px;clear:both;margin:1.5em 1%;padding:1% 2%}.jetpack-recipe-title{border-bottom:1px solid #ccc;margin:.25em 0;padding:.25em 0}.jetpack-recipe .jetpack-recipe-meta{display:block;font-size:.9em;list-style-type:none;margin-left:0;margin-right:0;padding:0;overflow:hidden;width:100%}.jetpack-recipe .jetpack-recipe-meta li{float:right;list-style-type:none;margin:0;padding:0 0 0 5%}.jetpack-recipe-meta li.jetpack-recipe-print{float:left;padding-left:0;text-align:left}.jetpack-recipe-notes{font-style:italic}
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/css/recipes-rtl.min.css b/plugins/jetpack/modules/shortcodes/css/recipes-rtl.min.css deleted file mode 100644 index a0492b5f..00000000 --- a/plugins/jetpack/modules/shortcodes/css/recipes-rtl.min.css +++ /dev/null @@ -1 +0,0 @@ -.jetpack-recipe{border:1px solid #f2f2f2;border-radius:1px;clear:both;margin:1.5em 1%;padding:1% 2%}.jetpack-recipe-title{border-bottom:1px solid #ccc;margin:.25em 0;padding:.25em 0}.jetpack-recipe .jetpack-recipe-meta{display:block;font-size:.9em;list-style-type:none;margin-left:0;margin-right:0;padding:0;overflow:hidden;width:100%}.jetpack-recipe .jetpack-recipe-meta li{float:right;list-style-type:none;margin:0;padding:0 0 0 5%}.jetpack-recipe-meta li.jetpack-recipe-print{float:left;padding-left:0;text-align:left}.jetpack-recipe-notes{font-style:italic}
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/css/recipes.css b/plugins/jetpack/modules/shortcodes/css/recipes.css deleted file mode 100644 index 63ab2169..00000000 --- a/plugins/jetpack/modules/shortcodes/css/recipes.css +++ /dev/null @@ -1,36 +0,0 @@ -.jetpack-recipe { - border: 1px solid #f2f2f2; - border-radius: 1px; - clear: both; - margin: 1.5em 1%; - padding: 1% 2%; -} -.jetpack-recipe-title { - border-bottom: 1px solid #ccc; - margin: .25em 0; - padding: .25em 0; -} -.jetpack-recipe .jetpack-recipe-meta { - display: block; - font-size: .9em; - list-style-type: none; - margin-right: 0; - margin-left: 0; - padding: 0; - overflow: hidden; - width: 100%; -} -.jetpack-recipe .jetpack-recipe-meta li { - float: left; - list-style-type: none; - margin: 0; - padding: 0 5% 0 0; -} -.jetpack-recipe-meta li.jetpack-recipe-print { - float: right; - padding-right: 0; - text-align: right; -} -.jetpack-recipe-notes { - font-style: italic; -} diff --git a/plugins/jetpack/modules/shortcodes/css/recipes.min.css b/plugins/jetpack/modules/shortcodes/css/recipes.min.css deleted file mode 100644 index e4e36a3d..00000000 --- a/plugins/jetpack/modules/shortcodes/css/recipes.min.css +++ /dev/null @@ -1,2 +0,0 @@ -/* Do not modify this file directly. It is concatenated from individual module CSS files. */ -.jetpack-recipe{border:1px solid #f2f2f2;border-radius:1px;clear:both;margin:1.5em 1%;padding:1% 2%}.jetpack-recipe-title{border-bottom:1px solid #ccc;margin:.25em 0;padding:.25em 0}.jetpack-recipe .jetpack-recipe-meta{display:block;font-size:.9em;list-style-type:none;margin-right:0;margin-left:0;padding:0;overflow:hidden;width:100%}.jetpack-recipe .jetpack-recipe-meta li{float:left;list-style-type:none;margin:0;padding:0 5% 0 0}.jetpack-recipe-meta li.jetpack-recipe-print{float:right;padding-right:0;text-align:right}.jetpack-recipe-notes{font-style:italic}
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.css b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.css deleted file mode 100644 index 3defeb94..00000000 --- a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.css +++ /dev/null @@ -1,145 +0,0 @@ -/* Do not modify this file directly. It is concatenated from individual module CSS files. */ -.slideshow-window { - background-color: #222; - border: 20px solid #222; - border-radius: 10px; - height: 0; - margin-bottom: 20px; - overflow: hidden; - padding-top: 30px !important; - padding-bottom: 56.25% !important; - position: relative; - z-index: 1; -} - -.slideshow-window.slideshow-white { - background-color: #fff; - border-color: #fff; -} - -.slideshow-window, .slideshow-window * { - box-sizing: content-box; -} - -.slideshow-loading { - height: 100%; - text-align: center; - margin: auto; -} - -body div.slideshow-window * img { - /* Override any styles that might be present in the page stylesheet */ - background-color: transparent !important; - background-image: none !important; - border-width: 0 !important; - display: block; - margin: 0 auto; - max-width: 100%; - max-height: 100%; - padding: 0 !important; - position: relative; - transform: translateY(-50%); - top: 50%; -} - -.slideshow-loading img { - vertical-align: middle; -} - -.slideshow-slide { - display: none; - height: 100% !important; - right: 0; - margin: auto; - position: absolute; - text-align: center; - top: 0; - width: 100% !important; -} - -.slideshow-slide img { - vertical-align: middle; -} - -.slideshow-line-height-hack { - overflow: hidden; - width: 0px; - font-size: 0px; -} - -.slideshow-slide-caption { - font-size: 13px; - font-family: "Helvetica Neue", sans-serif; - color: #f7f7f7; - text-shadow: #222 -1px 1px 2px; - line-height: 25px; - height: 25px; - position: absolute; - bottom: 5px; - right: 0; - z-index: 100; - width: 100%; - text-align: center; -} - -.slideshow-controls { - z-index: 1000; - position: absolute; - bottom: 30px; - margin: auto; - text-align: center; - width: 100%; - -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; - opacity: 0.5; - direction:ltr; - transition: 300ms opacity ease-out; -} - -.slideshow-window:hover .slideshow-controls { - -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; - opacity: 1; -} - -body div div.slideshow-controls a, -body div div.slideshow-controls a:hover { - border:2px solid rgba(255,255,255,0.1) !important; - background-color: #000 !important; - background-color: rgba(0,0,0,0.6) !important; - background-image: url('../img/slideshow-controls.png') !important; - background-repeat: no-repeat; - background-size: 142px 16px !important; - background-position: -34px 8px !important; - color: #222 !important; - margin: 0 5px !important; - padding: 0 !important; - display: inline-block !important; - *display: inline; - zoom: 1; - height: 32px !important; - width: 32px !important; - line-height: 32px !important; - text-align: center !important; - border-radius: 10em !important; - transition: 300ms border-color ease-out; -} - -@media only screen and (-webkit-min-device-pixel-ratio: 1.5) { - body div div.slideshow-controls a, - body div div.slideshow-controls a:hover { - background-image: url('../img/slideshow-controls-2x.png') !important; - } -} - -body div div.slideshow-controls a:hover { - border-color: rgba(255,255,255,1) !important; -} - -body div div.slideshow-controls a:first-child { background-position: -76px 8px !important;} -body div div.slideshow-controls a:last-child { background-position: -117px 8px !important;} -body div div.slideshow-controls a:nth-child(2) { background-position: -34px 8px !important;} -body div div.slideshow-controls a.running { background-position: -34px 8px !important;} -body div div.slideshow-controls a.paused { background-position: 9px 8px !important;} - -.slideshow-controls a img { - border: 50px dotted fuchsia; -} diff --git a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.min.css b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.min.css deleted file mode 100644 index 4342c699..00000000 --- a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.min.css +++ /dev/null @@ -1 +0,0 @@ -.slideshow-window{background-color:#222;border:20px solid #222;border-radius:10px;height:0;margin-bottom:20px;overflow:hidden;padding-top:30px!important;padding-bottom:56.25%!important;position:relative;z-index:1}.slideshow-window.slideshow-white{background-color:#fff;border-color:#fff}.slideshow-window,.slideshow-window *{box-sizing:content-box}.slideshow-loading{height:100%;text-align:center;margin:auto}body div.slideshow-window * img{background-color:transparent!important;background-image:none!important;border-width:0!important;display:block;margin:0 auto;max-width:100%;max-height:100%;padding:0!important;position:relative;transform:translateY(-50%);top:50%}.slideshow-loading img{vertical-align:middle}.slideshow-slide{display:none;height:100%!important;right:0;margin:auto;position:absolute;text-align:center;top:0;width:100%!important}.slideshow-slide img{vertical-align:middle}.slideshow-line-height-hack{overflow:hidden;width:0;font-size:0}.slideshow-slide-caption{font-size:13px;font-family:"Helvetica Neue",sans-serif;color:#f7f7f7;text-shadow:#222 -1px 1px 2px;line-height:25px;height:25px;position:absolute;bottom:5px;right:0;z-index:100;width:100%;text-align:center}.slideshow-controls{z-index:1000;position:absolute;bottom:30px;margin:auto;text-align:center;width:100%;opacity:.5;direction:ltr;transition:.3s opacity ease-out}.slideshow-window:hover .slideshow-controls{opacity:1}body div div.slideshow-controls a,body div div.slideshow-controls a:hover{border:2px solid rgba(255,255,255,.1)!important;background-color:#000!important;background-color:rgba(0,0,0,.6)!important;background-image:url(../img/slideshow-controls.png)!important;background-repeat:no-repeat;background-size:142px 16px!important;background-position:-34px 8px!important;color:#222!important;margin:0 5px!important;padding:0!important;display:inline-block!important;zoom:1;height:32px!important;width:32px!important;line-height:32px!important;text-align:center!important;border-radius:10em!important;transition:.3s border-color ease-out}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body div div.slideshow-controls a,body div div.slideshow-controls a:hover{background-image:url(../img/slideshow-controls-2x.png)!important}}body div div.slideshow-controls a:hover{border-color:rgba(255,255,255,1)!important}body div div.slideshow-controls a:first-child{background-position:-76px 8px!important}body div div.slideshow-controls a:last-child{background-position:-117px 8px!important}body div div.slideshow-controls a:nth-child(2){background-position:-34px 8px!important}body div div.slideshow-controls a.running{background-position:-34px 8px!important}body div div.slideshow-controls a.paused{background-position:9px 8px!important}.slideshow-controls a img{border:50px dotted #f0f}
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.css b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.css deleted file mode 100644 index 2e416a44..00000000 --- a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.css +++ /dev/null @@ -1,157 +0,0 @@ -.slideshow-window { - background-color: #222; - border: 20px solid #222; - border-radius: 10px; - height: 0; - margin-bottom: 20px; - overflow: hidden; - padding-top: 30px !important; - padding-bottom: 56.25% !important; - position: relative; - z-index: 1; -} - -.slideshow-window.slideshow-white { - background-color: #fff; - border-color: #fff; -} - -.slideshow-window, .slideshow-window * { - -moz-box-sizing: content-box; - -webkit-box-sizing: content-box; - box-sizing: content-box; -} - -.slideshow-loading { - height: 100%; - text-align: center; - margin: auto; -} - -body div.slideshow-window * img { - /* Override any styles that might be present in the page stylesheet */ - background-color: transparent !important; - background-image: none !important; - border-width: 0 !important; - display: block; - margin: 0 auto; - max-width: 100%; - max-height: 100%; - padding: 0 !important; - position: relative; - -webkit-transform: translateY(-50%); - -ms-transform: translateY(-50%); - transform: translateY(-50%); - top: 50%; -} - -.slideshow-loading img { - vertical-align: middle; -} - -.slideshow-slide { - display: none; - height: 100% !important; - left: 0; - margin: auto; - position: absolute; - text-align: center; - top: 0; - width: 100% !important; -} - -.slideshow-slide img { - vertical-align: middle; -} - -.slideshow-line-height-hack { - overflow: hidden; - width: 0px; - font-size: 0px; -} - -.slideshow-slide-caption { - font-size: 13px; - font-family: "Helvetica Neue", sans-serif; - color: #f7f7f7; - text-shadow: #222 1px 1px 2px; - line-height: 25px; - height: 25px; - position: absolute; - bottom: 5px; - left: 0; - z-index: 100; - width: 100%; - text-align: center; -} - -.slideshow-controls { - z-index: 1000; - position: absolute; - bottom: 30px; - margin: auto; - text-align: center; - width: 100%; - -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; - opacity: 0.5; - /*rtl:ignore*/ - direction:ltr; - -webkit-transition: 300ms opacity ease-out; - -moz-transition: 300ms opacity ease-out; - transition: 300ms opacity ease-out; -} - -.slideshow-window:hover .slideshow-controls { - -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; - opacity: 1; -} - -body div div.slideshow-controls a, -body div div.slideshow-controls a:hover { - border:2px solid rgba(255,255,255,0.1) !important; - background-color: #000 !important; - background-color: rgba(0,0,0,0.6) !important; - background-image: url('../img/slideshow-controls.png') !important; - background-repeat: no-repeat; - background-size: 142px 16px !important; - background-position: -34px 8px !important; - color: #222 !important; - margin: 0 5px !important; - padding: 0 !important; - display: inline-block !important; - *display: inline; - zoom: 1; - height: 32px !important; - width: 32px !important; - line-height: 32px !important; - text-align: center !important; - -khtml-border-radius: 10em !important; - -webkit-border-radius: 10em !important; - -moz-border-radius: 10em !important; - border-radius: 10em !important; - -webkit-transition: 300ms border-color ease-out; - -moz-transition: 300ms border-color ease-out; - -o-transition: 300ms border-color ease-out; - transition: 300ms border-color ease-out; -} - -@media only screen and (-webkit-min-device-pixel-ratio: 1.5) { - body div div.slideshow-controls a, - body div div.slideshow-controls a:hover { - background-image: url('../img/slideshow-controls-2x.png') !important; - } -} - -body div div.slideshow-controls a:hover { - border-color: rgba(255,255,255,1) !important; -} - -body div div.slideshow-controls a:first-child { background-position: -76px 8px !important;} -body div div.slideshow-controls a:last-child { background-position: -117px 8px !important;} -body div div.slideshow-controls a:nth-child(2) { background-position: -34px 8px !important;} -body div div.slideshow-controls a.running { background-position: -34px 8px !important;} -body div div.slideshow-controls a.paused { background-position: 9px 8px !important;} - -.slideshow-controls a img { - border: 50px dotted fuchsia; -} diff --git a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css deleted file mode 100644 index 9642a647..00000000 --- a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css +++ /dev/null @@ -1,2 +0,0 @@ -/* Do not modify this file directly. It is concatenated from individual module CSS files. */ -.slideshow-window{background-color:#222;border:20px solid #222;border-radius:10px;height:0;margin-bottom:20px;overflow:hidden;padding-top:30px!important;padding-bottom:56.25%!important;position:relative;z-index:1}.slideshow-window.slideshow-white{background-color:#fff;border-color:#fff}.slideshow-window,.slideshow-window *{box-sizing:content-box}.slideshow-loading{height:100%;text-align:center;margin:auto}body div.slideshow-window * img{background-color:transparent!important;background-image:none!important;border-width:0!important;display:block;margin:0 auto;max-width:100%;max-height:100%;padding:0!important;position:relative;transform:translateY(-50%);top:50%}.slideshow-loading img{vertical-align:middle}.slideshow-slide{display:none;height:100%!important;left:0;margin:auto;position:absolute;text-align:center;top:0;width:100%!important}.slideshow-slide img{vertical-align:middle}.slideshow-line-height-hack{overflow:hidden;width:0;font-size:0}.slideshow-slide-caption{font-size:13px;font-family:"Helvetica Neue",sans-serif;color:#f7f7f7;text-shadow:#222 1px 1px 2px;line-height:25px;height:25px;position:absolute;bottom:5px;left:0;z-index:100;width:100%;text-align:center}.slideshow-controls{z-index:1000;position:absolute;bottom:30px;margin:auto;text-align:center;width:100%;opacity:.5;direction:ltr;transition:.3s opacity ease-out}.slideshow-window:hover .slideshow-controls{opacity:1}body div div.slideshow-controls a,body div div.slideshow-controls a:hover{border:2px solid rgba(255,255,255,.1)!important;background-color:#000!important;background-color:rgba(0,0,0,.6)!important;background-image:url(../img/slideshow-controls.png)!important;background-repeat:no-repeat;background-size:142px 16px!important;background-position:-34px 8px!important;color:#222!important;margin:0 5px!important;padding:0!important;display:inline-block!important;zoom:1;height:32px!important;width:32px!important;line-height:32px!important;text-align:center!important;border-radius:10em!important;transition:.3s border-color ease-out}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body div div.slideshow-controls a,body div div.slideshow-controls a:hover{background-image:url(../img/slideshow-controls-2x.png)!important}}body div div.slideshow-controls a:hover{border-color:rgba(255,255,255,1)!important}body div div.slideshow-controls a:first-child{background-position:-76px 8px!important}body div div.slideshow-controls a:last-child{background-position:-117px 8px!important}body div div.slideshow-controls a:nth-child(2){background-position:-34px 8px!important}body div div.slideshow-controls a.running{background-position:-34px 8px!important}body div div.slideshow-controls a.paused{background-position:9px 8px!important}.slideshow-controls a img{border:50px dotted #f0f}
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/css/style.css b/plugins/jetpack/modules/shortcodes/css/style.css deleted file mode 100644 index 5ef78159..00000000 --- a/plugins/jetpack/modules/shortcodes/css/style.css +++ /dev/null @@ -1,188 +0,0 @@ -/** -* 1. Fullscreen styles -*/ -html.presentation-wrapper-fullscreen-parent, -body.presentation-wrapper-fullscreen-parent { - overflow: hidden !important; -} - -.presentation-wrapper-fullscreen-parent #wpadminbar { - display: none; -} - -.presentation-wrapper-fullscreen, -.presentation-wrapper-fullscreen-parent { - min-width: 100% !important; - min-height: 100% !important; - position: absolute !important; - top: 0 !important; - right: 0 !important; - bottom: 0 !important; - left: 0 !important; - margin: 0 !important; - padding: 0 !important; - z-index: 10000 !important; -} - -.presentation-wrapper-fullscreen { - background-color: #808080; - border: none !important; -} - -.presentation-wrapper-fullscreen .nav-arrow-left, -.presentation-wrapper-fullscreen .nav-arrow-right { - z-index: 20001; -} - -.presentation-wrapper-fullscreen .nav-fullscreen-button { - z-index: 20002; -} - - -/** - * 2. General presentation styles - */ -.presentation-wrapper { - margin: 20px auto; - border: 1px solid #e5e5e5; - overflow: hidden; - line-height: normal; -} - -.presentation { - position: relative; - margin: 0; - overflow: hidden; - outline: none; -} - -/** - * jmpress requires that step sizes are explicitly defined - * as it inserts sizeless divs before the steps. These - * dimensions are set by the js code on initialization - */ -.presentation, -.presentation .step { - background-repeat: no-repeat; - background-position: center; - background-size: 100% 100%; -} - -/** - * Opacity transition durations are set by the js code - * so they match the presentation animation durations - */ -.presentation .step.fade:not(.active) { - opacity: 0; -} - -.presentation .slide-content { - padding: 30px; -} - - -/** - * 3. Styles for the navigation arrows - */ -.presentation .nav-arrow-left, -.presentation .nav-arrow-right, -.presentation .nav-fullscreen-button { - position: absolute; - width: 34px; - background-repeat: no-repeat; - z-index: 2; - opacity: 0; - - -webkit-transition : opacity .25s; - -moz-transition : opacity .25s; - -ms-transition : opacity .25s; - -o-transition : opacity .25s; - transition : opacity .25s; -} - -.presentation .nav-arrow-left, -.presentation .nav-arrow-right { - height: 100%; - background-image: url(../images/slide-nav.png); - background-size: 450% 61px; -} - -.presentation .nav-arrow-left { - left: 0; - background-position: 4px 50%; -} - -.presentation .nav-arrow-right { - right: 0; - background-position: -120px 50%; -} - -.presentation .nav-fullscreen-button { - width: 32px; - height: 32px; - margin: 4px; - bottom: 0; - right: 0; - z-index: 3; - background-image: url(../images/expand.png); - background-size: 100% 100%; -} - -.presentation:hover .nav-arrow-left, -.presentation:hover .nav-arrow-right { - opacity: 1; -} - -.presentation:hover .nav-fullscreen-button { - opacity: 0.8; -} - -.presentation-wrapper-fullscreen .nav-fullscreen-button { - background-image: url(../images/collapse.png); -} - -/** - * 4. Styles for the autoplay overlay - */ -.presentation .autoplay-overlay { - height: 15%; - width: 80%; - margin: 30% 10%; - position: relative; - z-index: 100; - display: table; - border-radius: 50px; - background-color: #e5e5e5; - background-color: rgba(0, 0, 0, 0.75); - - -webkit-transition : opacity .5s; - -moz-transition : opacity .5s; - -ms-transition : opacity .5s; - -o-transition : opacity .5s; - transition : opacity .5s; -} - -.presentation .autoplay-overlay .overlay-msg { - position: relative; - display: table-cell; - text-align: center; - vertical-align: middle; - color: #fff; -} - -/** - * 5. Styles for fading steps - */ -.presentation .will-fade { - opacity: 0; -} - -.presentation .do-fade { - opacity: 1; - - -webkit-transition : opacity .5s; - -moz-transition : opacity .5s; - -ms-transition : opacity .5s; - -o-transition : opacity .5s; - transition : opacity .5s; -} diff --git a/plugins/jetpack/modules/shortcodes/dailymotion.php b/plugins/jetpack/modules/shortcodes/dailymotion.php deleted file mode 100644 index af503394..00000000 --- a/plugins/jetpack/modules/shortcodes/dailymotion.php +++ /dev/null @@ -1,341 +0,0 @@ -<?php - -/** - * Dailymotion code - * */ - -/** - * Original codes: - * - * <embed height="270" type="application/x-shockwave-flash" width="480" src="http://www.dailymotion.com/swf/video/xekmrq?additionalInfos=0" wmode="opaque" pluginspage="http://www.macromedia.com/go/getflashplayer" allowscriptaccess="never" allownetworking="internal" /> - * - * <object width="480" height="240"><param name="movie" value="http://www.dailymotion.com/swf/video/xen4ms_ghinzu-cold-love-mirror-mirror_music?additionalInfos=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param> - * <embed type="application/x-shockwave-flash" src="http://www.dailymotion.com/swf/video/xen4ms_ghinzu-cold-love-mirror-mirror_music?additionalInfos=0" width="480" height="240" allowfullscreen="true" allowscriptaccess="always"></embed> - * </object><br /><b><a href="http://www.dailymotion.com/video/xen4ms_ghinzu-cold-love-mirror-mirror_music">Ghinzu - Cold Love (Mirror Mirror)</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/GhinzuTV">GhinzuTV</a>. - <a href="http://www.dailymotion.com/us/channel/music">Watch more music videos, in HD!</a></i> - * - * Code as of 01.01.11: - * <object width="560" height="421"><param name="movie" value="http://www.dailymotion.com/swf/video/xaose5?width=560&theme=denim&foreground=%2392ADE0&highlight=%23A2ACBF&background=%23202226&start=&animatedTitle=&iframe=0&additionalInfos=0&autoPlay=0&hideInfos=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed type="application/x-shockwave-flash" src="http://www.dailymotion.com/swf/video/xaose5?width=560&theme=denim&foreground=%2392ADE0&highlight=%23A2ACBF&background=%23202226&start=&animatedTitle=&iframe=0&additionalInfos=0&autoPlay=0&hideInfos=0" width="560" height="421" allowfullscreen="true" allowscriptaccess="always"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x29zm17_funny-videos-of-cats-and-babies-compilation-2015_fun">Funny cats and babies!</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/GilLavie">GilLavie</a>. - <a target="_self" href="http://www.dailymotion.com/channel/funny/featured/1">Find more funny videos.</a></i> - * movie param enforces anti-xss protection - * - * Scroll down for the new <iframe> embed code handler. - */ - -function dailymotion_embed_to_shortcode( $content ) { - if ( ! is_string( $content ) || false === stripos( $content, 'www.dailymotion.com/swf/' ) ) { - return $content; - } - - $regexp = '!<object.*>\s*(<param.*></param>\s*)*<embed((?:\s+\w+="[^"]*")*)\s+src="http(?:\:|�*58;)//(www\.dailymotion\.com/swf/[^"]*)"((?:\s+\w+="[^"]*")*)\s*(?:/>|>\s*</embed>)\s*</object><br /><b><a .*>.*</a></b><br /><i>.*</i>!'; - $regexp_ent = str_replace( '&#0*58;', '&#0*58;|�*58;', htmlspecialchars( $regexp, ENT_NOQUOTES ) ); - - foreach ( array( 'regexp', 'regexp_ent' ) as $reg ) { - if ( ! preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) { - continue; - } - - foreach ( $matches as $match ) { - $src = html_entity_decode( $match[3] ); - $params = $match[2] . $match[4]; - - if ( 'regexp_ent' == $reg ) { - $src = html_entity_decode( $src ); - $params = html_entity_decode( $params ); - } - - $params = wp_kses_hair( $params, array( 'http' ) ); - - if ( ! isset( $params['type'] ) || 'application/x-shockwave-flash' != $params['type']['value'] ) { - continue; - } - - $id = basename( substr( $src, strlen( 'www.dailymotion.com/swf' ) ) ); - $id = preg_replace( '/[^a-z0-9].*$/i', '', $id ); - - $content = str_replace( $match[0], "[dailymotion id=$id]", $content ); - /** This action is documented in modules/shortcodes/youtube.php */ - do_action( 'jetpack_embed_to_shortcode', 'dailymotion', $id ); - } - } - return $content; -} -add_filter( 'pre_kses', 'dailymotion_embed_to_shortcode' ); - -/** - * DailyMotion shortcode - * - * The documented shortcode is: - * [dailymotion id=x8oma9] - * - * Possibilities, according to the old parsing regexp: - * [dailymotion x8oma9] - * [dailymotion=x8oma9] - * - * Hypothetical option, according to the old shortcode function is - * [dailymotion id=1&title=2&user=3&video=4] - * - * The new style is now: - * [dailymotion id=x8oma9 title=2 user=3 video=4] - * - * Supported parameters for player customization: width, height, - * autoplay, endscreen-enable, mute, sharing-enabled, start, subtitles-default, - * ui-highlight, ui-logo, ui-start-screen-info, ui-theme - * see https://developer.dailymotion.com/player#player-parameters - * - * @todo: Update code to sniff for iframe embeds and convert those to shortcodes. - * - * @param array $atts - * @return string html - */ - -function dailymotion_shortcode( $atts ) { - global $content_width; - - if ( isset( $atts[0] ) ) { - $id = ltrim( $atts[0], '=' ); - $atts['id'] = $id; - - } else { - $params = shortcode_new_to_old_params( $atts ); - parse_str( $params, $atts_new ); - - foreach ( $atts_new as $k => $v ) { - $atts[ $k ] = $v; - } - } - - $atts = shortcode_atts( - array( - 'id' => '', // string - 'width' => '', // int - 'height' => '', // int - 'title' => '', // string - 'user' => '', // string - 'video' => '', // string - 'autoplay' => 0, // int - 'endscreen-enable' => 1, // int - 'mute' => 0, // int - 'sharing-enable' => 1, // int - 'start' => '', // int - 'subtitles-default' => '', // string - 'ui-highlight' => '', // string - 'ui-logo' => 1, // int - 'ui-start-screen-info' => 0, // int - 'ui-theme' => '', // string - ), - $atts, - 'dailymotion' - ); - - if ( isset( $atts['id'] ) && ! empty( $atts['id'] ) ) { - $id = urlencode( $atts['id'] ); - } else { - return '<!--Dailymotion error: bad or missing ID-->'; - } - - /*set width and height using provided parameters if any */ - $width = isset( $atts['width'] ) ? intval( $atts['width'] ) : 0; - $height = isset( $atts['height'] ) ? intval( $atts['height'] ) : 0; - - if ( ! $width && ! $height ) { - if ( ! empty( $content_width ) ) { - $width = absint( $content_width ); - } else { - $width = 425; - } - $height = $width / 425 * 334; - } elseif ( ! $height ) { - $height = $width / 425 * 334; - } elseif ( ! $width ) { - $width = $height / 334 * 425; - } - - /** - * Let's add parameters if needed. - * - * @see https://developer.dailymotion.com/player - */ - $player_params = array(); - - if ( isset( $atts['autoplay'] ) && '1' === $atts['autoplay'] ) { - $player_params['autoplay'] = '1'; - } - if ( isset( $atts['endscreen-enable'] ) && '0' === $atts['endscreen-enable'] ) { - $player_params['endscreen-enable'] = '0'; - } - if ( isset( $atts['mute'] ) && '1' === $atts['mute'] ) { - $player_params['mute'] = '1'; - } - if ( isset( $atts['sharing-enable'] ) && '0' === $atts['sharing-enable'] ) { - $player_params['sharing-enable'] = '0'; - } - if ( isset( $atts['start'] ) && ! empty( $atts['start'] ) ) { - $player_params['start'] = abs( intval( $atts['start'] ) ); - } - if ( isset( $atts['subtitles-default'] ) && ! empty( $atts['subtitles-default'] ) ) { - $player_params['subtitles-default'] = esc_attr( $atts['subtitles-default'] ); - } - if ( isset( $atts['ui-highlight'] ) && ! empty( $atts['ui-highlight'] ) ) { - $player_params['ui-highlight'] = esc_attr( $atts['ui-highlight'] ); - } - if ( isset( $atts['ui-logo'] ) && '0' === $atts['ui-logo'] ) { - $player_params['ui-logo'] = '0'; - } - if ( isset( $atts['ui-start-screen-info'] ) && '0' === $atts['ui-start-screen-info'] ) { - $player_params['ui-start-screen-info'] = '0'; - } - if ( isset( $atts['ui-theme'] ) && in_array( strtolower( $atts['ui-theme'] ), array( 'dark', 'light' ) ) ) { - $player_params['ui-theme'] = esc_attr( $atts['ui-theme'] ); - } - - // Add those parameters to the Video URL. - $video_url = add_query_arg( - $player_params, - 'https://www.dailymotion.com/embed/video/' . $id - ); - - $output = ''; - - if ( preg_match( '/^[A-Za-z0-9]+$/', $id ) ) { - $output .= '<iframe width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '" src="' . esc_url( $video_url ) . '" style="border:0;" allowfullscreen></iframe>'; - - if ( array_key_exists( 'video', $atts ) && $video = preg_replace( '/[^-a-z0-9_]/i', '', $atts['video'] ) && array_key_exists( 'title', $atts ) && $title = wp_kses( $atts['title'], array() ) ) { - $output .= '<br /><strong><a href="' . esc_url( 'http://www.dailymotion.com/video/' . $video ) . '" target="_blank">' . esc_html( $title ) . '</a></strong>'; - } - - if ( array_key_exists( 'user', $atts ) && $user = preg_replace( '/[^-a-z0-9_]/i', '', $atts['user'] ) ) { - /* translators: %s is a Dailymotion user name */ - $output .= '<br /><em>' . wp_kses( - sprintf( __( 'Uploaded by %s', 'jetpack' ), '<a href="' . esc_url( 'http://www.dailymotion.com/' . $user ) . '" target="_blank">' . esc_html( $user ) . '</a>' ), - array( - 'a' => array( - 'href' => true, - 'target' => true, - ), - ) - ) . '</em>'; - } - } - - return $output; -} - -add_shortcode( 'dailymotion', 'dailymotion_shortcode' ); - -/** - * DailyMotion Channel Shortcode - * - * Examples: - * [dailymotion-channel user=MatthewDominick] - * [dailymotion-channel user=MatthewDominick type=grid] (supports grid, carousel, badge/default) - */ -function dailymotion_channel_shortcode( $atts ) { - $username = $atts['user']; - - switch ( $atts['type'] ) { - case 'grid': - return '<iframe width="300px" height="264px" scrolling="no" style="border:0;" src="' . esc_url( '//www.dailymotion.com/badge/user/' . $username . '?type=grid' ) . '"></iframe>'; - break; - case 'carousel': - return '<iframe width="300px" height="360px" scrolling="no" style="border:0;" src="' . esc_url( '//www.dailymotion.com/badge/user/' . $username . '?type=carousel' ) . '"></iframe>'; - break; - default: - return '<iframe width="300px" height="78px" scrolling="no" style="border:0;" src="' . esc_url( '//www.dailymotion.com/badge/user/' . $username ) . '"></iframe>'; - } -} - -add_shortcode( 'dailymotion-channel', 'dailymotion_channel_shortcode' ); - -/** - * Embed Reversal for Badge/Channel - */ -function dailymotion_channel_reversal( $content ) { - if ( ! is_string( $content ) || false === stripos( $content, 'dailymotion.com/badge/' ) ) { - return $content; - } - - /* - Sample embed code: - <iframe width="300px" height="360px" scrolling="no" frameborder="0" src="http://www.dailymotion.com/badge/user/Dailymotion?type=carousel"></iframe> - */ - - $regexes = array(); - - $regexes[] = '#<iframe[^>]+?src=" (?:https?:)?//(?:www\.)?dailymotion\.com/badge/user/([^"\'/]++) "[^>]*+></iframe>#ix'; - - // Let's play nice with the visual editor too. - $regexes[] = '#<iframe(?:[^&]|&(?!gt;))+?src=" (?:https?:)?//(?:www\.)?dailymotion\.com/badge/user/([^"\'/]++) "(?:[^&]|&(?!gt;))*+></iframe>#ix'; - - foreach ( $regexes as $regex ) { - if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) { - continue; - } - - foreach ( $matches as $match ) { - $url_pieces = parse_url( $match[1] ); - - if ( 'type=carousel' === $url_pieces['query'] ) { - $type = 'carousel'; - } elseif ( 'type=grid' === $url_pieces['query'] ) { - $type = 'grid'; - } else { - $type = 'badge'; - } - - $shortcode = '[dailymotion-channel user=' . esc_attr( $url_pieces['path'] ) . ' type=' . esc_attr( $type ) . ']'; - $replace_regex = sprintf( '#\s*%s\s*#', preg_quote( $match[0], '#' ) ); - $content = preg_replace( $replace_regex, sprintf( "\n\n%s\n\n", $shortcode ), $content ); - } - } - - return $content; -} - -add_filter( 'pre_kses', 'dailymotion_channel_reversal' ); - -/** - * Dailymotion Embed Reversal (with new iframe code as of 17.09.2014) - * - * Converts a generic HTML embed code from Dailymotion into an - * oEmbeddable URL. - */ - -function jetpack_dailymotion_embed_reversal( $content ) { - if ( ! is_string( $content ) || false === stripos( $content, 'dailymotion.com/embed' ) ) { - return $content; - } - - /* - Sample embed code as of Sep 17th 2014: - - <iframe frameborder="0" width="480" height="270" src="//www.dailymotion.com/embed/video/x25x71x" allowfullscreen></iframe><br /><a href="http://www.dailymotion.com/video/x25x71x_dog-with-legs-in-casts-learns-how-to-enter-the-front-door_animals" target="_blank">Dog with legs in casts learns how to enter the...</a> <i>by <a href="http://www.dailymotion.com/videobash" target="_blank">videobash</a></i> - */ - $regexes = array(); - - // I'm Konstantin and I love regex. - $regexes[] = '#<iframe[^>]+?src=" (?:https?:)?//(?:www\.)?dailymotion\.com/embed/video/([^"\'/]++) "[^>]*+>\s*+</iframe>\s*+(?:<br\s*+/>)?\s*+ - (?: <a[^>]+?href=" (?:https?:)?//(?:www\.)?dailymotion\.com/[^"\']++ "[^>]*+>.+?</a>\s*+ )? - (?: <i>.*?<a[^>]+?href=" (?:https?:)?//(?:www\.)?dailymotion\.com/[^"\']++ "[^>]*+>.+?</a>\s*+</i> )?#ix'; - - $regexes[] = '#<iframe(?:[^&]|&(?!gt;))+?src=" (?:https?:)?//(?:www\.)?dailymotion\.com/embed/video/([^"\'/]++) "(?:[^&]|&(?!gt;))*+>\s*+</iframe>\s*+(?:<br\s*+/>)?\s*+ - (?: <a(?:[^&]|&(?!gt;))+?href=" (?:https?:)?//(?:www\.)?dailymotion\.com/[^"\']++ "(?:[^&]|&(?!gt;))*+>.+?</a>\s*+ )? - (?: <i>.*?<a(?:[^&]|&(?!gt;))+?href=" (?:https?:)?//(?:www\.)?dailymotion\.com/[^"\']++ "(?:[^&]|&(?!gt;))*+>.+?</a>\s*+</i> )?#ix'; - - foreach ( $regexes as $regex ) { - if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) { - continue; - } - - foreach ( $matches as $match ) { - $url = esc_url( sprintf( 'https://dailymotion.com/video/%s', $match[1] ) ); - $replace_regex = sprintf( '#\s*%s\s*#', preg_quote( $match[0], '#' ) ); - $content = preg_replace( $replace_regex, sprintf( "\n\n%s\n\n", $url ), $content ); - - /** This action is documented in modules/shortcodes/youtube.php */ - do_action( 'jetpack_embed_to_shortcode', 'dailymotion', $url ); - } - } - - return $content; -} - -add_filter( 'pre_kses', 'jetpack_dailymotion_embed_reversal' ); diff --git a/plugins/jetpack/modules/shortcodes/diggthis.php b/plugins/jetpack/modules/shortcodes/diggthis.php deleted file mode 100644 index 0287218c..00000000 --- a/plugins/jetpack/modules/shortcodes/diggthis.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -/** - * Digg's API is no more and support has been removed - */ - -function digg_shortcode( $atts ) { - return ''; -} - -add_shortcode( 'digg', 'digg_shortcode' ); diff --git a/plugins/jetpack/modules/shortcodes/email-subscribe.php b/plugins/jetpack/modules/shortcodes/email-subscribe.php deleted file mode 100644 index 88c13090..00000000 --- a/plugins/jetpack/modules/shortcodes/email-subscribe.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php -/** - * Deprecated. No longer needed. - * - * @package Jetpack - */ diff --git a/plugins/jetpack/modules/shortcodes/facebook.php b/plugins/jetpack/modules/shortcodes/facebook.php deleted file mode 100644 index 9a7a53f8..00000000 --- a/plugins/jetpack/modules/shortcodes/facebook.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php -/** - * Facebook embeds - */ - -define( 'JETPACK_FACEBOOK_EMBED_REGEX', '#^https?://(www.)?facebook\.com/([^/]+)/(posts|photos)/([^/]+)?#' ); -define( 'JETPACK_FACEBOOK_ALTERNATE_EMBED_REGEX', '#^https?://(www.)?facebook\.com/permalink.php\?([^\s]+)#' ); -define( 'JETPACK_FACEBOOK_PHOTO_EMBED_REGEX', '#^https?://(www.)?facebook\.com/photo.php\?([^\s]+)#' ); -define( 'JETPACK_FACEBOOK_PHOTO_ALTERNATE_EMBED_REGEX', '#^https?://(www.)?facebook\.com/([^/]+)/photos/([^/]+)?#' ); -define( 'JETPACK_FACEBOOK_VIDEO_EMBED_REGEX', '#^https?://(www.)?facebook\.com/video.php\?([^\s]+)#' ); -define( 'JETPACK_FACEBOOK_VIDEO_ALTERNATE_EMBED_REGEX', '#^https?://(www.)?facebook\.com/([^/]+)/videos/([^/]+)?#' ); - - -// Example URL: https://www.facebook.com/VenusWilliams/posts/10151647007373076 -wp_embed_register_handler( 'facebook', JETPACK_FACEBOOK_EMBED_REGEX, 'jetpack_facebook_embed_handler' ); - -// Example URL: https://www.facebook.com/permalink.php?id=222622504529111&story_fbid=559431180743788 -wp_embed_register_handler( 'facebook-alternate', JETPACK_FACEBOOK_ALTERNATE_EMBED_REGEX, 'jetpack_facebook_embed_handler' ); - -// Photos are handled on a different endpoint; e.g. https://www.facebook.com/photo.php?fbid=10151609960150073&set=a.398410140072.163165.106666030072&type=1 -wp_embed_register_handler( 'facebook-photo', JETPACK_FACEBOOK_PHOTO_EMBED_REGEX, 'jetpack_facebook_embed_handler' ); - -// Photos (from pages for example) can be at -wp_embed_register_handler( 'facebook-alternate-photo', JETPACK_FACEBOOK_PHOTO_ALTERNATE_EMBED_REGEX, 'jetpack_facebook_embed_handler' ); - -// Videos e.g. https://www.facebook.com/video.php?v=772471122790796 -wp_embed_register_handler( 'facebook-video', JETPACK_FACEBOOK_VIDEO_EMBED_REGEX, 'jetpack_facebook_embed_handler' ); -// Videos https://www.facebook.com/WhiteHouse/videos/10153398464269238/ -wp_embed_register_handler( 'facebook-alternate-video', JETPACK_FACEBOOK_VIDEO_ALTERNATE_EMBED_REGEX, 'jetpack_facebook_embed_handler' ); - -function jetpack_facebook_embed_handler( $matches, $attr, $url ) { - if ( false !== strpos( $url, 'video.php' ) || false !== strpos( $url, '/videos/' ) ) { - $embed = sprintf( '<div class="fb-video" data-allowfullscreen="true" data-href="%s"></div>', esc_url( $url ) ); - } else { - $width = 552; // As of 01/2017, the default width of Facebook embeds when no width attribute provided - - global $content_width; - if ( isset( $content_width ) ) { - $width = min( $width, $content_width ); - } - - $embed = sprintf( '<fb:post href="%s" data-width="%s"></fb:post>', esc_url( $url ), esc_attr( $width ) ); - } - - // since Facebook is a faux embed, we need to load the JS SDK in the wpview embed iframe - if ( defined( 'DOING_AJAX' ) && DOING_AJAX && ! empty( $_POST['action'] ) && 'parse-embed' == $_POST['action'] ) { - ob_start(); - wp_scripts()->do_items( array( 'jetpack-facebook-embed' ) ); - $scripts = ob_get_clean(); - return $embed . $scripts; - } else { - wp_enqueue_script( 'jetpack-facebook-embed' ); - return $embed; - } -} - -add_shortcode( 'facebook', 'jetpack_facebook_shortcode_handler' ); - -function jetpack_facebook_shortcode_handler( $atts ) { - global $wp_embed; - - if ( empty( $atts['url'] ) ) { - return; - } - - if ( ! preg_match( JETPACK_FACEBOOK_EMBED_REGEX, $atts['url'] ) - && ! preg_match( JETPACK_FACEBOOK_PHOTO_EMBED_REGEX, $atts['url'] ) - && ! preg_match( JETPACK_FACEBOOK_VIDEO_EMBED_REGEX, $atts['url'] ) - && ! preg_match( JETPACK_FACEBOOK_VIDEO_ALTERNATE_EMBED_REGEX, $atts['url'] ) ) { - return; - } - - return $wp_embed->shortcode( $atts, $atts['url'] ); -} diff --git a/plugins/jetpack/modules/shortcodes/flatio.php b/plugins/jetpack/modules/shortcodes/flatio.php deleted file mode 100644 index bc0a51a4..00000000 --- a/plugins/jetpack/modules/shortcodes/flatio.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -/* - * Flat.io embed - * - * example URL: https://flat.io/score/5a5268ed41396318cbd7772c-string-quartet-for-rainy-days -*/ - -// Register oEmbed provider -wp_oembed_add_provider( 'https://flat.io/score/*', 'https://flat.io/services/oembed', false ); -wp_oembed_add_provider( 'https://*.flat.io/score/*', 'https://flat.io/services/oembed', false ); diff --git a/plugins/jetpack/modules/shortcodes/flickr.php b/plugins/jetpack/modules/shortcodes/flickr.php deleted file mode 100644 index 3669bbf0..00000000 --- a/plugins/jetpack/modules/shortcodes/flickr.php +++ /dev/null @@ -1,200 +0,0 @@ -<?php - -/* - Flickr Short Code - Author: kellan - License: BSD/GPL/public domain (take your pick) - -[flickr video=http://www.flickr.com/photos/chaddles/2402990826] -[flickr video=2402990826] -[flickr video=2402990826 show_info=no] -[flickr video=2402990826 w=200 h=150] -[flickr video=2402990826 secret=846d9c1b39] -*/ - -/* - * <object type="application/x-shockwave-flash" width="400" height="300" data="http://www.flickr.com/apps/video/stewart.swf?v=71377" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"> <param name="flashvars" value="intl_lang=en-us&photo_secret=846d9c1be9&photo_id=2345938910"></param> <param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=71377"></param> <param name="bgcolor" value="#000000"></param> <param name="allowFullScreen" value="true"></param><embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/video/stewart.swf?v=71377" bgcolor="#000000" allowfullscreen="true" flashvars="intl_lang=en-us&photo_secret=846d9c1be9&photo_id=2345938910" height="300" width="400"></embed></object> - */ - -function flickr_embed_to_shortcode( $content ) { - if ( ! is_string( $content ) || false === stripos( $content, '/www.flickr.com/apps/video/stewart.swf' ) ) { - return $content; - } - - $regexp = '%(<object.*?(?:<(?!/?(?:object|embed)\s+).*?)*?)?<embed((?:\s+\w+="[^"]*")*)\s+src="http(?:\:|�*58;)//www.flickr.com/apps/video/stewart.swf[^"]*"((?:\s+\w+="[^"]*")*)\s*(?:/>|>\s*</embed>)(?(1)\s*</object>)%'; - $regexp_ent = str_replace( - array( - '&#0*58;', - '[^>]*', - '[^<]*', - ), - array( - '&#0*58;|�*58;', - '[^&]*(?:&(?!gt;)[^&]*)*', - '[^&]*(?:&(?!lt;)[^&]*)*', - ), - htmlspecialchars( $regexp, ENT_NOQUOTES ) - ); - - foreach ( array( 'regexp', 'regexp_ent' ) as $reg ) { - if ( ! preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) { - continue; - } - foreach ( $matches as $match ) { - $params = $match[2] . $match[3]; - - if ( 'regexp_ent' == $reg ) { - $params = html_entity_decode( $params ); - } - - $params = wp_kses_hair( $params, array( 'http' ) ); - if ( ! isset( $params['type'] ) || 'application/x-shockwave-flash' != $params['type']['value'] || ! isset( $params['flashvars'] ) ) { - continue; - } - - wp_parse_str( html_entity_decode( $params['flashvars']['value'] ), $flashvars ); - - if ( ! isset( $flashvars['photo_id'] ) ) { - continue; - } - - $code_atts = array( 'video' => $flashvars['photo_id'] ); - - if ( isset( $flashvars['flickr_show_info_box'] ) && 'true' == $flashvars['flickr_show_info_box'] ) { - $code_atts['show_info'] = 'true'; - } - - if ( ! empty( $flashvars['photo_secret'] ) ) { - $code_atts['secret'] = $flashvars['photo_secret']; - } - - if ( ! empty( $params['width']['value'] ) ) { - $code_atts['w'] = (int) $params['width']['value']; - } - - if ( ! empty( $params['height']['value'] ) ) { - $code_atts['h'] = (int) $params['height']['value']; - } - - $code = '[flickr'; - foreach ( $code_atts as $k => $v ) { - $code .= " $k=$v"; - } - $code .= ']'; - - $content = str_replace( $match[0], $code, $content ); - /** This action is documented in modules/shortcodes/youtube.php */ - do_action( 'jetpack_embed_to_shortcode', 'flickr_video', $flashvars['photo_id'] ); - } - } - - return $content; -} - -add_filter( 'pre_kses', 'flickr_embed_to_shortcode' ); - -function flickr_shortcode_handler( $atts ) { - $atts = shortcode_atts( - array( - 'video' => 0, - 'photo' => 0, - 'show_info' => 0, - 'w' => 400, - 'h' => 300, - 'secret' => 0, - ), - $atts, - 'flickr' - ); - - if ( ! empty( $atts['video'] ) ) { - $showing = 'video'; - $src = $atts['video']; - } elseif ( ! empty( $atts['photo'] ) ) { - $showing = 'photo'; - $src = $atts['photo']; - } else { - return ''; - } - - if ( is_ssl() ) { - $src = str_replace( 'http://', 'https://', $src ); - } - - if ( 'video' === $showing ) { - - if ( ! is_numeric( $src ) && ! preg_match( '~^(https?:)?//([\da-z\-]+\.)*?((static)?flickr\.com|flic\.kr)/.*~i', $src ) ) { - return ''; - } - - if ( preg_match( '!photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/([0-9]+)/?$!', $src, $m ) ) { - $atts['photo_id'] = $m[4]; - } else { - $atts['photo_id'] = $atts['video']; - } - - if ( ! isset( $atts['show_info'] ) || in_array( $atts['show_info'], array( 'yes', 'true' ) ) ) { - $atts['show_info'] = 'true'; - } elseif ( in_array( $atts['show_info'], array( 'false', 'no' ) ) ) { - $atts['show_info'] = 'false'; - } - - if ( isset( $atts['secret'] ) ) { - $atts['secret'] = preg_replace( '![^\w]+!i', '', $atts['secret'] ); - } - - return flickr_shortcode_video_markup( $atts ); - } elseif ( 'photo' == $showing ) { - - if ( ! preg_match( '~^(https?:)?//([\da-z\-]+\.)*?((static)?flickr\.com|flic\.kr)/.*~i', $src ) ) { - return ''; - } - - $src = sprintf( '%s/player/', untrailingslashit( $src ) ); - - return sprintf( '<iframe src="%s" height="%s" width="%s" frameborder="0" allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen></iframe>', esc_url( $src ), esc_attr( $atts['h'] ), esc_attr( $atts['w'] ) ); - } - - return false; -} - -function flickr_shortcode_video_markup( $atts ) { - $atts = array_map( 'esc_attr', $atts ); - $http = ( is_ssl() ) ? 'https://' : 'http://'; - - $photo_vars = "photo_id=$atts[photo_id]"; - if ( isset( $atts['secret'] ) ) { - $photo_vars .= "&photo_secret=$atts[secret]"; - } - - return <<<EOD -<object type="application/x-shockwave-flash" width="$atts[w]" height="$atts[h]" data="{$http}www.flickr.com/apps/video/stewart.swf?v=1.161" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"> <param name="flashvars" value="$photo_vars&flickr_show_info_box=$atts[show_info]"></param><param name="movie" value="{$http}www.flickr.com/apps/video/stewart.swf?v=1.161"></param><param name="bgcolor" value="#000000"></param><param name="allowFullScreen" value="true"></param><param name="wmode" value="opaque"></param><embed type="application/x-shockwave-flash" src="{$http}www.flickr.com/apps/video/stewart.swf?v=1.161" bgcolor="#000000" allowfullscreen="true" flashvars="$photo_vars&flickr_show_info_box=$atts[show_info]" wmode="opaque" height="$atts[h]" width="$atts[w]"></embed></object> -EOD; -} - -add_shortcode( 'flickr', 'flickr_shortcode_handler' ); - -// Override core's Flickr support because Flickr oEmbed doesn't support web embeds -wp_embed_register_handler( 'flickr', '#https?://(www\.)?flickr\.com/.*#i', 'jetpack_flickr_oembed_handler' ); - -function jetpack_flickr_oembed_handler( $matches, $attr, $url ) { - // Legacy slideshow embeds end with /show/ - // e.g. http://www.flickr.com/photos/yarnaholic/sets/72157615194738969/show/ - if ( '/show/' !== substr( $url, -strlen( '/show/' ) ) ) { - // These lookups need cached, as they don't use WP_Embed (which caches) - $cache_key = md5( $url . serialize( $attr ) ); - $cache_group = 'oembed_flickr'; - - $html = wp_cache_get( $cache_key, $cache_group ); - - if ( false === $html ) { - $html = _wp_oembed_get_object()->get_html( $url, $attr ); - - wp_cache_set( $cache_key, $html, $cache_group, 60 * MINUTE_IN_SECONDS ); - } - - return $html; - } - - return flickr_shortcode_handler( array( 'photo' => $url ) ); -} diff --git a/plugins/jetpack/modules/shortcodes/getty.php b/plugins/jetpack/modules/shortcodes/getty.php deleted file mode 100644 index d473e726..00000000 --- a/plugins/jetpack/modules/shortcodes/getty.php +++ /dev/null @@ -1,222 +0,0 @@ -<?php -/** - * Getty shortcode - * - * [getty src="82278805" width="$width" height="$height"] - * <div class="getty embed image" style="background-color:#fff;display:inline-block;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;color:#a7a7a7;font-size:11px;width:100%;max-width:462px;"><div style="padding:0;margin:0;text-align:left;"><a href="http://www.gettyimages.com/detail/82278805" target="_blank" style="color:#a7a7a7;text-decoration:none;font-weight:normal !important;border:none;display:inline-block;">Embed from Getty Images</a></div><div style="overflow:hidden;position:relative;height:0;padding:80.086580% 0 0 0;width:100%;"><iframe src="//embed.gettyimages.com/embed/82278805?et=jGiu6FXXSpJDGf1SnwLV2g&sig=TFVNFtqghwNw5iJQ1MFWnI8f4Y40_sfogfZLhai6SfA=" width="462" height="370" scrolling="no" frameborder="0" style="display:inline-block;position:absolute;top:0;left:0;width:100%;height:100%;"></iframe></div><p style="margin:0;"></p></div> - * - * @package Jetpack - */ - -if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { - add_action( 'init', 'jetpack_getty_enable_embeds' ); -} else { - jetpack_getty_enable_embeds(); -} - -/** - * Register Getty as oembed provider. Add filter to reverse iframes to shortcode. Register [getty] shortcode. - * - * @since 4.5.0 - * @since 5.8.0 removed string parameter. - */ -function jetpack_getty_enable_embeds() { - - // Support their oEmbed Endpoint. - wp_oembed_add_provider( '#https?://www\.gettyimages\.com/detail/.*#i', 'https://embed.gettyimages.com/oembed/', true ); - wp_oembed_add_provider( '#https?://(www\.)?gty\.im/.*#i', 'https://embed.gettyimages.com/oembed/', true ); - - // Allow iframes to be filtered to short code (so direct copy+paste can be done). - add_filter( 'pre_kses', 'wpcom_shortcodereverse_getty' ); - - // Actually display the Getty Embed. - add_shortcode( 'getty', 'jetpack_getty_shortcode' ); -} - -/** - * Filters the oEmbed provider URL for Getty URLs to include site URL host as - * caller if available, falling back to "wordpress.com". Must be applied at - * time of embed in case that `init` is too early (WP.com REST API). - * - * @module shortcodes - * - * @since 5.8.0 - * - * @see WP_oEmbed::fetch - * - * @return string oEmbed provider URL - */ -add_filter( 'oembed_fetch_url', 'getty_add_oembed_endpoint_caller' ); - -/** - * Filter the embeds to add a caller parameter. - * - * @param string $provider URL of the oEmbed provider. - */ -function getty_add_oembed_endpoint_caller( $provider ) { - // By time filter is called, original provider URL has had url, maxwidth, - // maxheight query parameters added. - if ( 0 !== strpos( $provider, 'https://embed.gettyimages.com/oembed/' ) ) { - return $provider; - } - - // Set the caller argument to pass to Getty's oembed provider. - if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { - - // Only include caller for non-private sites. - if ( ! function_exists( 'is_private_blog' ) || ! is_private_blog() ) { - $host = wp_parse_url( get_bloginfo( 'url' ), PHP_URL_HOST ); - } - - // Fall back to WordPress.com. - if ( empty( $host ) ) { - $host = 'wordpress.com'; - } - } else { - $host = wp_parse_url( get_home_url(), PHP_URL_HOST ); - } - - return add_query_arg( 'caller', $host, $provider ); -} - -/** - * Compose shortcode based on Getty iframes. - * - * @since 4.5.0 - * - * @param string $content Post content. - * - * @return mixed - */ -function wpcom_shortcodereverse_getty( $content ) { - if ( ! is_string( $content ) || false === stripos( $content, '.gettyimages.com/' ) ) { - return $content; - } - - $regexp = '!<iframe\s+src=[\'"](https?:)?//embed\.gettyimages\.com/embed(/|/?\?assets=)([a-z0-9_-]+(,[a-z0-9_-]+)*)[^\'"]*?[\'"]((?:\s+\w+=[\'"][^\'"]*[\'"])*)((?:[\s\w]*))></iframe>!i'; - $regexp_ent = str_replace( '&#0*58;', '&#0*58;|�*58;', htmlspecialchars( $regexp, ENT_NOQUOTES ) ); - - // Markup pattern for 2017 embed syntax with significant differences from the prior pattern. - $regexp_2017 = '!<a.+?class=\'gie-(single|slideshow)\'.+?gie\.widgets\.load\({([^}]+)}\).+?embed-cdn\.gettyimages\.com/widgets\.js.+?</script>!'; - $regexp_2017_ent = str_replace( '&#0*58;', '&#0*58;|�*58;', htmlspecialchars( $regexp_2017, ENT_NOQUOTES ) ); - - foreach ( compact( 'regexp_2017', 'regexp_2017_ent', 'regexp', 'regexp_ent' ) as $reg => $regexp ) { - if ( ! preg_match_all( $regexp, $content, $matches, PREG_SET_ORDER ) ) { - continue; - } - - foreach ( $matches as $match ) { - if ( 'regexp_2017' === $reg || 'regexp_2017_ent' === $reg ) { - // Extract individual keys from the matched JavaScript object. - $params = $match[2]; - if ( ! preg_match_all( '!(?P<key>\w+)\s*:\s*([\'"](?P<value>[^\'"]*?)(px)?[\'"])!', $params, $key_matches, PREG_SET_ORDER ) ) { - continue; - } - - foreach ( $key_matches as $key_match ) { - switch ( $key_match['key'] ) { - case 'items': - $ids = $key_match['value']; - break; - case 'w': - $width = (int) $key_match['value']; - break; - case 'h': - $height = (int) $key_match['value']; - break; - case 'tld': - $tld = $key_match['value']; - break; - } - } - } else { - $params = $match[5]; - if ( 'regexp_ent' === $reg ) { - $params = html_entity_decode( $params ); - } - $params = wp_kses_hair( $params, array( 'http' ) ); - - $ids = esc_html( $match[3] ); - $width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0; - $height = isset( $params['height'] ) ? (int) $params['height']['value'] : 0; - } - - if ( empty( $ids ) ) { - continue; - } - - $shortcode = '[getty src="' . esc_attr( $ids ) . '"'; - if ( ! empty( $width ) ) { - $shortcode .= ' width="' . esc_attr( $width ) . '"'; - } - if ( ! empty( $height ) ) { - $shortcode .= ' height="' . esc_attr( $height ) . '"'; - } - /* - * While it does not appear to have any practical impact, Getty has - * requested that we include TLD in the embed request - */ - if ( ! empty( $tld ) ) { - $shortcode .= ' tld="' . esc_attr( $tld ) . '"'; - } - $shortcode .= ']'; - - $content = str_replace( $match[0], $shortcode, $content ); - } - } - - // strip out enclosing div and any other markup. - $regexp = '%<div class="getty\s[^>]*+>.*?<div[^>]*+>(\[getty[^\]]*+\])\s*</div>.*?</div>%is'; - $regexp_ent = str_replace( array( '&#0*58;', '[^>]' ), array( '&#0*58;|�*58;', '[^&]' ), htmlspecialchars( $regexp, ENT_NOQUOTES ) ); - - foreach ( compact( 'regexp', 'regexp_ent' ) as $reg => $regexp ) { - if ( ! preg_match_all( $regexp, $content, $matches, PREG_SET_ORDER ) ) { - continue; - } - - foreach ( $matches as $match ) { - $content = str_replace( $match[0], $match[1], $content ); - } - } - - /** This action is documented in modules/widgets/social-media-icons.php */ - do_action( 'jetpack_bump_stats_extras', 'html_to_shortcode', 'getty' ); - - return $content; -} - -/** - * Parse shortcode arguments and render its output. - * - * @since 4.5.0 - * - * @param array $atts Shortcode parameters. - * @param string $content Content enclosed by shortcode tags. - * - * @return string - */ -function jetpack_getty_shortcode( $atts, $content = '' ) { - - if ( ! empty( $content ) ) { - $src = $content; - } elseif ( ! empty( $atts['src'] ) ) { - $src = $atts['src']; - } elseif ( ! empty( $atts[0] ) ) { - $src = $atts[0]; - } else { - return '<!-- Missing Getty Source ID -->'; - } - - $src = preg_replace( '/^([\da-z-]+(,[\da-z-]+)*).*$/', '$1', $src ); - - $params = array( - 'width' => isset( $atts['width'] ) ? (int) $atts['width'] : null, - 'height' => isset( $atts['height'] ) ? (int) $atts['height'] : null, - ); - - if ( ! empty( $atts['tld'] ) ) { - $params['tld'] = $atts['tld']; - } - - return wp_oembed_get( 'https://gty.im/' . $src, array_filter( $params ) ); -} diff --git a/plugins/jetpack/modules/shortcodes/gist.php b/plugins/jetpack/modules/shortcodes/gist.php deleted file mode 100644 index 968e9e75..00000000 --- a/plugins/jetpack/modules/shortcodes/gist.php +++ /dev/null @@ -1,141 +0,0 @@ -<?php -/** - * GitHub's Gist site supports oEmbed but their oembed provider only - * returns raw HTML (no styling) and the first little bit of the code. - * - * Their JavaScript-based embed method is a lot better, so that's what we're using. - */ - -wp_embed_register_handler( 'github-gist', '#https?://gist\.github\.com/([a-zA-Z0-9/]+)(\#file\-[a-zA-Z0-9\_\-]+)?#', 'github_gist_embed_handler' ); -add_shortcode( 'gist', 'github_gist_shortcode' ); - -/** - * Handle gist embeds. - * - * @since 2.8.0 - * - * @global WP_Embed $wp_embed - * - * @param array $matches Results after parsing the URL using the regex in wp_embed_register_handler(). - * @param array $attr Embed attributes. - * @param string $url The original URL that was matched by the regex. - * @param array $rawattr The original unmodified attributes. - * @return string The embed HTML. - */ -function github_gist_embed_handler( $matches, $attr, $url, $rawattr ) { - // Let the shortcode callback do all the work - return github_gist_shortcode( $matches, $url ); -} - -/** - * Callback for gist shortcode. - * - * @since 2.8.0 - * - * @param array $atts Attributes found in the shortcode. - * @param string $content Content enclosed by the shortcode. - * - * @return string The gist HTML. - */ -function github_gist_shortcode( $atts, $content = '' ) { - - if ( empty( $atts[0] ) && empty( $content ) ) { - return '<!-- Missing Gist ID -->'; - } - - $id = ( ! empty( $content ) ) ? $content : $atts[0]; - - // Parse a URL - if ( ! is_numeric( $id ) ) { - $id = preg_replace( '#https?://gist.github.com/([a-zA-Z0-9]+)#', '$1', $id ); - } - - if ( ! $id ) { - return '<!-- Invalid Gist ID -->'; - } - - if ( Jetpack_AMP_Support::is_amp_request() ) { - /* - * According to <https://www.ampproject.org/docs/reference/components/amp-gist#height-(required)>: - * - * > Note: You must find the height of the gist by inspecting it with your browser (e.g., Chrome Developer Tools). - * - * However, this does not seem to be the case any longer. The actual height of the content does get set in the - * page after loading. So this is just the initial height. - * See <https://github.com/ampproject/amphtml/pull/17738>. - */ - $height = 240; - - $parsed_url = wp_parse_url( $id ); - - // Strip Github user name. - $id = preg_replace( '#^.*/(?=[a-z0-9]+)#', '', $parsed_url['path'] ); - - $file = null; - if ( ! empty( $parsed_url['query'] ) ) { - $query_args = wp_parse_args( $parsed_url['query'] ); - if ( isset( $query_args['file'] ) ) { - $file = $query_args['file']; - } - } - if ( ! $file && ! empty( $parsed_url['fragment'] ) && preg_match( '#^file-(.+)#', $parsed_url['fragment'], $matches ) ) { - $file = $matches[1]; - - // Make best guess of file for fragment that was slugified. - $file = preg_replace( '/-(\w+)/', '.$1', $file ); - } - - $amp_tag = sprintf( - '<amp-gist layout="fixed-height" data-gistid="%s" height="%s"', - esc_attr( basename( $id, '.json' ) ), - esc_attr( $height ) - ); - if ( ! empty( $file ) ) { - $amp_tag .= sprintf( ' data-file="%s"', esc_attr( $file ) ); - } - $amp_tag .= '></amp-gist>'; - return $amp_tag; - } - - wp_enqueue_script( - 'jetpack-gist-embed', - Jetpack::get_file_url_for_environment( '_inc/build/shortcodes/js/gist.min.js', 'modules/shortcodes/js/gist.js' ), - array( 'jquery' ), - false, - true - ); - - if ( false !== strpos( $id, '#file-' ) ) { - // URL points to a specific file in the gist - $id = str_replace( '#file-', '.json?file=', $id ); - $id = preg_replace( '/\-(?!.*\-)/', '.', $id ); - } else { - $file = ( ! empty( $atts['file'] ) ) ? '?file=' . urlencode( $atts['file'] ) : ''; - // URL points to the entire gist - $id .= ".json$file"; - } - - // inline style to prevent the bottom margin to the embed that themes like TwentyTen, et al., add to tables - $return = '<style>.gist table { margin-bottom: 0; }</style><div class="gist-oembed" data-gist="' . esc_attr( $id ) . '"></div>'; - - if ( isset( $_POST['type'] ) && 'embed' === $_POST['type'] && - isset( $_POST['action'] ) && 'parse-embed' === $_POST['action'] ) { - return github_gist_simple_embed( $id ); - } - - return $return; -} - -/** - * Use script tag to load shortcode in editor. - * - * @since 3.9.0 - * - * @param string $id The ID of the gist. - * - * @return string - */ -function github_gist_simple_embed( $id ) { - $id = str_replace( 'json', 'js', $id ); - return '<script type="text/javascript" src="https://gist.github.com/' . $id . '"></script>'; -} diff --git a/plugins/jetpack/modules/shortcodes/googleapps.php b/plugins/jetpack/modules/shortcodes/googleapps.php deleted file mode 100644 index 55c4580e..00000000 --- a/plugins/jetpack/modules/shortcodes/googleapps.php +++ /dev/null @@ -1,255 +0,0 @@ -<?php -/** - * Google Docs and Google Calendar Shortcode - * - * Presentation: - * <iframe src="https://docs.google.com/present/embed?id=dhfhrphh_123drp8s65c&interval=15&autoStart=true&loop=true&size=l" frameborder="0" width="700" height="559"></iframe> - * <iframe src="https://docs.google.com/presentation/embed?id=13ItX4jV0SOSdr-ZjHarcpTh9Lr4omfsHAp87jpxv8-0&start=false&loop=false&delayms=3000" frameborder="0" width="960" height="749" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe> - * - * Document: - * <iframe src="https://docs.google.com/document/pub?id=1kDatklacdZ_tZUOpWtt_ONzY97Ldj2zFcuO9LBY2Ln4&embedded=true"></iframe> - * <iframe src="https://docs.google.com/document/d/1kDatklacdZ_tZUOpWtt_ONzY97Ldj2zFcuO9LBY2Ln4/pub?embedded=true"></iframe> - * <iframe src="https://docs.google.com/document/d/e/2PACX-1vRkpIdasKL-eKXDjJgpEONduUspZTz0YmKaajfie0eJYnzikuyusuG1_V8X8T9XflN9l8A1oCM2sgEA/pub?embedded=true"></iframe> - * - * External document: - * <iframe width=100% height=560px frameborder=0 src=https://docs.google.com/a/pranab.in/viewer?a=v&pid=explorer&chrome=false&embedded=true&srcid=1VTMwdgGiDMt8MCr75-YkQP-4u9WmEp1Qvf6C26KYBgFilxU2qndpd-VHhBIn&hl=en></iframe> - * - * Spreadsheet Form: - * <iframe src="https://spreadsheets.google.com/embeddedform?formkey=dEVOYnMzZG5jMUpGbjFMYjFYNVB3NkE6MQ" width="760" height="710" frameborder="0" marginheight="0" marginwidth="0">Loading...</iframe> - * - * Spreadsheet Widget: - * <iframe width='500' height='300' frameborder='0' src='https://spreadsheets1.google.com/a/petedavies.com/pub?hl=en&hl=en&key=0AjSij7nlnXvKdHNsNjRSWG12YmVfOEFwdlMxQ3J1S1E&single=true&gid=0&output=html&widget=true'></iframe> - * <iframe width='500' height='300' frameborder='0' src='https://spreadsheets.google.com/spreadsheet/pub?hl=en&hl=en&key=0AhInIwfvYrIUdGJiTXhtUEhBSFVPUzdRZU5OMDlqdnc&output=html&widget=true'></iframe> - * - * Calendar: - * <iframe src="https://www.google.com/calendar/embed?src=serjant%40gmail.com&ctz=Europe/Sofia" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe> - * <iframe src="http://www.google.com/calendar/hosted/belcastro.com/embed?src=n8nr8sd6v9hnus3nmlk7ed1238%40group.calendar.google.com&ctz=Europe/Zurich" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe> - * - * Customized calendar: - * <iframe src="https://www.google.com/calendar/embed?title=asdf&showTitle=0&showNav=0&showDate=0&showPrint=0&showTabs=0&showCalendars=0& - * showTz=0&mode=AGENDA&height=300&wkst=2&hl=fi&bgcolor=%23ffcccc&src=m52gdmbgelo3itf00u1v44g0ns%40group.calendar.google.com&color=%234E5D6C& - * src=serjant%40gmail.com&color=%235229A3&ctz=Europe%2FRiga" style=" border:solid 1px #777 " width="500" height="300" frameborder="0" scrolling="no"></iframe> - * - * Generic - * <iframe src="https://docs.google.com/file/d/0B0SIdZW7iu-zX1RWREJpMXVHZVU/preview" width="640" height="480"></iframe> - * - * @package Jetpack - */ - -add_filter( 'pre_kses', 'googleapps_embed_to_shortcode' ); -add_shortcode( 'googleapps', 'googleapps_shortcode' ); - -/** - * Reverse iframe embed to shortcode mapping HTML attributes to shortcode attributes. - * - * @since 4.5.0 - * - * @param string $content Post content. - * - * @return mixed - */ -function googleapps_embed_to_shortcode( $content ) { - if ( - ! is_string( $content ) - || false === stripos( $content, '<iframe' ) - && false === stripos( $content, '.google.com' ) - ) { - return $content; - } - - $regexp = '#<iframe((?:\s+\w+="[^"]*")*?)\s*src="https?://(docs|drive|spreadsheets\d*|calendar|www)*\.google\.com/(?!maps)([-\w\./]+)(?:\?)?([^"]+)?"\s*((?:\s+\w+="[^"]*")*?)>.*?</iframe>#i'; - $regexp_ent = str_replace( '&#0*58;', '&#0*58;|�*58;', htmlspecialchars( $regexp, ENT_NOQUOTES ) ); - $regexp_squot = str_replace( '"', "'", $regexp ); - $regexp_ent_squot = str_replace( '"', "'", $regexp_ent ); - $regexp_noquot = '!<iframe(.*?)src=https://(docs|drive)\.google\.com/[-\.\w/]*?(viewer)\?(.*?)>(.*?)</iframe>!'; - $regexp_ent_noquot = str_replace( '&#0*58;', '&#0*58;|�*58;', htmlspecialchars( $regexp_noquot, ENT_NOQUOTES ) ); - - foreach ( compact( 'regexp', 'regexp_ent', 'regexp_squot', 'regexp_ent_squot', 'regexp_noquot', 'regexp_ent_noquot' ) as $reg => $regexp ) { - if ( ! preg_match_all( $regexp, $content, $matches, PREG_SET_ORDER ) ) { - continue; - } - - foreach ( $matches as $match ) { - $params = $match[1] . $match[5]; - if ( in_array( $reg, array( 'regexp_ent', 'regexp_ent_squot' ), true ) ) { - $params = html_entity_decode( $params ); - } - - $params = wp_kses_hair( $params, array( 'http' ) ); - - $width = 0; - $height = 0; - - if ( isset( $params['width'] ) ) { - $width = (int) $params['width']['value']; - } - - if ( isset( $params['height'] ) ) { - $height = (int) $params['height']['value']; - } - - // allow the user to specify width greater than 200 inside text widgets. - if ( - $width > 400 - // We don't need to check a nonce here. A nonce is already checked "further up" in most code paths. - // In the case where no nonce is ever checked, setting this $_POST parameter doesn't do anything the submitter couldn't already do (set the width/height). - && isset( $_POST['widget-text'] ) // phpcs:ignore WordPress.Security.NonceVerification.Missing - ) { - $width = 200; - $height = 200; - } - - $attributes = ''; - if ( isset( $params['width'] ) && '100%' === $params['width']['value'] ) { - $width = '100%'; - } - - if ( $width ) { - $attributes = ' width="' . $width . '"'; - } - - if ( $height ) { - $attributes .= ' height="' . $height . '"'; - } - - $domain = 'spreadsheets'; - if ( in_array( $match[2], array( 'docs', 'drive', 'www', 'calendar' ), true ) ) { - $domain = $match[2]; - } - - // Make sure this is actually something that the shortcode supports. If it's not, leave the HTML alone. - if ( ! googleapps_validate_domain_and_dir( $domain, $match[3] ) ) { - continue; - } - - /** This action is documented in modules/widgets/social-media-icons.php */ - do_action( 'jetpack_bump_stats_extras', 'html_to_shortcode', googleapps_service_name( $domain, $match[3] ) ); - - $content = str_replace( $match[0], '[googleapps domain="' . $domain . '" dir="' . $match[3] . '" query="' . esc_attr( $match[4] ) . '"' . $attributes . ' /]', $content ); - } - } - - return $content; -} - -/** - * Parse shortcode attributes and output a Google Docs embed. - * - * @since 4.5.0 - * - * @param array $atts Shortcode attributes. - * - * @return string - */ -function googleapps_shortcode( $atts ) { - global $content_width; - - $attr = shortcode_atts( - array( - 'width' => '100%', - 'height' => '560', - 'domain' => 'docs', - 'dir' => 'document', - 'query' => '', - 'src' => '', - ), - $atts - ); - - if ( isset( $content_width ) && is_numeric( $attr['width'] ) && $attr['width'] > $content_width ) { - $attr['width'] = $content_width; - } - - if ( isset( $content_width ) && '560' === $attr['height'] ) { - $attr['height'] = floor( $content_width * 3 / 4 ); - } - - if ( isset( $atts[0] ) && $atts[0] ) { - $attr['src'] = $atts[0]; - } - - if ( $attr['src'] && preg_match( '!https?://(docs|drive|spreadsheets\d*|calendar|www)*\.google\.com/([-\w\./]+)\?([^"]+)!', $attr['src'], $matches ) ) { - $attr['domain'] = $matches[1]; - $attr['dir'] = $matches[2]; - parse_str( htmlspecialchars_decode( $matches[3] ), $query_ar ); - $query_ar['chrome'] = 'false'; - $query_ar['embedded'] = 'true'; - $attr['query'] = http_build_query( $query_ar ); - } - - if ( ! googleapps_validate_domain_and_dir( $attr['domain'], $attr['dir'] ) ) { - return '<!-- Unsupported URL -->'; - } - - $attr['query'] = $attr['dir'] . '?' . $attr['query']; - - /** This action is documented in modules/widgets/social-media-icons.php */ - do_action( 'jetpack_bump_stats_extras', 'embeds', googleapps_service_name( $attr['domain'], $attr['dir'] ) ); - - return sprintf( - '<iframe src="%s" frameborder="0" width="%s" height="%s" marginheight="0" marginwidth="0" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe>', - esc_url( 'https://' . $attr['domain'] . '.google.com/' . $attr['query'] ), - esc_attr( $attr['width'] ), - esc_attr( $attr['height'] ) - ); -} - -/** - * Check that the domain blogs to a Google Apps domain. - * - * @since 4.5.0 - * - * @param string $domain Google subdomain. - * @param string $dir Subdirectory of the shared URL. - * - * @return bool - */ -function googleapps_validate_domain_and_dir( $domain, $dir ) { - if ( ! in_array( $domain, array( 'docs', 'drive', 'www', 'spreadsheets', 'calendar' ), true ) ) { - return false; - } - - // Calendars. - if ( ( 'www' === $domain || 'calendar' === $domain ) && 'calendar/' !== substr( $dir, 0, 9 ) ) { - return false; - } - - // Docs. - if ( in_array( $domain, array( 'docs', 'drive' ), true ) && ! preg_match( '![-\.\w/]*(presentation/embed|presentation/d/(.*)|present/embed|document/pub|spreadsheets/d/(.*)|document/d/(e/)?[\w-]+/pub|file/d/[\w-]+/preview|viewer|forms/d/(.*)/viewform|spreadsheet/\w+)$!', $dir ) ) { - return false; - } - - // Spreadsheets. - if ( 'spreadsheets' === $domain && ! preg_match( '!^([-\.\w/]+/pub|[-\.\w/]*embeddedform)$!', $dir ) ) { - return false; - } - - return true; -} - -/** - * Get the name of the service we'll be embedding. - * - * @since 4.5.0 - * - * @param string $domain Google subdomain. - * @param string $dir Subdirectory of the shared URL. - * - * @return string - */ -function googleapps_service_name( $domain, $dir ) { - switch ( $domain ) { - case 'drive': - case 'docs': - $service_name = ( 'present/embed' === $dir ) ? 'googledocs_presentation' : 'googledocs_document'; - break; - case 'spreadsheets': - $service_name = ( 'embeddedform' === $dir ) ? 'googledocs_form' : 'googledocs_spreadsheet'; - break; - case 'calendar': - default: - $service_name = 'google_calendar'; - } - - return $service_name; -} diff --git a/plugins/jetpack/modules/shortcodes/googlemaps.php b/plugins/jetpack/modules/shortcodes/googlemaps.php deleted file mode 100644 index 21d86088..00000000 --- a/plugins/jetpack/modules/shortcodes/googlemaps.php +++ /dev/null @@ -1,115 +0,0 @@ -<?php - -/* - * Google maps iframe - transforms code that looks like that: - * <iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&source=s_q&hl=bg&geocode=&q=%D0%9C%D0%BB%D0%B0%D0%B4%D0%BE%D1%81%D1%82+1,+%D0%A1%D0%BE%D1%84%D0%B8%D1%8F,+%D0%91%D1%8A%D0%BB%D0%B3%D0%B0%D1%80%D0%B8%D1%8F&sll=37.0625,-95.677068&sspn=40.545434,79.013672&ie=UTF8&hq=&hnear=%D0%9C%D0%BB%D0%B0%D0%B4%D0%BE%D1%81%D1%82+1&ll=42.654446,23.372061&spn=0.036864,0.077162&t=h&z=14&output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&source=embed&hl=bg&geocode=&q=%D0%9C%D0%BB%D0%B0%D0%B4%D0%BE%D1%81%D1%82+1,+%D0%A1%D0%BE%D1%84%D0%B8%D1%8F,+%D0%91%D1%8A%D0%BB%D0%B3%D0%B0%D1%80%D0%B8%D1%8F&sll=37.0625,-95.677068&sspn=40.545434,79.013672&ie=UTF8&hq=&hnear=%D0%9C%D0%BB%D0%B0%D0%B4%D0%BE%D1%81%D1%82+1&ll=42.654446,23.372061&spn=0.036864,0.077162&t=h&z=14" style="color:#0000FF;text-align:left">Вижте по-голяма карта</a></small> - * into the [googlemaps http://...] shortcode format - */ -function jetpack_googlemaps_embed_to_short_code( $content ) { - - if ( ! is_string( $content ) || ( false === strpos( $content, 'maps.google.' ) && 1 !== preg_match( '@google\.[^/]+/maps?@', $content ) ) ) { - return $content; - } - - // IE and TinyMCE format things differently - // <iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="<a href="https://maps.google.co.uk/maps/ms?msa=0&amp;msid=206216869547772496318.0004bf5f0ff25aea47bd9&amp;hl=en&amp;ie=UTF8&amp;t=m&amp;ll=50.91917,-1.398808&amp;spn=0.013225,0.011794&amp;output=embed"></iframe><br">https://maps.google.co.uk/maps/ms?msa=0&amp;msid=206216869547772496318.0004bf5f0ff25aea47bd9&amp;hl=en&amp;ie=UTF8&amp;t=m&amp;ll=50.91917,-1.398808&amp;spn=0.013225,0.011794&amp;output=embed"></iframe><br</a> /><small>View <a href="<a href="https://maps.google.co.uk/maps/ms?msa=0&amp;msid=206216869547772496318.0004bf5f0ff25aea47bd9&amp;hl=en&amp;ie=UTF8&amp;t=m&amp;ll=50.91917,-1.398808&amp;spn=0.013225,0.011794&amp;source=embed">https://maps.google.co.uk/maps/ms?msa=0&amp;msid=206216869547772496318.0004bf5f0ff25aea47bd9&amp;hl=en&amp;ie=UTF8&amp;t=m&amp;ll=50.91917,-1.398808&amp;spn=0.013225,0.011794&amp;source=embed</a>" style="color:#0000FF;text-align:left">OARA Membership Discount Map</a> in a larger map</small> - if ( strpos( $content, 'src="<a href="' ) !== false ) { - $content = preg_replace_callback( '#<iframe\s[^&]*?(?:&(?!gt;)[^&]*?)*?src="<a href="https?://(.*)?\.google\.(.*?)/(.*?)\?(.+?)"[^&]*?(?:&(?!gt;)[^&]*?)*?>\s*</iframe><br">[^"]*?">\s*</iframe>(?:<br</a>\s*/>\s*<small>.*?</small>)?#i', 'jetpack_googlemaps_embed_to_short_code_callback', $content ); - return $content; - } - - $content = preg_replace_callback( '!\<iframe\s[^>]*?src="https?://(.*)?\.google\.(.*?)/(.*?)\?(.+?)"[^>]*?\>\s*\</iframe\>(?:\s*(?:\<br\s*/?\>)?\s*\<small\>.*?\</small\>)?!i', 'jetpack_googlemaps_embed_to_short_code_callback', $content ); - - $content = preg_replace_callback( '#<iframe\s[^&]*?(?:&(?!gt;)[^&]*?)*?src="https?://(.*)?\.google\.(.*?)/(.*?)\?(.+?)"[^&]*?(?:&(?!gt;)[^&]*?)*?>\s*</iframe>(?:\s*(?:<br\s*/?>)?\s*<small>.*?</small>)?#i', 'jetpack_googlemaps_embed_to_short_code_callback', $content ); - - return $content; -} - -function jetpack_googlemaps_embed_to_short_code_callback( $match ) { - - if ( preg_match( '/\bwidth=[\'"](\d+)(%)?/', $match[0], $width ) ) { - $percent = ! empty( $width[2] ) ? '%' : ''; - $width = absint( $width[1] ) . $percent; - } else { - $width = 425; - } - - if ( preg_match( '/\bheight=[\'"](\d+)(%)?/', $match[0], $height ) ) { - $percent = ! empty( $height[2] ) ? '%' : ''; - $height = absint( $height[1] ) . $percent; - } else { - $height = 350; - } - - $url = "https://{$match[1]}.google.{$match[2]}/{$match[3]}?{$match[4]}&w={$width}&h={$height}"; - - /** This action is documented in modules/shortcodes/youtube.php */ - do_action( 'jetpack_embed_to_shortcode', 'googlemaps', $url ); - - return "[googlemaps $url]"; -} - -add_filter( 'pre_kses', 'jetpack_googlemaps_embed_to_short_code' ); - -/** - * [googlemaps] shortcode - * - * Example usage: - * [googlemaps https://maps.google.com/maps?f=q&hl=en&geocode=&q=San+Francisco,+CA&sll=43.469466,-83.998504&sspn=0.01115,0.025942&g=San+Francisco,+CA&ie=UTF8&z=12&iwloc=addr&ll=37.808156,-122.402458&output=embed&s=AARTsJp56EajYksz3JXgNCwT3LJnGsqqAQ&w=425&h=350] - * [googlemaps https://mapsengine.google.com/map/embed?mid=zbBhkou4wwtE.kUmp8K6QJ7SA&w=640&h=480] - */ -function jetpack_googlemaps_shortcode( $atts ) { - if ( ! isset( $atts[0] ) ) { - return ''; - } - - $params = ltrim( $atts[0], '=' ); - - $width = 425; - $height = 350; - - if ( preg_match( '!^https?://(www|maps|mapsengine)\.google(\.co|\.com)?(\.[a-z]+)?/.*?(\?.+)!i', $params, $match ) ) { - $params = str_replace( '&amp;', '&', $params ); - $params = str_replace( '&', '&', $params ); - parse_str( $params, $arg ); - - if ( isset( $arg['hq'] ) ) { - unset( $arg['hq'] ); - } - - $url = ''; - foreach ( (array) $arg as $key => $value ) { - if ( 'w' == $key ) { - $percent = ( '%' == substr( $value, -1 ) ) ? '%' : ''; - $width = (int) $value . $percent; - } elseif ( 'h' == $key ) { - $height = (int) $value; - } else { - $key = str_replace( '_', '.', $key ); - $url .= esc_attr( "$key=$value&" ); - } - } - $url = substr( $url, 0, -5 ); - - if ( is_ssl() ) { - $url = str_replace( 'http://', 'https://', $url ); - } - - $css_class = 'googlemaps'; - - if ( ! empty( $atts['align'] ) && in_array( strtolower( $atts['align'] ), array( 'left', 'center', 'right' ), true ) ) { - $atts['align'] = strtolower( $atts['align'] ); - - if ( $atts['align'] === 'left' ) { - $css_class .= ' alignleft'; - } elseif ( $atts['align'] === 'center' ) { - $css_class .= ' aligncenter'; - } elseif ( $atts['align'] === 'right' ) { - $css_class .= ' alignright'; - } - } - - return '<div class="' . esc_attr( $css_class ) . '"><iframe width="' . $width . '" height="' . $height . '" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' . $url . '"></iframe></div>'; - } -} -add_shortcode( 'googlemaps', 'jetpack_googlemaps_shortcode' ); diff --git a/plugins/jetpack/modules/shortcodes/googleplus.php b/plugins/jetpack/modules/shortcodes/googleplus.php deleted file mode 100644 index 8c9118e1..00000000 --- a/plugins/jetpack/modules/shortcodes/googleplus.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -/** - * Google+ embeds - * Google+ has shut down. Output the link for history's sake. - * Other than that, there's not much we can do. - */ - -define( 'JETPACK_GOOGLEPLUS_EMBED_REGEX', '#^https?://plus\.(sandbox\.)?google\.com/(u/\d+/)?([^/]+)/posts/([^/]+)$#' ); - -// Example URL: https://plus.google.com/114986219448604314131/posts/LgHkesWCmJo -// Alternate example: https://plus.google.com/u/0/100004581596612508203/posts/2UKwN67MBQs (note the /u/0/) -wp_embed_register_handler( 'googleplus', JETPACK_GOOGLEPLUS_EMBED_REGEX, 'jetpack_deprecated_embed_handler' ); - -add_shortcode( 'googleplus', 'jetpack_googleplus_shortcode_handler' ); - -function jetpack_googleplus_shortcode_handler( $atts ) { - global $wp_embed; - - if ( empty( $atts['url'] ) ) { - return; - } - - if ( ! preg_match( JETPACK_GOOGLEPLUS_EMBED_REGEX, $atts['url'] ) ) { - return; - } - - return sprintf( '<p>%s</p>', $wp_embed->shortcode( $atts, $atts['url'] ) ); -} diff --git a/plugins/jetpack/modules/shortcodes/googlevideo.php b/plugins/jetpack/modules/shortcodes/googlevideo.php deleted file mode 100644 index bf3ad707..00000000 --- a/plugins/jetpack/modules/shortcodes/googlevideo.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php - -/** - * google video is replaced by youtube, but its embeds will probably continue working indefinitely. - * [googlevideo=http://video.google.com/googleplayer.swf?docId=-6006084025483872237] - */ - -function googlevideo_shortcode( $atts ) { - if ( ! isset( $atts[0] ) ) { - return ''; - } - - $src = ltrim( $atts[0], '=' ); - - if ( 0 !== strpos( $src, 'http://video.google.com/googleplayer.swf' ) ) { - if ( ! preg_match( '|^http://(video\.google\.[a-z]{2,3}(?:.[a-z]{2})?)/|', $src ) || ! preg_match( '|.*docid=([0-9-]+).*|i', $src, $match ) || ! is_numeric( $match[1] ) ) { - return '<!--Google Video Error: bad URL entered-->'; - } - - $src = 'http://video.google.com/googleplayer.swf?docId=' . $match[1]; - } - - // default width should be 400 unless the theme's content width is smaller than that - global $content_width; - $default_width = intval( ! empty( $content_width ) ? min( $content_width, 400 ) : 400 ); - $height = intval( 0.825 * $default_width ); - $src = esc_attr( $src ); - - return "<span style='text-align:center;display:block;'><object width='{$default_width}' height='{$height}' type='application/x-shockwave-flash' data='{$src}'><param name='allowScriptAccess' value='never' /><param name='movie' value='$src'/><param name='quality' value='best'/><param name='bgcolor' value='#ffffff' /><param name='scale' value='noScale' /><param name='wmode' value='opaque' /></object></span>"; -} -add_shortcode( 'googlevideo', 'googlevideo_shortcode' ); diff --git a/plugins/jetpack/modules/shortcodes/gravatar.php b/plugins/jetpack/modules/shortcodes/gravatar.php deleted file mode 100644 index cb709af9..00000000 --- a/plugins/jetpack/modules/shortcodes/gravatar.php +++ /dev/null @@ -1,163 +0,0 @@ -<?php -/** - * Gravatar shortcode for avatar and profile. - * - * Usage: - * - * [gravatar email="user@example.org" size="48"] - * [gravatar_profile who="user@example.org"] - * - * @package Jetpack - */ - -add_shortcode( 'gravatar', 'jetpack_gravatar_shortcode' ); -add_shortcode( 'gravatar_profile', 'jetpack_gravatar_profile_shortcode' ); - -/** - * Get gravatar using the email provided at the specified size. - * - * @since 4.5.0 - * - * @param array $atts Shortcode attributes. - * - * @return bool|string - */ -function jetpack_gravatar_shortcode( $atts ) { - $atts = shortcode_atts( - array( - 'email' => '', - 'size' => 96, - ), - $atts - ); - - if ( empty( $atts['email'] ) || ! is_email( $atts['email'] ) ) { - return false; - } - - $atts['size'] = intval( $atts['size'] ); - if ( 0 > $atts['size'] ) { - $atts['size'] = 96; - } - - return get_avatar( $atts['email'], $atts['size'] ); -} - -/** - * Display Gravatar profile - * - * @since 4.5.0 - * - * @param array $atts Shortcode attributes. - * - * @uses shortcode_atts() - * @uses get_user_by() - * @uses is_email() - * @uses sanitize_email() - * @uses sanitize_user() - * @uses set_url_scheme() - * @uses wpcom_get_avatar_url() - * @uses get_user_attribute() - * @uses esc_url() - * @uses esc_html() - * @uses _e() - * - * @return string - */ -function jetpack_gravatar_profile_shortcode( $atts ) { - // Give each use of the shortcode a unique ID. - static $instance = 0; - - // Process passed attributes. - $atts = shortcode_atts( - array( - 'who' => null, - ), - $atts, - 'jetpack_gravatar_profile' - ); - - // Can specify username, user ID, or email address. - if ( is_numeric( $atts['who'] ) ) { - $user = get_user_by( 'id', (int) $atts['who'] ); - } elseif ( is_email( $atts['who'] ) ) { - $user = get_user_by( 'email', sanitize_email( $atts['who'] ) ); - } elseif ( is_string( $atts['who'] ) ) { - $user = get_user_by( 'login', sanitize_user( $atts['who'] ) ); - } else { - $user = false; - } - - // Bail if we don't have a user. - if ( false === $user ) { - return false; - } - - // Render the shortcode. - $gravatar_url = set_url_scheme( 'http://gravatar.com/' . $user->user_login ); - - if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { - $avatar_url = wpcom_get_avatar_url( $user->ID, 96 ); - $avatar_url = $avatar_url[0]; - $user_location = get_user_attribute( $user->ID, 'location' ); - } else { - $avatar_url = get_avatar_url( $user->user_email, array( 'size' => 96 ) ); - $user_location = get_user_meta( $user->ID, 'location', true ); - } - - ob_start(); - - ?> - <script type="text/javascript"> - ( function() { - if ( null === document.getElementById( 'gravatar-profile-embed-styles' ) ) { - var headID = document.getElementsByTagName( 'head' )[0]; - var styleNode = document.createElement( 'style' ); - styleNode.type = 'text/css'; - styleNode.id = 'gravatar-profile-embed-styles'; - - var gCSS = '.grofile-wrap { border: solid 1px #eee; padding: 10px; } .grofile { padding: 0 0 5px 0; } .grofile-left { float: left; display: block; width: 96px; margin-right: 15px; } .grofile .gravatar { margin-bottom: 5px; } .grofile-clear { clear: left; font-size: 1px; height: 1px; } .grofile ul li a { text-indent: -99999px; } .grofile .grofile-left a:hover { text-decoration: none !important; border: none !important; } .grofile-name { margin-top: 0; }'; - - if ( document.all ) { - styleNode.innerText = gCSS; - } else { - styleNode.textContent = gCSS; - } - - headID.appendChild( styleNode ); - } - } )(); - </script> - - <div class="grofile vcard" id="grofile-embed-<?php echo esc_attr( $instance ); ?>"> - <div class="grofile-inner"> - <div class="grofile-left"> - <div class="grofile-img"> - <a href="<?php echo esc_url( $gravatar_url ); ?>"> - <img src="<?php echo esc_url( $avatar_url ); ?>" width="96" height="96" class="no-grav gravatar photo" /> - </a> - </div> - </div> - <div class="grofile-right"> - <p class="grofile-name fn"> - <strong><?php echo esc_html( $user->display_name ); ?></strong> - <?php - if ( ! empty( $user_location ) ) : - ?> - <br><span class="grofile-location adr"><?php echo esc_html( $user_location ); ?></span><?php endif; ?> - </p> - <p class="grofile-bio"><strong><?php esc_html_e( 'Bio:', 'jetpack' ); ?></strong> <?php echo wp_kses_post( $user->description ); ?></p> - <p class="grofile-view"> - <a href="<?php echo esc_url( $gravatar_url ); ?>"><?php esc_html_e( 'View complete profile', 'jetpack' ); ?></a> - </p> - </div> - <span class="grofile-clear"> </span> - </div> - </div> - <?php - - // Increment and return the rendered profile. - $instance++; - - return ob_get_clean(); -} diff --git a/plugins/jetpack/modules/shortcodes/houzz.php b/plugins/jetpack/modules/shortcodes/houzz.php deleted file mode 100644 index 9d9b3131..00000000 --- a/plugins/jetpack/modules/shortcodes/houzz.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -/* - * Houzz Embed - * - * Examples: - * Post content: - * - [houzz=http://www.houzz.com/pro/james-crisp] - * - http://www.houzz.com/pro/james-crisp - * Blog sidebar: [houzz=http://www.houzz.com/profile/alon w=200 h=300] - */ - -// Register oEmbed provider -wp_oembed_add_provider( '#https?://(.+?\.)?houzz\.(com|co\.uk|com\.au|de|fr|ru|jp|it|es|dk|se)/.*#i', 'https://www.houzz.com/oembed', true ); - -// Create Shortcode -function jetpack_houzz_shortcode( $atts, $content = null ) { - $url = substr( $atts[0], 1 ); - $args = array(); - if ( isset( $atts['w'] ) && is_numeric( $atts['w'] ) ) { - $args['width'] = $atts['w']; - } - if ( isset( $atts['h'] ) && is_numeric( $atts['h'] ) ) { - $args['height'] = $atts['h']; - } - $oembed = _wp_oembed_get_object(); - return $oembed->get_html( $url, $args ); -} -add_shortcode( 'houzz', 'jetpack_houzz_shortcode' ); diff --git a/plugins/jetpack/modules/shortcodes/hulu.php b/plugins/jetpack/modules/shortcodes/hulu.php deleted file mode 100644 index 38203d4c..00000000 --- a/plugins/jetpack/modules/shortcodes/hulu.php +++ /dev/null @@ -1,275 +0,0 @@ -<?php -/** - * Hulu Shortcode - * - * [hulu 369061] - * [hulu id=369061] - * [hulu id=369061 width=512 height=288 start_time="10" end_time="20" thumbnail_frame="10"] - * [hulu http://www.hulu.com/watch/369061] - * [hulu id=gQ6Z0I990IWv_VFQI2J7Eg width=512 height=288] - * - * <object width="512" height="288"> - * <param name="movie" value="http://www.hulu.com/embed/gQ6Z0I990IWv_VFQI2J7Eg"></param> - * <param name="allowFullScreen" value="true"></param> - * <embed src="http://www.hulu.com/embed/gQ6Z0I990IWv_VFQI2J7Eg" type="application/x-shockwave-flash" width="512" height="288" allowFullScreen="true"></embed> - * </object> - * - * @package Jetpack - */ - -if ( get_option( 'embed_autourls' ) ) { - - // Convert hulu URLS to shortcodes for old comments, saved before comments for shortcodes were enabled. - add_filter( 'comment_text', 'jetpack_hulu_link', 1 ); -} - -add_shortcode( 'hulu', 'jetpack_hulu_shortcode' ); - -/** - * Return a Hulu video ID from a given set to attributes. - * - * @since 4.5.0 - * - * @param array $atts Shortcode parameters. - * - * @return string $id Hulu video ID. - */ -function jetpack_shortcode_get_hulu_id( $atts ) { - // This will catch an id explicitly defined as such, or assume any param without a label is the id. First found is used. - if ( isset( $atts['id'] ) ) { - // First we check to see if [hulu id=369061] or [hulu id=gQ6Z0I990IWv_VFQI2J7Eg] was used. - $id = esc_attr( $atts['id'] ); - } elseif ( isset( $atts[0] ) && preg_match( '|www\.hulu\.com/watch/(\d+)|i', $atts[0], $match ) ) { - // this checks for [hulu http://www.hulu.com/watch/369061]. - $id = (int) $match[1]; - } elseif ( isset( $atts[0] ) ) { - // This checks for [hulu 369061] or [hulu 65yppv6xqa45s5n7_m1wng]. - $id = esc_attr( $atts[0] ); - } else { - $id = 0; - } - - return $id; -} - -/** - * Convert a Hulu shortcode into an embed code. - * - * @since 4.5.0 - * - * @param array $atts An array of shortcode attributes. - * - * @return string The embed code for the Hulu video. - */ -function jetpack_hulu_shortcode( $atts ) { - global $content_width; - - // Set a default content width, if it's not specified. - $attr = shortcode_atts( - array( - 'id' => '', - 'width' => $content_width ? $content_width : 640, - 'start_time' => '', - 'end_time' => '', - 'thumbnail_frame' => '', - ), - $atts - ); - - $id = jetpack_shortcode_get_hulu_id( $atts ); - if ( ! $id ) { - return '<!-- Hulu Error: Hulu shortcode syntax invalid. -->'; - } - - $start_time = 0; - if ( is_numeric( $attr['start_time'] ) ) { - $start_time = intval( $attr['start_time'] ); - } - if ( is_numeric( $attr['end_time'] ) && intval( $attr['end_time'] ) > $start_time ) { - $end_time = intval( $attr['end_time'] ); - } - if ( is_numeric( $attr['thumbnail_frame'] ) ) { - $thumbnail_frame = intval( $attr['thumbnail_frame'] ); - } - - // check to see if $id is 76560 else we assume it's gQ6Z0I990IWv_VFQI2J7Eg - // If id is numeric, we'll send it off to the hulu oembed api to get the embed URL (and non-numeric id). - if ( is_numeric( $id ) ) { - $transient_key = "hulu-$id"; - $transient_value = get_transient( $transient_key ); - - if ( false === $transient_value ) { - // let's make a cross-site http request out to the hulu oembed api. - $oembed_url = sprintf( - 'https://www.hulu.com/api/oembed.json?url=%s', - rawurlencode( 'https://www.hulu.com/watch/' . esc_attr( $id ) ) - ); - $response = wp_remote_get( $oembed_url ); - $response_code = wp_remote_retrieve_response_code( $response ); - $response_message = wp_remote_retrieve_response_message( $response ); - if ( 200 !== $response_code && ! empty( $response_message ) ) { - return "<!-- Hulu Error: Hulu shortcode http error $response_message -->"; - } elseif ( 200 !== $response_code ) { - return "<!-- Hulu Error: Hulu shortcode unknown error occurred, $response_code -->"; - } else { - $response_body = wp_remote_retrieve_body( $response ); - $json = json_decode( $response_body ); - - // Pull out id from embed url (from oembed API). - $embed_url_params = array(); - parse_str( wp_parse_url( $json->embed_url, PHP_URL_QUERY ), $embed_url_params ); - - if ( isset( $embed_url_params['eid'] ) ) { - $id = $embed_url_params['eid']; - } - // let's cache this response indefinitely. - set_transient( $transient_key, $id ); - } - } else { - $id = $transient_value; - } - } - - if ( ! $id ) { - return '<!-- Hulu Error: Not a Hulu video. -->'; - } - - $query_args = array(); - $query_args['eid'] = esc_attr( $id ); - if ( isset( $start_time ) ) { - $query_args['st'] = intval( $start_time ); - } - if ( isset( $end_time ) ) { - $query_args['et'] = intval( $end_time ); - } - if ( isset( $thumbnail_frame ) ) { - $query_args['it'] = 'i' . intval( $thumbnail_frame ); - } - - $iframe_url = add_query_arg( $query_args, 'https://www.hulu.com/embed.html' ); - $width = intval( $attr['width'] ); - $height = round( ( $width / 640 ) * 360 ); - - $html = sprintf( - '<div class="embed-hulu" style="text-align: center;"><iframe src="%s" width="%s" height="%s" style="border:0;" scrolling="no" webkitAllowFullScreen -mozallowfullscreen allowfullscreen></iframe></div>', - esc_url( $iframe_url ), - esc_attr( $width ), - esc_attr( $height ) - ); - $html = apply_filters( 'video_embed_html', $html ); - - return $html; -} - -/** - * Callback to convert Hulu links in comments into a embed src. - * - * @since 4.5.0 - * - * @param array $matches Array of matches from regex. - * - * @return string - */ -function jetpack_hulu_link_callback( $matches ) { - $video_id = $matches[4]; - - // Make up an embed src to pass to the shortcode reversal function. - $attrs = array( - 'src' => 'https://www.hulu.com/embed.html?eid=' . esc_attr( $video_id ), - ); - - return wpcom_shortcodereverse_huluhelper( $attrs ); -} - -/** - * Convert Hulu links in comments into a Hulu shortcode. - * - * @since 4.5.0 - * - * @param string $content Post content. - * - * @return string - */ -function jetpack_hulu_link( $content ) { - $content = preg_replace_callback( '!^(http(s)?://)?(www\.)?hulu\.com\/watch\/([0-9]+)$!im', 'jetpack_hulu_link_callback', $content ); - - return $content; -} - -/** - * Makes a Hulu shortcode from $attrs and $pattern - * - * @since 4.5.0 - * - * @param array $attrs Shortcode attributes. - * - * @return string - */ -function wpcom_shortcodereverse_huluhelper( $attrs ) { - $attrs = wpcom_shortcodereverse_parseattr( $attrs ); - - $src_attributes = array(); - parse_str( wp_parse_url( $attrs['src'], PHP_URL_QUERY ), $src_attributes ); - - $attrs = array_merge( $attrs, $src_attributes ); - - // If we don't have an eid, we can't do anything. Just send back the src string. - if ( ! isset( $attrs['eid'] ) ) { - return $attrs['src']; - } - - $shortcode = '[hulu id=' . esc_attr( $attrs['eid'] ); - - if ( $attrs['width'] ) { - $shortcode .= ' width=' . intval( $attrs['width'] ); - } - - if ( $attrs['height'] ) { - $shortcode .= ' height=' . intval( $attrs['height'] ); - } - - if ( $attrs['st'] ) { - $shortcode .= ' start_time=' . intval( $attrs['st'] ); - } - - if ( $attrs['et'] ) { - $shortcode .= ' end_time=' . intval( $attrs['et'] ); - } - - if ( $attrs['it'] ) { - // the thumbnail frame attribute comes with an i in front of the value, so we've got to remove that. - $shortcode .= ' thumbnail_frame=' . intval( ltrim( $attrs['it'], 'i' ) ); - } - $shortcode .= ']'; - - return $shortcode; -} - -/** - * Initiates process to convert iframe HTML into a Hulu shortcode. - * - * Example: - * <iframe width="512" height="288" src="http://www.hulu.com/embed.html?eid=nlg_ios3tutcfrhatkiaow&et=20&st=10&it=i11" frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowfullscreen></iframe> - * - * Converts to: - * [hulu id=nlg_ios3tutcfrhatkiaow width=512 height=288 start_time=10 end_time=20 thumbnail_frame=11] - * - * @since 4.5.0 - * - * @param array $attrs Shortcode attributes. - * - * @return string - */ -function wpcom_shortcodereverse_huluembed( $attrs ) { - - $shortcode = wpcom_shortcodereverse_huluhelper( $attrs ); - - if ( '[' === substr( $shortcode, 0, 1 ) ) { - /** This action is documented in modules/widgets/social-media-icons.php */ - do_action( 'jetpack_bump_stats_extras', 'html_to_shortcode', 'hulu-embed' ); - } - - return $shortcode; -} -Filter_Embedded_HTML_Objects::register( '#^https?://www.hulu.com/embed.html#i', 'wpcom_shortcodereverse_huluembed', true ); diff --git a/plugins/jetpack/modules/shortcodes/images/collapse.png b/plugins/jetpack/modules/shortcodes/images/collapse.png Binary files differdeleted file mode 100644 index 921057f1..00000000 --- a/plugins/jetpack/modules/shortcodes/images/collapse.png +++ /dev/null diff --git a/plugins/jetpack/modules/shortcodes/images/expand.png b/plugins/jetpack/modules/shortcodes/images/expand.png Binary files differdeleted file mode 100644 index b1e0c56f..00000000 --- a/plugins/jetpack/modules/shortcodes/images/expand.png +++ /dev/null diff --git a/plugins/jetpack/modules/shortcodes/images/slide-nav.png b/plugins/jetpack/modules/shortcodes/images/slide-nav.png Binary files differdeleted file mode 100644 index 7fa82c4f..00000000 --- a/plugins/jetpack/modules/shortcodes/images/slide-nav.png +++ /dev/null diff --git a/plugins/jetpack/modules/shortcodes/img/slideshow-controls-2x.png b/plugins/jetpack/modules/shortcodes/img/slideshow-controls-2x.png Binary files differdeleted file mode 100644 index 2c76ac05..00000000 --- a/plugins/jetpack/modules/shortcodes/img/slideshow-controls-2x.png +++ /dev/null diff --git a/plugins/jetpack/modules/shortcodes/img/slideshow-controls.png b/plugins/jetpack/modules/shortcodes/img/slideshow-controls.png Binary files differdeleted file mode 100644 index 09ca4871..00000000 --- a/plugins/jetpack/modules/shortcodes/img/slideshow-controls.png +++ /dev/null diff --git a/plugins/jetpack/modules/shortcodes/img/slideshow-loader.gif b/plugins/jetpack/modules/shortcodes/img/slideshow-loader.gif Binary files differdeleted file mode 100644 index ce1c594e..00000000 --- a/plugins/jetpack/modules/shortcodes/img/slideshow-loader.gif +++ /dev/null diff --git a/plugins/jetpack/modules/shortcodes/instagram.php b/plugins/jetpack/modules/shortcodes/instagram.php deleted file mode 100644 index 656703bd..00000000 --- a/plugins/jetpack/modules/shortcodes/instagram.php +++ /dev/null @@ -1,243 +0,0 @@ -<?php - - -/** - * Embed Reversal for Instagram - * - * Hooked to pre_kses, converts an embed code from Instagram.com to an oEmbeddable URL. - * - * @return string The filtered or the original content. - **/ -function jetpack_instagram_embed_reversal( $content ) { - if ( ! is_string( $content ) || false === stripos( $content, 'instagram.com' ) ) { - return $content; - } - - /* - Sample embed code: - <blockquote class="instagram-media" data-instgrm-captioned data-instgrm-version="2" style=" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:658px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);"><div style="padding:8px;"><div style=" background:#F8F8F8; line-height:0; margin-top:40px; padding-bottom:55%; padding-top:45%; text-align:center; width:100%;"><div style="position:relative;"><div style=" -webkit-animation:dkaXkpbBxI 1s ease-out infinite; animation:dkaXkpbBxI 1s ease-out infinite; background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAMAAAApWqozAAAAGFBMVEUiIiI9PT0eHh4gIB4hIBkcHBwcHBwcHBydr+JQAAAACHRSTlMABA4YHyQsM5jtaMwAAADfSURBVDjL7ZVBEgMhCAQBAf//42xcNbpAqakcM0ftUmFAAIBE81IqBJdS3lS6zs3bIpB9WED3YYXFPmHRfT8sgyrCP1x8uEUxLMzNWElFOYCV6mHWWwMzdPEKHlhLw7NWJqkHc4uIZphavDzA2JPzUDsBZziNae2S6owH8xPmX8G7zzgKEOPUoYHvGz1TBCxMkd3kwNVbU0gKHkx+iZILf77IofhrY1nYFnB/lQPb79drWOyJVa/DAvg9B/rLB4cC+Nqgdz/TvBbBnr6GBReqn/nRmDgaQEej7WhonozjF+Y2I/fZou/qAAAAAElFTkSuQmCC); display:block; height:44px; margin:0 auto -44px; position:relative; top:-44px; width:44px;"></div><span style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:12px; font-style:normal; font-weight:bold; position:relative; top:15px;">Loading</span></div></div><p style=" font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin:8px 0 0 0; padding:0 4px; word-wrap:break-word;"> Balloons</p><p style=" line-height:32px; margin-bottom:0; margin-top:8px; padding:0; text-align:center;"> <a href="https://instagram.com/p/r9vfPrmjeB/" style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; text-decoration:none;" target="_top"> View on Instagram</a></p></div><style>@-webkit-keyframes"dkaXkpbBxI"{ 0%{opacity:0.5;} 50%{opacity:1;} 100%{opacity:0.5;} } @keyframes"dkaXkpbBxI"{ 0%{opacity:0.5;} 50%{opacity:1;} 100%{opacity:0.5;} }</style></blockquote> - <script async defer src="https://platform.instagram.com/en_US/embeds.js"></script> - */ - - $regexes = array(); - - // new style js. - $regexes[] = '#<blockquote[^>]+?class="instagram-media"[^>].+?>(.+?)</blockquote><script[^>]+?src="(https?:)?//platform\.instagram\.com/(.+?)/embeds\.js"></script>#ix'; - - // Let's play nice with the visual editor too. - $regexes[] = '#<blockquote(?:[^&]|&(?!gt;))+?class="instagram-media"(?:[^&]|&(?!gt;)).+?>(.+?)</blockquote><script(?:[^&]|&(?!gt;))+?src="(https?:)?//platform\.instagram\.com/(.+?)/embeds\.js"(?:[^&]|&(?!gt;))*+></script>#ix'; - - // old style iframe. - $regexes[] = '#<iframe[^>]+?src="((?:https?:)?//(?:www\.)?instagram\.com/p/([^"\'/]++)[^"\']*?)"[^>]*+>\s*?</iframe>#i'; - - // Let's play nice with the visual editor too. - $regexes[] = '#<iframe(?:[^&]|&(?!gt;))+?src="((?:https?:)?//(?:www\.)instagram\.com/p/([^"\'/]++)[^"\']*?)"(?:[^&]|&(?!gt;))*+>\s*?</iframe>#i'; - - foreach ( $regexes as $regex ) { - if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) { - continue; - } - - foreach ( $matches as $match ) { - if ( ! preg_match( '#(https?:)?//(?:www\.)?instagr(\.am|am\.com)/p/([^/]*)#i', $match[1], $url_matches ) ) { - continue; - } - - // Since we support Instagram via oEmbed, we simply leave a link on a line by itself. - $replace_regex = sprintf( '#\s*%s\s*#', preg_quote( $match[0], '#' ) ); - $url = esc_url( $url_matches[0] ); - - $content = preg_replace( $replace_regex, sprintf( "\n\n%s\n\n", $url ), $content ); - /** This action is documented in modules/shortcodes/youtube.php */ - do_action( 'jetpack_embed_to_shortcode', 'instagram', $url ); - } - } - - return $content; -} - -add_filter( 'pre_kses', 'jetpack_instagram_embed_reversal' ); - -/** - * Instagram's custom Embed provider. - * We first remove 2 different embed providers, both registered by Core. - * - The first is the original provider,that only supports images. - * - The second is tne new provider that replaced the first one in Core when Core added support for videos. https://core.trac.wordpress.org/changeset/44486 - * - * Once the core embed provider is removed (one or the other, depending on your version of Core), we declare our own. - */ -wp_oembed_remove_provider( '#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i' ); -wp_oembed_remove_provider( '#https?://(www\.)?instagr(\.am|am\.com)/(p|tv)/.*#i' ); -wp_embed_register_handler( - 'jetpack_instagram', - '#http(s?)://(www\.)?instagr(\.am|am\.com)/(p|tv)/([^\/]*)#i', - 'jetpack_instagram_handler' -); - -/** - * Handle Instagram embeds (build embed from regex). - * - * @param array $matches Array of matches from the regex. - * @param array $atts The original unmodified attributes. - * @param string $url The original URL that was matched by the regex. - */ -function jetpack_instagram_handler( $matches, $atts, $url ) { - global $content_width; - - // keep a copy of the passed-in URL since it's modified below - $passed_url = $url; - - $max_width = 698; - $min_width = 320; - - if ( is_feed() ) { - // Instagram offers direct links to images, but not to videos. - if ( 'p' === $matches[1] ) { - $media_url = sprintf( 'http://instagr.am/p/%1$s/media/?size=l', $matches[2] ); - return sprintf( - '<a href="%1$s" title="%2$s" target="_blank"><img src="%3$s" alt="%4$s" /></a>', - esc_url( $url ), - esc_attr__( 'View on Instagram', 'jetpack' ), - esc_url( $media_url ), - esc_html__( 'Instagram Photo', 'jetpack' ) - ); - } elseif ( 'tv' === $matches[1] ) { - return sprintf( - '<a href="%1$s" title="%2$s" target="_blank">%3$s</a>', - esc_url( $url ), - esc_attr__( 'View on Instagram', 'jetpack' ), - esc_html__( 'Instagram Video', 'jetpack' ) - ); - } - } - - $atts = shortcode_atts( - array( - 'width' => isset( $content_width ) ? $content_width : $max_width, - 'hidecaption' => false, - ), - $atts - ); - - $atts['width'] = absint( $atts['width'] ); - if ( $atts['width'] > $max_width ) { - $atts['width'] = $max_width; - } elseif ( $atts['width'] < $min_width ) { - $atts['width'] = $min_width; - } - - // remove the modal param from the URL - $url = remove_query_arg( 'modal', $url ); - - // force .com instead of .am for https support - $url = str_replace( 'instagr.am', 'instagram.com', $url ); - - // The oembed endpoint expects HTTP, but HTTP requests 301 to HTTPS - $instagram_http_url = str_replace( 'https://', 'http://', $url ); - $instagram_https_url = str_replace( 'http://', 'https://', $url ); - - $url_args = array( - 'url' => $instagram_http_url, - 'maxwidth' => $atts['width'], - ); - - if ( $atts['hidecaption'] ) { - $url_args['hidecaption'] = 'true'; - } - - $url = esc_url_raw( add_query_arg( $url_args, 'https://api.instagram.com/oembed/' ) ); - - /** - * Filter Object Caching for response from Instagram. - * - * Allow enabling of object caching for the response sent by Instagram when querying for Instagram image HTML. - * - * @module shortcodes - * - * @since 3.3.0 - * - * @param bool false Object caching is off by default. - * @param array $matches Array of Instagram URLs found in the post. - * @param array $atts Instagram Shortcode attributes. - * @param string $passed_url Instagram API URL. - */ - $response_body_use_cache = apply_filters( 'instagram_cache_oembed_api_response_body', false, $matches, $atts, $passed_url ); - $response_body = false; - if ( $response_body_use_cache ) { - $cache_key = 'oembed_response_body_' . md5( $url ); - $response_body = wp_cache_get( $cache_key, 'instagram_embeds' ); - } - - if ( ! $response_body ) { - // Not using cache (default case) or cache miss - $instagram_response = wp_remote_get( $url, array( 'redirection' => 0 ) ); - if ( is_wp_error( $instagram_response ) || 200 != $instagram_response['response']['code'] || empty( $instagram_response['body'] ) ) { - return '<!-- instagram error: invalid instagram resource -->'; - } - - $response_body = json_decode( $instagram_response['body'] ); - if ( $response_body_use_cache ) { - // if caching it is short-lived since this is a "Cache-Control: no-cache" resource - wp_cache_set( $cache_key, $response_body, 'instagram_embeds', HOUR_IN_SECONDS + mt_rand( 0, HOUR_IN_SECONDS ) ); - } - } - - if ( ! empty( $response_body->html ) ) { - wp_enqueue_script( - 'jetpack-instagram-embed', - Jetpack::get_file_url_for_environment( '_inc/build/shortcodes/js/instagram.min.js', 'modules/shortcodes/js/instagram.js' ), - array( 'jquery' ), - false, - true - ); - // there's a script in the response, which we strip on purpose since it's added by this ^ script - $ig_embed = preg_replace( '@<(script)[^>]*?>.*?</\\1>@si', '', $response_body->html ); - - return $ig_embed; - } - - return '<!-- instagram error: no embed found -->'; -} - -/** - * Handle an alternate Instagram URL format, where the username is also part of the URL. - * We do not actually need that username for the embed. - */ -wp_embed_register_handler( - 'jetpack_instagram_alternate_format', - '#https?://(?:www\.)?instagr(?:\.am|am\.com)/(?:[^/]*)/(p|tv)/([^\/]*)#i', - 'jetpack_instagram_alternate_format_handler' -); - -/** - * Handle alternate Instagram embeds (build embed from regex). - * - * @param array $matches Array of matches from the regex. - * @param array $atts The original unmodified attributes. - * @param string $url The original URL that was matched by the regex. - */ -function jetpack_instagram_alternate_format_handler( $matches, $atts, $url ) { - // Replace URL saved by original Instagram URL (no username). - $matches[0] = esc_url_raw( - sprintf( - 'https://www.instagram.com/%1$s/%2$s', - $matches[1], - $matches[2] - ) - ); - - return jetpack_instagram_handler( $matches, $atts, $url ); -} - -// [instagram url="http://instagram.com/p/PSbF9sEIGP/"] -// [instagram url="http://instagram.com/p/PSbF9sEIGP/" width="300"] -add_shortcode( 'instagram', 'jetpack_shortcode_instagram' ); -function jetpack_shortcode_instagram( $atts ) { - global $wp_embed; - - if ( empty( $atts['url'] ) ) { - return ''; - } - - return $wp_embed->shortcode( $atts, $atts['url'] ); -} diff --git a/plugins/jetpack/modules/shortcodes/js/brightcove.js b/plugins/jetpack/modules/shortcodes/js/brightcove.js deleted file mode 100644 index c4f8ba50..00000000 --- a/plugins/jetpack/modules/shortcodes/js/brightcove.js +++ /dev/null @@ -1,29 +0,0 @@ -/* global brightcove, brightcoveData */ -(function($){ - var script = document.createElement('script'), - tld = 'co.jp' === brightcoveData.tld ? 'co.jp' : 'com', - timer = false; - - // Load Brightcove script - script.src = 'https://sadmin.brightcove.' + tld + '/js/BrightcoveExperiences.js'; - script.type = 'text/javascript'; - script.language = 'JavaScript'; - document.head.appendChild( script ); - - // Start detection for Brightcove script loading in its object - try_brightcove(); - - // Detect if Brightcove script has loaded and bind some events once loaded - function try_brightcove() { - clearTimeout( timer ); - - if ( 'object' === typeof brightcove ) { - $( document ).ready( brightcove.createExperiences ); - $( 'body' ).on( 'post-load', brightcove.createExperiences ); - - brightcove.createExperiences(); - } else { - timer = setTimeout( try_brightcove, 100 ); - } - } -})(jQuery);
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/js/gist.js b/plugins/jetpack/modules/shortcodes/js/gist.js deleted file mode 100644 index 2714add4..00000000 --- a/plugins/jetpack/modules/shortcodes/js/gist.js +++ /dev/null @@ -1,28 +0,0 @@ -;(function( $, undefined ) { - var gistStylesheetLoaded = false, - gistEmbed = function() { - $( '.gist-oembed' ).each( function( i, el ) { - var url = 'https://gist.github.com/' + $( el ).data( 'gist' ); - - $.ajax( { - url: url, - dataType: 'jsonp' - } ).done( function( response ) { - $( el ).replaceWith( response.div ); - - if ( ! gistStylesheetLoaded ) { - var stylesheet = '<link rel="stylesheet" href="' + - response.stylesheet + - '" type="text/css" />'; - - $( 'head' ).append( stylesheet ); - - gistStylesheetLoaded = true; - } - } ); - } ); - }; - - $( document ).ready( gistEmbed ); - $( 'body' ).on( 'post-load', gistEmbed ); -})( jQuery ); diff --git a/plugins/jetpack/modules/shortcodes/js/instagram.js b/plugins/jetpack/modules/shortcodes/js/instagram.js deleted file mode 100644 index dfcc09ea..00000000 --- a/plugins/jetpack/modules/shortcodes/js/instagram.js +++ /dev/null @@ -1,21 +0,0 @@ -/* global window */ - -(function() { - var instagramEmbed = function() { - if ( 'undefined' !== typeof window.instgrm && window.instgrm.Embeds && 'function' === typeof window.instgrm.Embeds.process ) { - window.instgrm.Embeds.process(); - } else { - var s = document.createElement( 'script' ); - s.async = true; - s.defer = true; - s.src = '//platform.instagram.com/en_US/embeds.js'; - document.getElementsByTagName( 'body' )[0].appendChild( s ); - } - }; - - if ( 'undefined' !== typeof jQuery && 'undefined' !== typeof infiniteScroll ) { - jQuery( document.body ).on( 'post-load', instagramEmbed ); - } - - instagramEmbed(); -})();
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/js/jmpress.js b/plugins/jetpack/modules/shortcodes/js/jmpress.js deleted file mode 100644 index 385bb2a7..00000000 --- a/plugins/jetpack/modules/shortcodes/js/jmpress.js +++ /dev/null @@ -1,2710 +0,0 @@ -/** - * jmpress.js v0.4.5 - * http://jmpressjs.github.com/jmpress.js - * - * A jQuery plugin to build a website on the infinite canvas. - * - * Copyright 2013 Kyle Robinson Young @shama & Tobias Koppers @sokra - * Licensed MIT - * http://www.opensource.org/licenses/mit-license.php - * - * Based on the foundation laid by Bartek Szopka @bartaz - *//* - * core.js - * The core of jmpress.js - */ -(function( $, document, window, undefined ) { - - 'use strict'; - - /** - * Set supported prefixes - * - * @access protected - * @return Function to get prefixed property - */ - var pfx = (function () { - var style = document.createElement('dummy').style, - prefixes = 'Webkit Moz O ms Khtml'.split(' '), - memory = {}; - return function ( prop ) { - if ( typeof memory[ prop ] === "undefined" ) { - var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1), - props = (prop + ' ' + prefixes.join(ucProp + ' ') + ucProp).split(' '); - memory[ prop ] = null; - for ( var i in props ) { - if ( style[ props[i] ] !== undefined ) { - memory[ prop ] = props[i]; - break; - } - } - } - return memory[ prop ]; - }; - }()); - - /** - * map ex. "WebkitTransform" to "-webkit-transform" - */ - function mapProperty( name ) { - if(!name) { - return; - } - var index = 1 + name.substr(1).search(/[A-Z]/); - var prefix = name.substr(0, index).toLowerCase(); - var postfix = name.substr(index).toLowerCase(); - return "-" + prefix + "-" + postfix; - } - function addComma( attribute ) { - if(!attribute) { - return ""; - } - return attribute + ","; - } - /** - * Return an jquery object only if it's not empty - */ - function ifNotEmpty(el) { - if(el.length > 0) { - return el; - } - return null; - } - - /** - * Default Settings - */ - var defaults = { - /* CLASSES */ - stepSelector: '.step' - ,containerClass: '' - ,canvasClass: '' - ,areaClass: '' - ,notSupportedClass: 'not-supported' - - /* CONFIG */ - ,fullscreen: true - - /* ANIMATION */ - ,animation: { - transformOrigin: 'top left' - ,transitionProperty: addComma(mapProperty(pfx('transform'))) + addComma(mapProperty(pfx('perspective'))) + 'opacity' - ,transitionDuration: '1s' - ,transitionDelay: '500ms' - ,transitionTimingFunction: 'ease-in-out' - ,transformStyle: "preserve-3d" - } - ,transitionDuration: 1500 - }; - var callbacks = { - 'beforeChange': 1 - ,'beforeInitStep': 1 - ,'initStep': 1 - ,'beforeInit': 1 - ,'afterInit': 1 - ,'beforeDeinit': 1 - ,'afterDeinit': 1 - ,'applyStep': 1 - ,'unapplyStep': 1 - ,'setInactive': 1 - ,'beforeActive': 1 - ,'setActive': 1 - ,'selectInitialStep': 1 - ,'selectPrev': 1 - ,'selectNext': 1 - ,'selectHome': 1 - ,'selectEnd': 1 - ,'idle': 1 - ,'applyTarget': 1 - }; - for(var callbackName in callbacks) { - defaults[callbackName] = []; - } - - - /** - * Initialize jmpress - */ - function init( args ) { - args = $.extend(true, {}, args || {}); - - // accept functions and arrays of functions as callbacks - var callbackArgs = {}; - var callbackName = null; - for (callbackName in callbacks) { - callbackArgs[callbackName] = $.isFunction( args[callbackName] ) ? - [ args[callbackName] ] : - args[callbackName]; - args[callbackName] = []; - } - - // MERGE SETTINGS - var settings = $.extend(true, {}, defaults, args); - - for (callbackName in callbacks) { - if (callbackArgs[callbackName]) { - Array.prototype.push.apply(settings[callbackName], callbackArgs[callbackName]); - } - } - - /*** MEMBER VARS ***/ - - var jmpress = $( this ) - ,container = null - ,area = null - ,oldStyle = { - container: "" - ,area: "" - } - ,canvas = null - ,current = null - ,active = false - ,activeSubstep = null - ,activeDelegated = false; - - - /*** MEMBER FUNCTIONS ***/ - // functions have to be called with this - - /** - * Init a single step - * - * @param element the element of the step - * @param idx number of step - */ - function doStepInit( element, idx ) { - var data = dataset( element ); - var step = { - oldStyle: $(element).attr("style") || "" - }; - - var callbackData = { - data: data - ,stepData: step - }; - callCallback.call(this, 'beforeInitStep', $(element), callbackData); - step.delegate = data.delegate; - callCallback.call(this, 'initStep', $(element), callbackData); - - $(element).data('stepData', step); - - if ( !$(element).attr('id') ) { - $(element).attr('id', 'step-' + (idx + 1)); - } - - callCallback.call(this, 'applyStep', $(element), callbackData); - } - /** - * Deinit a single step - * - * @param element the element of the step - */ - function doStepDeinit( element ) { - var stepData = $(element).data('stepData'); - - $(element).attr("style", stepData.oldStyle); - - callCallback.call(this, 'unapplyStep', $(element), { - stepData: stepData - }); - } - /** - * Reapplies stepData to the element - * - * @param element - */ - function doStepReapply( element ) { - callCallback.call(this, 'unapplyStep', $(element), { - stepData: element.data("stepData") - }); - - callCallback.call(this, 'applyStep', $(element), { - stepData: element.data("stepData") - }); - } - /** - * Completly deinit jmpress - * - */ - function deinit() { - if ( active ) { - callCallback.call(this, 'setInactive', active, { - stepData: $(active).data('stepData') - ,reason: "deinit" - } ); - } - if (current.jmpressClass) { - $(jmpress).removeClass(current.jmpressClass); - } - - callCallback.call(this, 'beforeDeinit', $(this), {}); - - $(settings.stepSelector, jmpress).each(function( idx ) { - doStepDeinit.call(jmpress, this ); - }); - - container.attr("style", oldStyle.container); - if(settings.fullscreen) { - $("html").attr("style", ""); - } - area.attr("style", oldStyle.area); - $(canvas).children().each(function() { - jmpress.append( $( this ) ); - }); - if( settings.fullscreen ) { - canvas.remove(); - } else { - canvas.remove(); - area.remove(); - } - - callCallback.call(this, 'afterDeinit', $(this), {}); - - $(jmpress).data("jmpressmethods", false); - } - /** - * Call a callback - * - * @param callbackName String callback which should be called - * @param element some arguments to the callback - * @param eventData - */ - function callCallback( callbackName, element, eventData ) { - eventData.settings = settings; - eventData.current = current; - eventData.container = container; - eventData.parents = element ? getStepParents(element) : null; - eventData.current = current; - eventData.jmpress = this; - var result = {}; - $.each( settings[callbackName], function(idx, callback) { - result.value = callback.call( jmpress, element, eventData ) || result.value; - }); - return result.value; - } - /** - * - */ - function getStepParents( el ) { - return $(el).parentsUntil(jmpress).not(jmpress).filter(settings.stepSelector); - } - /** - * Reselect the active step - * - * @param String type reason of reselecting step - */ - function reselect( type ) { - return select( { step: active, substep: activeSubstep }, type); - } - /** - * Select a given step - * - * @param el element to select - * @param type reason of changing step - * @return Object element selected - */ - function select( el, type ) { - var substep; - if ( $.isPlainObject( el ) ) { - substep = el.substep; - el = el.step; - } - if ( typeof el === 'string') { - el = jmpress.find( el ).first(); - } - if ( !el || !$(el).data('stepData') ) { - return false; - } - - scrollFix.call(this); - - var step = $(el).data('stepData'); - - var cancelSelect = false; - callCallback.call(this, "beforeChange", el, { - stepData: step - ,reason: type - ,cancel: function() { - cancelSelect = true; - } - }); - if (cancelSelect) { - return undefined; - } - - var target = {}; - - var delegated = el; - if($(el).data("stepData").delegate) { - delegated = ifNotEmpty($(el).parentsUntil(jmpress).filter(settings.stepSelector).filter(step.delegate)) || - ifNotEmpty($(el).near(step.delegate)) || - ifNotEmpty($(el).near(step.delegate, true)) || - ifNotEmpty($(step.delegate, jmpress)); - if(delegated) { - step = delegated.data("stepData"); - } else { - // Do not delegate if expression not found - delegated = el; - } - } - if ( activeDelegated ) { - callCallback.call(this, 'setInactive', activeDelegated, { - stepData: $(activeDelegated).data('stepData') - ,delegatedFrom: active - ,reason: type - ,target: target - ,nextStep: delegated - ,nextSubstep: substep - ,nextStepData: step - } ); - } - var callbackData = { - stepData: step - ,delegatedFrom: el - ,reason: type - ,target: target - ,substep: substep - ,prevStep: activeDelegated - ,prevSubstep: activeSubstep - ,prevStepData: activeDelegated && $(activeDelegated).data('stepData') - }; - callCallback.call(this, 'beforeActive', delegated, callbackData); - callCallback.call(this, 'setActive', delegated, callbackData); - - // Set on step class on root element - if (current.jmpressClass) { - $(jmpress).removeClass(current.jmpressClass); - } - $(jmpress).addClass(current.jmpressClass = 'step-' + $(delegated).attr('id') ); - if (current.jmpressDelegatedClass) { - $(jmpress).removeClass(current.jmpressDelegatedClass); - } - $(jmpress).addClass(current.jmpressDelegatedClass = 'delegating-step-' + $(el).attr('id') ); - - callCallback.call(this, "applyTarget", delegated, $.extend({ - canvas: canvas - ,area: area - ,beforeActive: activeDelegated - }, callbackData)); - - active = el; - activeSubstep = callbackData.substep; - activeDelegated = delegated; - - if(current.idleTimeout) { - clearTimeout(current.idleTimeout); - } - current.idleTimeout = setTimeout(function() { - callCallback.call(this, 'idle', delegated, callbackData); - }, Math.max(1, settings.transitionDuration - 100)); - - return delegated; - } - /** - * This should fix ANY kind of buggy scrolling - */ - function scrollFix() { - (function fix() { - if ($(container)[0].tagName === "BODY") { - try { - window.scrollTo(0, 0); - } catch(e) {} - } - $(container).scrollTop(0); - $(container).scrollLeft(0); - function check() { - if ($(container).scrollTop() !== 0 || - $(container).scrollLeft() !== 0) { - fix(); - } - } - setTimeout(check, 1); - setTimeout(check, 10); - setTimeout(check, 100); - setTimeout(check, 200); - setTimeout(check, 400); - }()); - } - /** - * Alias for select - */ - function goTo( el ) { - return select.call(this, el, "jump" ); - } - /** - * Goto Next Slide - * - * @return Object newly active slide - */ - function next() { - return select.call(this, callCallback.call(this, 'selectNext', active, { - stepData: $(active).data('stepData') - ,substep: activeSubstep - }), "next" ); - } - /** - * Goto Previous Slide - * - * @return Object newly active slide - */ - function prev() { - return select.call(this, callCallback.call(this, 'selectPrev', active, { - stepData: $(active).data('stepData') - ,substep: activeSubstep - }), "prev" ); - } - /** - * Goto First Slide - * - * @return Object newly active slide - */ - function home() { - return select.call(this, callCallback.call(this, 'selectHome', active, { - stepData: $(active).data('stepData') - }), "home" ); - } - /** - * Goto Last Slide - * - * @return Object newly active slide - */ - function end() { - return select.call(this, callCallback.call(this, 'selectEnd', active, { - stepData: $(active).data('stepData') - }), "end" ); - } - /** - * Manipulate the canvas - * - * @param props - * @return Object - */ - function canvasMod( props ) { - css(canvas, props || {}); - return $(canvas); - } - /** - * Return current step - * - * @return Object - */ - function getActive() { - return activeDelegated && $(activeDelegated); - } - /** - * fire a callback - * - * @param callbackName - * @param element - * @param eventData - * @return void - */ - function fire( callbackName, element, eventData ) { - if( !callbacks[callbackName] ) { - $.error( "callback " + callbackName + " is not registered." ); - } else { - return callCallback.call(this, callbackName, element, eventData); - } - } - - /** - * PUBLIC METHODS LIST - */ - jmpress.data("jmpressmethods", { - select: select - ,reselect: reselect - ,scrollFix: scrollFix - ,goTo: goTo - ,next: next - ,prev: prev - ,home: home - ,end: end - ,canvas: canvasMod - ,container: function() { return container; } - ,settings: function() { return settings; } - ,active: getActive - ,current: function() { return current; } - ,fire: fire - ,init: function(step) { - doStepInit.call(this, $(step), current.nextIdNumber++); - } - ,deinit: function(step) { - if(step) { - doStepDeinit.call(this, $(step)); - } else { - deinit.call(this); - } - } - ,reapply: doStepReapply - }); - - /** - * Check for support - * This will be removed in near future, when support is coming - * - * @access protected - * @return void - */ - function checkSupport() { - var ua = navigator.userAgent.toLowerCase(); - return (ua.search(/(iphone)|(ipod)|(android)/) === -1) || (ua.search(/(chrome)/) !== -1); - } - - // BEGIN INIT - - // CHECK FOR SUPPORT - if (checkSupport() === false) { - if (settings.notSupportedClass) { - jmpress.addClass(settings.notSupportedClass); - } - return; - } else { - if (settings.notSupportedClass) { - jmpress.removeClass(settings.notSupportedClass); - } - } - - // grabbing all steps - var steps = $(settings.stepSelector, jmpress); - - // GERNERAL INIT OF FRAME - container = jmpress; - area = $('<div />'); - canvas = $('<div />'); - $(jmpress).children().filter(steps).each(function() { - canvas.append( $( this ) ); - }); - if(settings.fullscreen) { - container = $('body'); - $("html").css({ - overflow: 'hidden' - }); - area = jmpress; - } - oldStyle.area = area.attr("style") || ""; - oldStyle.container = container.attr("style") || ""; - if(settings.fullscreen) { - container.css({ - height: '100%' - }); - jmpress.append( canvas ); - } else { - container.css({ - position: "relative" - }); - area.append( canvas ); - jmpress.append( area ); - } - - $(container).addClass(settings.containerClass); - $(area).addClass(settings.areaClass); - $(canvas).addClass(settings.canvasClass); - - document.documentElement.style.height = "100%"; - container.css({ - overflow: 'hidden' - }); - - var props = { - position: "absolute" - ,transitionDuration: '0s' - }; - props = $.extend({}, settings.animation, props); - css(area, props); - css(area, { - top: '50%' - ,left: '50%' - ,perspective: '1000px' - }); - css(canvas, props); - - current = {}; - - callCallback.call(this, 'beforeInit', null, {}); - - // INITIALIZE EACH STEP - steps.each(function( idx ) { - doStepInit.call(jmpress, this, idx ); - }); - current.nextIdNumber = steps.length; - - callCallback.call(this, 'afterInit', null, {}); - - // START - select.call(this, callCallback.call(this, 'selectInitialStep', "init", {}) ); - - if (settings.initClass) { - $(steps).removeClass(settings.initClass); - } - } - /** - * Return default settings - * - * @return Object - */ - function getDefaults() { - return defaults; - } - /** - * Register a callback or a jmpress function - * - * @access public - * @param name String the name of the callback or function - * @param func Function? the function to be added - */ - function register(name, func) { - if( $.isFunction(func) ) { - if( methods[name] ) { - $.error( "function " + name + " is already registered." ); - } else { - methods[name] = func; - } - } else { - if( callbacks[name] ) { - $.error( "callback " + name + " is already registered." ); - } else { - callbacks[name] = 1; - defaults[name] = []; - } - } - } - /** - * Set CSS on element w/ prefixes - * - * @return Object element which properties were set - * - * TODO: Consider bypassing pfx and blindly set as jQuery - * already checks for support - */ - function css( el, props ) { - var key, pkey, cssObj = {}; - for ( key in props ) { - if ( props.hasOwnProperty(key) ) { - pkey = pfx(key); - if ( pkey !== null ) { - cssObj[pkey] = props[key]; - } - } - } - $(el).css(cssObj); - return el; - } - /** - * Return dataset for element - * - * @param el element - * @return Object - */ - function dataset( el ) { - if ( $(el)[0].dataset ) { - return $.extend({}, $(el)[0].dataset); - } - function toCamelcase( str ) { - str = str.split( '-' ); - for( var i = 1; i < str.length; i++ ) { - str[i] = str[i].substr(0, 1).toUpperCase() + str[i].substr(1); - } - return str.join( '' ); - } - var returnDataset = {}; - var attrs = $(el)[0].attributes; - $.each(attrs, function ( idx, attr ) { - if ( attr.nodeName.substr(0, 5) === "data-" ) { - returnDataset[ toCamelcase(attr.nodeName.substr(5)) ] = attr.nodeValue; - } - }); - return returnDataset; - } - /** - * Returns true, if jmpress is initialized - * - * @return bool - */ - function initialized() { - return !!$(this).data("jmpressmethods"); - } - - - /** - * PUBLIC STATIC METHODS LIST - */ - var methods = { - init: init - ,initialized: initialized - ,deinit: function() {} - ,css: css - ,pfx: pfx - ,defaults: getDefaults - ,register: register - ,dataset: dataset - }; - - /** - * $.jmpress() - */ - $.fn.jmpress = function( method ) { - function f() { - var jmpressmethods = $(this).data("jmpressmethods"); - if ( jmpressmethods && jmpressmethods[method] ) { - return jmpressmethods[method].apply( this, Array.prototype.slice.call( arguments, 1 )); - } else if ( methods[method] ) { - return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 )); - } else if ( callbacks[method] && jmpressmethods ) { - var settings = jmpressmethods.settings(); - var func = Array.prototype.slice.call( arguments, 1 )[0]; - if ($.isFunction( func )) { - settings[method] = settings[method] || []; - settings[method].push(func); - } - } else if ( typeof method === 'object' || ! method ) { - return init.apply( this, arguments ); - } else { - $.error( 'Method ' + method + ' does not exist on jQuery.jmpress' ); - } - // to allow chaining - return this; - } - var args = arguments; - var result; - $(this).each(function(idx, element) { - result = f.apply(element, args); - }); - return result; - }; - $.extend({ - jmpress: function( method ) { - if ( methods[method] ) { - return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 )); - } else if ( callbacks[method] ) { - // plugin interface - var func = Array.prototype.slice.call( arguments, 1 )[0]; - if ($.isFunction( func )) { - defaults[method].push(func); - } else { - $.error( 'Second parameter should be a function: $.jmpress( callbackName, callbackFunction )' ); - } - } else { - $.error( 'Method ' + method + ' does not exist on jQuery.jmpress' ); - } - } - }); - -}(jQuery, document, window)); - -/* - * near.js - * Find steps near each other - */ -(function( $, document, window, undefined ) { - - 'use strict'; - - // add near( selector, backwards = false) to jquery - - - function checkAndGo( elements, func, selector, backwards ) { - var next; - elements.each(function(idx, element) { - if(backwards) { - next = func(element, selector, backwards); - if (next) { - return false; - } - } - if( $(element).is(selector) ) { - next = element; - return false; - } - if(!backwards) { - next = func(element, selector, backwards); - if (next) { - return false; - } - } - }); - return next; - } - function findNextInChildren(item, selector, backwards) { - var children = $(item).children(); - if(backwards) { - children = $(children.get().reverse()); - } - return checkAndGo( children, findNextInChildren, selector, backwards ); - } - function findNextInSiblings(item, selector, backwards) { - return checkAndGo( - $(item)[backwards ? "prevAll" : "nextAll"](), - findNextInChildren, selector, backwards ); - } - function findNextInParents(item, selector, backwards) { - var next; - var parents = $(item).parents(); - parents = $(parents.get()); - $.each(parents.get(), function(idx, element) { - if( backwards && $(element).is(selector) ) { - next = element; - return false; - } - next = findNextInSiblings(element, selector, backwards); - if(next) { - return false; - } - }); - return next; - } - - $.fn.near = function( selector, backwards ) { - var array = []; - $(this).each(function(idx, element) { - var near = (backwards ? - false : - findNextInChildren( element, selector, backwards )) || - findNextInSiblings( element, selector, backwards ) || - findNextInParents( element, selector, backwards ); - if( near ) { - array.push(near); - } - }); - return $(array); - }; -}(jQuery, document, window)); -/* - * transform.js - * The engine that powers the transforms or falls back to other methods - */ -(function( $, document, window, undefined ) { - - 'use strict'; - - /* FUNCTIONS */ - function toCssNumber(number) { - return (Math.round(10000*number)/10000)+""; - } - - /** - * 3D and 2D engines - */ - var engines = { - 3: { - transform: function( el, data ) { - var transform = 'translate(-50%,-50%)'; - $.each(data, function(idx, item) { - var coord = ["X", "Y", "Z"]; - var i; - if(item[0] === "translate") { // ["translate", x, y, z] - transform += " translate3d(" + toCssNumber(item[1] || 0) + "px," + toCssNumber(item[2] || 0) + "px," + toCssNumber(item[3] || 0) + "px)"; - } else if(item[0] === "rotate") { - var order = item[4] ? [1, 2, 3] : [3, 2, 1]; - for(i = 0; i < 3; i++) { - transform += " rotate" + coord[order[i]-1] + "(" + toCssNumber(item[order[i]] || 0) + "deg)"; - } - } else if(item[0] === "scale") { - for(i = 0; i < 3; i++) { - transform += " scale" + coord[i] + "(" + toCssNumber(item[i+1] || 1) + ")"; - } - } - }); - $.jmpress("css", el, $.extend({}, { transform: transform })); - } - } - ,2: { - transform: function( el, data ) { - var transform = 'translate(-50%,-50%)'; - $.each(data, function(idx, item) { - var coord = ["X", "Y"]; - if(item[0] === "translate") { // ["translate", x, y, z] - transform += " translate(" + toCssNumber(item[1] || 0) + "px," + toCssNumber(item[2] || 0) + "px)"; - } else if(item[0] === "rotate") { - transform += " rotate(" + toCssNumber(item[3] || 0) + "deg)"; - } else if(item[0] === "scale") { - for(var i = 0; i < 2; i++) { - transform += " scale" + coord[i] + "(" + toCssNumber(item[i+1] || 1) + ")"; - } - } - }); - $.jmpress("css", el, $.extend({}, { transform: transform })); - } - } - ,1: { - // CHECK IF SUPPORT IS REALLY NEEDED? - // this not even work without scaling... - // it may better to display the normal view - transform: function( el, data ) { - var anitarget = { top: 0, left: 0 }; - $.each(data, function(idx, item) { - var coord = ["X", "Y"]; - if(item[0] === "translate") { // ["translate", x, y, z] - anitarget.left = Math.round(item[1] || 0) + "px"; - anitarget.top = Math.round(item[2] || 0) + "px"; - } - }); - el.animate(anitarget, 1000); // TODO: Use animation duration - } - } - }; - - /** - * Engine to power cross-browser translate, scale and rotate. - */ - var engine = (function() { - if ($.jmpress("pfx", "perspective")) { - return engines[3]; - } else if ($.jmpress("pfx", "transform")) { - return engines[2]; - } else { - // CHECK IF SUPPORT IS REALLY NEEDED? - return engines[1]; - } - }()); - - $.jmpress("defaults").reasonableAnimation = {}; - $.jmpress("initStep", function( step, eventData ) { - var data = eventData.data; - var stepData = eventData.stepData; - var pf = parseFloat; - $.extend(stepData, { - x: pf(data.x) || 0 - ,y: pf(data.y) || 0 - ,z: pf(data.z) || 0 - ,r: pf(data.r) || 0 - ,phi: pf(data.phi) || 0 - ,rotate: pf(data.rotate) || 0 - ,rotateX: pf(data.rotateX) || 0 - ,rotateY: pf(data.rotateY) || 0 - ,rotateZ: pf(data.rotateZ) || 0 - ,revertRotate: false - ,scale: pf(data.scale) || 1 - ,scaleX: pf(data.scaleX) || false - ,scaleY: pf(data.scaleY) || false - ,scaleZ: pf(data.scaleZ) || 1 - }); - }); - $.jmpress("afterInit", function( nil, eventData ) { - var stepSelector = eventData.settings.stepSelector, - current = eventData.current; - current.perspectiveScale = 1; - current.maxNestedDepth = 0; - var nestedSteps = $(eventData.jmpress).find(stepSelector).children(stepSelector); - while(nestedSteps.length) { - current.maxNestedDepth++; - nestedSteps = nestedSteps.children(stepSelector); - } - }); - $.jmpress("applyStep", function( step, eventData ) { - $.jmpress("css", $(step), { - position: "absolute" - ,transformStyle: "preserve-3d" - }); - if ( eventData.parents.length > 0 ) { - $.jmpress("css", $(step), { - top: "50%" - ,left: "50%" - }); - } - var sd = eventData.stepData; - var transform = [ - ["translate", - sd.x || (sd.r * Math.sin(sd.phi*Math.PI/180)), - sd.y || (-sd.r * Math.cos(sd.phi*Math.PI/180)), - sd.z], - ["rotate", - sd.rotateX, - sd.rotateY, - sd.rotateZ || sd.rotate, - true], - ["scale", - sd.scaleX || sd.scale, - sd.scaleY || sd.scale, - sd.scaleZ || sd.scale] - ]; - engine.transform( step, transform ); - }); - $.jmpress("setActive", function( element, eventData ) { - var target = eventData.target; - var step = eventData.stepData; - var tf = target.transform = []; - target.perspectiveScale = 1; - - for(var i = eventData.current.maxNestedDepth; i > (eventData.parents.length || 0); i--) { - tf.push(["scale"], ["rotate"], ["translate"]); - } - - tf.push(["scale", - 1 / (step.scaleX || step.scale), - 1 / (step.scaleY || step.scale), - 1 / (step.scaleZ)]); - tf.push(["rotate", - -step.rotateX, - -step.rotateY, - -(step.rotateZ || step.rotate)]); - tf.push(["translate", - -(step.x || (step.r * Math.sin(step.phi*Math.PI/180))), - -(step.y || (-step.r * Math.cos(step.phi*Math.PI/180))), - -step.z]); - target.perspectiveScale *= (step.scaleX || step.scale); - - $.each(eventData.parents, function(idx, element) { - var step = $(element).data("stepData"); - tf.push(["scale", - 1 / (step.scaleX || step.scale), - 1 / (step.scaleY || step.scale), - 1 / (step.scaleZ)]); - tf.push(["rotate", - -step.rotateX, - -step.rotateY, - -(step.rotateZ || step.rotate)]); - tf.push(["translate", - -(step.x || (step.r * Math.sin(step.phi*Math.PI/180))), - -(step.y || (-step.r * Math.cos(step.phi*Math.PI/180))), - -step.z]); - target.perspectiveScale *= (step.scaleX || step.scale); - }); - - $.each(tf, function(idx, item) { - if(item[0] !== "rotate") { - return; - } - function lowRotate(name) { - if(eventData.current["rotate"+name+"-"+idx] === undefined) { - eventData.current["rotate"+name+"-"+idx] = item[name] || 0; - } - var cur = eventData.current["rotate"+name+"-"+idx], tar = item[name] || 0, - curmod = cur % 360, tarmod = tar % 360; - if(curmod < 0) { - curmod += 360; - } - if(tarmod < 0) { - tarmod += 360; - } - var diff = tarmod - curmod; - if(diff < -180) { - diff += 360; - } else if(diff > 180) { - diff -= 360; - } - eventData.current["rotate"+name+"-"+idx] = item[name] = cur + diff; - } - lowRotate(1); - lowRotate(2); - lowRotate(3); - }); - }); - $.jmpress("applyTarget", function( active, eventData ) { - - var target = eventData.target, - props, step = eventData.stepData, - settings = eventData.settings, - zoomin = target.perspectiveScale * 1.3 < eventData.current.perspectiveScale, - zoomout = target.perspectiveScale > eventData.current.perspectiveScale * 1.3; - - // extract first scale from transform - var lastScale = -1; - $.each(target.transform, function(idx, item) { - if(item.length <= 1) { - return; - } - if(item[0] === "rotate" && - item[1] % 360 === 0 && - item[2] % 360 === 0 && - item[3] % 360 === 0) { - return; - } - if(item[0] === "scale") { - lastScale = idx; - } else { - return false; - } - }); - - if(lastScale !== eventData.current.oldLastScale) { - zoomin = zoomout = false; - eventData.current.oldLastScale = lastScale; - } - - var extracted = []; - if(lastScale !== -1) { - while(lastScale >= 0) { - if(target.transform[lastScale][0] === "scale") { - extracted.push(target.transform[lastScale]); - target.transform[lastScale] = ["scale"]; - } - lastScale--; - } - } - - var animation = settings.animation; - if(settings.reasonableAnimation[eventData.reason]) { - animation = $.extend({}, - animation, - settings.reasonableAnimation[eventData.reason]); - } - - props = { - // to keep the perspective look similar for different scales - // we need to 'scale' the perspective, too - perspective: Math.round(target.perspectiveScale * 1000) + "px" - }; - props = $.extend({}, animation, props); - if (!zoomin) { - props.transitionDelay = '0s'; - } - if (!eventData.beforeActive) { - props.transitionDuration = '0s'; - props.transitionDelay = '0s'; - } - $.jmpress("css", eventData.area, props); - engine.transform(eventData.area, extracted); - - props = $.extend({}, animation); - if (!zoomout) { - props.transitionDelay = '0s'; - } - if (!eventData.beforeActive) { - props.transitionDuration = '0s'; - props.transitionDelay = '0s'; - } - - eventData.current.perspectiveScale = target.perspectiveScale; - - $.jmpress("css", eventData.canvas, props); - engine.transform(eventData.canvas, target.transform); - }); - -}(jQuery, document, window)); -/* - * active.js - * Set the active classes on steps - */ -(function( $, document, window, undefined ) { - - 'use strict'; - var $jmpress = $.jmpress; - - /* DEFINES */ - var activeClass = 'activeClass', - nestedActiveClass = 'nestedActiveClass'; - - /* DEFAULTS */ - var defaults = $jmpress( 'defaults' ); - defaults[nestedActiveClass] = "nested-active"; - defaults[activeClass] = "active"; - - /* HOOKS */ - $jmpress( 'setInactive', function( step, eventData ) { - var settings = eventData.settings, - activeClassSetting = settings[activeClass], - nestedActiveClassSettings = settings[nestedActiveClass]; - if(activeClassSetting) { - $(step).removeClass( activeClassSetting ); - } - if(nestedActiveClassSettings) { - $.each(eventData.parents, function(idx, element) { - $(element).removeClass(nestedActiveClassSettings); - }); - } - }); - $jmpress( 'setActive', function( step, eventData ) { - var settings = eventData.settings, - activeClassSetting = settings[activeClass], - nestedActiveClassSettings = settings[nestedActiveClass]; - if(activeClassSetting) { - $(step).addClass( activeClassSetting ); - } - if(nestedActiveClassSettings) { - $.each(eventData.parents, function(idx, element) { - $(element).addClass(nestedActiveClassSettings); - }); - } - }); - -}(jQuery, document, window)); -/* - * circular.js - * Repeat from start after end - */ -(function( $, document, window, undefined ) { - - 'use strict'; - var $jmpress = $.jmpress; - - /* FUNCTIONS */ - function firstSlide( step, eventData ) { - return $(this).find(eventData.settings.stepSelector).first(); - } - function prevOrNext( jmpress, step, eventData, prev) { - if (!step) { - return false; - } - var stepSelector = eventData.settings.stepSelector; - step = $(step); - do { - var item = step.near( stepSelector, prev ); - if (item.length === 0 || item.closest(jmpress).length === 0) { - item = $(jmpress).find(stepSelector)[prev?"last":"first"](); - } - if (!item.length) { - return false; - } - step = item; - } while( step.data("stepData").exclude ); - return step; - } - - /* HOOKS */ - $jmpress( 'initStep', function( step, eventData ) { - eventData.stepData.exclude = eventData.data.exclude && ["false", "no"].indexOf(eventData.data.exclude) === -1; - }); - $jmpress( 'selectInitialStep', firstSlide); - $jmpress( 'selectHome', firstSlide); - $jmpress( 'selectEnd', function( step, eventData ) { - return $(this).find(eventData.settings.stepSelector).last(); - }); - $jmpress( 'selectPrev', function( step, eventData ) { - return prevOrNext(this, step, eventData, true); - }); - $jmpress( 'selectNext', function( step, eventData ) { - return prevOrNext(this, step, eventData); - }); -}(jQuery, document, window)); -/* - * start.js - * Set the first step to start on - */ -(function( $, document, window, undefined ) { - - 'use strict'; - - /* HOOKS */ - $.jmpress( 'selectInitialStep', function( nil, eventData ) { - return eventData.settings.start; - }); - -}(jQuery, document, window)); -/* - * ways.js - * Control the flow of the steps - */ -(function( $, document, window, undefined ) { - - 'use strict'; - var $jmpress = $.jmpress; - - /* FUNCTIONS */ - function routeFunc( jmpress, route, type ) { - for(var i = 0; i < route.length - 1; i++) { - var from = route[i]; - var to = route[i+1]; - if($(jmpress).jmpress("initialized")) { - $(from, jmpress).data("stepData")[type] = to; - } else { - $(from, jmpress).attr('data-' + type, to); - } - } - } - function selectPrevOrNext( step, eventData, attr, prev ) { - var stepData = eventData.stepData; - if(stepData[attr]) { - var near = $(step).near(stepData[attr], prev); - if(near && near.length) { - return near; - } - near = $(stepData[attr], this)[prev?"last":"first"](); - if(near && near.length) { - return near; - } - } - } - - /* EXPORTED FUNCTIONS */ - $jmpress( 'register', 'route', function( route, unidirectional, reversedRoute ) { - if( typeof route === "string" ) { - route = [route, route]; - } - routeFunc(this, route, reversedRoute ? "prev" : "next"); - if (!unidirectional) { - routeFunc(this, route.reverse(), reversedRoute ? "next" : "prev"); - } - }); - - /* HOOKS */ - $jmpress( 'initStep', function( step, eventData ) { - for(var attr in {next:1,prev:1}) { - eventData.stepData[attr] = eventData.data[attr]; - } - }); - $jmpress( 'selectNext', function( step, eventData ) { - return selectPrevOrNext.call(this, step, eventData, "next"); - }); - $jmpress( 'selectPrev', function( step, eventData ) { - return selectPrevOrNext.call(this, step, eventData, "prev", true); - }); - -}(jQuery, document, window)); -/* - * ajax.js - * Load steps via ajax - */ -(function( $, document, window, undefined ) { - - 'use strict'; - var $jmpress = $.jmpress; - - /* DEFINES */ - var afterStepLoaded = 'ajax:afterStepLoaded', - loadStep = 'ajax:loadStep'; - - /* REGISTER EVENTS */ - $jmpress('register', loadStep); - $jmpress('register', afterStepLoaded); - - /* DEFAULTS */ - $jmpress('defaults').ajaxLoadedClass = "loaded"; - - /* HOOKS */ - $jmpress('initStep', function( step, eventData ) { - eventData.stepData.src = $(step).attr('href') || eventData.data.src || false; - eventData.stepData.srcLoaded = false; - }); - $jmpress(loadStep, function( step, eventData ) { - var stepData = eventData.stepData, - href = stepData && stepData.src, - settings = eventData.settings; - if ( href ) { - $(step).addClass( settings.ajaxLoadedClass ); - stepData.srcLoaded = true; - $(step).load(href, function(response, status, xhr) { - $(eventData.jmpress).jmpress('fire', afterStepLoaded, step, $.extend({}, eventData, { - response: response - ,status: status - ,xhr: xhr - })); - }); - } - }); - $jmpress('idle', function( step, eventData ) { - if (!step) { - return; - } - var settings = eventData.settings, - jmpress = $(this), - stepData = eventData.stepData; - var siblings = $(step) - .add( $(step).near( settings.stepSelector ) ) - .add( $(step).near( settings.stepSelector, true) ) - .add( jmpress.jmpress('fire', 'selectPrev', step, { - stepData: $(step).data('stepData') - })) - .add( jmpress.jmpress('fire', 'selectNext', step, { - stepData: $(step).data('stepData') - })); - siblings.each(function() { - var step = this, - stepData = $(step).data("stepData"); - if(!stepData.src || stepData.srcLoaded) { - return; - } - jmpress.jmpress('fire', loadStep, step, { - stepData: $(step).data('stepData') - }); - }); - }); - $jmpress("setActive", function(step, eventData) { - var stepData = $(step).data("stepData"); - if(!stepData.src || stepData.srcLoaded) { - return; - } - $(this).jmpress('fire', loadStep, step, { - stepData: $(step).data('stepData') - }); - }); - -}(jQuery, document, window)); -/* - * hash.js - * Detect and set the URL hash - */ -(function( $, document, window, undefined ) { - - 'use strict'; - var $jmpress = $.jmpress, - hashLink = "a[href^='#']"; - - /* FUNCTIONS */ - function randomString() { - return "" + Math.round(Math.random() * 100000, 0); - } - /** - * getElementFromUrl - * - * @return String or undefined - */ - function getElementFromUrl(settings) { - // get id from url # by removing `#` or `#/` from the beginning, - // so both "fallback" `#slide-id` and "enhanced" `#/slide-id` will work - // TODO SECURITY check user input to be valid! - try { - var el = $( '#' + window.location.hash.replace(/^#\/?/,"") ); - return el.length > 0 && el.is(settings.stepSelector) ? el : undefined; - } catch(e) {} - } - function setHash(stepid) { - var shouldBeHash = "#/" + stepid; - if(window.history && window.history.pushState) { - // shouldBeHash = "#" + stepid; - // consider this for future versions - // it has currently issues, when startup with a link with hash (webkit) - if(window.location.hash !== shouldBeHash) { - window.history.pushState({}, '', shouldBeHash); - } - } else { - if(window.location.hash !== shouldBeHash) { - window.location.hash = shouldBeHash; - } - } - } - - /* DEFAULTS */ - $jmpress('defaults').hash = { - use: true - ,update: true - ,bindChange: true - // NOTICE: {use: true, update: false, bindChange: true} - // will cause a error after clicking on a link to the current step - }; - - /* HOOKS */ - $jmpress('selectInitialStep', function( step, eventData ) { - var settings = eventData.settings, - hashSettings = settings.hash, - current = eventData.current, - jmpress = $(this); - eventData.current.hashNamespace = ".jmpress-"+randomString(); - // HASH CHANGE EVENT - if ( hashSettings.use ) { - if ( hashSettings.bindChange ) { - $(window).bind('hashchange'+current.hashNamespace, function(event) { - var urlItem = getElementFromUrl(settings); - if ( jmpress.jmpress('initialized') ) { - jmpress.jmpress("scrollFix"); - } - if(urlItem && urlItem.length) { - if(urlItem.attr("id") !== jmpress.jmpress("active").attr("id")) { - jmpress.jmpress('select', urlItem); - } - setHash(urlItem.attr("id")); - } - event.preventDefault(); - }); - $(hashLink).on("click"+current.hashNamespace, function(event) { - var href = $(this).attr("href"); - try { - if($(href).is(settings.stepSelector)) { - jmpress.jmpress("select", href); - event.preventDefault(); - event.stopPropagation(); - } - } catch(e) {} - }); - } - return getElementFromUrl(settings); - } - }); - $jmpress('afterDeinit', function( nil, eventData ) { - $(hashLink).off(eventData.current.hashNamespace); - $(window).unbind(eventData.current.hashNamespace); - }); - $jmpress('setActive', function( step, eventData ) { - var settings = eventData.settings, - current = eventData.current; - // `#/step-id` is used instead of `#step-id` to prevent default browser - // scrolling to element in hash - if ( settings.hash.use && settings.hash.update ) { - clearTimeout(current.hashtimeout); - current.hashtimeout = setTimeout(function() { - setHash($(eventData.delegatedFrom).attr('id')); - }, settings.transitionDuration + 200); - } - }); - -}(jQuery, document, window)); -/* - * keyboard.js - * Keyboard event mapping and default keyboard actions - */ -(function( $, document, window, undefined ) { - - 'use strict'; - var $jmpress = $.jmpress, - jmpressNext = "next", - jmpressPrev = "prev"; - - /* FUNCTIONS */ - function randomString() { - return "" + Math.round(Math.random() * 100000, 0); - } - function stopEvent(event) { - event.preventDefault(); - event.stopPropagation(); - } - - /* DEFAULTS */ - $jmpress('defaults').keyboard = { - use: true - ,keys: { - 33: jmpressPrev // pg up - ,37: jmpressPrev // left - ,38: jmpressPrev // up - - ,9: jmpressNext+":"+jmpressPrev // tab - ,32: jmpressNext // space - ,34: jmpressNext // pg down - ,39: jmpressNext // right - ,40: jmpressNext // down - - ,36: "home" // home - - ,35: "end" // end - } - ,ignore: { - "INPUT": [ - 32 // space - ,37 // left - ,38 // up - ,39 // right - ,40 // down - ] - ,"TEXTAREA": [ - 32 // space - ,37 // left - ,38 // up - ,39 // right - ,40 // down - ] - ,"SELECT": [ - 38 // up - ,40 // down - ] - } - ,tabSelector: "a[href]:visible, :input:visible" - }; - - /* HOOKS */ - $jmpress('afterInit', function( nil, eventData ) { - var settings = eventData.settings, - keyboardSettings = settings.keyboard, - ignoreKeyboardSettings = keyboardSettings.ignore, - current = eventData.current, - jmpress = $(this); - - // tabindex make it focusable so that it can receive key events - if(!settings.fullscreen) { - jmpress.attr("tabindex", 0); - } - - current.keyboardNamespace = ".jmpress-"+randomString(); - - // KEYPRESS EVENT: this fixes a Opera bug - $(settings.fullscreen ? document : jmpress) - .bind("keypress"+current.keyboardNamespace, function( event ) { - - for( var nodeName in ignoreKeyboardSettings ) { - if ( event.target.nodeName === nodeName && ignoreKeyboardSettings[nodeName].indexOf(event.which) !== -1 ) { - return; - } - } - if(event.which >= 37 && event.which <= 40 || event.which === 32) { - stopEvent(event); - } - }); - // KEYDOWN EVENT - $(settings.fullscreen ? document : jmpress) - .bind("keydown"+current.keyboardNamespace, function( event ) { - var eventTarget = $(event.target); - - if ( !settings.fullscreen && !eventTarget.closest(jmpress).length || !keyboardSettings.use ) { - return; - } - - for( var nodeName in ignoreKeyboardSettings ) { - if ( eventTarget[0].nodeName === nodeName && ignoreKeyboardSettings[nodeName].indexOf(event.which) !== -1 ) { - return; - } - } - - var reverseSelect = false; - var nextFocus; - if (event.which === 9) { - // tab - if ( !eventTarget.closest( jmpress.jmpress('active') ).length ) { - if ( !event.shiftKey ) { - nextFocus = jmpress.jmpress('active').find("a[href], :input").filter(":visible").first(); - } else { - reverseSelect = true; - } - } else { - nextFocus = eventTarget.near( keyboardSettings.tabSelector, event.shiftKey ); - if( !$(nextFocus) - .closest( settings.stepSelector ) - .is(jmpress.jmpress('active') ) ) { - nextFocus = undefined; - } - } - if( nextFocus && nextFocus.length > 0 ) { - nextFocus.focus(); - jmpress.jmpress("scrollFix"); - stopEvent(event); - return; - } else { - if(event.shiftKey) { - reverseSelect = true; - } - } - } - - var action = keyboardSettings.keys[ event.which ]; - if ( typeof action === "string" ) { - if (action.indexOf(":") !== -1) { - action = action.split(":"); - action = event.shiftKey ? action[1] : action[0]; - } - jmpress.jmpress( action ); - stopEvent(event); - } else if ( $.isFunction(action) ) { - action.call(jmpress, event); - } else if ( action ) { - jmpress.jmpress.apply( jmpress, action ); - stopEvent(event); - } - - if (reverseSelect) { - // tab - nextFocus = jmpress.jmpress('active').find("a[href], :input").filter(":visible").last(); - nextFocus.focus(); - jmpress.jmpress("scrollFix"); - } - }); - }); - $jmpress('afterDeinit', function( nil, eventData ) { - $(document).unbind(eventData.current.keyboardNamespace); - }); - - -}(jQuery, document, window)); -/* - * viewport.js - * Scale to fit a given viewport - */ -(function( $, document, window, undefined ) { - - 'use strict'; - - function randomString() { - return "" + Math.round(Math.random() * 100000, 0); - } - - var browser = (function() { - var ua = navigator.userAgent.toLowerCase(); - var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || - /(webkit)[ \/]([\w.]+)/.exec(ua) || - /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || - /(msie) ([\w.]+)/.exec(ua) || - ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || - []; - return match[1] || ""; - }()); - - var defaults = $.jmpress("defaults"); - defaults.viewPort = { - width: false - ,height: false - ,maxScale: 0 - ,minScale: 0 - ,zoomable: 0 - ,zoomBindMove: true - ,zoomBindWheel: true - }; - var keys = defaults.keyboard.keys; - keys[browser === 'mozilla' ? 107 : 187] = "zoomIn"; // + - keys[browser === 'mozilla' ? 109 : 189] = "zoomOut"; // - - defaults.reasonableAnimation.resize = { - transitionDuration: '0s' - ,transitionDelay: '0ms' - }; - defaults.reasonableAnimation.zoom = { - transitionDuration: '0s' - ,transitionDelay: '0ms' - }; - $.jmpress("initStep", function( step, eventData ) { - for(var variable in {"viewPortHeight":1, "viewPortWidth":1, "viewPortMinScale":1, "viewPortMaxScale":1, "viewPortZoomable":1}) { - eventData.stepData[variable] = eventData.data[variable] && parseFloat(eventData.data[variable]); - } - }); - $.jmpress("afterInit", function( nil, eventData ) { - var jmpress = this; - eventData.current.viewPortNamespace = ".jmpress-"+randomString(); - $(window).bind("resize"+eventData.current.viewPortNamespace, function (event) { - $(jmpress).jmpress("reselect", "resize"); - }); - eventData.current.userZoom = 0; - eventData.current.userTranslateX = 0; - eventData.current.userTranslateY = 0; - if(eventData.settings.viewPort.zoomBindWheel) { - $(eventData.settings.fullscreen ? document : this) - .bind("mousewheel"+eventData.current.viewPortNamespace+" DOMMouseScroll"+eventData.current.viewPortNamespace, function( event, delta ) { - delta = delta || event.originalEvent.wheelDelta || -event.originalEvent.detail /* mozilla */; - var direction = (delta / Math.abs(delta)); - if(direction < 0) { - $(eventData.jmpress).jmpress("zoomOut", event.originalEvent.x, event.originalEvent.y); - } else if(direction > 0) { - $(eventData.jmpress).jmpress("zoomIn", event.originalEvent.x, event.originalEvent.y); - } - return false; - }); - } - if(eventData.settings.viewPort.zoomBindMove) { - $(eventData.settings.fullscreen ? document : this).bind("mousedown"+eventData.current.viewPortNamespace, function (event) { - if(eventData.current.userZoom) { - eventData.current.userTranslating = { x: event.clientX, y: event.clientY }; - event.preventDefault(); - event.stopImmediatePropagation(); - } - }).bind("mousemove"+eventData.current.viewPortNamespace, function (event) { - var userTranslating = eventData.current.userTranslating; - if(userTranslating) { - $(jmpress).jmpress("zoomTranslate", event.clientX - userTranslating.x, event.clientY - userTranslating.y); - userTranslating.x = event.clientX; - userTranslating.y = event.clientY; - event.preventDefault(); - event.stopImmediatePropagation(); - } - }).bind("mouseup"+eventData.current.viewPortNamespace, function (event) { - if(eventData.current.userTranslating) { - eventData.current.userTranslating = undefined; - event.preventDefault(); - event.stopImmediatePropagation(); - } - }); - } - }); - function maxAbs(value, range) { - return Math.max(Math.min(value, range), -range); - } - function zoom(x, y, direction) { - var current = $(this).jmpress("current"), - settings = $(this).jmpress("settings"), - stepData = $(this).jmpress("active").data("stepData"), - container = $(this).jmpress("container"); - if(current.userZoom === 0 && direction < 0) { - return; - } - var zoomableSteps = stepData.viewPortZoomable || settings.viewPort.zoomable; - if(current.userZoom === zoomableSteps && direction > 0) { - return; - } - current.userZoom += direction; - - var halfWidth = $(container).innerWidth()/2, - halfHeight = $(container).innerHeight()/2; - - x = x ? x - halfWidth : x; - y = y ? y - halfHeight : y; - - // TODO this is not perfect... too much math... :( - current.userTranslateX = - maxAbs(current.userTranslateX - direction * x / current.zoomOriginWindowScale / zoomableSteps, - halfWidth * current.userZoom * current.userZoom / zoomableSteps); - current.userTranslateY = - maxAbs(current.userTranslateY - direction * y / current.zoomOriginWindowScale / zoomableSteps, - halfHeight * current.userZoom * current.userZoom / zoomableSteps); - - $(this).jmpress("reselect", "zoom"); - } - $.jmpress("register", "zoomIn", function(x, y) { - zoom.call(this, x||0, y||0, 1); - }); - $.jmpress("register", "zoomOut", function(x, y) { - zoom.call(this, x||0, y||0, -1); - }); - $.jmpress("register", "zoomTranslate", function(x, y) { - var current = $(this).jmpress("current"), - settings = $(this).jmpress("settings"), - stepData = $(this).jmpress("active").data("stepData"), - container = $(this).jmpress("container"); - var zoomableSteps = stepData.viewPortZoomable || settings.viewPort.zoomable; - var halfWidth = $(container).innerWidth(), - halfHeight = $(container).innerHeight(); - current.userTranslateX = - maxAbs(current.userTranslateX + x / current.zoomOriginWindowScale, - halfWidth * current.userZoom * current.userZoom / zoomableSteps); - current.userTranslateY = - maxAbs(current.userTranslateY + y / current.zoomOriginWindowScale, - halfHeight * current.userZoom * current.userZoom / zoomableSteps); - $(this).jmpress("reselect", "zoom"); - }); - $.jmpress('afterDeinit', function( nil, eventData ) { - $(eventData.settings.fullscreen ? document : this).unbind(eventData.current.viewPortNamespace); - $(window).unbind(eventData.current.viewPortNamespace); - }); - $.jmpress("setActive", function( step, eventData ) { - var viewPort = eventData.settings.viewPort; - var viewPortHeight = eventData.stepData.viewPortHeight || viewPort.height; - var viewPortWidth = eventData.stepData.viewPortWidth || viewPort.width; - var viewPortMaxScale = eventData.stepData.viewPortMaxScale || viewPort.maxScale; - var viewPortMinScale = eventData.stepData.viewPortMinScale || viewPort.minScale; - // Correct the scale based on the window's size - var windowScaleY = viewPortHeight && $(eventData.container).innerHeight()/viewPortHeight; - var windowScaleX = viewPortWidth && $(eventData.container).innerWidth()/viewPortWidth; - var windowScale = (windowScaleX || windowScaleY) && Math.min( windowScaleX || windowScaleY, windowScaleY || windowScaleX ); - - if(windowScale) { - windowScale = windowScale || 1; - if(viewPortMaxScale) { - windowScale = Math.min(windowScale, viewPortMaxScale); - } - if(viewPortMinScale) { - windowScale = Math.max(windowScale, viewPortMinScale); - } - - var zoomableSteps = eventData.stepData.viewPortZoomable || eventData.settings.viewPort.zoomable; - if(zoomableSteps) { - var diff = (1/windowScale) - (1/viewPortMaxScale); - diff /= zoomableSteps; - windowScale = 1/((1/windowScale) - diff * eventData.current.userZoom); - } - - eventData.target.transform.reverse(); - if(eventData.current.userTranslateX && eventData.current.userTranslateY) { - eventData.target.transform.push(["translate", eventData.current.userTranslateX, eventData.current.userTranslateY, 0]); - } else { - eventData.target.transform.push(["translate"]); - } - eventData.target.transform.push(["scale", - windowScale, - windowScale, - 1]); - eventData.target.transform.reverse(); - eventData.target.perspectiveScale /= windowScale; - } - eventData.current.zoomOriginWindowScale = windowScale; - }); - $.jmpress("setInactive", function( step, eventData ) { - if(!eventData.nextStep || !step || $(eventData.nextStep).attr("id") !== $(step).attr("id")) { - eventData.current.userZoom = 0; - eventData.current.userTranslateX = 0; - eventData.current.userTranslateY = 0; - } - }); - -}(jQuery, document, window)); - -/* - * mouse.js - * Clicking to select a step - */ -(function( $, document, window, undefined ) { - - 'use strict'; - var $jmpress = $.jmpress; - - /* FUNCTIONS */ - function randomString() { - return "" + Math.round(Math.random() * 100000, 0); - } - - /* DEFAULTS */ - $jmpress("defaults").mouse = { - clickSelects: true - }; - - /* HOOKS */ - $jmpress("afterInit", function( nil, eventData ) { - var settings = eventData.settings, - stepSelector = settings.stepSelector, - current = eventData.current, - jmpress = $(this); - current.clickableStepsNamespace = ".jmpress-"+randomString(); - jmpress.bind("click"+current.clickableStepsNamespace, function(event) { - if (!settings.mouse.clickSelects || current.userZoom) { - return; - } - - // get clicked step - var clickedStep = $(event.target).closest(stepSelector); - - // clicks on the active step do default - if ( clickedStep.is( jmpress.jmpress("active") ) ) { - return; - } - - if (clickedStep.length) { - // select the clicked step - jmpress.jmpress("select", clickedStep[0], "click"); - event.preventDefault(); - event.stopPropagation(); - } - }); - }); - $jmpress('afterDeinit', function( nil, eventData ) { - $(this).unbind(eventData.current.clickableStepsNamespace); - }); - -}(jQuery, document, window)); -/* - * mobile.js - * Adds support for swipe on touch supported browsers - */ -(function( $, document, window, undefined ) { - - 'use strict'; - var $jmpress = $.jmpress; - - /* FUNCTIONS */ - function randomString() { - return "" + Math.round(Math.random() * 100000, 0); - } - - /* HOOKS */ - $jmpress( 'afterInit', function( step, eventData ) { - var settings = eventData.settings, - current = eventData.current, - jmpress = eventData.jmpress; - current.mobileNamespace = ".jmpress-"+randomString(); - var data, start = [0,0]; - $(settings.fullscreen ? document : jmpress) - .bind("touchstart"+current.mobileNamespace, function( event ) { - - data = event.originalEvent.touches[0]; - start = [ data.pageX, data.pageY ]; - - }).bind("touchmove"+current.mobileNamespace, function( event ) { - data = event.originalEvent.touches[0]; - event.preventDefault(); - return false; - }).bind("touchend"+current.mobileNamespace, function( event ) { - var end = [ data.pageX, data.pageY ], - diff = [ end[0]-start[0], end[1]-start[1] ]; - - if(Math.max(Math.abs(diff[0]), Math.abs(diff[1])) > 50) { - diff = Math.abs(diff[0]) > Math.abs(diff[1]) ? diff[0] : diff[1]; - $(jmpress).jmpress(diff > 0 ? "prev" : "next"); - event.preventDefault(); - return false; - } - }); - }); - $jmpress('afterDeinit', function( nil, eventData ) { - var settings = eventData.settings, - current = eventData.current, - jmpress = eventData.jmpress; - $(settings.fullscreen ? document : jmpress).unbind(current.mobileNamespace); - }); - -}(jQuery, document, window)); -/* - * templates.js - * The amazing template engine - */ -(function( $, document, window, undefined ) { - - 'use strict'; - var $jmpress = $.jmpress, - templateFromParentIdent = "_template_", - templateFromApplyIdent = "_applied_template_"; - - /* STATIC VARS */ - var templates = {}; - - /* FUNCTIONS */ - function addUndefined( target, values, prefix ) { - for( var name in values ) { - var targetName = name; - if ( prefix ) { - targetName = prefix + targetName.substr(0, 1).toUpperCase() + targetName.substr(1); - } - if ( $.isPlainObject(values[name]) ) { - addUndefined( target, values[name], targetName ); - } else if( target[targetName] === undefined ) { - target[targetName] = values[name]; - } - } - } - function applyChildrenTemplates( children, templateChildren ) { - if ($.isArray(templateChildren)) { - if (templateChildren.length < children.length) { - $.error("more nested steps than children in template"); - } else { - children.each(function(idx, child) { - child = $(child); - var tmpl = child.data(templateFromParentIdent) || {}; - addUndefined(tmpl, templateChildren[idx]); - child.data(templateFromParentIdent, tmpl); - }); - } - } else if($.isFunction(templateChildren)) { - children.each(function(idx, child) { - child = $(child); - var tmpl = child.data(templateFromParentIdent) || {}; - addUndefined(tmpl, templateChildren(idx, child, children)); - child.data(templateFromParentIdent, tmpl); - }); - } // TODO: else if(object) - } - function applyTemplate( data, element, template, eventData ) { - if (template.children) { - var children = element.children( eventData.settings.stepSelector ); - applyChildrenTemplates( children, template.children ); - } - applyTemplateData( data, template ); - } - function applyTemplateData( data, template ) { - addUndefined(data, template); - } - - /* HOOKS */ - $jmpress("beforeInitStep", function( step, eventData ) { - step = $(step); - var data = eventData.data, - templateFromAttr = data.template, - templateFromApply = step.data(templateFromApplyIdent), - templateFromParent = step.data(templateFromParentIdent); - if(templateFromAttr) { - $.each(templateFromAttr.split(" "), function(idx, tmpl) { - var template = templates[tmpl]; - applyTemplate( data, step, template, eventData ); - }); - } - if (templateFromApply) { - applyTemplate( data, step, templateFromApply, eventData ); - } - if (templateFromParent) { - applyTemplate( data, step, templateFromParent, eventData ); - step.data(templateFromParentIdent, null); - if(templateFromParent.template) { - $.each(templateFromParent.template.split(" "), function(idx, tmpl) { - var template = templates[tmpl]; - applyTemplate( data, step, template, eventData ); - }); - } - } - }); - $jmpress("beforeInit", function( nil, eventData ) { - var data = $jmpress("dataset", this), - dataTemplate = data.template, - stepSelector = eventData.settings.stepSelector; - if (dataTemplate) { - var template = templates[dataTemplate]; - applyChildrenTemplates( $(this).find(stepSelector).filter(function() { - return !$(this).parent().is(stepSelector); - }), template.children ); - } - }); - - /* EXPORTED FUNCTIONS */ - $jmpress("register", "template", function( name, tmpl ) { - if (templates[name]) { - templates[name] = $.extend(true, {}, templates[name], tmpl); - } else { - templates[name] = $.extend(true, {}, tmpl); - } - }); - $jmpress("register", "apply", function( selector, tmpl ) { - if( !tmpl ) { - // TODO ERROR because settings not found - var stepSelector = $(this).jmpress("settings").stepSelector; - applyChildrenTemplates( $(this).find(stepSelector).filter(function() { - return !$(this).parent().is(stepSelector); - }), selector ); - } else if($.isArray(tmpl)) { - applyChildrenTemplates( $(selector), tmpl ); - } else { - var template; - if(typeof tmpl === "string") { - template = templates[tmpl]; - } else { - template = $.extend(true, {}, tmpl); - } - $(selector).each(function(idx, element) { - element = $(element); - var tmpl = element.data(templateFromApplyIdent) || {}; - addUndefined(tmpl, template); - element.data(templateFromApplyIdent, tmpl); - }); - } - }); - -}(jQuery, document, window)); -/* - * jqevents.js - * Fires jQuery events - */ -(function( $, document, window, undefined ) { - - 'use strict'; - - /* HOOKS */ - // the events should not bubble up the tree - // elsewise nested jmpress would cause buggy behavior - $.jmpress("setActive", function( step, eventData ) { - if(eventData.prevStep !== step) { - $(step).triggerHandler("enterStep"); - } - }); - $.jmpress("setInactive", function( step, eventData ) { - if(eventData.nextStep !== step) { - $(step).triggerHandler("leaveStep"); - } - }); - -}(jQuery, document, window)); -/* - * animation.js - * Apply custom animations to steps - */ -(function( $, document, window, undefined ) { - - 'use strict'; - - function parseSubstepInfo(str) { - var arr = str.split(" "); - var className = arr[0]; - var config = { willClass: "will-"+className, doClass: "do-"+className, hasClass: "has-"+className }; - var state = ""; - for(var i = 1; i < arr.length; i++) { - var s = arr[i]; - switch(state) { - case "": - if(s === "after") { - state = "after"; - } else { - $.warn("unknown keyword in '"+str+"'. '"+s+"' unknown."); - } - break; - case "after": - if(s.match(/^[1-9][0-9]*m?s?/)) { - var value = parseFloat(s); - if(s.indexOf("ms") !== -1) { - value *= 1; - } else if(s.indexOf("s") !== -1) { - value *= 1000; - } else if(s.indexOf("m") !== -1) { - value *= 60000; - } - config.delay = value; - } else { - config.after = Array.prototype.slice.call(arr, i).join(" "); - i = arr.length; - } - } - } - return config; - } - function find(array, selector, start, end) { - end = end || (array.length - 1); - start = start || 0; - for(var i = start; i < end + 1; i++) { - if($(array[i].element).is(selector)) { - return i; - } - } - } - function addOn(list, substep, delay) { - $.each(substep._on, function(idx, child) { - list.push({substep: child.substep, delay: child.delay + delay}); - addOn(list, child.substep, child.delay + delay); - }); - } - $.jmpress("defaults").customAnimationDataAttribute = "jmpress"; - $.jmpress("afterInit", function( nil, eventData ) { - eventData.current.animationTimeouts = []; - eventData.current.animationCleanupWaiting = []; - }); - $.jmpress("applyStep", function( step, eventData ) { - // read custom animation from elements - var substepsData = {}; - var listOfSubsteps = []; - $(step).find("[data-"+eventData.settings.customAnimationDataAttribute+"]") - .each(function(idx, element) { - if($(element).closest(eventData.settings.stepSelector).is(step)) { - listOfSubsteps.push({element: element}); - } - }); - if(listOfSubsteps.length === 0) { - return; - } - $.each(listOfSubsteps, function(idx, substep) { - substep.info = parseSubstepInfo( - $(substep.element).data(eventData.settings.customAnimationDataAttribute)); - $(substep.element).addClass(substep.info.willClass); - substep._on = []; - substep._after = null; - }); - var current = {_after: undefined, _on: [], info: {}}; // virtual zero step - $.each(listOfSubsteps, function(idx, substep) { - var other = substep.info.after; - if(other) { - if(other === "step") { - other = current; - } else if(other === "prev") { - other = listOfSubsteps[idx-1]; - } else { - var index = find(listOfSubsteps, other, 0, idx - 1); - if(index === undefined) { - index = find(listOfSubsteps, other); - } - other = (index === undefined || index === idx) ? listOfSubsteps[idx-1] : listOfSubsteps[index]; - } - } else { - other = listOfSubsteps[idx-1]; - } - if(other) { - if(!substep.info.delay) { - if(!other._after) { - other._after = substep; - return; - } - other = other._after; - } - other._on.push({substep: substep, delay: substep.info.delay || 0}); - } - }); - if(current._after === undefined && current._on.length === 0) { - var startStep = find(listOfSubsteps, eventData.stepData.startSubstep) || 0; - current._after = listOfSubsteps[startStep]; - } - var substepsInOrder = []; - function findNextFunc(idx, item) { - if(item.substep._after) { - current = item.substep._after; - return false; - } - } - do { - var substepList = [{substep: current, delay: 0}]; - addOn(substepList, current, 0); - substepsInOrder.push(substepList); - current = null; - $.each(substepList, findNextFunc); - } while(current); - substepsData.list = substepsInOrder; - $(step).data("substepsData", substepsData); - }); - $.jmpress("unapplyStep", function( step, eventData ) { - var substepsData = $(step).data("substepsData"); - if(substepsData) { - $.each(substepsData.list, function(idx, activeSubsteps) { - $.each(activeSubsteps, function(idx, substep) { - if(substep.substep.info.willClass) { - $(substep.substep.element).removeClass(substep.substep.info.willClass); - } - if(substep.substep.info.hasClass) { - $(substep.substep.element).removeClass(substep.substep.info.hasClass); - } - if(substep.substep.info.doClass) { - $(substep.substep.element).removeClass(substep.substep.info.doClass); - } - }); - }); - } - }); - $.jmpress("setActive", function(step, eventData) { - var substepsData = $(step).data("substepsData"); - if(!substepsData) { - return; - } - if(eventData.substep === undefined) { - eventData.substep = - (eventData.reason === "prev" ? - substepsData.list.length-1 : - 0 - ); - } - var substep = eventData.substep; - $.each(eventData.current.animationTimeouts, function(idx, timeout) { - clearTimeout(timeout); - }); - eventData.current.animationTimeouts = []; - $.each(substepsData.list, function(idx, activeSubsteps) { - var applyHas = idx < substep; - var applyDo = idx <= substep; - $.each(activeSubsteps, function(idx, substep) { - if(substep.substep.info.hasClass) { - $(substep.substep.element)[(applyHas?"add":"remove")+"Class"](substep.substep.info.hasClass); - } - function applyIt() { - $(substep.substep.element).addClass(substep.substep.info.doClass); - } - if(applyDo && !applyHas && substep.delay && eventData.reason !== "prev") { - if(substep.substep.info.doClass) { - $(substep.substep.element).removeClass(substep.substep.info.doClass); - eventData.current.animationTimeouts.push(setTimeout(applyIt, substep.delay)); - } - } else { - if(substep.substep.info.doClass) { - $(substep.substep.element)[(applyDo?"add":"remove")+"Class"](substep.substep.info.doClass); - } - } - }); - }); - }); - $.jmpress("setInactive", function(step, eventData) { - if(eventData.nextStep === step) { - return; - } - function cleanupAnimation( substepsData ) { - $.each(substepsData.list, function(idx, activeSubsteps) { - $.each(activeSubsteps, function(idx, substep) { - if(substep.substep.info.hasClass) { - $(substep.substep.element).removeClass(substep.substep.info.hasClass); - } - if(substep.substep.info.doClass) { - $(substep.substep.element).removeClass(substep.substep.info.doClass); - } - }); - }); - } - $.each(eventData.current.animationCleanupWaiting, function(idx, item) { - cleanupAnimation(item); - }); - eventData.current.animationCleanupWaiting = []; - var substepsData = $(step).data("substepsData"); - if(substepsData) { - eventData.current.animationCleanupWaiting.push( substepsData ); - } - }); - $.jmpress("selectNext", function( step, eventData ) { - if(eventData.substep === undefined) { - return; - } - var substepsData = $(step).data("substepsData"); - if(!substepsData) { - return; - } - if(eventData.substep < substepsData.list.length-1) { - return {step: step, substep: eventData.substep+1}; - } - }); - $.jmpress("selectPrev", function( step, eventData ) { - if(eventData.substep === undefined) { - return; - } - var substepsData = $(step).data("substepsData"); - if(!substepsData) { - return; - } - if(eventData.substep > 0) { - return {step: step, substep: eventData.substep-1}; - } - }); - -}(jQuery, document, window)); -/*! - * plugin for jmpress.js v0.4.5 - * - * Copyright 2013 Kyle Robinson Young @shama & Tobias Koppers @sokra - * Licensed MIT - * http://www.opensource.org/licenses/mit-license.php - *//* - * jmpress.toggle plugin - * For binding a key to toggle de/initialization of jmpress.js. - */ -(function( $, document, window, undefined ) { - 'use strict'; - $.jmpress("register", "toggle", function( key, config, initial ) { - var jmpress = this; - $(document).bind("keydown", function( event ) { - if ( event.keyCode === key ) { - if ($(jmpress).jmpress("initialized")) { - $(jmpress).jmpress("deinit"); - } else { - $(jmpress).jmpress(config); - } - } - }); - if ( initial ) { - $(jmpress).jmpress(config); - } - }); -}(jQuery, document, window)); - -/* - * jmpress.secondary plugin - * Apply a secondary animation when step is selected. - */ -(function( $, document, window, undefined ) { - 'use strict'; - $.jmpress("initStep", function( step, eventData ) { - for(var name in eventData.data) { - if(name.indexOf("secondary") === 0) { - eventData.stepData[name] = eventData.data[name]; - } - } - }); - function exchangeIf(childStepData, condition, step) { - if(childStepData.secondary && - childStepData.secondary.split(" ").indexOf(condition) !== -1) { - for(var name in childStepData) { - if(name.length > 9 && name.indexOf("secondary") === 0) { - var tmp = childStepData[name]; - var normal = name.substr(9); - normal = normal.substr(0, 1).toLowerCase() + normal.substr(1); - childStepData[name] = childStepData[normal]; - childStepData[normal] = tmp; - } - } - $(this).jmpress("reapply", $(step)); - } - } - $.jmpress("beforeActive", function( step, eventData ) { - exchangeIf.call(eventData.jmpress, $(step).data("stepData"), "self", step); - var parent = $(step).parent(); - $(parent) - .children(eventData.settings.stepSelector) - .each(function(idx, child) { - var childStepData = $(child).data("stepData"); - exchangeIf.call(eventData.jmpress, childStepData, "siblings", child); - }); - function grandchildrenFunc(idx, child) { - var childStepData = $(child).data("stepData"); - exchangeIf.call(eventData.jmpress, childStepData, "grandchildren", child); - } - for(var i = 1; i < eventData.parents.length; i++) { - $(eventData.parents[i]) - .children(eventData.settings.stepSelector) - .each(); - } - }); - $.jmpress("setInactive", function( step, eventData ) { - exchangeIf.call(eventData.jmpress, $(step).data("stepData"), "self", step); - var parent = $(step).parent(); - $(parent) - .children(eventData.settings.stepSelector) - .each(function(idx, child) { - var childStepData = $(child).data("stepData"); - exchangeIf.call(eventData.jmpress, childStepData, "siblings", child); - }); - function grandchildrenFunc(idx, child) { - var childStepData = $(child).data("stepData"); - exchangeIf.call(eventData.jmpress, childStepData, "grandchildren", child); - } - for(var i = 1; i < eventData.parents.length; i++) { - $(eventData.parents[i]) - .children(eventData.settings.stepSelector) - .each(grandchildrenFunc); - } - }); -}(jQuery, document, window)); - -/* - * jmpress.duration plugin - * For auto advancing steps after a given duration and optionally displaying a - * progress bar. - */ -(function( $, document, window, undefined ) { - 'use strict'; - - $.jmpress("defaults").duration = { - defaultValue: -1 - ,defaultAction: "next" - ,barSelector: undefined - ,barProperty: "width" - ,barPropertyStart: "0" - ,barPropertyEnd: "100%" - }; - $.jmpress("initStep", function( step, eventData ) { - eventData.stepData.duration = eventData.data.duration && parseInt(eventData.data.duration, 10); - eventData.stepData.durationAction = eventData.data.durationAction; - }); - $.jmpress("setInactive", function( step, eventData ) { - var settings = eventData.settings, - durationSettings = settings.duration, - current = eventData.current; - var dur = eventData.stepData.duration || durationSettings.defaultValue; - if( current.durationTimeout ) { - if( durationSettings.barSelector ) { - var css = { - transitionProperty: durationSettings.barProperty - ,transitionDuration: '0' - ,transitionDelay: '0' - ,transitionTimingFunction: 'linear' - }; - css[durationSettings.barProperty] = durationSettings.barPropertyStart; - var bars = $(durationSettings.barSelector); - $.jmpress("css", bars, css); - bars.each(function(idx, element) { - var next = $(element).next(); - var parent = $(element).parent(); - $(element).detach(); - if(next.length) { - next.insertBefore(element); - } else { - parent.append(element); - } - }); - } - clearTimeout(current.durationTimeout); - delete current.durationTimeout; - } - }); - $.jmpress("setActive", function( step, eventData ) { - var settings = eventData.settings, - durationSettings = settings.duration, - current = eventData.current; - var dur = eventData.stepData.duration || durationSettings.defaultValue; - if( dur && dur > 0 ) { - if( durationSettings.barSelector ) { - var css = { - transitionProperty: durationSettings.barProperty - ,transitionDuration: (dur-settings.transitionDuration*2/3-100)+"ms" - ,transitionDelay: (settings.transitionDuration*2/3)+'ms' - ,transitionTimingFunction: 'linear' - }; - css[durationSettings.barProperty] = durationSettings.barPropertyEnd; - $.jmpress("css", $(durationSettings.barSelector), css); - } - var jmpress = this; - if(current.durationTimeout) { - clearTimeout(current.durationTimeout); - current.durationTimeout = undefined; - } - current.durationTimeout = setTimeout(function() { - var action = eventData.stepData.durationAction || durationSettings.defaultAction; - $(jmpress).jmpress(action); - }, dur); - } - }); -}(jQuery, document, window)); - -/* - * jmpress.presentation-mode plugin - * Display a window for the presenter with notes and a control and view of the - * presentation - */ -(function( $, document, window, undefined ) { - - 'use strict'; - var $jmpress = $.jmpress; - - var PREFIX = "jmpress-presentation-"; - - /* FUNCTIONS */ - function randomString() { - return "" + Math.round(Math.random() * 100000, 0); - } - - /* DEFAULTS */ - $jmpress("defaults").presentationMode = { - use: true, - url: "presentation-screen.html", - notesUrl: false, - transferredValues: ["userZoom", "userTranslateX", "userTranslateY"] - }; - $jmpress("defaults").keyboard.keys[80] = "presentationPopup"; // p key - - /* HOOKS */ - $jmpress("afterInit", function( nil, eventData) { - var current = eventData.current; - - current.selectMessageListeners = []; - - if(eventData.settings.presentationMode.use) { - - window.addEventListener("message", function(event) { - // We do not test orgin, because we want to accept messages - // from all orgins - try { - if(typeof event.data !== "string" || event.data.indexOf(PREFIX) !== 0) { - return; - } - var json = JSON.parse(event.data.slice(PREFIX.length)); - switch(json.type) { - case "select": - $.each(eventData.settings.presentationMode.transferredValues, function(idx, name) { - eventData.current[name] = json[name]; - }); - if(/[a-z0-9\-]+/i.test(json.targetId) && typeof json.substep in {number:1,undefined:1}) { - $(eventData.jmpress).jmpress("select", {step: "#"+json.targetId, substep: json.substep}, json.reason); - } else { - $.error("For security reasons the targetId must match /[a-z0-9\\-]+/i and substep must be a number."); - } - break; - case "listen": - current.selectMessageListeners.push(event.source); - break; - case "ok": - clearTimeout(current.presentationPopupTimeout); - break; - case "read": - try { - event.source.postMessage(PREFIX + JSON.stringify({type: "url", url: window.location.href, notesUrl: eventData.settings.presentationMode.notesUrl}), "*"); - } catch(e) { - $.error("Cannot post message to source: " + e); - } - break; - default: - throw "Unknown message type: " + json.type; - } - } catch(e) { - $.error("Received message is malformed: " + e); - } - }); - try { - if(window.parent && window.parent !== window) { - window.parent.postMessage(PREFIX + JSON.stringify({ - "type": "afterInit" - }), "*"); - } - } catch(e) { - $.error("Cannot post message to parent: " + e); - } - } - }); - $jmpress("afterDeinit", function( nil, eventData) { - if(eventData.settings.presentationMode.use) { - try { - if(window.parent && window.parent !== window) { - window.parent.postMessage(PREFIX + JSON.stringify({ - "type": "afterDeinit" - }), "*"); - } - } catch(e) { - $.error("Cannot post message to parent: " + e); - } - } - }); - $jmpress("setActive", function( step, eventData) { - var stepId = $(eventData.delegatedFrom).attr("id"), - substep = eventData.substep, - reason = eventData.reason; - $.each(eventData.current.selectMessageListeners, function(idx, listener) { - try { - var msg = { - "type": "select", - "targetId": stepId, - "substep": substep, - "reason": reason - }; - $.each(eventData.settings.presentationMode.transferredValues, function(idx, name) { - msg[name] = eventData.current[name]; - }); - listener.postMessage(PREFIX + JSON.stringify(msg), "*"); - } catch(e) { - $.error("Cannot post message to listener: " + e); - } - }); - }); - $jmpress("register", "presentationPopup", function() { - function trySend() { - jmpress.jmpress("current").presentationPopupTimeout = setTimeout(trySend, 100); - try { - popup.postMessage(PREFIX + JSON.stringify({type: "url", url: window.location.href, notesUrl: jmpress.jmpress("settings").presentationMode.notesUrl}), "*"); - } catch(e) { - } - } - var jmpress = $(this), - popup; - if(jmpress.jmpress("settings").presentationMode.use) { - popup = window.open($(this).jmpress("settings").presentationMode.url); - jmpress.jmpress("current").presentationPopupTimeout = setTimeout(trySend, 100); - } - }); -}(jQuery, document, window)); diff --git a/plugins/jetpack/modules/shortcodes/js/jquery.cycle.min.js b/plugins/jetpack/modules/shortcodes/js/jquery.cycle.min.js deleted file mode 100644 index 35a4d0cf..00000000 --- a/plugins/jetpack/modules/shortcodes/js/jquery.cycle.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/*! - * jQuery Cycle Plugin (with Transition Definitions) - * Examples and documentation at: http://jquery.malsup.com/cycle/ - * Copyright (c) 2007-2010 M. Alsup - * Version: 2.9999.8 (26-OCT-2012) - * Dual licensed under the MIT and GPL licenses. - * http://jquery.malsup.com/license.html - */ -!function(e,t){"use strict";function n(t){e.fn.cycle.debug&&i(t)}function i(){window.console&&console.log&&console.log("[cycle] "+Array.prototype.join.call(arguments," "))}function c(t,n,i){var c=e(t).data("cycle.opts");if(c){var s=!!t.cyclePause;s&&c.paused?c.paused(t,c,n,i):!s&&c.resumed&&c.resumed(t,c,n,i)}}function s(n,s,o){function l(t,n,c){if(!t&&n===!0){var s=e(c).data("cycle.opts");if(!s)return i("options not found, can not resume"),!1;c.cycleTimeout&&(clearTimeout(c.cycleTimeout),c.cycleTimeout=0),d(s.elements,s,1,!s.backwards)}}if(n.cycleStop===t&&(n.cycleStop=0),s!==t&&null!==s||(s={}),s.constructor==String){switch(s){case"destroy":case"stop":var a=e(n).data("cycle.opts");return a?(n.cycleStop++,n.cycleTimeout&&clearTimeout(n.cycleTimeout),n.cycleTimeout=0,a.elements&&e(a.elements).stop(),e(n).removeData("cycle.opts"),"destroy"==s&&r(n,a),!1):!1;case"toggle":return n.cyclePause=1===n.cyclePause?0:1,l(n.cyclePause,o,n),c(n),!1;case"pause":return n.cyclePause=1,c(n),!1;case"resume":return n.cyclePause=0,l(!1,o,n),c(n),!1;case"prev":case"next":return(a=e(n).data("cycle.opts"))?(e.fn.cycle[s](a),!1):(i('options not found, "prev/next" ignored'),!1);default:s={fx:s}}return s}if(s.constructor==Number){var f=s;return(s=e(n).data("cycle.opts"))?0>f||f>=s.elements.length?(i("invalid slide index: "+f),!1):(s.nextSlide=f,n.cycleTimeout&&(clearTimeout(n.cycleTimeout),n.cycleTimeout=0),"string"==typeof o&&(s.oneTimeFx=o),d(s.elements,s,1,f>=s.currSlide),!1):(i("options not found, can not advance slide"),!1)}return s}function o(t,n){if(!e.support.opacity&&n.cleartype&&t.style.filter)try{t.style.removeAttribute("filter")}catch(i){}}function r(t,n){n.next&&e(n.next).unbind(n.prevNextEvent),n.prev&&e(n.prev).unbind(n.prevNextEvent),(n.pager||n.pagerAnchorBuilder)&&e.each(n.pagerAnchors||[],function(){this.unbind().remove()}),n.pagerAnchors=null,e(t).unbind("mouseenter.cycle mouseleave.cycle"),n.destroy&&n.destroy(n)}function l(n,s,r,l,h){var g,x=e.extend({},e.fn.cycle.defaults,l||{},e.metadata?n.metadata():e.meta?n.data():{}),v=e.isFunction(n.data)?n.data(x.metaAttr):null;v&&(x=e.extend(x,v)),x.autostop&&(x.countdown=x.autostopCount||r.length);var w=n[0];if(n.data("cycle.opts",x),x.$cont=n,x.stopCount=w.cycleStop,x.elements=r,x.before=x.before?[x.before]:[],x.after=x.after?[x.after]:[],!e.support.opacity&&x.cleartype&&x.after.push(function(){o(this,x)}),x.continuous&&x.after.push(function(){d(r,x,0,!x.backwards)}),a(x),e.support.opacity||!x.cleartype||x.cleartypeNoBg||y(s),"static"==n.css("position")&&n.css("position","relative"),x.width&&n.width(x.width),x.height&&"auto"!=x.height&&n.height(x.height),x.startingSlide!==t?(x.startingSlide=parseInt(x.startingSlide,10),x.startingSlide>=r.length||x.startSlide<0?x.startingSlide=0:g=!0):x.backwards?x.startingSlide=r.length-1:x.startingSlide=0,x.random){x.randomMap=[];for(var b=0;b<r.length;b++)x.randomMap.push(b);if(x.randomMap.sort(function(){return Math.random()-.5}),g)for(var S=0;S<r.length;S++)x.startingSlide==x.randomMap[S]&&(x.randomIndex=S);else x.randomIndex=1,x.startingSlide=x.randomMap[1]}else x.startingSlide>=r.length&&(x.startingSlide=0);x.currSlide=x.startingSlide||0;var B=x.startingSlide;s.css({position:"absolute",top:0,left:0}).hide().each(function(t){var n;n=x.backwards?B?B>=t?r.length+(t-B):B-t:r.length-t:B?t>=B?r.length-(t-B):B-t:r.length-t,e(this).css("z-index",n)}),e(r[B]).css("opacity",1).show(),o(r[B],x),x.fit&&(x.aspect?s.each(function(){var t=e(this),n=x.aspect===!0?t.width()/t.height():x.aspect;x.width&&t.width()!=x.width&&(t.width(x.width),t.height(x.width/n)),x.height&&t.height()<x.height&&(t.height(x.height),t.width(x.height*n))}):(x.width&&s.width(x.width),x.height&&"auto"!=x.height&&s.height(x.height))),!x.center||x.fit&&!x.aspect||s.each(function(){var t=e(this);t.css({"margin-left":x.width?(x.width-t.width())/2+"px":0,"margin-top":x.height?(x.height-t.height())/2+"px":0})}),!x.center||x.fit||x.slideResize||s.each(function(){var t=e(this);t.css({"margin-left":x.width?(x.width-t.width())/2+"px":0,"margin-top":x.height?(x.height-t.height())/2+"px":0})});var I=(x.containerResize||x.containerResizeHeight)&&!n.innerHeight();if(I){for(var O=0,F=0,A=0;A<r.length;A++){var H=e(r[A]),k=H[0],T=H.outerWidth(),R=H.outerHeight();T||(T=k.offsetWidth||k.width||H.attr("width")),R||(R=k.offsetHeight||k.height||H.attr("height")),O=T>O?T:O,F=R>F?R:F}x.containerResize&&O>0&&F>0&&n.css({width:O+"px",height:F+"px"}),x.containerResizeHeight&&F>0&&n.css({height:F+"px"})}var W=!1;if(x.pause&&n.bind("mouseenter.cycle",function(){W=!0,this.cyclePause++,c(w,!0)}).bind("mouseleave.cycle",function(){W&&this.cyclePause--,c(w,!0)}),f(x)===!1)return!1;var P=!1;if(l.requeueAttempts=l.requeueAttempts||0,s.each(function(){var t=e(this);if(this.cycleH=x.fit&&x.height?x.height:t.height()||this.offsetHeight||this.height||t.attr("height")||0,this.cycleW=x.fit&&x.width?x.width:t.width()||this.offsetWidth||this.width||t.attr("width")||0,t.is("img")){var n=e.browser.msie&&28==this.cycleW&&30==this.cycleH&&!this.complete,c=e.browser.mozilla&&34==this.cycleW&&19==this.cycleH&&!this.complete,s=e.browser.opera&&(42==this.cycleW&&19==this.cycleH||37==this.cycleW&&17==this.cycleH)&&!this.complete,o=0===this.cycleH&&0===this.cycleW&&!this.complete;if(n||c||s||o){if(h.s&&x.requeueOnImageNotLoaded&&++l.requeueAttempts<100)return i(l.requeueAttempts," - img slide not loaded, requeuing slideshow: ",this.src,this.cycleW,this.cycleH),setTimeout(function(){e(h.s,h.c).cycle(l)},x.requeueTimeout),P=!0,!1;i("could not determine size of image: "+this.src,this.cycleW,this.cycleH)}}return!0}),P)return!1;if(x.cssBefore=x.cssBefore||{},x.cssAfter=x.cssAfter||{},x.cssFirst=x.cssFirst||{},x.animIn=x.animIn||{},x.animOut=x.animOut||{},s.not(":eq("+B+")").css(x.cssBefore),e(s[B]).css(x.cssFirst),x.timeout){x.timeout=parseInt(x.timeout,10),x.speed.constructor==String&&(x.speed=e.fx.speeds[x.speed]||parseInt(x.speed,10)),x.sync||(x.speed=x.speed/2);for(var z="none"==x.fx?0:"shuffle"==x.fx?500:250;x.timeout-x.speed<z;)x.timeout+=x.speed}if(x.easing&&(x.easeIn=x.easeOut=x.easing),x.speedIn||(x.speedIn=x.speed),x.speedOut||(x.speedOut=x.speed),x.slideCount=r.length,x.currSlide=x.lastSlide=B,x.random?(++x.randomIndex==r.length&&(x.randomIndex=0),x.nextSlide=x.randomMap[x.randomIndex]):x.backwards?x.nextSlide=0===x.startingSlide?r.length-1:x.startingSlide-1:x.nextSlide=x.startingSlide>=r.length-1?0:x.startingSlide+1,!x.multiFx){var C=e.fn.cycle.transitions[x.fx];if(e.isFunction(C))C(n,s,x);else if("custom"!=x.fx&&!x.multiFx)return i("unknown transition: "+x.fx,"; slideshow terminating"),!1}var E=s[B];return x.skipInitializationCallbacks||(x.before.length&&x.before[0].apply(E,[E,E,x,!0]),x.after.length&&x.after[0].apply(E,[E,E,x,!0])),x.next&&e(x.next).bind(x.prevNextEvent,function(){return p(x,1)}),x.prev&&e(x.prev).bind(x.prevNextEvent,function(){return p(x,0)}),(x.pager||x.pagerAnchorBuilder)&&m(r,x),u(x,r),x}function a(t){t.original={before:[],after:[]},t.original.cssBefore=e.extend({},t.cssBefore),t.original.cssAfter=e.extend({},t.cssAfter),t.original.animIn=e.extend({},t.animIn),t.original.animOut=e.extend({},t.animOut),e.each(t.before,function(){t.original.before.push(this)}),e.each(t.after,function(){t.original.after.push(this)})}function f(t){var c,s,o=e.fn.cycle.transitions;if(t.fx.indexOf(",")>0){for(t.multiFx=!0,t.fxs=t.fx.replace(/\s*/g,"").split(","),c=0;c<t.fxs.length;c++){var r=t.fxs[c];s=o[r],s&&o.hasOwnProperty(r)&&e.isFunction(s)||(i("discarding unknown transition: ",r),t.fxs.splice(c,1),c--)}if(!t.fxs.length)return i("No valid transitions named; slideshow terminating."),!1}else if("all"==t.fx){t.multiFx=!0,t.fxs=[];for(var l in o)o.hasOwnProperty(l)&&(s=o[l],o.hasOwnProperty(l)&&e.isFunction(s)&&t.fxs.push(l))}if(t.multiFx&&t.randomizeEffects){var a=Math.floor(20*Math.random())+30;for(c=0;a>c;c++){var f=Math.floor(Math.random()*t.fxs.length);t.fxs.push(t.fxs.splice(f,1)[0])}n("randomized fx sequence: ",t.fxs)}return!0}function u(t,n){t.addSlide=function(i,c){var s=e(i),o=s[0];t.autostopCount||t.countdown++,n[c?"unshift":"push"](o),t.els&&t.els[c?"unshift":"push"](o),t.slideCount=n.length,t.random&&(t.randomMap.push(t.slideCount-1),t.randomMap.sort(function(){return Math.random()-.5})),s.css("position","absolute"),s[c?"prependTo":"appendTo"](t.$cont),c&&(t.currSlide++,t.nextSlide++),e.support.opacity||!t.cleartype||t.cleartypeNoBg||y(s),t.fit&&t.width&&s.width(t.width),t.fit&&t.height&&"auto"!=t.height&&s.height(t.height),o.cycleH=t.fit&&t.height?t.height:s.height(),o.cycleW=t.fit&&t.width?t.width:s.width(),s.css(t.cssBefore),(t.pager||t.pagerAnchorBuilder)&&e.fn.cycle.createPagerAnchor(n.length-1,o,e(t.pager),n,t),e.isFunction(t.onAddSlide)?t.onAddSlide(s):s.hide()}}function d(i,c,s,o){function r(){var e=0;c.timeout;c.timeout&&!c.continuous?(e=h(i[c.currSlide],i[c.nextSlide],c,o),"shuffle"==c.fx&&(e-=c.speedOut)):c.continuous&&l.cyclePause&&(e=10),e>0&&(l.cycleTimeout=setTimeout(function(){d(i,c,0,!c.backwards)},e))}var l=c.$cont[0],a=i[c.currSlide],f=i[c.nextSlide];if(s&&c.busy&&c.manualTrump&&(n("manualTrump in go(), stopping active transition"),e(i).stop(!0,!0),c.busy=0,clearTimeout(l.cycleTimeout)),c.busy)return void n("transition active, ignoring new tx request");if(l.cycleStop==c.stopCount&&(0!==l.cycleTimeout||s)){if(!s&&!l.cyclePause&&!c.bounce&&(c.autostop&&--c.countdown<=0||c.nowrap&&!c.random&&c.nextSlide<c.currSlide))return void(c.end&&c.end(c));var u=!1;if(!s&&l.cyclePause||c.nextSlide==c.currSlide)r();else{u=!0;var p=c.fx;a.cycleH=a.cycleH||e(a).height(),a.cycleW=a.cycleW||e(a).width(),f.cycleH=f.cycleH||e(f).height(),f.cycleW=f.cycleW||e(f).width(),c.multiFx&&(o&&(c.lastFx===t||++c.lastFx>=c.fxs.length)?c.lastFx=0:!o&&(c.lastFx===t||--c.lastFx<0)&&(c.lastFx=c.fxs.length-1),p=c.fxs[c.lastFx]),c.oneTimeFx&&(p=c.oneTimeFx,c.oneTimeFx=null),e.fn.cycle.resetState(c,p),c.before.length&&e.each(c.before,function(e,t){l.cycleStop==c.stopCount&&t.apply(f,[a,f,c,o])});var m=function(){c.busy=0,e.each(c.after,function(e,t){l.cycleStop==c.stopCount&&t.apply(f,[a,f,c,o])}),l.cycleStop||r()};n("tx firing("+p+"); currSlide: "+c.currSlide+"; nextSlide: "+c.nextSlide),c.busy=1,c.fxFn?c.fxFn(a,f,c,m,o,s&&c.fastOnEvent):e.isFunction(e.fn.cycle[c.fx])?e.fn.cycle[c.fx](a,f,c,m,o,s&&c.fastOnEvent):e.fn.cycle.custom(a,f,c,m,o,s&&c.fastOnEvent)}if(u||c.nextSlide==c.currSlide){var y;c.lastSlide=c.currSlide,c.random?(c.currSlide=c.nextSlide,++c.randomIndex==i.length&&(c.randomIndex=0,c.randomMap.sort(function(){return Math.random()-.5})),c.nextSlide=c.randomMap[c.randomIndex],c.nextSlide==c.currSlide&&(c.nextSlide=c.currSlide==c.slideCount-1?0:c.currSlide+1)):c.backwards?(y=c.nextSlide-1<0,y&&c.bounce?(c.backwards=!c.backwards,c.nextSlide=1,c.currSlide=0):(c.nextSlide=y?i.length-1:c.nextSlide-1,c.currSlide=y?0:c.nextSlide+1)):(y=c.nextSlide+1==i.length,y&&c.bounce?(c.backwards=!c.backwards,c.nextSlide=i.length-2,c.currSlide=i.length-1):(c.nextSlide=y?0:c.nextSlide+1,c.currSlide=y?i.length-1:c.nextSlide-1))}u&&c.pager&&c.updateActivePagerLink(c.pager,c.currSlide,c.activePagerClass)}}function h(e,t,i,c){if(i.timeoutFn){for(var s=i.timeoutFn.call(e,e,t,i,c);"none"!=i.fx&&s-i.speed<250;)s+=i.speed;if(n("calculated timeout: "+s+"; speed: "+i.speed),s!==!1)return s}return i.timeout}function p(t,n){var i=n?1:-1,c=t.elements,s=t.$cont[0],o=s.cycleTimeout;if(o&&(clearTimeout(o),s.cycleTimeout=0),t.random&&0>i)t.randomIndex--,-2==--t.randomIndex?t.randomIndex=c.length-2:-1==t.randomIndex&&(t.randomIndex=c.length-1),t.nextSlide=t.randomMap[t.randomIndex];else if(t.random)t.nextSlide=t.randomMap[t.randomIndex];else if(t.nextSlide=t.currSlide+i,t.nextSlide<0){if(t.nowrap)return!1;t.nextSlide=c.length-1}else if(t.nextSlide>=c.length){if(t.nowrap)return!1;t.nextSlide=0}var r=t.onPrevNextEvent||t.prevNextClick;return e.isFunction(r)&&r(i>0,t.nextSlide,c[t.nextSlide]),d(c,t,1,n),!1}function m(t,n){var i=e(n.pager);e.each(t,function(c,s){e.fn.cycle.createPagerAnchor(c,s,i,t,n)}),n.updateActivePagerLink(n.pager,n.startingSlide,n.activePagerClass)}function y(t){function i(e){return e=parseInt(e,10).toString(16),e.length<2?"0"+e:e}function c(t){for(;t&&"html"!=t.nodeName.toLowerCase();t=t.parentNode){var n=e.css(t,"background-color");if(n&&n.indexOf("rgb")>=0){var c=n.match(/\d+/g);return"#"+i(c[0])+i(c[1])+i(c[2])}if(n&&"transparent"!=n)return n}return"#ffffff"}n("applying clearType background-color hack"),t.each(function(){e(this).css("background-color",c(this))})}var g="2.9999.8";e.support===t&&(e.support={opacity:!e.browser.msie}),e.expr[":"].paused=function(e){return e.cyclePause},e.fn.cycle=function(t,c){var o={s:this.selector,c:this.context};return 0===this.length&&"stop"!=t?!e.isReady&&o.s?(i("DOM not ready, queuing slideshow"),e(function(){e(o.s,o.c).cycle(t,c)}),this):(i("terminating; zero elements found by selector"+(e.isReady?"":" (DOM not ready)")),this):this.each(function(){var r=s(this,t,c);if(r!==!1){r.updateActivePagerLink=r.updateActivePagerLink||e.fn.cycle.updateActivePagerLink,this.cycleTimeout&&clearTimeout(this.cycleTimeout),this.cycleTimeout=this.cyclePause=0,this.cycleStop=0;var a=e(this),f=r.slideExpr?e(r.slideExpr,this):a.children(),u=f.get();if(u.length<2)return void i("terminating; too few slides: "+u.length);var p=l(a,f,u,r,o);if(p!==!1){var m=p.continuous?10:h(u[p.currSlide],u[p.nextSlide],p,!p.backwards);m&&(m+=p.delay||0,10>m&&(m=10),n("first timeout: "+m),this.cycleTimeout=setTimeout(function(){d(u,p,0,!r.backwards)},m))}}})},e.fn.cycle.resetState=function(t,n){n=n||t.fx,t.before=[],t.after=[],t.cssBefore=e.extend({},t.original.cssBefore),t.cssAfter=e.extend({},t.original.cssAfter),t.animIn=e.extend({},t.original.animIn),t.animOut=e.extend({},t.original.animOut),t.fxFn=null,e.each(t.original.before,function(){t.before.push(this)}),e.each(t.original.after,function(){t.after.push(this)});var i=e.fn.cycle.transitions[n];e.isFunction(i)&&i(t.$cont,e(t.elements),t)},e.fn.cycle.updateActivePagerLink=function(t,n,i){e(t).each(function(){e(this).children().removeClass(i).eq(n).addClass(i)})},e.fn.cycle.next=function(e){p(e,1)},e.fn.cycle.prev=function(e){p(e,0)},e.fn.cycle.createPagerAnchor=function(t,i,s,o,r){var l;if(e.isFunction(r.pagerAnchorBuilder)?(l=r.pagerAnchorBuilder(t,i),n("pagerAnchorBuilder("+t+", el) returned: "+l)):l='<a href="#">'+(t+1)+"</a>",l){var a=e(l);if(0===a.parents("body").length){var f=[];s.length>1?(s.each(function(){var t=a.clone(!0);e(this).append(t),f.push(t[0])}),a=e(f)):a.appendTo(s)}r.pagerAnchors=r.pagerAnchors||[],r.pagerAnchors.push(a);var u=function(n){n.preventDefault(),r.nextSlide=t;var i=r.$cont[0],c=i.cycleTimeout;c&&(clearTimeout(c),i.cycleTimeout=0);var s=r.onPagerEvent||r.pagerClick;e.isFunction(s)&&s(r.nextSlide,o[r.nextSlide]),d(o,r,1,r.currSlide<t)};/mouseenter|mouseover/i.test(r.pagerEvent)?a.hover(u,function(){}):a.bind(r.pagerEvent,u),/^click/.test(r.pagerEvent)||r.allowPagerClickBubble||a.bind("click.cycle",function(){return!1});var h=r.$cont[0],p=!1;r.pauseOnPagerHover&&a.hover(function(){p=!0,h.cyclePause++,c(h,!0,!0)},function(){p&&h.cyclePause--,c(h,!0,!0)})}},e.fn.cycle.hopsFromLast=function(e,t){var n,i=e.lastSlide,c=e.currSlide;return n=t?c>i?c-i:e.slideCount-i:i>c?i-c:i+e.slideCount-c},e.fn.cycle.commonReset=function(t,n,i,c,s,o){e(i.elements).not(t).hide(),"undefined"==typeof i.cssBefore.opacity&&(i.cssBefore.opacity=1),i.cssBefore.display="block",i.slideResize&&c!==!1&&n.cycleW>0&&(i.cssBefore.width=n.cycleW),i.slideResize&&s!==!1&&n.cycleH>0&&(i.cssBefore.height=n.cycleH),i.cssAfter=i.cssAfter||{},i.cssAfter.display="none",e(t).css("zIndex",i.slideCount+(o===!0?1:0)),e(n).css("zIndex",i.slideCount+(o===!0?0:1))},e.fn.cycle.custom=function(t,n,i,c,s,o){var r=e(t),l=e(n),a=i.speedIn,f=i.speedOut,u=i.easeIn,d=i.easeOut;l.css(i.cssBefore),o&&(a=f="number"==typeof o?o:1,u=d=null);var h=function(){l.animate(i.animIn,a,u,function(){c()})};r.animate(i.animOut,f,d,function(){r.css(i.cssAfter),i.sync||h()}),i.sync&&h()},e.fn.cycle.transitions={fade:function(t,n,i){n.not(":eq("+i.currSlide+")").css("opacity",0),i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i),i.cssBefore.opacity=0}),i.animIn={opacity:1},i.animOut={opacity:0},i.cssBefore={top:0,left:0}}},e.fn.cycle.ver=function(){return g},e.fn.cycle.defaults={activePagerClass:"activeSlide",after:null,allowPagerClickBubble:!1,animIn:null,animOut:null,aspect:!1,autostop:0,autostopCount:0,backwards:!1,before:null,center:null,cleartype:!e.support.opacity,cleartypeNoBg:!1,containerResize:1,containerResizeHeight:0,continuous:0,cssAfter:null,cssBefore:null,delay:0,easeIn:null,easeOut:null,easing:null,end:null,fastOnEvent:0,fit:0,fx:"fade",fxFn:null,height:"auto",manualTrump:!0,metaAttr:"cycle",next:null,nowrap:0,onPagerEvent:null,onPrevNextEvent:null,pager:null,pagerAnchorBuilder:null,pagerEvent:"click.cycle",pause:0,pauseOnPagerHover:0,prev:null,prevNextEvent:"click.cycle",random:0,randomizeEffects:1,requeueOnImageNotLoaded:!0,requeueTimeout:250,rev:0,shuffle:null,skipInitializationCallbacks:!1,slideExpr:null,slideResize:1,speed:1e3,speedIn:null,speedOut:null,startingSlide:t,sync:1,timeout:4e3,timeoutFn:null,updateActivePagerLink:null,width:null}}(jQuery),function(e){"use strict";e.fn.cycle.transitions.none=function(t,n,i){i.fxFn=function(t,n,i,c){e(n).show(),e(t).hide(),c()}},e.fn.cycle.transitions.fadeout=function(t,n,i){n.not(":eq("+i.currSlide+")").css({display:"block",opacity:1}),i.before.push(function(t,n,i,c,s,o){e(t).css("zIndex",i.slideCount+(o!==!0?1:0)),e(n).css("zIndex",i.slideCount+(o!==!0?0:1))}),i.animIn.opacity=1,i.animOut.opacity=0,i.cssBefore.opacity=1,i.cssBefore.display="block",i.cssAfter.zIndex=0},e.fn.cycle.transitions.scrollUp=function(t,n,i){t.css("overflow","hidden"),i.before.push(e.fn.cycle.commonReset);var c=t.height();i.cssBefore.top=c,i.cssBefore.left=0,i.cssFirst.top=0,i.animIn.top=0,i.animOut.top=-c},e.fn.cycle.transitions.scrollDown=function(t,n,i){t.css("overflow","hidden"),i.before.push(e.fn.cycle.commonReset);var c=t.height();i.cssFirst.top=0,i.cssBefore.top=-c,i.cssBefore.left=0,i.animIn.top=0,i.animOut.top=c},e.fn.cycle.transitions.scrollLeft=function(t,n,i){t.css("overflow","hidden"),i.before.push(e.fn.cycle.commonReset);var c=t.width();i.cssFirst.left=0,i.cssBefore.left=c,i.cssBefore.top=0,i.animIn.left=0,i.animOut.left=0-c},e.fn.cycle.transitions.scrollRight=function(t,n,i){t.css("overflow","hidden"),i.before.push(e.fn.cycle.commonReset);var c=t.width();i.cssFirst.left=0,i.cssBefore.left=-c,i.cssBefore.top=0,i.animIn.left=0,i.animOut.left=c},e.fn.cycle.transitions.scrollHorz=function(t,n,i){t.css("overflow","hidden").width(),i.before.push(function(t,n,i,c){i.rev&&(c=!c),e.fn.cycle.commonReset(t,n,i),i.cssBefore.left=c?n.cycleW-1:1-n.cycleW,i.animOut.left=c?-t.cycleW:t.cycleW}),i.cssFirst.left=0,i.cssBefore.top=0,i.animIn.left=0,i.animOut.top=0},e.fn.cycle.transitions.scrollVert=function(t,n,i){t.css("overflow","hidden"),i.before.push(function(t,n,i,c){i.rev&&(c=!c),e.fn.cycle.commonReset(t,n,i),i.cssBefore.top=c?1-n.cycleH:n.cycleH-1,i.animOut.top=c?t.cycleH:-t.cycleH}),i.cssFirst.top=0,i.cssBefore.left=0,i.animIn.top=0,i.animOut.left=0},e.fn.cycle.transitions.slideX=function(t,n,i){i.before.push(function(t,n,i){e(i.elements).not(t).hide(),e.fn.cycle.commonReset(t,n,i,!1,!0),i.animIn.width=n.cycleW}),i.cssBefore.left=0,i.cssBefore.top=0,i.cssBefore.width=0,i.animIn.width="show",i.animOut.width=0},e.fn.cycle.transitions.slideY=function(t,n,i){i.before.push(function(t,n,i){e(i.elements).not(t).hide(),e.fn.cycle.commonReset(t,n,i,!0,!1),i.animIn.height=n.cycleH}),i.cssBefore.left=0,i.cssBefore.top=0,i.cssBefore.height=0,i.animIn.height="show",i.animOut.height=0},e.fn.cycle.transitions.shuffle=function(t,n,i){var c,s=t.css("overflow","visible").width();for(n.css({left:0,top:0}),i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i,!0,!0,!0)}),i.speedAdjusted||(i.speed=i.speed/2,i.speedAdjusted=!0),i.random=0,i.shuffle=i.shuffle||{left:-s,top:15},i.els=[],c=0;c<n.length;c++)i.els.push(n[c]);for(c=0;c<i.currSlide;c++)i.els.push(i.els.shift());i.fxFn=function(t,n,i,c,s){i.rev&&(s=!s);var o=e(s?t:n);e(n).css(i.cssBefore);var r=i.slideCount;o.animate(i.shuffle,i.speedIn,i.easeIn,function(){for(var n=e.fn.cycle.hopsFromLast(i,s),l=0;n>l;l++)s?i.els.push(i.els.shift()):i.els.unshift(i.els.pop());if(s)for(var a=0,f=i.els.length;f>a;a++)e(i.els[a]).css("z-index",f-a+r);else{var u=e(t).css("z-index");o.css("z-index",parseInt(u,10)+1+r)}o.animate({left:0,top:0},i.speedOut,i.easeOut,function(){e(s?this:t).hide(),c&&c()})})},e.extend(i.cssBefore,{display:"block",opacity:1,top:0,left:0})},e.fn.cycle.transitions.turnUp=function(t,n,i){i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i,!0,!1),i.cssBefore.top=n.cycleH,i.animIn.height=n.cycleH,i.animOut.width=n.cycleW}),i.cssFirst.top=0,i.cssBefore.left=0,i.cssBefore.height=0,i.animIn.top=0,i.animOut.height=0},e.fn.cycle.transitions.turnDown=function(t,n,i){i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i,!0,!1),i.animIn.height=n.cycleH,i.animOut.top=t.cycleH}),i.cssFirst.top=0,i.cssBefore.left=0,i.cssBefore.top=0,i.cssBefore.height=0,i.animOut.height=0},e.fn.cycle.transitions.turnLeft=function(t,n,i){i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i,!1,!0),i.cssBefore.left=n.cycleW,i.animIn.width=n.cycleW}),i.cssBefore.top=0,i.cssBefore.width=0,i.animIn.left=0,i.animOut.width=0},e.fn.cycle.transitions.turnRight=function(t,n,i){i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i,!1,!0),i.animIn.width=n.cycleW,i.animOut.left=t.cycleW}),e.extend(i.cssBefore,{top:0,left:0,width:0}),i.animIn.left=0,i.animOut.width=0},e.fn.cycle.transitions.zoom=function(t,n,i){i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i,!1,!1,!0),i.cssBefore.top=n.cycleH/2,i.cssBefore.left=n.cycleW/2,e.extend(i.animIn,{top:0,left:0,width:n.cycleW,height:n.cycleH}),e.extend(i.animOut,{width:0,height:0,top:t.cycleH/2,left:t.cycleW/2})}),i.cssFirst.top=0,i.cssFirst.left=0,i.cssBefore.width=0,i.cssBefore.height=0},e.fn.cycle.transitions.fadeZoom=function(t,n,i){i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i,!1,!1),i.cssBefore.left=n.cycleW/2,i.cssBefore.top=n.cycleH/2,e.extend(i.animIn,{top:0,left:0,width:n.cycleW,height:n.cycleH})}),i.cssBefore.width=0,i.cssBefore.height=0,i.animOut.opacity=0},e.fn.cycle.transitions.blindX=function(t,n,i){var c=t.css("overflow","hidden").width();i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i),i.animIn.width=n.cycleW,i.animOut.left=t.cycleW}),i.cssBefore.left=c,i.cssBefore.top=0,i.animIn.left=0,i.animOut.left=c},e.fn.cycle.transitions.blindY=function(t,n,i){var c=t.css("overflow","hidden").height();i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i),i.animIn.height=n.cycleH,i.animOut.top=t.cycleH}),i.cssBefore.top=c,i.cssBefore.left=0,i.animIn.top=0,i.animOut.top=c},e.fn.cycle.transitions.blindZ=function(t,n,i){var c=t.css("overflow","hidden").height(),s=t.width();i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i),i.animIn.height=n.cycleH,i.animOut.top=t.cycleH}),i.cssBefore.top=c,i.cssBefore.left=s,i.animIn.top=0,i.animIn.left=0,i.animOut.top=c,i.animOut.left=s},e.fn.cycle.transitions.growX=function(t,n,i){i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i,!1,!0),i.cssBefore.left=this.cycleW/2,i.animIn.left=0,i.animIn.width=this.cycleW,i.animOut.left=0}),i.cssBefore.top=0,i.cssBefore.width=0},e.fn.cycle.transitions.growY=function(t,n,i){i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i,!0,!1),i.cssBefore.top=this.cycleH/2,i.animIn.top=0,i.animIn.height=this.cycleH,i.animOut.top=0}),i.cssBefore.height=0,i.cssBefore.left=0},e.fn.cycle.transitions.curtainX=function(t,n,i){i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i,!1,!0,!0),i.cssBefore.left=n.cycleW/2,i.animIn.left=0,i.animIn.width=this.cycleW,i.animOut.left=t.cycleW/2,i.animOut.width=0}),i.cssBefore.top=0,i.cssBefore.width=0},e.fn.cycle.transitions.curtainY=function(t,n,i){i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i,!0,!1,!0),i.cssBefore.top=n.cycleH/2,i.animIn.top=0,i.animIn.height=n.cycleH,i.animOut.top=t.cycleH/2,i.animOut.height=0}),i.cssBefore.height=0,i.cssBefore.left=0},e.fn.cycle.transitions.cover=function(t,n,i){var c=i.direction||"left",s=t.css("overflow","hidden").width(),o=t.height();i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i),i.cssAfter.display="","right"==c?i.cssBefore.left=-s:"up"==c?i.cssBefore.top=o:"down"==c?i.cssBefore.top=-o:i.cssBefore.left=s}),i.animIn.left=0,i.animIn.top=0,i.cssBefore.top=0,i.cssBefore.left=0},e.fn.cycle.transitions.uncover=function(t,n,i){var c=i.direction||"left",s=t.css("overflow","hidden").width(),o=t.height();i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i,!0,!0,!0),"right"==c?i.animOut.left=s:"up"==c?i.animOut.top=-o:"down"==c?i.animOut.top=o:i.animOut.left=-s}),i.animIn.left=0,i.animIn.top=0,i.cssBefore.top=0,i.cssBefore.left=0},e.fn.cycle.transitions.toss=function(t,n,i){var c=t.css("overflow","visible").width(),s=t.height();i.before.push(function(t,n,i){e.fn.cycle.commonReset(t,n,i,!0,!0,!0),i.animOut.left||i.animOut.top?i.animOut.opacity=0:e.extend(i.animOut,{left:2*c,top:-s/2,opacity:0})}),i.cssBefore.left=0,i.cssBefore.top=0,i.animIn.left=0},e.fn.cycle.transitions.wipe=function(t,n,i){var c=t.css("overflow","hidden").width(),s=t.height();i.cssBefore=i.cssBefore||{};var o;if(i.clip)if(/l2r/.test(i.clip))o="rect(0px 0px "+s+"px 0px)";else if(/r2l/.test(i.clip))o="rect(0px "+c+"px "+s+"px "+c+"px)";else if(/t2b/.test(i.clip))o="rect(0px "+c+"px 0px 0px)";else if(/b2t/.test(i.clip))o="rect("+s+"px "+c+"px "+s+"px 0px)";else if(/zoom/.test(i.clip)){var r=parseInt(s/2,10),l=parseInt(c/2,10);o="rect("+r+"px "+l+"px "+r+"px "+l+"px)"}i.cssBefore.clip=i.cssBefore.clip||o||"rect(0px 0px 0px 0px)";var a=i.cssBefore.clip.match(/(\d+)/g),f=parseInt(a[0],10),u=parseInt(a[1],10),d=parseInt(a[2],10),h=parseInt(a[3],10);i.before.push(function(t,n,i){if(t!=n){var o=e(t),r=e(n);e.fn.cycle.commonReset(t,n,i,!0,!0,!1),i.cssAfter.display="block";var l=1,a=parseInt(i.speedIn/13,10)-1;!function p(){var e=f?f-parseInt(l*(f/a),10):0,t=h?h-parseInt(l*(h/a),10):0,n=s>d?d+parseInt(l*((s-d)/a||1),10):s,i=c>u?u+parseInt(l*((c-u)/a||1),10):c;r.css({clip:"rect("+e+"px "+i+"px "+n+"px "+t+"px)"}),l++<=a?setTimeout(p,13):o.css("display","none")}()}}),e.extend(i.cssBefore,{display:"block",opacity:1,top:0,left:0}),i.animIn={left:0},i.animOut={left:0}}}(jQuery);
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/js/main.js b/plugins/jetpack/modules/shortcodes/js/main.js deleted file mode 100644 index c6ed9d07..00000000 --- a/plugins/jetpack/modules/shortcodes/js/main.js +++ /dev/null @@ -1,258 +0,0 @@ -(function($){ - var jmpressOpts = { - fullscreen : false, - hash : { use : false }, - mouse : { clickSelects : false }, - keyboard : { use : true }, - animation : { transitionDuration : '1s' }, - presentationMode : false, - stepSelector : '.step', - duration : { - defaultValue: 0 - } - }; - - /** - * Presentation constructor - */ - function Presentation (wrapper) { - var _self, duration, new_css, ie_regex, matches; - - _self = this; - - _self.wrapper = $(wrapper); // The wrapper for toggling fullscreen - _self.slideshow = $('.presentation', wrapper); // Holds the slides for jmpress - _self.navLeft = $('.nav-arrow-left', wrapper); - _self.navRight = $('.nav-arrow-right', wrapper); - _self.expandButton = $('.nav-fullscreen-button', wrapper); - _self.overlay = $('.autoplay-overlay', wrapper); - _self.fullscreen = false; - _self.autoPlaying = false; - _self.autoplayTime = parseFloat(_self.slideshow.attr('data-autoplay'), 10) || 0; - - // The wrapper is scaled to the contents' size so that its border wraps tightly - _self.wrapper.css({ - width: _self.slideshow.width(), - height: _self.slideshow.height() - }); - - duration = _self.slideshow.attr('duration') || '1s'; - jmpressOpts.animation.transitionDuration = duration; - - // Compensate for transition times - if( _self.autoplayTime ) { - _self.autoplayTime += parseFloat(duration, 10) * 1000; - } - - // Set the opacity transition duration - // as it is delegated by css and not jmpress - duration = 'opacity ' + duration; - new_css = { - 'width' : _self.slideshow.width(), - 'height' : _self.slideshow.height(), - '-webkit-transition': duration, - '-moz-transition' : duration, - '-ms-transition' : duration, - '-o-transition' : duration, - 'transition' : duration - }; - - $('.step', _self.slideshow).each(function(i, step) { - $(step).css(new_css); - }); - - // Apply attribute to allow fading individual bullets here, - // otherwise wp_kses will strip the attribute out - $('.step.fadebullets li', _self.slideshow).each(function(i, step) { - $(step).attr('data-jmpress', 'fade'); - }); - - // Register resizing to window when fullscreen - $(window).resize(function() { - if ( _self.fullscreen ) { - _self.resizePresentation(); - } - }); - - // Register the nav bars to move the slides - _self.navLeft.on('click', function(){ - _self.slideshow.jmpress('prev'); - _self.overlay.css('opacity', 0); - return false; - }); - - _self.navRight.on('click', function(){ - _self.slideshow.jmpress('next'); - _self.overlay.css('opacity', 0); - return false; - }); - - _self.slideshow.on('click', function() { - _self.setAutoplay(true); - return false; - }); - - _self.slideshow.on('focusout', function() { - _self.setAutoplay(false); - }); - - // Register toggling fullscreen except for IE 9 or lower - ie_regex = /MSIE\s(\d+)\.\d+/; - matches = ie_regex.exec(navigator.userAgent); - - if ( matches && parseInt(matches[1], 10) < 10 ) { - _self.expandButton.remove(); - _self.expandButton = null; - } else { - _self.expandButton.on('click', function() { - _self.setFullscreen( !_self.fullscreen ); - return false; - }); - } - - // Register ESC key to exit fullscreen - $(window).on('keydown', function( event ) { - if ( event.which === 27 ) { - _self.setFullscreen( false ); - } - }); - - // Start the presentation - _self.slideshow.jmpress(jmpressOpts); - - // Make content visible and remove error message on jmpress success - if ( _self.slideshow.jmpress('initialized') ) { - _self.slideshow.css('display', ''); - _self.overlay.css('display', ''); - $('.not-supported-msg', _self.wrapper).remove(); - } - - // A bug in Firefox causes issues with the nav arrows appearing - // on hover in presentation mode. Explicitly disabling fullscreen - // on init seems to fix the issue - _self.setFullscreen( false ); - } - - $.extend( Presentation.prototype, { - resizePresentation: function () { - var scale, duration, settings, new_css, widthScale, heightScale; - - // Set the animation duration to 0 during resizing - // so that there isn't an animation delay when scaling - // up the slide contents - settings = this.slideshow.jmpress('settings'); - duration = settings.animation.transitionDuration; - - settings.animation.transitionDuration = '0s'; - this.slideshow.jmpress('reselect'); - - scale = 1; - new_css = { - top : 0, - left : 0, - zoom : 1 - }; - - // Expand the presentation to fill the lesser of the max width or height - // This avoids content moving past the window for certain window sizes - if ( this.fullscreen ) { - widthScale = $(window).width() / this.slideshow.width(); - heightScale = $(window).height() / this.slideshow.height(); - - scale = Math.min(widthScale, heightScale); - - new_css.top = ( $(window).height() - (scale * this.slideshow.height()) ) / 2; - new_css.left = ( $(window).width() - (scale * this.slideshow.width() ) ) / 2; - } - - // Firefox does not support the zoom property; IE does, but it does not work - // well like in webkit, so we manually transform and position the slideshow - if ( this.slideshow.css('-moz-transform') || this.slideshow.css('-ms-transform') ) { - // Firefox keeps the center of the element in place and expands outward - // so we must shift everything to compensate - new_css.top += (scale - 1) * this.slideshow.height() / 2; - new_css.left += (scale - 1) * this.slideshow.width() / 2; - - scale = 'scale(' + scale + ')'; - - $.extend(new_css, { - '-moz-transform' : scale, - '-ms-transform' : scale, - 'transform' : scale - }); - } else { - // webkit scales everything with zoom so we need to offset the right amount - // so that the content is vertically centered after scaling effects - new_css.top /= scale; - new_css.left /= scale; - new_css.zoom = scale; - } - - this.slideshow.css(new_css); - - settings.animation.transitionDuration = duration; - this.slideshow.jmpress('reselect'); - }, - - setFullscreen: function ( on ) { - this.fullscreen = on; - this.setAutoplay(false); - - // Save the scroll positions before going into fullscreen mode - if ( on ) { - this.scrollVert = $(window).scrollTop(); - this.scrollHoriz = $(window).scrollLeft(); - - // Chrome Bug: Force scroll to be at top - // otherwise the presentation can end up offscreen - $(window).scrollTop(0); - $(window).scrollLeft(0); - } - - $('html').toggleClass('presentation-global-fullscreen', on); - $('body').toggleClass('presentation-global-fullscreen', on); - - this.wrapper.toggleClass('presentation-wrapper-fullscreen', on); - - this.wrapper.parents().each(function(i, e){ - $(e).toggleClass('presentation-wrapper-fullscreen-parent', on); - }); - - this.resizePresentation(); - - // Reset the scroll positions after exiting fullscreen mode - if ( !on ) { - $(window).scrollTop(this.scrollVert); - $(window).scrollLeft(this.scrollHoriz); - } - }, - - setAutoplay: function ( on ) { - var _self = this, newAutoplayTime; - - if ( _self.autoPlaying === on ) { - return; - } - - newAutoplayTime = (on && _self.autoplayTime > 0) ? _self.autoplayTime : 0; - _self.slideshow.jmpress('settings').duration.defaultValue = newAutoplayTime; - - // Move to the next slide when activating autoplay - if( newAutoplayTime ) { - _self.slideshow.jmpress('next'); - _self.overlay.css('opacity', 0); - } else { - _self.slideshow.jmpress('reselect'); - } - - _self.autoPlaying = on; - } - }); - - $( document ).ready( function(){ - $('.presentation-wrapper').map(function() { - new Presentation(this); - }); - }); - -})(jQuery); diff --git a/plugins/jetpack/modules/shortcodes/js/quiz.js b/plugins/jetpack/modules/shortcodes/js/quiz.js deleted file mode 100644 index 5a43c9bc..00000000 --- a/plugins/jetpack/modules/shortcodes/js/quiz.js +++ /dev/null @@ -1,55 +0,0 @@ -(function($){ - $.fn.shuffleQuiz = function() { - var allElems = this.get(), - getRandom = function(max) { - return Math.floor(Math.random() * max); - }, - shuffled = $.map(allElems, function(){ - var random = getRandom(allElems.length), - randEl = $(allElems[random]).clone(true)[0]; - allElems.splice(random, 1); - return randEl; - }); - - this.each(function(i){ - $(this).replaceWith($(shuffled[i])); - }); - - return $(shuffled); - }; -})(jQuery); - -jQuery( function( $ ) { - $( '.jetpack-quiz' ).each( function() { - var quiz = $(this); - quiz.find( 'div.jetpack-quiz-answer' ).shuffleQuiz(); - quiz.find( 'div[data-correct]' ).removeAttr( 'data-correct' ).data( 'correct', 1 ); - quiz.find( 'div.jetpack-quiz-answer:last' ).addClass( 'last' ); - }); - - $( 'div.jetpack-quiz' ).on( 'click', 'div.jetpack-quiz-answer', function() { - var trackid, answer = $( this ), - quiz = answer.closest( 'div.jetpack-quiz' ); - - if ( quiz.data( 'a8ctraining' ) ) { - new Image().src = '//pixel.wp.com/b.gif?v=wpcom-no-pv&x_trainingchaos-' + quiz.data( 'username' ) + '=' + quiz.data( 'a8ctraining' ) + '&rand=' + Math.random(); - quiz.data( 'a8ctraining', false ); - quiz.data( 'trackid', false ); - } - - trackid = quiz.data( 'trackid' ); - if ( answer.data( 'correct' ) ) { - answer.addClass( 'correct' ); - if ( trackid ) { - new Image().src = '//pixel.wp.com/b.gif?v=wpcom-no-pv&x_quiz-' + trackid + '=correct&rand=' + Math.random(); - } - } else { - answer.addClass( 'wrong' ); - if ( trackid ) { - new Image().src = '//pixel.wp.com/b.gif?v=wpcom-no-pv&x_quiz-' + trackid + '=wrong&rand=' + Math.random(); - } - } - // only track the first answer - quiz.data( 'trackid', false ); - }); -} ); diff --git a/plugins/jetpack/modules/shortcodes/js/recipes-printthis.js b/plugins/jetpack/modules/shortcodes/js/recipes-printthis.js deleted file mode 100644 index 4561642d..00000000 --- a/plugins/jetpack/modules/shortcodes/js/recipes-printthis.js +++ /dev/null @@ -1,289 +0,0 @@ -// jshint ignore: start -/* - * printThis v1.9.0 - * @desc Printing plug-in for jQuery - * @author Jason Day - * - * Resources (based on) : - * jPrintArea: http://plugins.jquery.com/project/jPrintArea - * jqPrint: https://github.com/permanenttourist/jquery.jqprint - * Ben Nadal: http://www.bennadel.com/blog/1591-Ask-Ben-Print-Part-Of-A-Web-Page-With-jQuery.htm - * - * Licensed under the MIT licence: - * http://www.opensource.org/licenses/mit-license.php - * - * (c) Jason Day 2015 - * - * Usage: - * - * $("#mySelector").printThis({ - * debug: false, * show the iframe for debugging - * importCSS: true, * import page CSS - * importStyle: false, * import style tags - * printContainer: true, * grab outer container as well as the contents of the selector - * loadCSS: "path/to/my.css", * path to additional css file - us an array [] for multiple - * pageTitle: "", * add title to print page - * removeInline: false, * remove all inline styles from print elements - * printDelay: 333, * variable print delay - * header: null, * prefix to html - * footer: null, * postfix to html - * base: false, * preserve the BASE tag, or accept a string for the URL - * formValues: true * preserve input/form values - * canvas: false * copy canvas elements (experimental) - * doctypeString: '...' * enter a different doctype for older markup - * }); - * - * Notes: - * - the loadCSS will load additional css (with or without @media print) into the iframe, adjusting layout - * - * jshint onevar: false, smarttabs: true, devel: true - */ -; -(function($) { - var opt; - $.fn.printThis = function(options) { - opt = $.extend({}, $.fn.printThis.defaults, options); - var $element = this instanceof jQuery ? this : $(this); - - var strFrameName = "printThis-" + (new Date()).getTime(); - - if (window.location.hostname !== document.domain && navigator.userAgent.match(/msie/i)) { - // Ugly IE hacks due to IE not inheriting document.domain from parent - // checks if document.domain is set by comparing the host name against document.domain - var iframeSrc = "javascript:document.write(\"<head><script>document.domain=\\\"" + document.domain + "\\\";</s" + "cript></head><body></body>\")"; - var printI = document.createElement('iframe'); - printI.name = "printIframe"; - printI.id = strFrameName; - printI.className = "MSIE"; - document.body.appendChild(printI); - printI.src = iframeSrc; - - } else { - // other browsers inherit document.domain, and IE works if document.domain is not explicitly set - var $frame = $("<iframe id='" + strFrameName + "' name='printIframe' />"); - $frame.appendTo("body"); - } - - - var $iframe = $("#" + strFrameName); - - // show frame if in debug mode - if (!opt.debug) $iframe.css({ - position: "absolute", - width: "0px", - height: "0px", - left: "-600px", - top: "-600px" - }); - - // $iframe.ready() and $iframe.load were inconsistent between browsers - setTimeout(function() { - - // Add doctype to fix the style difference between printing and render - function setDocType($iframe,doctype){ - var win, doc; - win = $iframe.get(0); - win = win.contentWindow || win.contentDocument || win; - doc = win.document || win.contentDocument || win; - doc.open(); - doc.write(doctype); - doc.close(); - } - if(opt.doctypeString){ - setDocType($iframe,opt.doctypeString); - } - - var $doc = $iframe.contents(), - $head = $doc.find("head"), - $body = $doc.find("body"), - $base = $('base'), - baseURL; - - // add base tag to ensure elements use the parent domain - if (opt.base === true && $base.length > 0) { - // take the base tag from the original page - baseURL = $base.attr('href'); - } else if (typeof opt.base === 'string') { - // An exact base string is provided - baseURL = opt.base; - } else { - // Use the page URL as the base - baseURL = document.location.protocol + '//' + document.location.host; - } - - $head.append('<base href="' + baseURL + '">'); - - // import page stylesheets - if (opt.importCSS) $("link[rel=stylesheet]").each(function() { - var href = $(this).attr("href"); - if (href) { - var media = $(this).attr("media") || "all"; - $head.append("<link type='text/css' rel='stylesheet' href='" + href + "' media='" + media + "'>"); - } - }); - - // import style tags - if (opt.importStyle) $("style").each(function() { - $(this).clone().appendTo($head); - }); - - // add title of the page - if (opt.pageTitle) $head.append("<title>" + opt.pageTitle + "</title>"); - - // import additional stylesheet(s) - if (opt.loadCSS) { - if( $.isArray(opt.loadCSS)) { - jQuery.each(opt.loadCSS, function(index, value) { - $head.append("<link type='text/css' rel='stylesheet' href='" + this + "'>"); - }); - } else { - $head.append("<link type='text/css' rel='stylesheet' href='" + opt.loadCSS + "'>"); - } - } - - // print header - if (opt.header) $body.append(opt.header); - - if (opt.canvas) { - // add canvas data-ids for easy access after the cloning. - var canvasId = 0; - $element.find('canvas').each(function(){ - $(this).attr('data-printthis', canvasId++); - }); - } - - // grab $.selector as container - if (opt.printContainer) $body.append($element.outer()); - - // otherwise just print interior elements of container - else $element.each(function() { - $body.append($(this).html()); - }); - - if (opt.canvas) { - // Re-draw new canvases by referencing the originals - $body.find('canvas').each(function(){ - var cid = $(this).data('printthis'), - $src = $('[data-printthis="' + cid + '"]'); - - this.getContext('2d').drawImage($src[0], 0, 0); - - // Remove the mark-up from the original - $src.removeData('printthis'); - }); - } - - // capture form/field values - if (opt.formValues) { - // loop through inputs - var $input = $element.find('input'); - if ($input.length) { - $input.each(function() { - var $this = $(this), - $name = $(this).attr('name'), - $checker = $this.is(':checkbox') || $this.is(':radio'), - $iframeInput = $doc.find('input[name="' + $name + '"]'), - $value = $this.val(); - - // order matters here - if (!$checker) { - $iframeInput.val($value); - } else if ($this.is(':checked')) { - if ($this.is(':checkbox')) { - $iframeInput.attr('checked', 'checked'); - } else if ($this.is(':radio')) { - $doc.find('input[name="' + $name + '"][value="' + $value + '"]').attr('checked', 'checked'); - } - } - - }); - } - - // loop through selects - var $select = $element.find('select'); - if ($select.length) { - $select.each(function() { - var $this = $(this), - $name = $(this).attr('name'), - $value = $this.val(); - $doc.find('select[name="' + $name + '"]').val($value); - }); - } - - // loop through textareas - var $textarea = $element.find('textarea'); - if ($textarea.length) { - $textarea.each(function() { - var $this = $(this), - $name = $(this).attr('name'), - $value = $this.val(); - $doc.find('textarea[name="' + $name + '"]').val($value); - }); - } - } // end capture form/field values - - // remove inline styles - if (opt.removeInline) { - // $.removeAttr available jQuery 1.7+ - if ($.isFunction($.removeAttr)) { - $doc.find("body *").removeAttr("style"); - } else { - $doc.find("body *").attr("style", ""); - } - } - - // print "footer" - if (opt.footer) $body.append(opt.footer); - - setTimeout(function() { - if ($iframe.hasClass("MSIE")) { - // check if the iframe was created with the ugly hack - // and perform another ugly hack out of neccessity - window.frames["printIframe"].focus(); - $head.append("<script> window.print(); </s" + "cript>"); - } else { - // proper method - if (document.queryCommandSupported("print")) { - $iframe[0].contentWindow.document.execCommand("print", false, null); - } else { - $iframe[0].contentWindow.focus(); - $iframe[0].contentWindow.print(); - } - } - - // remove iframe after print - if (!opt.debug) { - setTimeout(function() { - $iframe.remove(); - }, 1000); - } - - }, opt.printDelay); - - }, 333); - - }; - - // defaults - $.fn.printThis.defaults = { - debug: false, // show the iframe for debugging - importCSS: true, // import parent page css - importStyle: false, // import style tags - printContainer: true, // print outer container/$.selector - loadCSS: "", // load an additional css file - load multiple stylesheets with an array [] - pageTitle: "", // add title to print page - removeInline: false, // remove all inline styles - printDelay: 333, // variable print delay - header: null, // prefix to html - footer: null, // postfix to html - formValues: true, // preserve input/form values - canvas: false, // Copy canvas content (experimental) - base: false, // preserve the BASE tag, or accept a string for the URL - doctypeString: '<!DOCTYPE html>' // html doctype - }; - - // $.selector container - jQuery.fn.outer = function() { - return $($("<div></div>").html(this.clone())).html(); - } -})(jQuery); diff --git a/plugins/jetpack/modules/shortcodes/js/recipes.js b/plugins/jetpack/modules/shortcodes/js/recipes.js deleted file mode 100644 index 3c987acc..00000000 --- a/plugins/jetpack/modules/shortcodes/js/recipes.js +++ /dev/null @@ -1,11 +0,0 @@ -/* global jetpack_recipes_vars */ -( function( $ ) { - $( window ).load( function() { - $( '.jetpack-recipe-print a' ).click( function( event ) { - event.preventDefault(); - - // Print the DIV. - $( this ).closest( '.jetpack-recipe' ).printThis( { pageTitle: jetpack_recipes_vars.pageTitle, loadCSS: jetpack_recipes_vars.loadCSS } ); - } ); - } ); -} )( jQuery ); diff --git a/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js b/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js deleted file mode 100644 index e17a2d74..00000000 --- a/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js +++ /dev/null @@ -1,194 +0,0 @@ -/* jshint onevar:false, loopfunc:true */ -/* global jetpackSlideshowSettings, escape */ - -function JetpackSlideshow( element, transition, autostart ) { - this.element = element; - this.images = []; - this.controls = {}; - this.transition = transition || 'fade'; - this.autostart = autostart; -} - -JetpackSlideshow.prototype.showLoadingImage = function( toggle ) { - if ( toggle ) { - this.loadingImage_ = document.createElement( 'div' ); - this.loadingImage_.className = 'slideshow-loading'; - var img = document.createElement( 'img' ); - img.src = jetpackSlideshowSettings.spinner; - this.loadingImage_.appendChild( img ); - this.loadingImage_.appendChild( this.makeZeroWidthSpan() ); - this.element.append( this.loadingImage_ ); - } else if ( this.loadingImage_ ) { - this.loadingImage_.parentNode.removeChild( this.loadingImage_ ); - this.loadingImage_ = null; - } -}; - -JetpackSlideshow.prototype.init = function() { - this.showLoadingImage(true); - - var self = this; - // Set up DOM. - for ( var i = 0; i < this.images.length; i++ ) { - var imageInfo = this.images[i]; - var img = document.createElement( 'img' ); - img.src = imageInfo.src; - img.title = typeof( imageInfo.title ) !== 'undefined' ? imageInfo.title : ''; - img.alt = typeof( imageInfo.alt ) !== 'undefined' ? imageInfo.alt : ''; - img.align = 'middle'; - img.setAttribute('itemprop','image'); - img.nopin = 'nopin'; - var caption = document.createElement( 'div' ); - caption.className = 'slideshow-slide-caption'; - caption.setAttribute('itemprop','caption description'); - caption.innerHTML = imageInfo.caption; - var container = document.createElement('div'); - container.className = 'slideshow-slide'; - container.setAttribute('itemprop','associatedMedia'); - container.setAttribute('itemscope',''); - container.setAttribute('itemtype','https://schema.org/ImageObject'); - - // Hide loading image once first image has loaded. - if ( i === 0 ) { - if ( img.complete ) { - // IE, image in cache - setTimeout( function() { - self.finishInit_(); - }, 1); - } else { - jQuery( img ).load(function() { - self.finishInit_(); - }); - } - } - container.appendChild( img ); - // I'm not sure where these were coming from, but IE adds - // bad values for width/height for portrait-mode images - img.removeAttribute('width'); - img.removeAttribute('height'); - container.appendChild( this.makeZeroWidthSpan() ); - container.appendChild( caption ); - this.element.append( container ); - } -}; - -JetpackSlideshow.prototype.makeZeroWidthSpan = function() { - var emptySpan = document.createElement( 'span' ); - emptySpan.className = 'slideshow-line-height-hack'; - // Having a NBSP makes IE act weird during transitions, but other - // browsers ignore a text node with a space in it as whitespace. - if ( -1 !== window.navigator.userAgent.indexOf( 'MSIE ' ) ) { - emptySpan.appendChild( document.createTextNode(' ') ); - } else { - emptySpan.innerHTML = ' '; - } - return emptySpan; -}; - -JetpackSlideshow.prototype.finishInit_ = function() { - this.showLoadingImage( false ); - this.renderControls_(); - - var self = this; - if ( this.images.length > 1 ) { - // Initialize Cycle instance. - this.element.cycle( { - fx: this.transition, - prev: this.controls.prev, - next: this.controls.next, - timeout: jetpackSlideshowSettings.speed, - slideExpr: '.slideshow-slide', - onPrevNextEvent: function() { - return self.onCyclePrevNextClick_.apply( self, arguments ); - } - } ); - - var slideshow = this.element; - - if ( ! this.autostart ) { - slideshow.cycle( 'pause' ); - jQuery(this.controls.stop).removeClass( 'running' ); - jQuery(this.controls.stop).addClass( 'paused' ); - } - - jQuery( this.controls.stop ).click( function() { - var button = jQuery(this); - if ( ! button.hasClass( 'paused' ) ) { - slideshow.cycle( 'pause' ); - button.removeClass( 'running' ); - button.addClass( 'paused' ); - } else { - button.addClass( 'running' ); - button.removeClass( 'paused' ); - slideshow.cycle( 'resume', true ); - } - return false; - } ); - } else { - this.element.children( ':first' ).show(); - this.element.css( 'position', 'relative' ); - } - this.initialized_ = true; -}; - -JetpackSlideshow.prototype.renderControls_ = function() { - if ( this.controlsDiv_ ) { - return; - } - - var controlsDiv = document.createElement( 'div' ); - controlsDiv.className = 'slideshow-controls'; - - var controls = [ 'prev', 'stop', 'next' ]; - for ( var i = 0; i < controls.length; i++ ) { - var controlName = controls[i]; - var a = document.createElement( 'a' ); - a.href = '#'; - controlsDiv.appendChild( a ); - this.controls[controlName] = a; - } - this.element.append( controlsDiv ); - this.controlsDiv_ = controlsDiv; -}; - -JetpackSlideshow.prototype.onCyclePrevNextClick_ = function( isNext, i/*, slideElement*/ ) { - // If blog_id not present don't track page views - if ( ! jetpackSlideshowSettings.blog_id ) { - return; - } - - var postid = this.images[i].id; - var stats = new Image(); - stats.src = document.location.protocol + - '//pixel.wp.com/g.gif?host=' + - escape( document.location.host ) + - '&rand=' + Math.random() + - '&blog=' + jetpackSlideshowSettings.blog_id + - '&subd=' + jetpackSlideshowSettings.blog_subdomain + - '&user_id=' + jetpackSlideshowSettings.user_id + - '&post=' + postid + - '&ref=' + escape( document.location ); -}; - -( function ( $ ) { - function jetpack_slideshow_init() { - $( '.jetpack-slideshow-noscript' ).remove(); - - $( '.jetpack-slideshow' ).each( function () { - var container = $( this ); - - if ( container.data( 'processed' ) ) { - return; - } - - var slideshow = new JetpackSlideshow( container, container.data( 'trans' ), container.data( 'autostart' ) ); - slideshow.images = container.data( 'gallery' ); - slideshow.init(); - - container.data( 'processed', true ); - } ); - } - - $( document ).ready( jetpack_slideshow_init ); - $( 'body' ).on( 'post-load', jetpack_slideshow_init ); -} )( jQuery ); diff --git a/plugins/jetpack/modules/shortcodes/kickstarter.php b/plugins/jetpack/modules/shortcodes/kickstarter.php deleted file mode 100644 index 1e6664bb..00000000 --- a/plugins/jetpack/modules/shortcodes/kickstarter.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php -/** - * Kickstarter shortcode - * - * Usage: - * [kickstarter url="https://www.kickstarter.com/projects/peaktoplateau/yak-wool-baselayers-from-tibet-to-the-world" width="480" height=""] - * - * @package Jetpack - */ - -add_shortcode( 'kickstarter', 'jetpack_kickstarter_shortcode' ); -add_filter( 'pre_kses', 'jetpack_kickstarter_embed_to_shortcode' ); - -/** - * Parse shortcode arguments and render its output. - * - * @since 4.5.0 - * - * @param array $atts Shortcode parameters. - * - * @return string - */ -function jetpack_kickstarter_shortcode( $atts ) { - if ( empty( $atts['url'] ) ) { - return ''; - } - - $url = esc_url_raw( $atts['url'] ); - if ( ! preg_match( '#^(www\.)?kickstarter\.com$#i', wp_parse_url( $url, PHP_URL_HOST ) ) ) { - return '<!-- Invalid Kickstarter URL -->'; - } - - global $wp_embed; - return $wp_embed->shortcode( $atts, $url ); -} - -/** - * Converts Kickstarter iframe embeds to a shortcode. - * - * EG: <iframe width="480" height="360" src="http://www.kickstarter.com/projects/deweymac/dewey-mac-kid-detective-book-make-diy-and-stem-spy/widget/video.html" frameborder="0" scrolling="no"> </iframe> - * - * @since 4.5.0 - * - * @param string $content Entry content that possibly includes a Kickstarter embed. - * - * @return string - */ -function jetpack_kickstarter_embed_to_shortcode( $content ) { - if ( ! is_string( $content ) || false === stripos( $content, 'www.kickstarter.com/projects' ) ) { - return $content; - } - - $regexp = '!<iframe((?:\s+\w+=[\'"][^\'"]*[\'"])*)\s+src=[\'"](http://www\.kickstarter\.com/projects/[^/]+/[^/]+)/[^\'"]+[\'"]((?:\s+\w+=[\'"][^\'"]*[\'"])*)>[\s]*</iframe>!i'; - $regexp_ent = str_replace( '&#0*58;', '&#0*58;|�*58;', htmlspecialchars( $regexp, ENT_NOQUOTES ) ); // phpcs:ignore - - foreach ( array( 'regexp', 'regexp_ent' ) as $reg ) { - if ( ! preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) { - continue; - } - - foreach ( $matches as $match ) { - $url = esc_url( $match[2] ); - - $params = $match[1] . $match[3]; - - if ( 'regexp_ent' === $reg ) { - $params = html_entity_decode( $params ); - } - - $params = wp_kses_hair( $params, array( 'http' ) ); - - $width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0; - - $shortcode = '[kickstarter url=' . $url . ( ( ! empty( $width ) ) ? " width=$width" : '' ) . ']'; - $content = str_replace( $match[0], $shortcode, $content ); - } - } - - return $content; -} diff --git a/plugins/jetpack/modules/shortcodes/mailchimp.php b/plugins/jetpack/modules/shortcodes/mailchimp.php deleted file mode 100644 index ce815673..00000000 --- a/plugins/jetpack/modules/shortcodes/mailchimp.php +++ /dev/null @@ -1,226 +0,0 @@ -<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName -/** - * MailChimp Subscriber Popup Form shortcode - * - * Example: - * [mailchimp_subscriber_popup baseUrl="mc.us11.list-manage.com" uuid="1ca7856462585a934b8674c71" lid="2d24f1898b"] - * - * Embed code example: - * <script type="text/javascript" src="//downloads.mailchimp.com/js/signup-forms/popup/unique-methods/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script><script type="text/javascript">window.dojoRequire(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us11.list-manage.com","uuid":"1ca7856462585a934b8674c71","lid":"2d24f1898b","uniqueMethods":true}) })</script> - */ - -/** - * Register [mailchimp_subscriber_popup] shortcode and add a filter to 'pre_kses' queue to reverse MailChimp embed to shortcode. - * - * @since 4.5.0 - */ -function jetpack_mailchimp_subscriber_popup() { - add_shortcode( - 'mailchimp_subscriber_popup', - array( - 'MailChimp_Subscriber_Popup', - 'shortcode', - ) - ); - add_filter( - 'pre_kses', - array( - 'MailChimp_Subscriber_Popup', - 'reversal', - ) - ); -} - -if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { - add_action( 'init', 'jetpack_mailchimp_subscriber_popup' ); -} else { - jetpack_mailchimp_subscriber_popup(); -} - -/** - * Class MailChimp_Subscriber_Popup - * - * @since 4.5.0 - */ -class MailChimp_Subscriber_Popup { - - /** - * Regular expressions to reverse script tags to shortcodes. - * - * @var array - */ - private static $reversal_regexes = array( - /* raw examplejs */ - '/<script type="text\/javascript" src="(https?:)?\/\/downloads\.mailchimp\.com\/js\/signup-forms\/popup\/unique-methods\/embed\.js" data-dojo-config="([^"]*?)"><\/script><script type="text\/javascript">window.dojoRequire\(\["mojo\/signup-forms\/Loader"\]\, function\(L\) { L\.start\({([^}]*?)}\) }\)<\/script>/s', //phpcs:ignore - /* visual editor */ - '/<script type="text\/javascript" src="(https?:)?\/\/downloads\.mailchimp\.com\/js\/signup-forms\/popup\/unique-methods\/embed\.js" data-dojo-config="([^"]*?)"><\/script><script type="text\/javascript">window.dojoRequire\(\["mojo\/signup-forms\/Loader"]\, function\(L\) { L\.start\({([^}]*?)}\) }\)<\/script>/s', - ); - - /** - * Allowed configuration attributes. Used in reversal when checking allowed attributes. - * - * @var array - */ - private static $allowed_config = array( - 'usePlainJson' => 'true', - 'isDebug' => 'false', - ); - - /** - * Allowed JS variables. Used in reversal to whitelist variables. - * - * @var array - */ - private static $allowed_js_vars = array( - 'baseUrl', - 'uuid', - 'lid', - ); - - /** - * Runs the whole reversal. - * - * @since 4.5.0 - * - * @param string $content Post Content. - * - * @return string Content with embeds replaced - */ - public static function reversal( $content ) { - // Bail without the js src. - if ( ! is_string( $content ) || false === stripos( $content, 'downloads.mailchimp.com/js/signup-forms/popup/unique-methods/embed.js' ) ) { - return $content; - } - - require_once ABSPATH . WPINC . '/class-json.php'; - $wp_json = new Services_JSON(); - - // loop through our rules and find valid embeds. - foreach ( self::$reversal_regexes as $regex ) { - - if ( ! preg_match_all( $regex, $content, $matches ) ) { - continue; - } - - foreach ( $matches[3] as $index => $js_vars ) { - // the regex rule for a specific embed. - $replace_regex = sprintf( '#\s*%s\s*#', preg_quote( $matches[0][ $index ], '#' ) ); - - $attrs = $wp_json->decode( '{' . $js_vars . '}' ); - - if ( $matches[2][ $index ] ) { - $config_attrs = $wp_json->decode( '{' . $matches[2][ $index ] . '}' ); - foreach ( $config_attrs as $key => $value ) { - $attrs->$key = ( 1 === $value ) ? 'true' : 'false'; - } - } - - $shortcode = self::build_shortcode_from_reversal_attrs( $attrs ); - - $content = preg_replace( $replace_regex, "\n\n$shortcode\n\n", $content ); - - /** This action is documented in modules/widgets/social-media-icons.php */ - do_action( 'jetpack_bump_stats_extras', 'html_to_shortcode', 'mailchimp_subscriber_popup' ); - } - } - - return $content; - } - - /** - * Builds the actual shortcode based on passed in attributes. - * - * @since 4.5.0 - * - * @param array $attrs A valid list of attributes (gets matched against self::$allowed_config and self::$allowed_js_vars). - * - * @return string - */ - private static function build_shortcode_from_reversal_attrs( $attrs ) { - $shortcode = '[mailchimp_subscriber_popup '; - - foreach ( $attrs as $key => $value ) { - // skip unsupported keys. - if ( - ! in_array( $key, array_keys( self::$allowed_config ), true ) - && ! in_array( $key, self::$allowed_js_vars, true ) - ) { - continue; - } - - $value = esc_attr( $value ); - $shortcode .= "$key='$value' "; - } - return trim( $shortcode ) . ']'; - } - - /** - * Parses the shortcode back out to embedded information. - * - * @since 4.5.0 - * - * @param array $lcase_attrs Lowercase shortcode attributes. - * - * @return string - */ - public static function shortcode( $lcase_attrs ) { - static $displayed_once = false; - - // Limit to one form per page load. - if ( $displayed_once ) { - return ''; - } - - if ( empty( $lcase_attrs ) ) { - return '<!-- Missing MailChimp baseUrl, uuid or lid -->'; - } - - $defaults = array_fill_keys( self::$allowed_js_vars, '' ); - $defaults = array_merge( $defaults, self::$allowed_config ); - - // Convert $attrs back to proper casing since they come through in all lowercase. - $attrs = array(); - foreach ( $defaults as $key => $value ) { - if ( array_key_exists( strtolower( $key ), $lcase_attrs ) ) { - $attrs[ $key ] = $lcase_attrs[ strtolower( $key ) ]; - } - } - $attrs = array_map( 'esc_js', array_filter( shortcode_atts( $defaults, $attrs ) ) ); - - // Split config & js vars. - $js_vars = array(); - $config_vars = array(); - foreach ( $attrs as $key => $value ) { - if ( - 'baseUrl' === $key - && ( - ! preg_match( '#mc\.us\d+\.list-manage\d?\.com#', $value, $matches ) - || $value !== $matches[0] - ) - ) { - return '<!-- Invalid MailChimp baseUrl -->'; - } - - if ( in_array( $key, self::$allowed_js_vars, true ) ) { - $js_vars[ $key ] = $value; - } else { - $config_vars[] = "$key: $value"; - } - } - - // If one of these parameters is missing we can't render the form so exist. - if ( empty( $js_vars['baseUrl'] ) || empty( $js_vars['uuid'] ) || empty( $js_vars['lid'] ) ) { - return '<!-- Missing MailChimp baseUrl, uuid or lid -->'; - } - - // Add a uniqueMethods parameter if it is missing from the data we got from the embed code. - $js_vars['uniqueMethods'] = true; - - /** This action is already documented in modules/widgets/gravatar-profile.php */ - do_action( 'jetpack_stats_extra', 'mailchimp_subscriber_popup', 'view' ); - - $displayed_once = true; - - return "\n\n" . '<script type="text/javascript" data-dojo-config="' . esc_attr( implode( ', ', $config_vars ) ) . '">jQuery.getScript( "//downloads.mailchimp.com/js/signup-forms/popup/unique-methods/embed.js", function( data, textStatus, jqxhr ) { window.dojoRequire(["mojo/signup-forms/Loader"], function(L) { L.start(' . wp_json_encode( $js_vars ) . ') });} );</script>' . "\n\n"; - } -} diff --git a/plugins/jetpack/modules/shortcodes/medium.php b/plugins/jetpack/modules/shortcodes/medium.php deleted file mode 100644 index 02d02aaf..00000000 --- a/plugins/jetpack/modules/shortcodes/medium.php +++ /dev/null @@ -1,71 +0,0 @@ -<?php - -// Embed support for Medium https://medium.com/p/3eaed64aed8a - -/** - * Faux-oembed support for Medium permalinks - * - * e.g. - * https://medium.com/help-center - * https://medium.com/@richroll - */ -wp_embed_register_handler( 'medium', '#^https?://medium.com/([a-zA-z0-9-_@]+)#', 'jetpack_embed_medium_oembed' ); - -function jetpack_embed_medium_oembed( $matches, $attr, $url ) { - $attr = jetpack_embed_medium_args( $attr ); - $attr['url'] = $url; - - return jetpack_embed_medium_embed_html( $attr ); -} - -function jetpack_embed_medium_embed_html( $args ) { - $args = jetpack_embed_medium_args( $args ); - - if ( empty( $args['url'] ) ) { - return; - } - - $args['type'] = jetpack_embed_medium_get_embed_type( $args['url'] ); - - return sprintf( '<script async src="https://static.medium.com/embed.js"></script><a class="m-%1$s" href="%2$s" target="_blank" data-width="%3$s" data-border="%4$s" data-collapsed="%5$s">View %1$s at Medium.com</a>', esc_attr( $args['type'] ), esc_url( $args['url'] ), esc_attr( $args['width'] ), esc_attr( $args['border'] ), esc_attr( $args['collapsed'] ) ); -} - -/** - * Shortcode support that allows passing in URL - * - * [medium url="https://medium.com/help-center" width="100%" border="false" collapsed="true"] - */ -add_shortcode( 'medium', 'jetpack_embed_medium_shortcode' ); - -function jetpack_embed_medium_shortcode( $atts ) { - $atts = jetpack_embed_medium_args( $atts ); - - if ( ! empty( $atts['url'] ) ) { - global $wp_embed; - return $wp_embed->shortcode( $atts, $atts['url'] ); - } -} - -function jetpack_embed_medium_get_embed_type( $url ) { - $url_path = parse_url( $url, PHP_URL_PATH ); - if ( preg_match( '/^\/@[\.\w]+$/', $url_path ) ) { - return 'profile'; - } elseif ( preg_match( '/^\/[\da-zA-Z-]+$/', $url_path ) ) { - return 'collection'; - } - - return 'story'; -} - -function jetpack_embed_medium_args( $atts ) { - return shortcode_atts( - array( - 'url' => '', - 'width' => '400', - 'border' => true, - 'collapsed' => false, - ), - $atts, - 'medium' - ); -} diff --git a/plugins/jetpack/modules/shortcodes/mixcloud.php b/plugins/jetpack/modules/shortcodes/mixcloud.php deleted file mode 100644 index 3580a924..00000000 --- a/plugins/jetpack/modules/shortcodes/mixcloud.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php -/* - * Mixcloud embeds - * - * examples: - * [mixcloud MalibuRum/play-6-kissy-sellouts-winter-sun-house-party-mix/ /] - * [mixcloud MalibuRum/play-6-kissy-sellouts-winter-sun-house-party-mix/ width=640 height=480 /] - * [mixcloud http://www.mixcloud.com/MalibuRum/play-6-kissy-sellouts-winter-sun-house-party-mix/ /] - * [mixcloud http://www.mixcloud.com/MalibuRum/play-6-kissy-sellouts-winter-sun-house-party-mix/ width=640 height=480 /] - * [mixcloud]http://www.mixcloud.com/MalibuRum/play-6-kissy-sellouts-winter-sun-house-party-mix/[/mixcloud] - * [mixcloud]MalibuRum/play-6-kissy-sellouts-winter-sun-house-party-mix/[/mixcloud] - * [mixcloud http://www.mixcloud.com/mat/playlists/classics/ width=660 height=208 hide_cover=1 hide_tracklist=1] -*/ - -// Register oEmbed provider -// Example URL: http://www.mixcloud.com/oembed/?url=http://www.mixcloud.com/MalibuRum/play-6-kissy-sellouts-winter-sun-house-party-mix/ -wp_oembed_add_provider( '#https?://(?:www\.)?mixcloud\.com/\S*#i', 'https://www.mixcloud.com/oembed', true ); - -// Register mixcloud shortcode -add_shortcode( 'mixcloud', 'mixcloud_shortcode' ); -function mixcloud_shortcode( $atts, $content = null ) { - - if ( empty( $atts[0] ) && empty( $content ) ) { - return '<!-- mixcloud error: invalid mixcloud resource -->'; - } - - $regular_expression = '/((?<=mixcloud\\.com\\/)[\\w-\\/]+$)|(^[\\w-\\/]+$)/i'; - preg_match( $regular_expression, $content, $match ); - if ( ! empty( $match ) ) { - $resource_id = trim( $match[0] ); - } else { - preg_match( $regular_expression, $atts[0], $match ); - if ( ! empty( $match ) ) { - $resource_id = trim( $match[0] ); - } - } - - if ( empty( $resource_id ) ) { - return '<!-- mixcloud error: invalid mixcloud resource -->'; - } - - $mixcloud_url = 'https://mixcloud.com/' . $resource_id; - - $atts = shortcode_atts( - array( - 'width' => false, - 'height' => false, - 'color' => false, - 'light' => false, - 'dark' => false, - 'hide_tracklist' => false, - 'hide_cover' => false, - 'mini' => false, - 'hide_followers' => false, - 'hide_artwork' => false, - ), - $atts - ); - - // remove falsey values - $atts = array_filter( $atts ); - - $query_args = array( 'url' => $mixcloud_url ); - $query_args = array_merge( $query_args, $atts ); - - $url = add_query_arg( urlencode_deep( $query_args ), 'https://www.mixcloud.com/oembed/' ); - $mixcloud_response = wp_remote_get( $url, array( 'redirection' => 0 ) ); - if ( is_wp_error( $mixcloud_response ) || 200 !== $mixcloud_response['response']['code'] || empty( $mixcloud_response['body'] ) ) { - return '<!-- mixcloud error: invalid mixcloud resource -->'; - } - - $response_body = json_decode( $mixcloud_response['body'] ); - - return $response_body->html; -} diff --git a/plugins/jetpack/modules/shortcodes/pinterest.php b/plugins/jetpack/modules/shortcodes/pinterest.php deleted file mode 100644 index caecc619..00000000 --- a/plugins/jetpack/modules/shortcodes/pinterest.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php -/** - * Pinterest embeds - * - * Based on "Board Widget" example here: http://business.pinterest.com/widget-builder/#code - */ - -// Example URL: http://pinterest.com/pinterest/pin-pets/ -// Second Example URL: https://uk.pinterest.com/annsawesomepins/travel/ -wp_embed_register_handler( - 'pinterest', - '#' - . 'https?://' - . '(?:www\.)?' - . '(?:[a-z]{2}\.)?' - . 'pinterest\.[a-z.]+/' - . '([^/]+)' - . '(/[^/]+)?' - . '#', - 'pinterest_embed_handler' -); - -function pinterest_embed_handler( $matches, $attr, $url ) { - // Pinterest's JS handles making the embed - $script_src = '//assets.pinterest.com/js/pinit.js'; - wp_enqueue_script( 'pinterest-embed', $script_src, array(), false, true ); - - $path = parse_url( $url, PHP_URL_PATH ); - if ( 0 === strpos( $path, '/pin/' ) ) { - $embed_type = 'embedPin'; - } elseif ( preg_match( '#^/([^/]+)/?$#', $path ) ) { - $embed_type = 'embedUser'; - } elseif ( preg_match( '#^/([^/]+)/([^/]+)/?$#', $path ) ) { - $embed_type = 'embedBoard'; - } else { - if ( current_user_can( 'edit_posts' ) ) { - return __( 'Sorry, that Pinterest URL was not recognized.', 'jetpack' ); - } - return; - } - - $return = sprintf( '<a data-pin-do="%s" href="%s"></a>', esc_attr( $embed_type ), esc_url( $url ) ); - - // If we're generating an embed view for the WordPress Admin via ajax... - if ( doing_action( 'wp_ajax_parse-embed' ) ) { - $return .= sprintf( '<script src="%s"></script>', esc_url( $script_src ) ); - } - - return $return; -} diff --git a/plugins/jetpack/modules/shortcodes/polldaddy.php b/plugins/jetpack/modules/shortcodes/polldaddy.php deleted file mode 100644 index 10a62d65..00000000 --- a/plugins/jetpack/modules/shortcodes/polldaddy.php +++ /dev/null @@ -1,4 +0,0 @@ -<?php -/** - * Deprecated alias for Crowdsignal. - */ diff --git a/plugins/jetpack/modules/shortcodes/presentations.php b/plugins/jetpack/modules/shortcodes/presentations.php deleted file mode 100644 index 77089189..00000000 --- a/plugins/jetpack/modules/shortcodes/presentations.php +++ /dev/null @@ -1,465 +0,0 @@ -<?php -/* -Plugin Name: Presentations -Plugin URI: http://automattic.com/wordpress-plugins/ -Description: Presentations plugin based on the work done by <a href="http://darylkoop.com/">Daryl Koopersmith</a>. Powered by jmpress.js -Version: 0.2 -Author: Automattic -Author URI: http://automattic.com/wordpress-plugins/ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - - -/** - * Known issues: - * - * - IE 7/8 are not supported by jmpress and presentations will not work - * - IE 9 will not animate transitions at all, though it's possible to at least - * switch between slides. - * - Infinite Scroll themes will not load presentations properly unless the post - * happens to be on the first loaded page. The permalink page will function - * properly, however. - * - Exiting fullscreen mode will not properly reset the scroll locations in Safari - */ - - -/* -HOW TO: How the plugin settings are organized and which features are supported. - -The entire presentation should be wrapped with a [presentation] shortcode, and every -individual slide should be wrapped with a [slide] shortcode. Any settings supported -by [slide] can be set into [presentation], which will apply that setting for the entire -presentation unless overridden by individual slides. - -- [presentation] only settings: - - duration: transition durations, default is one second. - - height: content height, default is 400px - - width: content width, default is 550px - - autoplay: delay between transitions in seconds, default 3s - when set the presentation will automatically transition between slides - as long as the presentation remains in focus - -- [slide] settings: - - transition: specifies where the next slide will be placed relative - to the last one before it. Supported values are "up", "down" - "left", "right", or "none". Default value is "down". - - - scale: scales the content relative to other slides, default value is one - - - rotate: rotates the content by the specified degrees, default is zero - - - fade: slides will fade in and out during transition. Values of "on" or - "true" will enable fading, while values of "no" or "false" will - disable it. Default value is "on" - - - bgcolor: specifies a background color for the slides. Any CSS valid value - is permitted. Default color is transparent. - - - bgimg: specifies an image url which will fill the background. Image is - set to fill the background 100% width and height - - - fadebullets: any html <li> tags will start out with an opacity of 0 and any - subsequent slide transitions will show the bullets one by one -*/ - -if ( ! class_exists( 'Presentations' ) ) : - class Presentations { - - private $presentation_settings; - private $presentation_initialized; - private $scripts_and_style_included; - - /** - * Constructor - */ - function __construct() { - $this->presentation_initialized = false; - $this->scripts_and_style_included = false; - - // Registers shortcodes - add_action( 'wp_head', array( &$this, 'add_scripts' ), 1 ); - - add_shortcode( 'presentation', array( &$this, 'presentation_shortcode' ) ); - add_shortcode( 'slide', array( &$this, 'slide_shortcode' ) ); - } - - function add_scripts() { - $this->scripts_and_style_included = false; - - if ( empty( $GLOBALS['posts'] ) || ! is_array( $GLOBALS['posts'] ) ) { - return; - } - - foreach ( $GLOBALS['posts'] as $p ) { - if ( has_shortcode( $p->post_content, 'presentation' ) ) { - $this->scripts_and_style_included = true; - break; - } - } - - if ( ! $this->scripts_and_style_included ) { - return; - } - - $plugin = plugin_dir_url( __FILE__ ); - // Add CSS - wp_enqueue_style( 'presentations', $plugin . 'css/style.css' ); - // Add JavaScript - wp_enqueue_script( 'jquery' ); - wp_enqueue_script( - 'jmpress', - Jetpack::get_file_url_for_environment( '_inc/build/shortcodes/js/jmpress.min.js', 'modules/shortcodes/js/jmpress.js' ), - array( 'jquery' ), - '0.4.5', - true - ); - wp_enqueue_script( - 'presentations', - Jetpack::get_file_url_for_environment( '_inc/build/shortcodes/js/main.min.js', 'modules/shortcodes/js/main.js' ), - array( 'jquery', 'jmpress' ), - false, - true - ); - } - - function presentation_shortcode( $atts, $content = '' ) { - // Mark that we've found a valid [presentation] shortcode - $this->presentation_initialized = true; - - $atts = shortcode_atts( - array( - 'duration' => '', - 'height' => '', - 'width' => '', - 'bgcolor' => '', - 'bgimg' => '', - 'autoplay' => '', - - // Settings - 'transition' => '', - 'scale' => '', - 'rotate' => '', - 'fade' => '', - 'fadebullets' => '', - ), - $atts, - 'presentation' - ); - - $this->presentation_settings = array( - 'transition' => 'down', - 'scale' => 1, - 'rotate' => 0, - 'fade' => 'on', - 'fadebullets' => 0, - 'last' => array( - 'x' => 0, - 'y' => 0, - 'scale' => 1, - 'rotate' => 0, - ), - ); - - // Set the presentation-wide settings - if ( '' != trim( $atts['transition'] ) ) { - $this->presentation_settings['transition'] = $atts['transition']; - } - - if ( '' != trim( $atts['scale'] ) ) { - $this->presentation_settings['scale'] = floatval( $atts['scale'] ); - } - - if ( '' != trim( $atts['rotate'] ) ) { - $this->presentation_settings['rotate'] = floatval( $atts['rotate'] ); - } - - if ( '' != trim( $atts['fade'] ) ) { - $this->presentation_settings['fade'] = $atts['fade']; - } - - if ( '' != trim( $atts['fadebullets'] ) ) { - $this->presentation_settings['fadebullets'] = $atts['fadebullets']; - } - - // Set any settings the slides don't care about - if ( '' != trim( $atts['duration'] ) ) { - $duration = floatval( $atts['duration'] ) . 's'; - } else { - $duration = '1s'; - } - - // Autoplay durations are set in milliseconds - if ( '' != trim( $atts['autoplay'] ) ) { - $autoplay = floatval( $atts['autoplay'] ) * 1000; - } else { - $autoplay = 0; - } // No autoplay - - // Set the presentation size as specified or with some nicely sized dimensions - if ( '' != trim( $atts['width'] ) ) { - $this->presentation_settings['width'] = intval( $atts['width'] ); - } else { - $this->presentation_settings['width'] = 480; - } - - if ( '' != trim( $atts['height'] ) ) { - $this->presentation_settings['height'] = intval( $atts['height'] ); - } else { - $this->presentation_settings['height'] = 370; - } - - // Hide the content by default in case the scripts fail - $style = 'display: none; width: ' . $this->presentation_settings['width'] . 'px; height: ' . $this->presentation_settings['height'] . 'px;'; - - // Check for background color XOR background image - // Use a white background if nothing specified - if ( preg_match( '/https?\:\/\/[^\'"\s]*/', $atts['bgimg'], $matches ) ) { - $style .= ' background-image: url("' . esc_url( $matches[0] ) . '");'; - } elseif ( '' != trim( $atts['bgcolor'] ) ) { - $style .= ' background-color: ' . esc_attr( $atts['bgcolor'] ) . ';'; - } else { - $style .= ' background-color: #fff;'; - } - - // Not supported message style is inlined incase the style sheet doesn't get included - $out = "<section class='presentation-wrapper'>"; - $out .= "<p class='not-supported-msg' style='display: inherit; padding: 25%; text-align: center;'>"; - $out .= __( 'This slideshow could not be started. Try refreshing the page or viewing it in another browser.', 'jetpack' ) . '</p>'; - - // Bail out unless the scripts were added - if ( $this->scripts_and_style_included ) { - $out .= sprintf( - '<div class="presentation" duration="%s" data-autoplay="%s" style="%s">', - esc_attr( $duration ), - esc_attr( $autoplay ), - esc_attr( $style ) - ); - $out .= "<div class='nav-arrow-left'></div>"; - $out .= "<div class='nav-arrow-right'></div>"; - $out .= "<div class='nav-fullscreen-button'></div>"; - - if ( $autoplay ) { - $out .= '<div class="autoplay-overlay" style="display: none;"><p class="overlay-msg">'; - $out .= __( 'Click to autoplay the presentation!', 'jetpack' ); - $out .= '</p></div>'; - } - - $out .= do_shortcode( $content ); - } - - $out .= '</section>'; - - $this->presentation_initialized = false; - - return $out; - } - - function slide_shortcode( $atts, $content = '' ) { - // Bail out unless wrapped by a [presentation] shortcode - if ( ! $this->presentation_initialized ) { - return $content; - } - - $atts = shortcode_atts( - array( - 'transition' => '', - 'scale' => '', - 'rotate' => '', - 'fade' => '', - 'fadebullets' => '', - 'bgcolor' => '', - 'bgimg' => '', - ), - $atts, - 'slide' - ); - - // Determine positioning based on transition - if ( '' == trim( $atts['transition'] ) ) { - $atts['transition'] = $this->presentation_settings['transition']; - } - - // Setting the content scale - if ( '' == trim( $atts['scale'] ) ) { - $atts['scale'] = $this->presentation_settings['scale']; - } - - if ( '' == trim( $atts['scale'] ) ) { - $scale = 1; - } else { - $scale = floatval( $atts['scale'] ); - } - - if ( $scale < 0 ) { - $scale *= -1; - } - - // Setting the content rotation - if ( '' == trim( $atts['rotate'] ) ) { - $atts['rotate'] = $this->presentation_settings['rotate']; - } - - if ( '' == trim( $atts['rotate'] ) ) { - $rotate = 0; - } else { - $rotate = floatval( $atts['rotate'] ); - } - - // Setting if the content should fade - if ( '' == trim( $atts['fade'] ) ) { - $atts['fade'] = $this->presentation_settings['fade']; - } - - if ( 'on' == $atts['fade'] || 'true' == $atts['fade'] ) { - $fade = 'fade'; - } else { - $fade = ''; - } - - // Setting if bullets should fade on step changes - if ( '' == trim( $atts['fadebullets'] ) ) { - $atts['fadebullets'] = $this->presentation_settings['fadebullets']; - } - - if ( 'on' == $atts['fadebullets'] || 'true' == $atts['fadebullets'] ) { - $fadebullets = 'fadebullets'; - } else { - $fadebullets = ''; - } - - $coords = $this->get_coords( - array( - 'transition' => $atts['transition'], - 'scale' => $scale, - 'rotate' => $rotate, - ) - ); - - $x = $coords['x']; - $y = $coords['y']; - - // Check for background color XOR background image - // Use a white background if nothing specified - if ( preg_match( '/https?\:\/\/[^\'"\s]*/', $atts['bgimg'], $matches ) ) { - $style = 'background-image: url("' . esc_url( $matches[0] ) . '");'; - } elseif ( '' != trim( $atts['bgcolor'] ) ) { - $style = 'background-color: ' . esc_attr( $atts['bgcolor'] ) . ';'; - } else { - $style = ''; - } - - // Put everything together and let jmpress do the magic! - $out = sprintf( - '<div class="step %s %s" data-x="%s" data-y="%s" data-scale="%s" data-rotate="%s" style="%s">', - esc_attr( $fade ), - esc_attr( $fadebullets ), - esc_attr( $x ), - esc_attr( $y ), - esc_attr( $scale ), - esc_attr( $rotate ), - esc_attr( $style ) - ); - - $out .= '<div class="slide-content">'; - $out .= do_shortcode( $content ); - $out .= '</div></div>'; - - return $out; - } - - /** - * Determines the position of the next slide based on the position and scaling of the previous slide. - * - * @param array $args : an array with the following key-value pairs - * string $transition: the transition name, "up", "down", "left", or "right" - * float $scale: the scale of the next slide (used to determine the position of the slide after that) - * - * @return array with the 'x' and 'y' coordinates of the slide - */ - function get_coords( $args ) { - if ( 0 == $args['scale'] ) { - $args['scale'] = 1; - } - - $width = $this->presentation_settings['width']; - $height = $this->presentation_settings['height']; - $last = $this->presentation_settings['last']; - $scale = $last['scale']; - - $next = array( - 'x' => $last['x'], - 'y' => $last['y'], - 'scale' => $args['scale'], - 'rotate' => $args['rotate'], - ); - - // All angles are measured from the vertical axis, so everything is backwards! - $diagAngle = atan2( $width, $height ); - $diagonal = sqrt( pow( $width, 2 ) + pow( $height, 2 ) ); - - // We offset the angles by the angle formed by the diagonal so that - // we can multiply the sines directly against the diagonal length - $theta = deg2rad( $last['rotate'] ) - $diagAngle; - $phi = deg2rad( $next['rotate'] ) - $diagAngle; - - // We start by displacing by the slide dimensions - $totalHorizDisp = $width * $scale; - $totalVertDisp = $height * $scale; - - // If the previous slide was rotated, we add the incremental offset from the rotation - // Namely the difference between the regular dimension (no rotation) and the component - // of the diagonal for that angle - $totalHorizDisp += ( ( ( abs( sin( $theta ) ) * $diagonal ) - $width ) / 2 ) * $scale; - $totalVertDisp += ( ( ( abs( cos( $theta ) ) * $diagonal ) - $height ) / 2 ) * $scale; - - // Similarly, we check if the current slide has been rotated and add whatever additional - // offset has been added. This is so that two rotated corners don't clash with each other. - // Note: we are checking the raw angle relative to the vertical axis, NOT the diagonal angle. - if ( 0 !== $next['rotate'] % 180 ) { - $totalHorizDisp += ( abs( ( sin( $phi ) * $diagonal ) - $width ) / 2 ) * $next['scale']; - $totalVertDisp += ( abs( ( cos( $phi ) * $diagonal ) - $height ) / 2 ) * $next['scale']; - } - - switch ( trim( $args['transition'] ) ) { - case 'none': - break; - - case 'left': - $next['x'] -= $totalHorizDisp; - break; - - case 'right': - $next['x'] += $totalHorizDisp; - break; - - case 'up': - $next['y'] -= $totalVertDisp; - break; - - case 'down': - default: - $next['y'] += $totalVertDisp; - break; - } - - $this->presentation_settings['last'] = $next; - - return $next; - } - } - - $GLOBALS['presentations'] = new Presentations(); -endif; diff --git a/plugins/jetpack/modules/shortcodes/quiz.php b/plugins/jetpack/modules/shortcodes/quiz.php deleted file mode 100644 index fa4ed960..00000000 --- a/plugins/jetpack/modules/shortcodes/quiz.php +++ /dev/null @@ -1,309 +0,0 @@ -<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileNam -/** - * Quiz shortcode. - * - * Usage: - * - * [quiz] - * [question]What's the right answer?[/question] - * [wrong]This one?[explanation]Nope[/explanation][/wrong] - * [answer]Yes, this is the one![explanation]Yay![/explanation][/answer] - * [wrong]Maybe this one[explanation]Keep trying[/explanation][/wrong] - * [wrong]How about this one?[explanation]Try again[/explanation][/wrong] - * [/quiz] - */ -class Quiz_Shortcode { - - /** - * Parameters admitted by [quiz] shortcode. - * - * @since 4.5.0 - * - * @var array - */ - private static $quiz_params = array(); - - /** - * Whether the scripts were enqueued. - * - * @since 4.5.0 - * - * @var bool - */ - private static $scripts_enqueued = false; - - /** - * In a8c training, store user currently logged in. - * - * @since 4.5.0 - * - * @var null - */ - private static $username = null; - - /** - * Whether the noscript tag was already printed. - * - * @since 4.5.0 - * - * @var bool - */ - private static $noscript_info_printed = false; - - /** - * Whether JavaScript is available. - * - * @since 4.5.0 - * - * @var null - */ - private static $javascript_unavailable = null; - - /** - * Register all shortcodes. - * - * @since 4.5.0 - */ - public static function init() { - add_shortcode( 'quiz', array( __CLASS__, 'shortcode' ) ); - add_shortcode( 'question', array( __CLASS__, 'question_shortcode' ) ); - add_shortcode( 'answer', array( __CLASS__, 'answer_shortcode' ) ); - add_shortcode( 'wrong', array( __CLASS__, 'wrong_shortcode' ) ); - add_shortcode( 'explanation', array( __CLASS__, 'explanation_shortcode' ) ); - } - - /** - * Enqueue assets needed by the quiz, - * - * @since 4.5.0 - */ - private static function enqueue_scripts() { - wp_enqueue_style( 'quiz', plugins_url( 'css/quiz.css', __FILE__ ), array(), JETPACK__VERSION ); - wp_enqueue_script( - 'quiz', - Jetpack::get_file_url_for_environment( '_inc/build/shortcodes/js/quiz.min.js', 'modules/shortcodes/js/quiz.js' ), - array( 'jquery' ), - JETPACK__VERSION, - true - ); - } - - /** - * Check if this is a feed and thus JS is unavailable. - * - * @since 4.5.0 - * - * @return bool|null - */ - private static function is_javascript_unavailable() { - if ( ! is_null( self::$javascript_unavailable ) ) { - return self::$javascript_unavailable; - } - - if ( is_feed() ) { - self::$javascript_unavailable = true; - return self::$javascript_unavailable; - } - - self::$javascript_unavailable = false; - return self::$javascript_unavailable; - } - - /** - * Display message when JS is not available. - * - * @since 4.5.0 - * - * @return string - */ - private static function noscript_info() { - if ( self::$noscript_info_printed ) { - return ''; - } - self::$noscript_info_printed = true; - return '<noscript><div><i>' . esc_html__( 'Please view this post in your web browser to complete the quiz.', 'jetpack' ) . '</i></div></noscript>'; - } - - /** - * Check if we're in WordPress.com. - * - * @since 4.5.0 - * - * @return bool - */ - public static function is_wpcom() { - return defined( 'IS_WPCOM' ) && IS_WPCOM; - } - - /** - * Parse shortcode arguments and render its output. - * - * @since 4.5.0 - * - * @param array $atts Shortcode parameters. - * @param string $content Content enclosed by shortcode tags. - * - * @return string - */ - public static function shortcode( $atts, $content = null ) { - - // There's nothing to do if there's nothing enclosed. - if ( empty( $content ) ) { - return ''; - } - - $id = ''; - - if ( self::is_javascript_unavailable() ) { - // in an e-mail print the question and the info sentence once per question, too. - self::$noscript_info_printed = false; - } else { - - if ( ! self::$scripts_enqueued ) { - // lazy enqueue cannot use the wp_enqueue_scripts action anymore. - self::enqueue_scripts(); - self::$scripts_enqueued = true; - } - - $default_atts = self::is_wpcom() - ? array( - 'trackid' => '', - 'a8ctraining' => '', - ) - : array( - 'trackid' => '', - ); - - self::$quiz_params = shortcode_atts( $default_atts, $atts ); - - if ( ! empty( self::$quiz_params['trackid'] ) ) { - $id .= ' data-trackid="' . esc_attr( self::$quiz_params['trackid'] ) . '"'; - } - if ( self::is_wpcom() && ! empty( self::$quiz_params['a8ctraining'] ) ) { - if ( is_null( self::$username ) ) { - self::$username = wp_get_current_user()->user_login; - } - $id .= ' data-a8ctraining="' . esc_attr( self::$quiz_params['a8ctraining'] ) . '" data-username="' . esc_attr( self::$username ) . '"'; - } - } - - $quiz = self::do_shortcode( $content ); - return '<div class="jetpack-quiz quiz"' . $id . '>' . $quiz . '</div>'; - } - - /** - * Strip line breaks, restrict allowed HTML to a few whitelisted tags and execute nested shortcodes. - * - * @since 4.5.0 - * - * @param string $content Post content. - * - * @return mixed|string - */ - private static function do_shortcode( $content ) { - // strip autoinserted line breaks. - $content = preg_replace( '#(<(?:br /|/?p)>\n?)*(\[/?[a-z]+\])(<(?:br /|/?p)>\n?)*#', '$2', $content ); - - // Add internal parameter so it's only rendered when it has it. - $content = preg_replace( '/\[(question|answer|wrong|explanation)\]/i', '[$1 quiz_item="true"]', $content ); - $content = do_shortcode( $content ); - $content = wp_kses( - $content, - array( - 'tt' => array(), - 'a' => array( 'href' => true ), - 'pre' => array(), - 'strong' => array(), - 'i' => array(), - 'br' => array(), - 'img' => array( 'src' => true ), - 'div' => array( - 'class' => true, - 'data-correct' => 1, - 'data-track-id' => 1, - 'data-a8ctraining' => 1, - 'data-username' => 1, - ), - ) - ); - return $content; - } - - /** - * Render question. - * - * @since 4.5.0 - * - * @param array $atts Shortcode attributes. - * @param null $content Post content. - * - * @return string - */ - public static function question_shortcode( $atts, $content = null ) { - return isset( $atts['quiz_item'] ) - ? '<div class="jetpack-quiz-question question">' . self::do_shortcode( $content ) . '</div>' - : ''; - } - - /** - * Render correct answer. - * - * @since 4.5.0 - * - * @param array $atts Shortcode attributes. - * @param null $content Post content. - * - * @return string - */ - public static function answer_shortcode( $atts, $content = null ) { - if ( self::is_javascript_unavailable() ) { - return self::noscript_info(); - } - - return isset( $atts['quiz_item'] ) - ? '<div class="jetpack-quiz-answer answer" data-correct="1">' . self::do_shortcode( $content ) . '</div>' - : ''; - } - - /** - * Render wrong response. - * - * @since 4.5.0 - * - * @param array $atts Shortcode attributes. - * @param null $content Post content. - * - * @return string - */ - public static function wrong_shortcode( $atts, $content = null ) { - if ( self::is_javascript_unavailable() ) { - return self::noscript_info(); - } - - return isset( $atts['quiz_item'] ) - ? '<div class="jetpack-quiz-answer answer">' . self::do_shortcode( $content ) . '</div>' - : ''; - } - - /** - * Render explanation for wrong or right answer. - * - * @since 4.5.0 - * - * @param array $atts Shortcode attributes. - * @param null $content Post content. - * - * @return string - */ - public static function explanation_shortcode( $atts, $content = null ) { - if ( self::is_javascript_unavailable() ) { - return self::noscript_info(); - } - - return isset( $atts['quiz_item'] ) - ? '<div class="jetpack-quiz-explanation explanation">' . self::do_shortcode( $content ) . '</div>' - : ''; - } -} - -Quiz_Shortcode::init(); diff --git a/plugins/jetpack/modules/shortcodes/recipe.php b/plugins/jetpack/modules/shortcodes/recipe.php deleted file mode 100644 index 7846b154..00000000 --- a/plugins/jetpack/modules/shortcodes/recipe.php +++ /dev/null @@ -1,515 +0,0 @@ -<?php - -/** - * Embed recipe 'cards' in post, with basic styling and print functionality - * - * To Do - * - defaults settings - * - basic styles/themecolor styles - * - validation/sanitization - * - print styles - */ -class Jetpack_Recipes { - - private $scripts_and_style_included = false; - - function __construct() { - add_action( 'init', array( $this, 'action_init' ) ); - - add_filter( 'wp_kses_allowed_html', array( $this, 'add_recipes_kses_rules' ), 10, 2 ); - } - - /** - * Add Schema-specific attributes to our allowed tags in wp_kses, - * so we can have better Schema.org compliance. - * - * @param array $allowedtags Array of allowed HTML tags in recipes. - * @param array $context Context to judge allowed tags by. - */ - function add_recipes_kses_rules( $allowedtags, $context ) { - if ( in_array( $context, array( '', 'post', 'data' ) ) ) : - // Create an array of all the tags we'd like to add the itemprop attribute to. - $tags = array( 'li', 'ol', 'ul', 'img', 'p', 'h3', 'time' ); - foreach ( $tags as $tag ) { - $allowedtags = $this->add_kses_rule( - $allowedtags, - $tag, - array( - 'class' => array(), - 'itemprop' => array(), - 'datetime' => array(), - ) - ); - } - - // Allow itemscope and itemtype for divs. - $allowedtags = $this->add_kses_rule( - $allowedtags, - 'div', - array( - 'class' => array(), - 'itemscope' => array(), - 'itemtype' => array(), - ) - ); - endif; - - return $allowedtags; - } - - /** - * Function to add a new property rule to our kses array. - * Used by add_recipe_kses_rules() above. - * - * @param array $all_tags Array of allowed HTML tags in recipes. - * @param string $tag New HTML tag to add to the array of allowed HTML. - * @param array $rules Array of allowed attributes for that HTML tag. - */ - private function add_kses_rule( $all_tags, $tag, $rules ) { - - // If the tag doesn't already exist, add it. - if ( ! isset( $all_tags[ $tag ] ) ) { - $all_tags[ $tag ] = array(); - } - - // Merge the new tags with existing tags. - $all_tags[ $tag ] = array_merge( $all_tags[ $tag ], $rules ); - - return $all_tags; - } - - /** - * Register our shortcode and enqueue necessary files. - */ - function action_init() { - // Enqueue styles if [recipe] exists. - add_action( 'wp_head', array( $this, 'add_scripts' ), 1 ); - - // Render [recipe], along with other shortcodes that can be nested within. - add_shortcode( 'recipe', array( $this, 'recipe_shortcode' ) ); - add_shortcode( 'recipe-notes', array( $this, 'recipe_notes_shortcode' ) ); - add_shortcode( 'recipe-ingredients', array( $this, 'recipe_ingredients_shortcode' ) ); - add_shortcode( 'recipe-directions', array( $this, 'recipe_directions_shortcode' ) ); - } - - /** - * Enqueue scripts and styles - */ - function add_scripts() { - if ( empty( $GLOBALS['posts'] ) || ! is_array( $GLOBALS['posts'] ) ) { - return; - } - - foreach ( $GLOBALS['posts'] as $p ) { - if ( has_shortcode( $p->post_content, 'recipe' ) ) { - $this->scripts_and_style_included = true; - break; - } - } - - if ( ! $this->scripts_and_style_included ) { - return; - } - - wp_enqueue_style( 'jetpack-recipes-style', plugins_url( '/css/recipes.css', __FILE__ ), array(), '20130919' ); - wp_style_add_data( 'jetpack-recipes-style', 'rtl', 'replace' ); - - // add $themecolors-defined styles. - wp_add_inline_style( 'jetpack-recipes-style', self::themecolor_styles() ); - - wp_enqueue_script( - 'jetpack-recipes-printthis', - Jetpack::get_file_url_for_environment( '_inc/build/shortcodes/js/recipes-printthis.min.js', 'modules/shortcodes/js/recipes-printthis.js' ), - array( 'jquery' ), - '20170202' - ); - - wp_enqueue_script( - 'jetpack-recipes-js', - Jetpack::get_file_url_for_environment( '_inc/build/shortcodes/js/recipes.min.js', 'modules/shortcodes/js/recipes.js' ), - array( 'jquery', 'jetpack-recipes-printthis' ), - '20131230' - ); - - $title_var = wp_title( '|', false, 'right' ); - $rtl = is_rtl() ? '-rtl' : ''; - $print_css_var = plugins_url( "/css/recipes-print{$rtl}.css", __FILE__ ); - - wp_localize_script( - 'jetpack-recipes-js', - 'jetpack_recipes_vars', - array( - 'pageTitle' => $title_var, - 'loadCSS' => $print_css_var, - ) - ); - } - - /** - * Our [recipe] shortcode. - * Prints recipe data styled to look good on *any* theme. - * - * @param array $atts Array of shortcode attributes. - * @param string $content Post content. - * - * @return string HTML for recipe shortcode. - */ - static function recipe_shortcode( $atts, $content = '' ) { - $atts = shortcode_atts( - array( - 'title' => '', // string. - 'servings' => '', // intval. - 'time' => '', // string. - 'difficulty' => '', // string. - 'print' => '', // string. - 'source' => '', // string. - 'sourceurl' => '', // string. - 'image' => '', // string. - 'description' => '', // string. - ), - $atts, - 'recipe' - ); - - return self::recipe_shortcode_html( $atts, $content ); - } - - /** - * The recipe output - * - * @param array $atts Array of shortcode attributes. - * @param string $content Post content. - * - * @return string HTML output - */ - static function recipe_shortcode_html( $atts, $content = '' ) { - - $html = '<div class="hrecipe jetpack-recipe" itemscope itemtype="https://schema.org/Recipe">'; - - // Print the recipe title if exists. - if ( '' !== $atts['title'] ) { - $html .= '<h3 class="jetpack-recipe-title" itemprop="name">' . esc_html( $atts['title'] ) . '</h3>'; - } - - // Print the recipe meta if exists. - if ( '' !== $atts['servings'] || '' != $atts['time'] || '' != $atts['difficulty'] || '' != $atts['print'] ) { - $html .= '<ul class="jetpack-recipe-meta">'; - - if ( '' !== $atts['servings'] ) { - $html .= sprintf( - '<li class="jetpack-recipe-servings" itemprop="recipeYield"><strong>%1$s: </strong>%2$s</li>', - esc_html_x( 'Servings', 'recipe', 'jetpack' ), - esc_html( $atts['servings'] ) - ); - } - - if ( '' !== $atts['time'] ) { - // Get a time that's supported by Schema.org. - $duration = WPCOM_JSON_API_Date::format_duration( $atts['time'] ); - // If no duration can be calculated, let's output what the user provided. - if ( empty( $duration ) ) { - $duration = $atts['time']; - } - - $html .= sprintf( - '<li class="jetpack-recipe-time"> - <time itemprop="totalTime" datetime="%3$s"><strong>%1$s: </strong>%2$s</time> - </li>', - esc_html_x( 'Time', 'recipe', 'jetpack' ), - esc_html( $atts['time'] ), - esc_attr( $duration ) - ); - } - - if ( '' !== $atts['difficulty'] ) { - $html .= sprintf( - '<li class="jetpack-recipe-difficulty"><strong>%1$s: </strong>%2$s</li>', - esc_html_x( 'Difficulty', 'recipe', 'jetpack' ), - esc_html( $atts['difficulty'] ) - ); - } - - if ( '' !== $atts['source'] ) { - $html .= sprintf( - '<li class="jetpack-recipe-source"><strong>%1$s: </strong>', - esc_html_x( 'Source', 'recipe', 'jetpack' ) - ); - - if ( '' !== $atts['sourceurl'] ) : - // Show the link if we have one. - $html .= sprintf( - '<a href="%2$s">%1$s</a>', - esc_html( $atts['source'] ), - esc_url( $atts['sourceurl'] ) - ); - else : - // Skip the link. - $html .= sprintf( - '%1$s', - esc_html( $atts['source'] ) - ); - endif; - - $html .= '</li>'; - } - - if ( 'false' !== $atts['print'] ) { - $html .= sprintf( - '<li class="jetpack-recipe-print"><a href="#">%1$s</a></li>', - esc_html_x( 'Print', 'recipe', 'jetpack' ) - ); - } - - $html .= '</ul>'; - } // End if(). - - // Output the image, if we have one. - if ( '' !== $atts['image'] ) { - $html .= sprintf( - '<img class="jetpack-recipe-image" itemprop="image" src="%1$s" />', - esc_url( $atts['image'] ) - ); - } - - // Output the description, if we have one. - if ( '' !== $atts['description'] ) { - $html .= sprintf( - '<p class="jetpack-recipe-description" itemprop="description">%1$s</p>', - esc_html( $atts['description'] ) - ); - } - - // Print content between codes. - $html .= '<div class="jetpack-recipe-content">' . do_shortcode( $content ) . '</div>'; - - // Close it up. - $html .= '</div>'; - - // If there is a recipe within a recipe, remove the shortcode. - if ( has_shortcode( $html, 'recipe' ) ) { - remove_shortcode( 'recipe' ); - } - - // Sanitize html. - $html = wp_kses_post( $html ); - - // Return the HTML block. - return $html; - } - - /** - * Our [recipe-notes] shortcode. - * Outputs ingredients, styled in a div. - * - * @param array $atts Array of shortcode attributes. - * @param string $content Post content. - * - * @return string HTML for recipe notes shortcode. - */ - static function recipe_notes_shortcode( $atts, $content = '' ) { - $atts = shortcode_atts( - array( - 'title' => '', // string. - ), - $atts, - 'recipe-notes' - ); - - $html = ''; - - // Print a title if one exists. - if ( '' !== $atts['title'] ) { - $html .= '<h4 class="jetpack-recipe-notes-title">' . esc_html( $atts['title'] ) . '</h4>'; - } - - $html .= '<div class="jetpack-recipe-notes">'; - - // Format content using list functionality, if desired. - $html .= self::output_list_content( $content, 'notes' ); - - $html .= '</div>'; - - // Sanitize html. - $html = wp_kses_post( $html ); - - // Return the HTML block. - return $html; - } - - /** - * Our [recipe-ingredients] shortcode. - * Outputs notes, styled in a div. - * - * @param array $atts Array of shortcode attributes. - * @param string $content Post content. - * - * @return string HTML for recipe ingredients shortcode. - */ - static function recipe_ingredients_shortcode( $atts, $content = '' ) { - $atts = shortcode_atts( - array( - 'title' => esc_html_x( 'Ingredients', 'recipe', 'jetpack' ), // string. - ), - $atts, - 'recipe-ingredients' - ); - - $html = '<div class="jetpack-recipe-ingredients">'; - - // Print a title unless the user has opted to exclude it. - if ( 'false' !== $atts['title'] ) { - $html .= '<h4 class="jetpack-recipe-ingredients-title">' . esc_html( $atts['title'] ) . '</h4>'; - } - - // Format content using list functionality. - $html .= self::output_list_content( $content, 'ingredients' ); - - $html .= '</div>'; - - // Sanitize html. - $html = wp_kses_post( $html ); - - // Return the HTML block. - return $html; - } - - /** - * Reusable function to check for shortened formatting. - * Basically, users can create lists with the following shorthand: - * - item one - * - item two - * - item three - * And we'll magically convert it to a list. This has the added benefit - * of including itemprops for the recipe schema. - * - * @param string $content HTML content. - * @param string $type Type of list. - * - * @return string content formatted as a list item - */ - static function output_list_content( $content, $type ) { - $html = ''; - - switch ( $type ) { - case 'directions': - $list_item_replacement = '<li class="jetpack-recipe-directions">${1}</li>'; - $itemprop = ' itemprop="recipeInstructions"'; - $listtype = 'ol'; - break; - case 'ingredients': - $list_item_replacement = '<li class="jetpack-recipe-ingredient" itemprop="recipeIngredient">${1}</li>'; - $itemprop = ''; - $listtype = 'ul'; - break; - default: - $list_item_replacement = '<li class="jetpack-recipe-notes">${1}</li>'; - $itemprop = ''; - $listtype = 'ul'; - } - - // Check to see if the user is trying to use shortened formatting. - if ( - strpos( $content, '–' ) !== false || - strpos( $content, '—' ) !== false || - strpos( $content, '-' ) !== false || - strpos( $content, '*' ) !== false || - strpos( $content, '#' ) !== false || - strpos( $content, '–' ) !== false || // ndash. - strpos( $content, '—' ) !== false || // mdash. - preg_match( '/\d+\.\s/', $content ) - ) { - // Remove breaks and extra whitespace. - $content = str_replace( "<br />\n", "\n", $content ); - $content = trim( $content ); - - $ul_pattern = '/(?:^|\n|\<p\>)+(?:[\-–—]+|\–|\—|\*)+\h+(.*)/mi'; - $ol_pattern = '/(?:^|\n|\<p\>)+(?:\d+\.|#+)+\h+(.*)/mi'; - - preg_match_all( $ul_pattern, $content, $ul_matches ); - preg_match_all( $ol_pattern, $content, $ol_matches ); - - if ( 0 !== count( $ul_matches[0] ) || 0 !== count( $ol_matches[0] ) ) { - - if ( 0 !== count( $ol_matches[0] ) ) { - $listtype = 'ol'; - $list_item_pattern = $ol_pattern; - } else { - $listtype = 'ul'; - $list_item_pattern = $ul_pattern; - } - $html .= '<' . $listtype . $itemprop . '>'; - $html .= preg_replace( $list_item_pattern, $list_item_replacement, $content ); - $html .= '</' . $listtype . '>'; - - // Strip out any empty <p> tags and stray </p> tags, because those are just silly. - $empty_p_pattern = '/(<p>)*\s*<\/p>/mi'; - $html = preg_replace( $empty_p_pattern, '', $html ); - } else { - $html .= do_shortcode( $content ); - } - } else { - $html .= do_shortcode( $content ); - } - - // Return our formatted content. - return $html; - } - - /** - * Our [recipe-directions] shortcode. - * Outputs directions, styled in a div. - * - * @param array $atts Array of shortcode attributes. - * @param string $content Post content. - * - * @return string HTML for recipe directions shortcode. - */ - static function recipe_directions_shortcode( $atts, $content = '' ) { - $atts = shortcode_atts( - array( - 'title' => esc_html_x( 'Directions', 'recipe', 'jetpack' ), // string. - ), - $atts, - 'recipe-directions' - ); - - $html = '<div class="jetpack-recipe-directions">'; - - // Print a title unless the user has specified to exclude it. - if ( 'false' !== $atts['title'] ) { - $html .= '<h4 class="jetpack-recipe-directions-title">' . esc_html( $atts['title'] ) . '</h4>'; - } - - // Format content using list functionality. - $html .= self::output_list_content( $content, 'directions' ); - - $html .= '</div>'; - - // Sanitize html. - $html = wp_kses_post( $html ); - - // Return the HTML block. - return $html; - } - - /** - * Use $themecolors array to style the Recipes shortcode - * - * @print style block - * @return string $style - */ - function themecolor_styles() { - global $themecolors; - $style = ''; - - if ( isset( $themecolors ) ) { - $style .= '.jetpack-recipe { border-color: #' . esc_attr( $themecolors['border'] ) . '; }'; - $style .= '.jetpack-recipe-title { border-bottom-color: #' . esc_attr( $themecolors['link'] ) . '; }'; - } - - return $style; - } - -} - -new Jetpack_Recipes(); diff --git a/plugins/jetpack/modules/shortcodes/scribd.php b/plugins/jetpack/modules/shortcodes/scribd.php deleted file mode 100644 index 1810c2fa..00000000 --- a/plugins/jetpack/modules/shortcodes/scribd.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -/* - Scribd Short Code -Author: Nick Momrik - -[scribd id=DOCUMENT_ID key=DOCUMENT_KEY mode=MODE] -DOCUMENT_ID is an integer (also used as an object_id) -DOCUMENT_KEY is an alphanumeric hash ('-' character as well) -MODE can be 'list', 'book', 'slide', 'slideshow', or 'tile' - -[scribd id=39027960 key=key-3kaiwcjqhtipf25m8tw mode=list] -*/ - -function scribd_shortcode_handler( $atts ) { - $atts = shortcode_atts( - array( - 'id' => 0, - 'key' => 0, - 'mode' => '', - ), - $atts, - 'scribd' - ); - - $modes = array( 'list', 'book', 'slide', 'slideshow', 'tile' ); - - $atts['id'] = (int) $atts['id']; - if ( preg_match( '/^[A-Za-z0-9-]+$/', $atts['key'], $m ) ) { - $atts['key'] = $m[0]; - - if ( ! in_array( $atts['mode'], $modes ) ) { - $atts['mode'] = ''; - } - - return scribd_shortcode_markup( $atts ); - } else { - return ''; - } -} - -function scribd_shortcode_markup( $atts ) { - $markup = <<<EOD -<iframe class="scribd_iframe_embed" src="//www.scribd.com/embeds/$atts[id]/content?start_page=1&view_mode=$atts[mode]&access_key=$atts[key]" data-auto-height="true" scrolling="no" id="scribd_$atts[id]" width="100%" height="500" frameborder="0"></iframe> -<div style="font-size:10px;text-align:center;width:100%"><a href="http://www.scribd.com/doc/$atts[id]" target="_blank">View this document on Scribd</a></div> -EOD; - - return $markup; -} - -add_shortcode( 'scribd', 'scribd_shortcode_handler' ); - -// Scribd supports HTTPS, so use that endpoint to get HTTPS-compatible embeds -function scribd_https_oembed( $providers ) { - if ( isset( $providers['#https?://(www\.)?scribd\.com/doc/.*#i'] ) ) { - $providers['#https?://(www\.)?scribd\.com/doc/.*#i'][0] = 'https://www.scribd.com/services/oembed'; - } - - return $providers; -} - -add_filter( 'oembed_providers', 'scribd_https_oembed' ); diff --git a/plugins/jetpack/modules/shortcodes/sitemap.php b/plugins/jetpack/modules/shortcodes/sitemap.php deleted file mode 100644 index d26210f0..00000000 --- a/plugins/jetpack/modules/shortcodes/sitemap.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php -/** - * Sitemap shortcode. - * - * Usage: [sitemap] - * - * @package Jetpack - */ - -add_shortcode( 'sitemap', 'jetpack_sitemap_shortcode' ); - -/** - * Renders a tree of pages. - * - * @since 4.5.0 - * - * @return string - */ -function jetpack_sitemap_shortcode() { - $tree = wp_list_pages( - array( - 'title_li' => '<b><a href="/">' . esc_html( get_bloginfo( 'name' ) ) . '</a></b>', - 'exclude' => get_option( 'page_on_front' ), - 'echo' => false, - ) - ); - return empty( $tree ) - ? '' - : '<ul class="jetpack-sitemap-shortcode">' . $tree . '</ul>'; -} diff --git a/plugins/jetpack/modules/shortcodes/slideshare.php b/plugins/jetpack/modules/shortcodes/slideshare.php deleted file mode 100644 index 898ae57e..00000000 --- a/plugins/jetpack/modules/shortcodes/slideshare.php +++ /dev/null @@ -1,121 +0,0 @@ -<?php -/** - * Slideshare shortcode format: - * Old style (still compatible): [slideshare id=5342235&doc=camprock-101002163655-phpapp01&w=300&h=200] - * New style: [slideshare id=5342235&w=300&h=200&fb=0&mw=0&mh=0&sc=no] - * - * Legend: - * id = Document ID provided by Slideshare - * w = Width of iFrame (int) - * h = Height of iFrame (int) - * fb = iFrame frameborder (int) - * mw = iFrame marginwidth (int) - * mh = iFrame marginheight (int) - * sc = iFrame Scrollbar (yes/no) - * pro = Slideshare Pro (yes/no) - * style = Inline CSS (string) - **/ - -add_shortcode( 'slideshare', 'slideshare_shortcode' ); - -function slideshare_shortcode( $atts ) { - global $content_width; - - $params = shortcode_new_to_old_params( $atts ); - parse_str( $params, $arguments ); - - if ( empty( $arguments ) ) { - return '<!-- SlideShare error: no arguments -->'; - } - - $attr = shortcode_atts( - array( - 'id' => '', - 'w' => '', - 'h' => '', - 'fb' => '', - 'mw' => '', - 'mh' => '', - 'sc' => '', - 'pro' => '', - 'style' => '', - ), - $arguments - ); - - // check that the Slideshare ID contains letters, numbers and query strings - $pattern = '/[^-_a-zA-Z0-9?=&]/'; - if ( empty( $attr['id'] ) || preg_match( $pattern, $attr['id'] ) ) { - return '<!-- SlideShare error: id is missing or has illegal characters -->'; - } - - // check the width/height - $w = $attr['w']; - if ( empty( $w ) && ! empty( $content_width ) ) { - $w = intval( $content_width ); - } elseif ( ! ( $w = intval( $w ) ) || $w < 300 || $w > 1600 ) { - $w = 425; - } else { - $w = intval( $w ); - } - - $h = ceil( $w * 348 / 425 ); // Note: user-supplied height is ignored. - - if ( isset( $attr['pro'] ) && $attr['pro'] ) { - $source = 'https://www.slideshare.net/slidesharepro/' . $attr['id']; - } else { - $source = 'https://www.slideshare.net/slideshow/embed_code/' . $attr['id']; - } - - if ( isset( $rel ) ) { - $source = add_query_arg( 'rel', intval( $rel ), $source ); - } - - if ( isset( $startSlide ) ) { - $source = add_query_arg( 'startSlide', intval( $startSlide ), $source ); - } - - $player = sprintf( "<iframe src='%s' width='%d' height='%d'", esc_url( $source ), $w, $h ); - - // check the frameborder - if ( ! empty( $attr['fb'] ) || '0' === $attr['fb'] ) { - $player .= " frameborder='" . intval( $attr['fb'] ) . "'"; - } - - // check the margin width; if not empty, cast as int - if ( ! empty( $attr['mw'] ) || '0' === $attr['mw'] ) { - $player .= " marginwidth='" . intval( $attr['mw'] ) . "'"; - } - - // check the margin height, if not empty, cast as int - if ( ! empty( $attr['mh'] ) || '0' === $attr['mh'] ) { - $player .= " marginheight='" . intval( $attr['mh'] ) . "'"; - } - - if ( ! empty( $attr['style'] ) ) { - $player .= " style='" . esc_attr( $attr['style'] ) . "'"; - } - - // check the scrollbar; cast as a lowercase string for comparison - if ( ! empty( $attr['sc'] ) ) { - $sc = strtolower( $attr['sc'] ); - - if ( in_array( $sc, array( 'yes', 'no' ) ) ) { - $player .= " scrolling='" . $sc . "'"; - } - } - - $player .= ' allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>'; - - /** - * Filter the returned SlideShare shortcode. - * - * @module shortcodes - * - * @since 4.7.0 - * - * @param string $player The iframe to return. - * @param array $atts The attributes specified in the shortcode. - */ - return apply_filters( 'jetpack_slideshare_shortcode', $player, $atts ); -} diff --git a/plugins/jetpack/modules/shortcodes/slideshow.php b/plugins/jetpack/modules/shortcodes/slideshow.php deleted file mode 100644 index 43428dc8..00000000 --- a/plugins/jetpack/modules/shortcodes/slideshow.php +++ /dev/null @@ -1,316 +0,0 @@ -<?php - -/** - * Slideshow shortcode usage: [gallery type="slideshow"] or the older [slideshow] - */ -class Jetpack_Slideshow_Shortcode { - public $instance_count = 0; - - function __construct() { - global $shortcode_tags; - - // Only if the slideshow shortcode has not already been defined. - if ( ! array_key_exists( 'slideshow', $shortcode_tags ) ) { - add_shortcode( 'slideshow', array( $this, 'shortcode_callback' ) ); - } - - // Only if the gallery shortcode has not been redefined. - if ( isset( $shortcode_tags['gallery'] ) && 'gallery_shortcode' === $shortcode_tags['gallery'] ) { - add_filter( 'post_gallery', array( $this, 'post_gallery' ), 1002, 2 ); - add_filter( 'jetpack_gallery_types', array( $this, 'add_gallery_type' ), 10 ); - } - - /** - * For the moment, comment out the setting for v2.8. - * The remainder should work as it always has. - * See: https://github.com/Automattic/jetpack/pull/85/files - */ - // add_action( 'admin_init', array( $this, 'register_settings' ), 5 ); - } - - /** - * Responds to the [gallery] shortcode, but not an actual shortcode callback. - * - * @param $value string An empty string if nothing has modified the gallery output, the output html otherwise - * @param $attr array The shortcode attributes array - * - * @return string The (un)modified $value - */ - function post_gallery( $value, $attr ) { - // Bail if somebody else has done something - if ( ! empty( $value ) ) { - return $value; - } - - // If [gallery type="slideshow"] have it behave just like [slideshow] - if ( ! empty( $attr['type'] ) && 'slideshow' == $attr['type'] ) { - return $this->shortcode_callback( $attr ); - } - - return $value; - } - - /** - * Add the Slideshow type to gallery settings - * - * @see Jetpack_Tiled_Gallery::media_ui_print_templates - * - * @param $types array An array of types where the key is the value, and the value is the caption. - * - * @return array - */ - function add_gallery_type( $types = array() ) { - $types['slideshow'] = esc_html__( 'Slideshow', 'jetpack' ); - - return $types; - } - - function register_settings() { - add_settings_section( 'slideshow_section', __( 'Image Gallery Slideshow', 'jetpack' ), '__return_empty_string', 'media' ); - - add_settings_field( 'jetpack_slideshow_background_color', __( 'Background color', 'jetpack' ), array( $this, 'slideshow_background_color_callback' ), 'media', 'slideshow_section' ); - - register_setting( 'media', 'jetpack_slideshow_background_color', array( $this, 'slideshow_background_color_sanitize' ) ); - } - - function slideshow_background_color_callback() { - $options = array( - 'black' => __( 'Black', 'jetpack' ), - 'white' => __( 'White', 'jetpack' ), - ); - $this->settings_select( 'jetpack_slideshow_background_color', $options ); - } - - function settings_select( $name, $values, $extra_text = '' ) { - if ( empty( $name ) || empty( $values ) || ! is_array( $values ) ) { - return; - } - $option = get_option( $name ); - ?> - <fieldset> - <select name="<?php echo esc_attr( $name ); ?>" id="<?php echo esc_attr( $name ); ?>"> - <?php foreach ( $values as $key => $value ) : ?> - <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $option ); ?>> - <?php echo esc_html( $value ); ?> - </option> - <?php endforeach; ?> - </select> - <?php if ( ! empty( $extra_text ) ) : ?> - <p class="description"><?php echo esc_html( $extra_text ); ?></p> - <?php endif; ?> - </fieldset> - <?php - } - - function slideshow_background_color_sanitize( $value ) { - return ( 'white' == $value ) ? 'white' : 'black'; - } - - function shortcode_callback( $attr ) { - $post_id = get_the_ID(); - - $attr = shortcode_atts( - array( - 'trans' => 'fade', - 'order' => 'ASC', - 'orderby' => 'menu_order ID', - 'id' => $post_id, - 'include' => '', - 'exclude' => '', - 'autostart' => true, - 'size' => '', - ), - $attr, - 'slideshow' - ); - - if ( 'rand' == strtolower( $attr['order'] ) ) { - $attr['orderby'] = 'none'; - } - - $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); - if ( ! $attr['orderby'] ) { - $attr['orderby'] = 'menu_order ID'; - } - - if ( ! $attr['size'] ) { - $attr['size'] = 'full'; - } - - // Don't restrict to the current post if include - $post_parent = ( empty( $attr['include'] ) ) ? intval( $attr['id'] ) : null; - - $attachments = get_posts( - array( - 'post_status' => 'inherit', - 'post_type' => 'attachment', - 'post_mime_type' => 'image', - 'posts_per_page' => - 1, - 'post_parent' => $post_parent, - 'order' => $attr['order'], - 'orderby' => $attr['orderby'], - 'include' => $attr['include'], - 'exclude' => $attr['exclude'], - 'suppress_filters' => false, - ) - ); - - if ( count( $attachments ) < 1 ) { - return false; - } - - $gallery_instance = sprintf( 'gallery-%d-%d', $attr['id'], ++$this->instance_count ); - - $gallery = array(); - foreach ( $attachments as $attachment ) { - $attachment_image_src = wp_get_attachment_image_src( $attachment->ID, $attr['size'] ); - $attachment_image_src = $attachment_image_src[0]; // [url, width, height] - $attachment_image_title = get_the_title( $attachment->ID ); - $attachment_image_alt = get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ); - /** - * Filters the Slideshow slide caption. - * - * @module shortcodes - * - * @since 2.3.0 - * - * @param string wptexturize( strip_tags( $attachment->post_excerpt ) ) Post excerpt. - * @param string $attachment ->ID Attachment ID. - */ - $caption = apply_filters( 'jetpack_slideshow_slide_caption', wptexturize( strip_tags( $attachment->post_excerpt ) ), $attachment->ID ); - - $gallery[] = (object) array( - 'src' => (string) esc_url_raw( $attachment_image_src ), - 'id' => (string) $attachment->ID, - 'title' => (string) esc_attr( $attachment_image_title ), - 'alt' => (string) esc_attr( $attachment_image_alt ), - 'caption' => (string) $caption, - 'itemprop' => 'image', - ); - } - - $color = Jetpack_Options::get_option( 'slideshow_background_color', 'black' ); - - $js_attr = array( - 'gallery' => $gallery, - 'selector' => $gallery_instance, - 'trans' => $attr['trans'] ? $attr['trans'] : 'fade', - 'autostart' => $attr['autostart'] ? $attr['autostart'] : 'true', - 'color' => $color, - ); - - // Show a link to the gallery in feeds. - if ( is_feed() ) { - return sprintf( - '<a href="%s">%s</a>', - esc_url( get_permalink( $post_id ) . '#' . $gallery_instance . '-slideshow' ), - esc_html__( 'Click to view slideshow.', 'jetpack' ) - ); - } - - return $this->slideshow_js( $js_attr ); - } - - /** - * Render the slideshow js - * - * Returns the necessary markup and js to fire a slideshow. - * - * @param $attr array Attributes for the slideshow. - * - * @uses $this->enqueue_scripts() - * - * @return string HTML output. - */ - function slideshow_js( $attr ) { - // Enqueue scripts - $this->enqueue_scripts(); - - $output = ''; - - if ( defined( 'JSON_HEX_AMP' ) ) { - // This is nice to have, but not strictly necessary since we use _wp_specialchars() below - $gallery = json_encode( $attr['gallery'], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); // phpcs:ignore PHPCompatibility - } else { - $gallery = json_encode( $attr['gallery'] ); - } - - $output .= '<p class="jetpack-slideshow-noscript robots-nocontent">' . esc_html__( 'This slideshow requires JavaScript.', 'jetpack' ) . '</p>'; - $output .= sprintf( - '<div id="%s" class="slideshow-window jetpack-slideshow slideshow-%s" data-trans="%s" data-autostart="%s" data-gallery="%s" itemscope itemtype="https://schema.org/ImageGallery"></div>', - esc_attr( $attr['selector'] . '-slideshow' ), - esc_attr( $attr['color'] ), - esc_attr( $attr['trans'] ), - esc_attr( $attr['autostart'] ), - /* - * The input to json_encode() above can contain '"'. - * - * For calls to json_encode() lacking the JSON_HEX_AMP option, - * that '"' is left unaltered. Running '"' through esc_attr() - * also leaves it unaltered since esc_attr() does not double-encode. - * - * This means we end up with an attribute like - * `data-gallery="{"foo":"""}"`, - * which is interpreted by the browser as `{"foo":"""}`, - * which cannot be JSON decoded. - * - * The preferred workaround is to include the JSON_HEX_AMP (and friends) - * options, but these are not available until 5.3.0. - * Alternatively, we can use _wp_specialchars( , , , true ) instead of - * esc_attr(), which will double-encode. - * - * Since we can't rely on JSON_HEX_AMP, we do both. - */ - _wp_specialchars( wp_check_invalid_utf8( $gallery ), ENT_QUOTES, false, true ) - ); - - return $output; - } - - /** - * Actually enqueues the scripts and styles. - */ - function enqueue_scripts() { - - wp_enqueue_script( 'jquery-cycle', plugins_url( '/js/jquery.cycle.min.js', __FILE__ ), array( 'jquery' ), '20161231', true ); - wp_enqueue_script( - 'jetpack-slideshow', - Jetpack::get_file_url_for_environment( '_inc/build/shortcodes/js/slideshow-shortcode.min.js', 'modules/shortcodes/js/slideshow-shortcode.js' ), - array( 'jquery-cycle' ), - '20160119.1', - true - ); - wp_enqueue_style( 'jetpack-slideshow', plugins_url( '/css/slideshow-shortcode.css', __FILE__ ) ); - wp_style_add_data( 'jetpack-slideshow', 'rtl', 'replace' ); - - wp_localize_script( - 'jetpack-slideshow', - 'jetpackSlideshowSettings', - /** - * Filters the slideshow JavaScript spinner. - * - * @module shortcodes - * - * @since 2.1.0 - * @since 4.7.0 Added the `speed` option to the array of options. - * - * @param array $args - * - string - spinner - URL of the spinner image. - * - string - speed - Speed of the slideshow. Defaults to 4000. - */ - apply_filters( - 'jetpack_js_slideshow_settings', - array( - 'spinner' => plugins_url( '/img/slideshow-loader.gif', __FILE__ ), - 'speed' => '4000', - ) - ) - ); - } - - public static function init() { - new Jetpack_Slideshow_Shortcode(); - } -} - -Jetpack_Slideshow_Shortcode::init(); diff --git a/plugins/jetpack/modules/shortcodes/soundcloud.php b/plugins/jetpack/modules/shortcodes/soundcloud.php deleted file mode 100644 index 71f281c3..00000000 --- a/plugins/jetpack/modules/shortcodes/soundcloud.php +++ /dev/null @@ -1,327 +0,0 @@ -<?php -/* -Plugin Name: SoundCloud Shortcode -Plugin URI: https://wordpress.org/extend/plugins/soundcloud-shortcode/ -Description: Converts SoundCloud WordPress shortcodes to a SoundCloud widget. Example: [soundcloud]http://soundcloud.com/forss/flickermood[/soundcloud] -Version: 2.3 -Author: SoundCloud Inc., simplified for Jetpack by Automattic, Inc. -Author URI: http://soundcloud.com -License: GPLv2 - -Original version: Johannes Wagener <johannes@soundcloud.com> -Options support: Tiffany Conroy <tiffany@soundcloud.com> -HTML5 & oEmbed support: Tim Bormans <tim@soundcloud.com> -*/ - -/* -A8C: Taken from http://plugins.svn.wordpress.org/soundcloud-shortcode/trunk/ -at revision 664386. - -Commenting out (instead of removing) and replacing code with custom modifs -so it's eqsy to see what differs from the standard DOTORG version. - -All custom modifs are annoted with "A8C" keyword in comment. -*/ - -/** - * Register oEmbed provider - */ - -/* - A8C: oEmbed is handled now in core; see wp-includes/class-oembed.php -wp_oembed_add_provider( '#https?://(?:api\.)?soundcloud\.com/.*#i', 'http://soundcloud.com/oembed', true ); -*/ - - -/** - * Register SoundCloud shortcode - */ - -add_shortcode( 'soundcloud', 'soundcloud_shortcode' ); - -/** - * SoundCloud shortcode handler - * - * @param string|array $atts The attributes passed to the shortcode like [soundcloud attr1="value" /]. - * Is an empty string when no arguments are given. - * @param string $content The content between non-self closing [soundcloud]...[/soundcloud] tags. - * - * @return string Widget embed code HTML - */ -function soundcloud_shortcode( $atts, $content = null ) { - - // Custom shortcode options - $shortcode_options = array_merge( array( 'url' => trim( $content ) ), is_array( $atts ) ? $atts : array() ); - - // Turn shortcode option "param" (param=value¶m2=value) into array - $shortcode_params = array(); - if ( isset( $shortcode_options['params'] ) ) { - parse_str( html_entity_decode( $shortcode_options['params'] ), $shortcode_params ); - } - $shortcode_options['params'] = $shortcode_params; - - /* - A8C: The original plugin exposes options we don't. SoundCloud omits "visual" shortcode - option when false, so if logic here remains, impossible to have non-visual shortcode. - $player_type = soundcloud_get_option( 'player_type', 'visual' ); - $isIframe = $player_type !== 'flash'; - $isVisual = ! $player_type || $player_type === 'visual' || $shortcode_options['visual']; - */ - - // User preference options - $plugin_options = array_filter( - array( - 'iframe' => true, // A8C: See above comment; flash is not a supported option - 'width' => soundcloud_get_option( 'player_width' ), - 'height' => soundcloud_url_has_tracklist( $shortcode_options['url'] ) ? soundcloud_get_option( 'player_height_multi' ) : soundcloud_get_option( 'player_height' ), - 'params' => array_filter( - array( - 'auto_play' => soundcloud_get_option( 'auto_play' ), - 'show_comments' => soundcloud_get_option( 'show_comments' ), - 'color' => soundcloud_get_option( 'color' ), - 'visual' => 'false', // A8C: Merged with params below at $options assignment - ) - ), - ) - ); - - // Needs to be an array - if ( ! isset( $plugin_options['params'] ) ) { - $plugin_options['params'] = array(); - } - - // plugin options < shortcode options - $options = array_merge( - $plugin_options, - $shortcode_options - ); - - // plugin params < shortcode params - $options['params'] = array_merge( - $plugin_options['params'], - $shortcode_options['params'] - ); - - // The "url" option is required - if ( ! isset( $options['url'] ) ) { - return ''; - } else { - $options['url'] = trim( $options['url'] ); - } - - // Both "width" and "height" need to be integers - if ( isset( $options['width'] ) && ! preg_match( '/^\d+$/', $options['width'] ) ) { - // set to 0 so oEmbed will use the default 100% and WordPress themes will leave it alone - $options['width'] = 0; - } - if ( isset( $options['height'] ) && ! preg_match( '/^\d+$/', $options['height'] ) ) { - unset( $options['height'] ); - } - - // The "iframe" option must be true to load the iframe widget - $iframe = soundcloud_booleanize( $options['iframe'] ); - - // Remove visual parameter from Flash widget, when it's false because that's the default, or when displaying the smallest player - if ( $options['params']['visual'] && ( ! $iframe || ! soundcloud_booleanize( $options['params']['visual'] ) || ( isset( $options['height'] ) && '20' == $options['height'] ) ) ) { - unset( $options['params']['visual'] ); - } - - // Merge in "url" value - $options['params'] = array_merge( - array( - 'url' => $options['url'], - ), - $options['params'] - ); - - // Return html embed code - if ( $iframe ) { - return soundcloud_iframe_widget( $options ); - } else { - return soundcloud_flash_widget( $options ); - } -} - -/** - * Plugin options getter - * - * @param string|array $option Option name - * @param mixed $default Default value - * - * @return mixed Option value - */ -function soundcloud_get_option( $option, $default = false ) { - $value = get_option( 'soundcloud_' . $option ); - - return $value === '' ? $default : $value; -} - -/** - * Booleanize a value - * - * @param boolean|string $value - * - * @return boolean - */ -function soundcloud_booleanize( $value ) { - return is_bool( $value ) ? $value : $value === 'true' ? true : false; -} - -/** - * Decide if a url has a tracklist - * - * @param string $url - * - * @return boolean - */ -function soundcloud_url_has_tracklist( $url ) { - return preg_match( '/^(.+?)\/(sets|groups|playlists)\/(.+?)$/', $url ); -} - -/** - * Parameterize url - * - * @param array $match Matched regex - * - * @return string Parameterized url - */ -function soundcloud_oembed_params_callback( $match ) { - global $soundcloud_oembed_params; - - // Convert URL to array - $url = parse_url( urldecode( $match[1] ) ); - // Convert URL query to array - parse_str( $url['query'], $query_array ); - // Build new query string - $query = http_build_query( array_merge( $query_array, $soundcloud_oembed_params ) ); - - return 'src="' . $url['scheme'] . '://' . $url['host'] . $url['path'] . '?' . $query; -} - -/** - * Iframe widget embed code - * - * @param array $options Parameters - * - * @return string Iframe embed code - */ -function soundcloud_iframe_widget( $options ) { - - // Build URL - $url = set_url_scheme( 'https://w.soundcloud.com/player/?' . http_build_query( $options['params'] ) ); - // Set default width if not defined - $width = isset( $options['width'] ) && $options['width'] !== 0 ? $options['width'] : '100%'; - // Set default height if not defined - $height = isset( $options['height'] ) && $options['height'] !== 0 - ? $options['height'] - : ( soundcloud_url_has_tracklist( $options['url'] ) || ( isset( $options['params']['visual'] ) && soundcloud_booleanize( $options['params']['visual'] ) ) ? '450' : '166' ); - - return sprintf( '<iframe width="%s" height="%s" scrolling="no" frameborder="no" src="%s"></iframe>', $width, $height, $url ); -} - -/** - * Legacy Flash widget embed code - * - * @param array $options Parameters - * - * @return string Flash embed code - */ -function soundcloud_flash_widget( $options ) { - // Build URL - $url = set_url_scheme( 'https://player.soundcloud.com/player.swf?' . http_build_query( $options['params'] ) ); - // Set default width if not defined - $width = isset( $options['width'] ) && $options['width'] !== 0 ? $options['width'] : '100%'; - // Set default height if not defined - $height = isset( $options['height'] ) && $options['height'] !== 0 ? $options['height'] : ( soundcloud_url_has_tracklist( $options['url'] ) ? '255' : '81' ); - - return preg_replace( - '/\s\s+/', - '', - sprintf( - '<object width="%s" height="%s"> - <param name="movie" value="%s" /> - <param name="allowscriptaccess" value="always" /> - <embed width="%s" height="%s" src="%s" allowscriptaccess="always" type="application/x-shockwave-flash"></embed> - </object>', - $width, - $height, - $url, - $width, - $height, - $url - ) - ); -} - -/** - * SoundCloud Embed Reversal - * - * Converts a generic HTML embed code from SoundClound into a - * WordPress.com-compatibly shortcode. - * - * @param string $content HTML content. - * - * @return string Parsed content. - */ -function jetpack_soundcloud_embed_reversal( $content ) { - if ( ! is_string( $content ) || false === stripos( $content, 'w.soundcloud.com/player' ) ) { - return $content; - } - - /* - Sample embed code: - - <iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/150745932&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true"></iframe> - */ - - $regexes = array(); - - $regexes[] = '#<iframe[^>]+?src="((?:https?:)?//w\.soundcloud\.com/player/[^"\']++)"[^>]*+>\s*?</iframe>#i'; - $regexes[] = '#<iframe(?:[^&]|&(?!gt;))+?src="((?:https?:)?//w\.soundcloud\.com/player/[^"\']++)"(?:[^&]|&(?!gt;))*+>\s*?</iframe>#i'; - - foreach ( $regexes as $regex ) { - if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) { - continue; - } - - foreach ( $matches as $match ) { - - // if pasted from the visual editor - prevent double encoding - $match[1] = str_replace( '&amp;', '&', $match[1] ); - - $args = parse_url( html_entity_decode( $match[1] ), PHP_URL_QUERY ); - $args = wp_parse_args( $args ); - - if ( ! preg_match( '#^(?:https?:)?//api\.soundcloud\.com/.+$#i', $args['url'], $url_matches ) ) { - continue; - } - - if ( ! preg_match( '#height="(\d+)"#i', $match[0], $hmatch ) ) { - $height = ''; - } else { - $height = ' height="' . intval( $hmatch[1] ) . '"'; - } - - unset( $args['url'] ); - $params = 'params="'; - if ( count( $args ) > 0 ) { - foreach ( $args as $key => $value ) { - $params .= esc_html( $key ) . '=' . esc_html( $value ) . '&'; - } - $params = substr( $params, 0, -5 ); - } - $params .= '"'; - - $shortcode = '[soundcloud url="' . esc_url( $url_matches[0] ) . '" ' . $params . ' width="100%"' . $height . ' iframe="true" /]'; - - $replace_regex = sprintf( '#\s*%s\s*#', preg_quote( $match[0], '#' ) ); - $content = preg_replace( $replace_regex, sprintf( "\n\n%s\n\n", $shortcode ), $content ); - /** This action is documented in modules/shortcodes/youtube.php */ - do_action( 'jetpack_embed_to_shortcode', 'soundcloud', $url_matches[0] ); - } - } - - return $content; -} - -add_filter( 'pre_kses', 'jetpack_soundcloud_embed_reversal' ); diff --git a/plugins/jetpack/modules/shortcodes/spotify.php b/plugins/jetpack/modules/shortcodes/spotify.php deleted file mode 100644 index 632838f1..00000000 --- a/plugins/jetpack/modules/shortcodes/spotify.php +++ /dev/null @@ -1,97 +0,0 @@ -<?php -/** - * Spotify shortcode. - * - * Usage: - * [spotify id="spotify:track:4bz7uB4edifWKJXSDxwHcs" width="400" height="100"] - */ - -if ( ! shortcode_exists( 'spotify' ) ) { - add_shortcode( 'spotify', 'jetpack_spotify_shortcode' ); - - if ( get_option( 'embed_autourls' ) ) { - // If user enabled autourls, also convert syntax like spotify:track:4bz7uB4edifWKJXSDxwHcs - add_filter( 'the_content', 'jetpack_spotify_embed_ids', 7 ); - } -} - -/** - * Parse shortcode arguments and render its output. - * - * @since 4.5.0 - * - * @param array $atts - * @param string $content - * - * @return string - */ -function jetpack_spotify_shortcode( $atts = array(), $content = '' ) { - - if ( ! empty( $content ) ) { - $id = $content; - } elseif ( ! empty( $atts['id'] ) ) { - $id = $atts['id']; - } elseif ( ! empty( $atts[0] ) ) { - $id = $atts[0]; - } else { - return '<!-- Missing Spotify ID -->'; - } - - if ( empty( $atts['width'] ) ) { - $atts['width'] = 300; - } - - if ( empty( $atts['height'] ) ) { - $atts['height'] = 380; - } - - $atts['width'] = (int) $atts['width']; - $atts['height'] = (int) $atts['height']; - - // Spotify accepts both URLs and their Spotify ID format, so let them sort it out and validate - $embed_url = add_query_arg( 'uri', urlencode( $id ), 'https://embed.spotify.com/' ); - - return '<iframe src="' . esc_url( $embed_url ) . '" style="display:block; margin:0 auto; width:' . esc_attr( $atts['width'] ) . 'px; height:' . esc_attr( $atts['height'] ) . 'px;" frameborder="0" allowtransparency="true"></iframe>'; -} - -/** - * Turn text like this on it's own line into an embed: spotify:track:4bz7uB4edifWKJXSDxwHcs - * The core WordPress embed functionality only works with URLs - * Modified version of WP_Embed::autoembed() - * - * @since 4.5.0 - * - * @param $content - * - * @return string - */ -function jetpack_spotify_embed_ids( $content ) { - $textarr = wp_html_split( $content ); - - foreach ( $textarr as &$element ) { - if ( '' == $element || '<' === $element[0] ) { - continue; - } - - if ( substr( ltrim( $element ), 0, 8 ) !== 'spotify:' ) { - continue; - } - - $element = preg_replace_callback( '|^\s*(spotify:[^\s"]+:[^\s"]+)\s*$|im', 'jetpack_spotify_embed_ids_callback', $element ); - } - - return implode( '', $textarr ); -} - -/** - * Call shortcode with ID provided by matching pattern. - * - * @since 4.5.0 - * - * @param array $matches - * - * @return string - */ -function jetpack_spotify_embed_ids_callback( $matches ) { - return "\n" . jetpack_spotify_shortcode( array(), $matches[1] ) . "\n"; -} diff --git a/plugins/jetpack/modules/shortcodes/ted.php b/plugins/jetpack/modules/shortcodes/ted.php deleted file mode 100644 index f66f77d5..00000000 --- a/plugins/jetpack/modules/shortcodes/ted.php +++ /dev/null @@ -1,78 +0,0 @@ -<?php -/* - * TED Player embed code - * http://www.ted.com - * - * http://www.ted.com/talks/view/id/210 - * http://www.ted.com/talks/marc_goodman_a_vision_of_crimes_in_the_future.html - * [ted id="210" lang="en"] - * [ted id="http://www.ted.com/talks/view/id/210" lang="en"] - * [ted id=1539 lang=fr width=560 height=315] - */ - -wp_oembed_add_provider( '!https?://(www\.)?ted.com/talks/view/id/.+!i', 'http://www.ted.com/talks/oembed.json', true ); -wp_oembed_add_provider( '!https?://(www\.)?ted.com/talks/[a-zA-Z\-\_]+\.html!i', 'http://www.ted.com/talks/oembed.json', true ); - -function jetpack_shortcode_get_ted_id( $atts ) { - return ( ! empty( $atts['id'] ) ? $atts['id'] : 0 ); -} - -add_shortcode( 'ted', 'shortcode_ted' ); -function shortcode_ted( $atts ) { - global $wp_embed; - - $defaults = array( - 'id' => '', - 'width' => '', - 'height' => '', - 'lang' => 'en', - ); - $atts = shortcode_atts( $defaults, $atts, 'ted' ); - - if ( empty( $atts['id'] ) ) { - return '<!-- Missing TED ID -->'; - } - - $url = ''; - if ( preg_match( '#^[\d]+$#', $atts['id'], $matches ) ) { - $url = 'http://ted.com/talks/view/id/' . $matches[0]; - } elseif ( preg_match( '#^https?://(www\.)?ted\.com/talks/view/id/[0-9]+$#', $atts['id'], $matches ) ) { - $url = $matches[0]; - } - - unset( $atts['id'] ); - - $args = array(); - if ( is_numeric( $atts['width'] ) ) { - $args['width'] = $atts['width']; - } elseif ( $embed_size_w = get_option( 'embed_size_w' ) ) { - $args['width'] = $embed_size_w; - } elseif ( ! empty( $GLOBALS['content_width'] ) ) { - $args['width'] = (int) $GLOBALS['content_width']; - } else { - $args['width'] = 500; - } - - // Default to a 16x9 aspect ratio if there's no height set - if ( is_numeric( $atts['height'] ) ) { - $args['height'] = $atts['height']; - } else { - $args['height'] = $args['width'] * 0.5625; - } - - if ( ! empty( $atts['lang'] ) ) { - $args['lang'] = sanitize_key( $atts['lang'] ); - add_filter( 'oembed_fetch_url', 'ted_filter_oembed_fetch_url', 10, 3 ); - } - $retval = $wp_embed->shortcode( $args, $url ); - remove_filter( 'oembed_fetch_url', 'ted_filter_oembed_fetch_url', 10 ); - - return $retval; -} - -/** - * Filter the request URL to also include the $lang parameter - */ -function ted_filter_oembed_fetch_url( $provider, $url, $args ) { - return add_query_arg( 'lang', $args['lang'], $provider ); -} diff --git a/plugins/jetpack/modules/shortcodes/tweet.php b/plugins/jetpack/modules/shortcodes/tweet.php deleted file mode 100644 index 5d6acd29..00000000 --- a/plugins/jetpack/modules/shortcodes/tweet.php +++ /dev/null @@ -1,276 +0,0 @@ -<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName -/** - * Tweet shortcode. - * Params map to key value pairs, and all but tweet are optional: - * tweet = id or permalink url* (Required) - * align = none|left|right|center - * width = number in pixels example: width="300" - * lang = en|fr|de|ko|etc... language country code. - * hide_thread = true | false ** - * hide_media = true | false ** - * - * Basic: - * [tweet https://twitter.com/jack/statuses/20 width="350"] - * - * More parameters and another tweet syntax admitted: - * [tweet tweet="https://twitter.com/jack/statuses/20" align="left" width="350" align="center" lang="es"] - * - * @package Jetpack - */ - -add_shortcode( 'tweet', array( 'Jetpack_Tweet', 'jetpack_tweet_shortcode' ) ); - -/** - * Tweet Shortcode class. - */ -class Jetpack_Tweet { - - /** - * Array of arguments about a tweet. - * - * @var array - */ - public static $provider_args; - - /** - * Parse shortcode arguments and render its output. - * - * @since 4.5.0 - * - * @param array $atts Shortcode parameters. - * - * @return string - */ - public static function jetpack_tweet_shortcode( $atts ) { - global $wp_embed; - - $default_atts = array( - 'tweet' => '', - 'align' => 'none', - 'width' => '', - 'lang' => 'en', - 'hide_thread' => 'false', - 'hide_media' => 'false', - ); - - $attr = shortcode_atts( $default_atts, $atts ); - - self::$provider_args = $attr; - - /* - * figure out the tweet id for the requested tweet - * supporting both omitted attributes and tweet="tweet_id" - * and supporting both an id and a URL - */ - if ( empty( $attr['tweet'] ) && ! empty( $atts[0] ) ) { - $attr['tweet'] = $atts[0]; - } - - if ( ctype_digit( $attr['tweet'] ) ) { - $id = 'https://twitter.com/jetpack/status/' . $attr['tweet']; - $tweet_id = intval( $attr['tweet'] ); - } else { - preg_match( '/^http(s|):\/\/twitter\.com(\/\#\!\/|\/)([a-zA-Z0-9_]{1,20})\/status(es)*\/(\d+)$/', $attr['tweet'], $urlbits ); - - if ( isset( $urlbits[5] ) && intval( $urlbits[5] ) ) { - $id = 'https://twitter.com/' . $urlbits[3] . '/status/' . intval( $urlbits[5] ); - $tweet_id = intval( $urlbits[5] ); - } else { - return '<!-- Invalid tweet id -->'; - } - } - - /* - * Fetch tweet. - * - * On WordPress.com, we also cache tweets for better performance and less requests. - */ - if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { - /* - * See if we have the tweet stored in our tweet store - * if not get_tweet_store queues up a job to request - */ - $data = get_tweet_store( $tweet_id ); - if ( $data ) { - $tweet_handler = new Tweet_Handler(); - - /* - * Replace Unicode characters with ther entities like Blackbird Pie v 0.3.2 did - * to store tweets from other languages (important for non-english bloggers) - */ - $data->text = $tweet_handler->unicode_replace_entities( $data->text ); - $data->user->screen_name = $tweet_handler->unicode_replace_entities( $data->user->screen_name ); - $data->user->name = $tweet_handler->unicode_replace_entities( $data->user->name ); - - $tweet = esc_html( $data->text ); - $tweet = $tweet_handler->expand_tco_links( $tweet, $data ); - - $tweet = $tweet_handler->autolink( $tweet ); - - $screen_name = esc_html( $data->user->screen_name ); - $name = esc_html( $data->user->name ); - - $url = 'https://twitter.com/' . $screen_name . '/status/' . intval( $data->id ); - - // Only show the user's real name if they set it to something different from their screename. - if ( $screen_name !== $name ) { - $real_name = '<br />' . $name; - } else { - $real_name = '<br /> '; - } - - $time = strtotime( $data->created_at ); - $human_readable = date( 'F d, Y', $time ); - $data_datetime = date( 'Y-m-d\TH:i:sP', $time ); - - /* - * Additional params. - */ - - // align (float). - $extra_classes = ''; - if ( in_array( $attr['align'], array( 'left', 'right', 'center' ), true ) ) { - $extra_classes = ' tw-align-' . $attr['align']; - } - - if ( 'true' === $attr['hide_thread'] ) { - $extra_classes .= ' tw-hide-thread'; - } - - if ( 'true' === $attr['hide_media'] ) { - $extra_classes .= ' tw-hide-media'; - } - - // lang. - $lang = substr( $attr['lang'], 0, 2 ); - if ( empty( $lang ) ) { - $lang = 'en'; - } - - // width. - $width_html = ''; - $width = intval( $attr['width'] ); - if ( $width > 100 ) { - $width_html = ' width="' . esc_attr( $width ) . '"'; - } - - // in reply to id (conversation tweets). - $in_reply_to_html = ''; - $in_reply_to = intval( $data->in_reply_to_status_id ); - if ( ! empty( $in_reply_to ) && 'false' === $attr['hide_thread'] ) { - $in_reply_to_html = ' data-in-reply-to="' . esc_attr( $in_reply_to ) . '"'; - } - - // Generate the HTML output. - $output = sprintf( - '<blockquote class="twitter-tweet%1$s"%2$s%3$s lang="%4$s"><p>%5$s</p>— %6$s (@%7$s) <a href="%8$s" data-datetime="%9$s">%10$s</a></blockquote>', - esc_attr( $extra_classes ), - $width_html, - $in_reply_to_html, - esc_attr( $lang ), - $tweet, - wp_kses( $real_name, array( 'br' => array() ) ), - esc_html( $screen_name ), - esc_url( $url ), - esc_attr( $data_datetime ), - esc_html( $human_readable ) - ); - } else { - /** - * Filter the default display when a tweet is not available in the store. - * Not available in Jetpack. - * - * @module shortcodes - * - * @since 5.1.0 - * - * @param string $message Default display when a tweet is not available. - * @param string $id Twitter URL. - * @param array $attr Shortcode attributes. - */ - return apply_filters( 'tweet_shortcode_pending_tweet', '', $id, $attr ); - } - } else { - // Add shortcode arguments to provider URL. - add_filter( 'oembed_fetch_url', array( 'Jetpack_Tweet', 'jetpack_tweet_url_extra_args' ), 10, 3 ); - - /* - * In Jetpack, we use $wp_embed->shortcode() to return the tweet output. - * @see https://github.com/Automattic/jetpack/pull/11173 - */ - $output = $wp_embed->shortcode( $atts, $id ); - - // Clean up filter. - remove_filter( 'oembed_fetch_url', array( 'Jetpack_Tweet', 'jetpack_tweet_url_extra_args' ), 10 ); - } - - // Add Twitter widgets.js script to the footer. - add_action( 'wp_footer', array( 'Jetpack_Tweet', 'jetpack_tweet_shortcode_script' ) ); - - /** This action is documented in modules/widgets/social-media-icons.php */ - do_action( 'jetpack_bump_stats_extras', 'embeds', 'tweet' ); - - return $output; - } - - /** - * Adds parameters to URL used to fetch the tweet. - * - * @since 4.5.0 - * - * @param string $provider URL of provider that supplies the tweet we're requesting. - * @param string $url URL of tweet to embed. - * @param array $args Parameters supplied to shortcode and passed to wp_oembed_get. - * - * @return string - */ - public static function jetpack_tweet_url_extra_args( $provider, $url, $args = array() ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable - foreach ( self::$provider_args as $key => $value ) { - switch ( $key ) { - case 'align': - case 'lang': - case 'hide_thread': - case 'hide_media': - $provider = add_query_arg( $key, $value, $provider ); - break; - } - } - - // Disable script since we're enqueing it in our own way in the footer. - $provider = add_query_arg( 'omit_script', 'true', $provider ); - - // Twitter doesn't support maxheight so don't send it. - $provider = remove_query_arg( 'maxheight', $provider ); - - /** - * Filter the Twitter Partner ID. - * - * @module shortcodes - * - * @since 4.6.0 - * - * @param string $partner_id Twitter partner ID. - */ - $partner = apply_filters( 'jetpack_twitter_partner_id', 'jetpack' ); - - // Add Twitter partner ID to track embeds from Jetpack. - if ( ! empty( $partner ) ) { - $provider = add_query_arg( 'partner', $partner, $provider ); - } - - return $provider; - } - - /** - * Enqueue front end assets. - * - * @since 4.5.0 - */ - public static function jetpack_tweet_shortcode_script() { - if ( ! wp_script_is( 'twitter-widgets', 'registered' ) ) { - wp_register_script( 'twitter-widgets', 'https://platform.twitter.com/widgets.js', array(), JETPACK__VERSION, true ); - wp_print_scripts( 'twitter-widgets' ); - } - } - -} // class end diff --git a/plugins/jetpack/modules/shortcodes/twitchtv.php b/plugins/jetpack/modules/shortcodes/twitchtv.php deleted file mode 100644 index a5439d05..00000000 --- a/plugins/jetpack/modules/shortcodes/twitchtv.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php -/** - * twitch.tv shortcode - * [twitchtv url='http://www.twitch.tv/paperbat' height='378' width='620' autoplay='false'] - * [twitchtv url='http://www.twitch.tv/paperbat/b/323486192' height='378' width='620' autoplay='false'] - **/ - -/** - * (Live URL) http://www.twitch.tv/paperbat - * - * <iframe src="https://player.twitch.tv/?autoplay=false&muted=false&channel=paperbat" width="620" height="378" frameborder="0" scrolling="no" allowfullscreen></iframe> - * - * (Archive URL) http://www.twitch.tv/paperbat/v/323486192 - * - * <iframe src="https://player.twitch.tv/?autoplay=false&muted=false&video=v323486192" width="620" height="378" frameborder="0" scrolling="no" allowfullscreen></iframe> - * - * @param $atts array User supplied shortcode arguments. - * - * @return string HTML output of the shortcode. - */ -function wpcom_twitchtv_shortcode( $atts ) { - $attr = shortcode_atts( - array( - 'height' => 378, - 'width' => 620, - 'url' => '', - 'autoplay' => 'false', - 'muted' => 'false', - 'time' => null, - ), - $atts - ); - - if ( empty( $attr['url'] ) ) { - return '<!-- Invalid twitchtv URL -->'; - } - - preg_match( '|^http://www.twitch.tv/([^/?]+)(/v/(\d+))?|i', $attr['url'], $match ); - - $url_args = array( - 'autoplay' => ( false !== $attr['autoplay'] && 'false' !== $attr['autoplay'] ) ? 'true' : 'false', - 'muted' => ( false !== $attr['muted'] && 'false' !== $attr['muted'] ) ? 'true' : 'false', - 'time' => $attr['time'], - ); - - $width = intval( $attr['width'] ); - $height = intval( $attr['height'] ); - - $user_id = $match[1]; - $video_id = 0; - if ( ! empty( $match[3] ) ) { - $video_id = (int) $match[3]; - } - - do_action( 'jetpack_bump_stats_extras', 'twitchtv', 'shortcode' ); - - if ( $video_id > 0 ) { - $url_args['video'] = 'v' . $video_id; - } else { - $url_args['channel'] = $user_id; - } - - $url = add_query_arg( $url_args, 'https://player.twitch.tv/' ); - - return sprintf( - '<iframe src="%s" width="%d" height="%d" frameborder="0" scrolling="no" allowfullscreen></iframe>', - esc_url( $url ), - esc_attr( $width ), - esc_attr( $height ) - ); -} - -add_shortcode( 'twitch', 'wpcom_twitchtv_shortcode' ); -add_shortcode( 'twitchtv', 'wpcom_twitchtv_shortcode' ); diff --git a/plugins/jetpack/modules/shortcodes/twitter-timeline.php b/plugins/jetpack/modules/shortcodes/twitter-timeline.php deleted file mode 100644 index 38558b49..00000000 --- a/plugins/jetpack/modules/shortcodes/twitter-timeline.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php -add_shortcode( 'twitter-timeline', 'twitter_timeline_shortcode' ); - -function twitter_timeline_shortcode( $atts ) { - $default_atts = array( - 'username' => '', - 'id' => '', - 'width' => '450', - 'height' => '282', - ); - - $atts = shortcode_atts( $default_atts, $atts, 'twitter-timeline' ); - - $atts['username'] = preg_replace( '/[^A-Za-z0-9_]+/', '', $atts['username'] ); - - if ( empty( $atts['username'] ) && ! is_numeric( $atts['id'] ) ) { - return '<!-- ' . __( 'Must specify Twitter Timeline id or username.', 'jetpack' ) . ' -->'; - } - - $output = '<a class="twitter-timeline"'; - - /** This filter is documented in modules/shortcodes/tweet.php */ - $partner = apply_filters( 'jetpack_twitter_partner_id', 'jetpack' ); - if ( ! empty( $partner ) ) { - $output .= ' data-partner="' . esc_attr( $partner ) . '"'; - } - if ( is_numeric( $atts['width'] ) ) { - $output .= ' data-width="' . esc_attr( $atts['width'] ) . '"'; - } - if ( is_numeric( $atts['height'] ) ) { - $output .= ' data-height="' . esc_attr( $atts['height'] ) . '"'; - } - if ( is_numeric( $atts['id'] ) ) { - $output .= ' data-widget-id="' . esc_attr( $atts['id'] ) . '"'; - } - if ( ! empty( $atts['username'] ) ) { - $output .= ' href="' . esc_url( 'https://twitter.com/' . $atts['username'] ) . '"'; - } - - $output .= '>'; - - $output .= sprintf( __( 'Tweets by @%s', 'jetpack' ), $atts['username'] ); - - $output .= '</a>'; - - wp_enqueue_script( 'jetpack-twitter-timeline' ); - - return $output; -} - -function twitter_timeline_js() { - if ( is_customize_preview() ) { - wp_enqueue_script( 'jetpack-twitter-timeline' ); - } -} -add_action( 'wp_enqueue_scripts', 'twitter_timeline_js' ); diff --git a/plugins/jetpack/modules/shortcodes/unavailable.php b/plugins/jetpack/modules/shortcodes/unavailable.php deleted file mode 100644 index 9a6bb201..00000000 --- a/plugins/jetpack/modules/shortcodes/unavailable.php +++ /dev/null @@ -1,78 +0,0 @@ -<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName -/** - * Display a message on the frontend when we retire a shortcode, - * explaining why the shortcode is not available anymore. - * - * @package Jetpack - */ - -/** - * Class Jetpack_Shortcode_Unavailable - */ -class Jetpack_Shortcode_Unavailable { - /** - * Set up the actions and filters for the class to listen to. - * - * @param array $shortcodes An associative array of keys being the shortcodes that are unavailable, and a string explaining why. - */ - public function __construct( $shortcodes ) { - $this->shortcodes = $shortcodes; - - add_action( 'template_redirect', array( $this, 'add_shortcodes' ) ); - } - - /** - * For all of our defined unavailable shortcodes, if something else hasn't - * already claimed them, add a handler to nullify their output. - */ - public function add_shortcodes() { - foreach ( array_keys( $this->shortcodes ) as $shortcode ) { - if ( ! shortcode_exists( $shortcode ) ) { - add_shortcode( $shortcode, array( $this, 'stub_shortcode' ) ); - } - } - } - - /** - * Nullify the output of unavailable shortcodes. Includes a filter to make - * it easier to notify admins that a shortcode that they used is unavailable. - * - * @param array $atts Shortcode attributes. - * @param string $content Post content. - * @param string $shortcode Shortcode name. - * - * @return mixed|void - */ - public function stub_shortcode( $atts, $content = '', $shortcode = '' ) { - $str = ''; - if ( current_user_can( 'edit_posts' ) && ! empty( $this->shortcodes[ $shortcode ] ) ) { - $str = sprintf( '<div><strong>%s</strong></div>', $this->shortcodes[ $shortcode ] ); - } - /** - * Filter the front-end output of unavailable shortcodes. - * - * @module shortcodes - * - * @since 4.5.0 - * - * @param string $str The html displayed in lieu of the shortcode. - * @param array $atts The attributes (numeric or named) passed to the shortcode. - * @param string $content The content (if any) between the opening and closing tags. - * @param string $shortcode The shortcode tag used to invoke this. - */ - return apply_filters( 'jetpack_stub_shortcode', $str, $atts, $content, $shortcode ); - } -} - -/** - * Init class. - */ -function jetpack_init_shortcode_unavailable() { - new Jetpack_Shortcode_Unavailable( - array( - 'blip.tv' => __( 'The Blip.tv service has been shut down since August 20th, 2015.', 'jetpack' ), - 'lytro' => __( 'Lytro has been shut down since March 2019.', 'jetpack' ), - ) - ); -} -add_action( 'init', 'jetpack_init_shortcode_unavailable' ); diff --git a/plugins/jetpack/modules/shortcodes/untappd-menu.php b/plugins/jetpack/modules/shortcodes/untappd-menu.php deleted file mode 100644 index f8f62f0b..00000000 --- a/plugins/jetpack/modules/shortcodes/untappd-menu.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php -/** - * Untappd Shortcodes - * - * @author kraftbj - * - * [untappd-menu location="123" theme="123"] - * @since 4.1.0 - * @param location int Location ID for the Untappd venue. Required. - * @param theme int Theme ID for the Untappd menu. Required. - */ - -class Jetpack_Untappd { - - function __construct() { - add_action( 'init', array( $this, 'action_init' ) ); - } - - function action_init() { - add_shortcode( 'untappd-menu', array( $this, 'menu_shortcode' ) ); - } - - /** - * [untappd-menu] shortcode. - */ - static function menu_shortcode( $atts, $content = '' ) { - // Let's bail if we don't have location or theme. - if ( ! isset( $atts['location'] ) || ! isset( $atts['theme'] ) ) { - if ( current_user_can( 'edit_posts' ) ) { - return __( 'No location or theme ID provided in the untappd-menu shortcode.', 'jetpack' ); - } - return; - } - - // Let's apply some defaults. - $atts = shortcode_atts( - array( - 'location' => '', - 'theme' => '', - ), - $atts, - 'untappd-menu' - ); - - // We're going to clean the user input. - $atts = array_map( 'absint', $atts ); - - if ( $atts['location'] < 1 || $atts['theme'] < 1 ) { - return; - } - - static $untappd_menu = 1; - - $html = '<div id="menu-container-untappd-' . $untappd_menu . '" class="untappd-menu"></div>'; - $html .= '<script type="text/javascript">' . PHP_EOL; - $html .= '!function(e,n){var t=document.createElement("script"),a=document.getElementsByTagName("script")[0];' . PHP_EOL; - $html .= 't.async=1,a.parentNode.insertBefore(t,a),t.onload=t.onreadystatechange=function(e,a){' . PHP_EOL; - $html .= '(a||!t.readyState||/loaded|complete/.test(t.readyState))&&(t.onload=t.onreadystatechange=null,t=void 0,a||n&&n())},' . PHP_EOL; - $html .= 't.src=e}("https://embed-menu-preloader.untappdapi.com/embed-menu-preloader.min.js",function(){' . PHP_EOL; - $html .= 'PreloadEmbedMenu( "menu-container-untappd-' . $untappd_menu . '",' . $atts['location'] . ',' . $atts['theme'] . ' )});' . PHP_EOL; - $html .= '</script>'; - - $untappd_menu++; - - return $html; - } -} - -new Jetpack_Untappd(); diff --git a/plugins/jetpack/modules/shortcodes/upcoming-events.php b/plugins/jetpack/modules/shortcodes/upcoming-events.php deleted file mode 100644 index 02f6dda1..00000000 --- a/plugins/jetpack/modules/shortcodes/upcoming-events.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -/** - * Most of the heavy lifting done in iCalendarReader class - */ -class Upcoming_Events_Shortcode { - - public static function init() { - add_shortcode( 'upcomingevents', array( __CLASS__, 'shortcode' ) ); - } - - public static function shortcode( $atts = array() ) { - jetpack_require_lib( 'icalendar-reader' ); - $atts = shortcode_atts( - array( - 'url' => '', - 'number' => 0, - ), - $atts, - 'upcomingevents' - ); - $args = array( - 'context' => 'shortcode', - 'number' => absint( $atts['number'] ), - ); - $events = icalendar_render_events( $atts['url'], $args ); - - if ( ! $events ) { - $events = sprintf( '<p>%s</p>', __( 'No upcoming events', 'jetpack' ) ); - } - - return $events; - } -} - -add_action( 'plugins_loaded', array( 'Upcoming_Events_Shortcode', 'init' ), 101 ); diff --git a/plugins/jetpack/modules/shortcodes/ustream.php b/plugins/jetpack/modules/shortcodes/ustream.php deleted file mode 100644 index 0ab664c1..00000000 --- a/plugins/jetpack/modules/shortcodes/ustream.php +++ /dev/null @@ -1,135 +0,0 @@ -<?php -/** - * Ustream.tv shortcode - * - * Example: - * [ustream id=1524 live=1] - * [ustreamsocial id=12980237 width="500"] - * - * Embed code example, from http://www.ustream.tv/leolaporte - * <iframe src="http://www.ustream.tv/embed/recorded/1524?v=3&wmode=direct" width="480" height="296" scrolling="no" frameborder="0" style="border: 0 none transparent;"></iframe> - * - * @package Jetpack - */ - -add_shortcode( 'ustream', 'ustream_shortcode' ); -add_shortcode( 'ustreamsocial', 'ustreamsocial_shortcode' ); - -/** - * Parse shortcode arguments and render output for ustream single video. - * - * @since 4.5.0 - * - * @param array $atts array of user-supplied arguments. - * - * @return string HTML output. - */ -function ustream_shortcode( $atts ) { - if ( isset( $atts[0] ) ) { - return '<!-- ustream error: bad parameters -->'; - } - - $defaults = array( - 'width' => 480, - 'height' => 296, - 'id' => 0, - 'live' => 0, - 'highlight' => 0, - 'version' => 3, - 'hwaccel' => 1, - ); - $atts = array_map( 'intval', shortcode_atts( $defaults, $atts ) ); - - if ( 0 >= $atts['id'] ) { - return '<!-- ustream error: bad video ID -->'; - } - - if ( 0 >= $atts['height'] ) { - return '<!-- ustream error: height invalid -->'; - } - - if ( 0 >= $atts['width'] ) { - return '<!-- ustream error: width invalid -->'; - } - - if ( $atts['live'] ) { - $recorded = ''; - } else { - $recorded = 'recorded/'; - } - - if ( ! $atts['live'] && ( 0 < $atts['highlight'] ) ) { - $highlight = sprintf( '/highlight/%d', esc_attr( $atts['highlight'] ) ); - } else { - $highlight = ''; - } - - $url_base = sprintf( - 'https://www.ustream.tv/embed/%s%d%s', - $recorded, - esc_attr( $atts['id'] ), - $highlight - ); - - $video_options = array( - 'html5ui' => 1, - 'v' => absint( $atts['version'] ), - ); - - if ( 0 < $atts['hwaccel'] ) { - $video_options['wmode'] = 'direct'; - } - - $url = add_query_arg( - $video_options, - $url_base - ); - - $output = sprintf( - '<iframe src="%1$s" width="%2$d" height="%3$d" scrolling="no" style="border: 0 none transparent;"></iframe>', - esc_url( $url ), - absint( $atts['width'] ), - absint( $atts['height'] ) - ); - - return $output; -} - -/** - * Parse shortcode arguments and render output for ustream's Social Stream. - * - * @since 4.5.0 - * - * @param array $atts array of user-supplied arguments. - * - * @return string HTML output. - */ -function ustreamsocial_shortcode( $atts ) { - $defaults = array( - 'id' => 0, - 'height' => 420, - 'width' => 320, - ); - $atts = array_map( 'intval', shortcode_atts( $defaults, $atts ) ); - - if ( 0 >= $atts['id'] ) { - return '<!-- ustreamsocial error: bad social stream ID -->'; - } - - if ( 0 >= $atts['height'] ) { - return '<!-- ustreamsocial error: height invalid -->'; - } - - if ( 0 >= $atts['width'] ) { - return '<!-- ustreamsocial error: width invalid -->'; - } - - $url = 'https://www.ustream.tv/socialstream/' . esc_attr( $atts['id'] ); - - return sprintf( - '<iframe id="SocialStream" src="%1$s" class="" name="SocialStream" width="%2$d" height="%3$d" scrolling="no" allowtransparency="true" style="visibility: visible; margin-top: 0; margin-bottom: 0; border: 0;"></iframe>', - esc_url( $url ), - absint( $atts['width'] ), - absint( $atts['height'] ) - ); -} diff --git a/plugins/jetpack/modules/shortcodes/videopress.php b/plugins/jetpack/modules/shortcodes/videopress.php deleted file mode 100644 index a4bfd167..00000000 --- a/plugins/jetpack/modules/shortcodes/videopress.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php -/** - * Provides VideoPress videos support when module is disabled. - * - * @since 2.4 - * @since 3.9.5 Added compatibility with refactored VideoPress module. - */ - -if ( ! Jetpack::is_module_active( 'videopress' ) ) { - - Jetpack::dns_prefetch( - array( - '//v0.wordpress.com', - ) - ); - - include_once JETPACK__PLUGIN_DIR . 'modules/videopress/utility-functions.php'; - include_once JETPACK__PLUGIN_DIR . 'modules/videopress/shortcode.php'; - -} diff --git a/plugins/jetpack/modules/shortcodes/vimeo.php b/plugins/jetpack/modules/shortcodes/vimeo.php deleted file mode 100644 index 91492d9c..00000000 --- a/plugins/jetpack/modules/shortcodes/vimeo.php +++ /dev/null @@ -1,301 +0,0 @@ -<?php - -/* -[vimeo 141358] -[vimeo http://vimeo.com/141358] -[vimeo 141358 h=500&w=350] -[vimeo id=141358 width=350 height=500] - -<iframe src="http://player.vimeo.com/video/18427511" width="400" height="225" frameborder="0"></iframe><p><a href="http://vimeo.com/18427511">Eskmo 'We Got More' (Official Video)</a> from <a href="http://vimeo.com/ninjatune">Ninja Tune</a> on <a href="http://vimeo.com">Vimeo</a>.</p> -*/ - -function jetpack_shortcode_get_vimeo_id( $atts ) { - if ( isset( $atts[0] ) ) { - $atts[0] = trim( $atts[0], '=' ); - $id = false; - if ( is_numeric( $atts[0] ) ) { - $id = (int) $atts[0]; - } elseif ( preg_match( '|vimeo\.com/(\d+)/?$|i', $atts[0], $match ) ) { - $id = (int) $match[1]; - } elseif ( preg_match( '|player\.vimeo\.com/video/(\d+)/?$|i', $atts[0], $match ) ) { - $id = (int) $match[1]; - } - - return $id; - } - - return 0; -} - -/** - * Convert a Vimeo shortcode into an embed code. - * - * @param array $atts An array of shortcode attributes. - * - * @return string The embed code for the Vimeo video. - */ -function vimeo_shortcode( $atts ) { - global $content_width; - - $attr = array_map( - 'intval', - shortcode_atts( - array( - 'id' => 0, - 'width' => 0, - 'height' => 0, - 'autoplay' => 0, - 'loop' => 0, - ), - $atts - ) - ); - - if ( isset( $atts[0] ) ) { - $attr['id'] = jetpack_shortcode_get_vimeo_id( $atts ); - } - - if ( ! $attr['id'] ) { - return '<!-- vimeo error: not a vimeo video -->'; - } - - // [vimeo 141358 h=500&w=350] - $params = shortcode_new_to_old_params( $atts ); // h=500&w=350 - $params = str_replace( array( '&', '&' ), '&', $params ); - parse_str( $params, $args ); - - $width = intval( $attr['width'] ); - $height = intval( $attr['height'] ); - - // Support w and h argument as fallback. - if ( empty( $width ) && isset( $args['w'] ) ) { - $width = intval( $args['w'] ); - - if ( empty( $height ) && ! isset( $args['h'] ) ) { - // The case where w=300 is specified without h=200, otherwise $height - // will always equal the default of 300, no matter what w was set to. - $height = round( ( $width / 640 ) * 360 ); - } - } - - if ( empty( $height ) && isset( $args['h'] ) ) { - $height = (int) $args['h']; - - if ( ! isset( $args['w'] ) ) { - $width = round( ( $height / 360 ) * 640 ); - } - } - - if ( ! $width && ! empty( $content_width ) ) { - $width = absint( $content_width ); - } - - // If setting the width with content_width has failed, defaulting - if ( ! $width ) { - $width = 640; - } - - if ( ! $height ) { - $height = round( ( $width / 640 ) * 360 ); - } - - /** - * Filter the Vimeo player width. - * - * @module shortcodes - * - * @since 3.4.0 - * - * @param int $width Width of the Vimeo player in pixels. - */ - $width = (int) apply_filters( 'vimeo_width', $width ); - - /** - * Filter the Vimeo player height. - * - * @module shortcodes - * - * @since 3.4.0 - * - * @param int $height Height of the Vimeo player in pixels. - */ - $height = (int) apply_filters( 'vimeo_height', $height ); - - $url = esc_url( 'https://player.vimeo.com/video/' . $attr['id'] ); - - // Handle autoplay and loop arguments. - if ( - isset( $args['autoplay'] ) && '1' === $args['autoplay'] // Parsed from the embedded URL. - || $attr['autoplay'] // Parsed from shortcode arguments. - || in_array( 'autoplay', $atts ) // Catch the argument passed without a value. - ) { - $url = add_query_arg( 'autoplay', 1, $url ); - } - - if ( - isset( $args['loop'] ) && '1' === $args['loop'] // Parsed from the embedded URL. - || $attr['loop'] // Parsed from shortcode arguments. - || in_array( 'loop', $atts ) // Catch the argument passed without a value. - ) { - $url = add_query_arg( 'loop', 1, $url ); - } - - $html = sprintf( - '<div class="embed-vimeo" style="text-align: center;"><iframe src="%1$s" width="%2$u" height="%3$u" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>', - esc_url( $url ), - esc_attr( $width ), - esc_attr( $height ) - ); - - /** - * Filter the Vimeo player HTML. - * - * @module shortcodes - * - * @since 1.2.3 - * - * @param string $html Embedded Vimeo player HTML. - */ - $html = apply_filters( 'video_embed_html', $html ); - - return $html; -} - -add_shortcode( 'vimeo', 'vimeo_shortcode' ); - -/** - * Callback to modify output of embedded Vimeo video using Jetpack's shortcode. - * - * @since 3.9 - * - * @param array $matches Regex partial matches against the URL passed. - * @param array $attr Attributes received in embed response - * @param array $url Requested URL to be embedded - * - * @return string Return output of Vimeo shortcode with the proper markup. - */ -function wpcom_vimeo_embed_url( $matches, $attr, $url ) { - return vimeo_shortcode( array( $url ) ); -} - -/** - * For bare URLs on their own line of the form - * http://vimeo.com/12345 - * - * @since 3.9 - * - * @uses wpcom_vimeo_embed_url - */ -function wpcom_vimeo_embed_url_init() { - wp_embed_register_handler( 'wpcom_vimeo_embed_url', '#https?://(.+\.)?vimeo\.com/#i', 'wpcom_vimeo_embed_url' ); -} - -// Register handler to modify Vimeo embeds using Jetpack's shortcode output. -add_action( 'init', 'wpcom_vimeo_embed_url_init' ); - -function vimeo_embed_to_shortcode( $content ) { - if ( ! is_string( $content ) || false === stripos( $content, 'player.vimeo.com/video/' ) ) { - return $content; - } - - $regexp = '!<iframe\s+src=[\'"](https?:)?//player\.vimeo\.com/video/(\d+)[\w=&;?]*[\'"]((?:\s+\w+=[\'"][^\'"]*[\'"])*)((?:[\s\w]*))></iframe>!i'; - $regexp_ent = str_replace( '&#0*58;', '&#0*58;|�*58;', htmlspecialchars( $regexp, ENT_NOQUOTES ) ); - - foreach ( array( 'regexp', 'regexp_ent' ) as $reg ) { - if ( ! preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) { - continue; - } - - foreach ( $matches as $match ) { - $id = (int) $match[2]; - - $params = $match[3]; - - if ( 'regexp_ent' == $reg ) { - $params = html_entity_decode( $params ); - } - - $params = wp_kses_hair( $params, array( 'http' ) ); - - $width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0; - $height = isset( $params['height'] ) ? (int) $params['height']['value'] : 0; - - $wh = ''; - if ( $width && $height ) { - $wh = ' w=' . $width . ' h=' . $height; - } - - $shortcode = '[vimeo ' . $id . $wh . ']'; - $content = str_replace( $match[0], $shortcode, $content ); - } - } - - return $content; -} - -add_filter( 'pre_kses', 'vimeo_embed_to_shortcode' ); - -/** - * Replaces shortcodes and plain-text URLs to Vimeo videos with Vimeo embeds. - * Covers shortcode usage [vimeo 1234] | [vimeo https://vimeo.com/1234] | [vimeo http://vimeo.com/1234] - * Or plain text URLs https://vimeo.com/1234 | vimeo.com/1234 | //vimeo.com/1234 - * Links are left intact. - * - * @since 3.7.0 - * @since 3.9.5 One regular expression matches shortcodes and plain URLs. - * - * @param string $content HTML content - * @return string The content with embeds instead of URLs - */ -function vimeo_link( $content ) { - /** - * [vimeo 12345] - * [vimeo http://vimeo.com/12345] - */ - $shortcode = '(?:\[vimeo\s+[^0-9]*)([0-9]+)(?:\])'; - - /** - * http://vimeo.com/12345 - * https://vimeo.com/12345 - * //vimeo.com/12345 - * vimeo.com/some/descender/12345 - * - * Should not capture inside HTML attributes - * [Not] <a href="vimeo.com/12345">Cool Video</a> - * [Not] <a href="https://vimeo.com/12345">vimeo.com/12345</a> - * - * Could erroneously capture: - * <a href="some.link/maybe/even/vimeo">This video (vimeo.com/12345) is teh cat's meow!</a> - */ - $plain_url = "(?:[^'\">]?\/?(?:https?:\/\/)?vimeo\.com[^0-9]+)([0-9]+)(?:[^'\"0-9<]|$)"; - - return jetpack_preg_replace_callback_outside_tags( - sprintf( '#%s|%s#i', $shortcode, $plain_url ), - 'vimeo_link_callback', - $content, - 'vimeo' - ); -} - -/** - * Callback function for the regex that replaces Vimeo URLs with Vimeo embeds. - * - * @since 3.7.0 - * - * @param array $matches An array containing a Vimeo URL. - * @return string The Vimeo HTML embed code. - */ -function vimeo_link_callback( $matches ) { - $id = isset( $matches[2] ) ? $matches[2] : $matches[1]; - if ( isset( $id ) && ctype_digit( $id ) ) { - return "\n" . vimeo_shortcode( array( 'id' => $id ) ) . "\n"; - } - return $matches[0]; -} - -/** This filter is documented in modules/shortcodes/youtube.php */ -if ( ! is_admin() && apply_filters( 'jetpack_comments_allow_oembed', true ) ) { - // We attach wp_kses_post to comment_text in default-filters.php with priority of 10 anyway, so the iframe gets filtered out. - // Higher priority because we need it before auto-link and autop get to it - add_filter( 'comment_text', 'vimeo_link', 1 ); -} diff --git a/plugins/jetpack/modules/shortcodes/vine.php b/plugins/jetpack/modules/shortcodes/vine.php deleted file mode 100644 index 444b9999..00000000 --- a/plugins/jetpack/modules/shortcodes/vine.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php -/** - * Vine shortcode - */ - -/** - * Vine embed code: - * <iframe class="vine-embed" src="https://vine.co/v/bjHh0zHdgZT" width="600" height="600" frameborder="0"></iframe> - * <script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script> - * - * URL example: - * https://vine.co/v/bjHh0zHdgZT/ - * - * Embed shortcode examples: - * [embed]https://vine.co/v/bjHh0zHdgZT[/embed] - * [embed width="300"]https://vine.co/v/bjHh0zHdgZT[/embed] - * [embed type="postcard" width="300"]https://vine.co/v/bjHh0zHdgZT[/embed] - **/ - -function vine_embed_video( $matches, $attr, $url, $rawattr ) { - static $vine_flag_embedded_script; - - $max_height = 300; - $type = 'simple'; - - // Only allow 'postcard' or 'simple' types - if ( isset( $rawattr['type'] ) && $rawattr['type'] === 'postcard' ) { - $type = 'postcard'; - } - - $vine_size = Jetpack::get_content_width(); - - // If the user enters a value for width or height, we ignore the Jetpack::get_content_width() - if ( isset( $rawattr['width'] ) || isset( $rawattr['height'] ) ) { - // 300 is the minimum size that Vine provides for embeds. Lower than that, the postcard embeds looks weird. - $vine_size = max( $max_height, min( $attr['width'], $attr['height'] ) ); - } - - if ( empty( $vine_size ) ) { - $vine_size = $max_height; - } - - $url = 'https://vine.co/v/' . $matches[1] . '/embed/' . $type; - $vine_html = sprintf( '<span class="embed-vine" style="display: block;"><iframe class="vine-embed" src="%s" width="%s" height="%s" frameborder="0"></iframe></span>', esc_url( $url ), (int) $vine_size, (int) $vine_size ); - - if ( $vine_flag_embedded_script !== true ) { - $vine_html .= '<script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>'; - $vine_flag_embedded_script = true; - } - - return $vine_html; -} -wp_embed_register_handler( 'jetpack_vine', '#https?://vine.co/v/([a-z0-9]+).*#i', 'vine_embed_video' ); - -function vine_shortcode( $atts ) { - global $wp_embed; - - if ( empty( $atts['url'] ) ) { - return ''; - } - - if ( ! preg_match( '#https?://vine.co/v/([a-z0-9]+).*#i', $atts['url'] ) ) { - return ''; - } - - return $wp_embed->shortcode( $atts, $atts['url'] ); -} -add_shortcode( 'vine', 'vine_shortcode' ); diff --git a/plugins/jetpack/modules/shortcodes/vr.php b/plugins/jetpack/modules/shortcodes/vr.php deleted file mode 100644 index 0df06a4d..00000000 --- a/plugins/jetpack/modules/shortcodes/vr.php +++ /dev/null @@ -1,136 +0,0 @@ -<?php - -// VR Viewer Shortcode -// converts [vr] shortcode to an iframe viewer hosted on vr.me.sh - - -/** - * Scrub URL paramaters for VR viewer - * - * @param url_params - parameter array which is passed to the jetpack_vr_viewer - * @param url_params['url'] - url of 360 media - * @param url_params['guid'] - guid for videopress - * @param url_params['view'] - cinema, 360 - controls if panaroma view, or 360 - * @param url_params['rotation'] - number for rotating media - * @param url_params['preview'] - show preview image or not - * @return url_params array or false - */ -function jetpack_vr_viewer_get_viewer_url_params( $params ) { - $url_params = array(); - - if ( isset( $params['rotation'] ) ) { - $url_params['rotation'] = intval( $params['rotation'], 10 ); - } - - if ( isset( $params['view'] ) && in_array( $params['view'], array( 'cinema', '360' ), true ) ) { - $url_params['view'] = $params['view']; - } - - if ( isset( $params['preview'] ) && $params['preview'] ) { - $url_params['preview'] = 1; - } - - if ( isset( $params['url'] ) ) { - return array_merge( $url_params, array( 'url' => $params['url'] ) ); - } elseif ( isset( $params['guid'] ) ) { - return array_merge( $url_params, array( 'guid' => $params['guid'] ) ); - } - - return false; -} - -/** - * Get padding for IFRAME depending on view type - * - * @param view - string cinema, 360 - default cinema - * @return css padding - */ -function jetpack_vr_viewer_iframe_padding( $view ) { - if ( $view === '360' ) { - return '100%'; // 1:1 square aspect for 360 - } - - return '50%'; // 2:1 panorama aspect -} - -/** - * Create HTML for VR Viewer IFRAME and wrapper - * The viewer code is hosted on vr.me.sh site which is then displayed - * within posts via an IFRAME. This function returns the IFRAME html. - * - * @param url_params - parameter array which is passed to the jetpack_vr_viewer - * @param url_params['url'] - url of 360 media - * @param url_params['guid'] - guid for videopress - * @param url_params['view'] - cinema, 360 - controls if panaroma view, or 360 - * @param url_params['rotation'] - number for rotating media - * @param url_params['preview'] - show preview image or not - * @return html - an iframe for viewer - */ -function jetpack_vr_viewer_get_html( $url_params ) { - global $content_width; - - $iframe = add_query_arg( $url_params, 'https://vr.me.sh/view/' ); - - // set some defaults - $maxwidth = ( isset( $content_width ) ) ? $content_width : 720; - $view = ( isset( $url_params['view'] ) ) ? $url_params['view'] : 'cinema'; - - $rtn = '<div style="position: relative; max-width: ' . $maxwidth . 'px; margin-left: auto; margin-right: auto; overflow: hidden;">'; - $rtn .= '<div style="padding-top: ' . jetpack_vr_viewer_iframe_padding( $view ) . ';"></div>'; - $rtn .= '<iframe style="position: absolute; top: 0; right: 0; bottom: 0; left: 0; height: 100%" allowfullscreen="true" frameborder="0" width="100%" height="300" src="' . esc_url( $iframe ) . '">'; - $rtn .= '</iframe>'; - $rtn .= '</div>'; - - return $rtn; -} - -/** - * Convert [vr] shortcode to viewer - * - * Shortcode example: - * [vr url="https://en-blog.files.wordpress.com/2016/12/regents_park.jpg" view="360"] - * - * VR Viewer embed code: - * <div style="position: relative; max-width: 720px; margin-left: auto; margin-right: auto; overflow: hidden;"> - * <div style="padding-top: 100%;"></div> - * <iframe style="position: absolute; top: 0; right: 0; bottom: 0; left: 0; height: 100%" allowfullscreen="true" frameborder="0" width="100%" height="400" src="https://vr.me.sh/view/?view=360&url=https://en-blog.files.wordpress.com/2016/12/regents_park.jpg"> - * </iframe> - * </div> - * - * @return html - complete vr viewer html - */ -function jetpack_vr_viewer_shortcode( $atts ) { - $params = shortcode_atts( - array( - 0 => null, - 'url' => null, - 'src' => null, - 'guid' => null, - 'rotation' => null, - 'view' => null, - 'preview' => false, - ), - $atts - ); - - // We offer a few ways to specify the URL - if ( $params[0] ) { - $params['url'] = $params[0]; - } elseif ( $params['src'] ) { - $params['url'] = $params['src']; - } - - $url_params = jetpack_vr_viewer_get_viewer_url_params( $params ); - if ( $url_params ) { - return jetpack_vr_viewer_get_html( $url_params ); - } - - // add check for user - if ( current_user_can( 'edit_posts' ) ) { - return '[vr] shortcode requires a data source to be given'; - } else { - return ''; - } -} - -add_shortcode( 'vr', 'jetpack_vr_viewer_shortcode' ); diff --git a/plugins/jetpack/modules/shortcodes/wordads.php b/plugins/jetpack/modules/shortcodes/wordads.php deleted file mode 100644 index bca6c48a..00000000 --- a/plugins/jetpack/modules/shortcodes/wordads.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php - -/** - * Embed WordAds 'ad' in post - */ -class Jetpack_WordAds_Shortcode { - - private $scripts_and_style_included = false; - - function __construct() { - add_action( 'init', array( $this, 'action_init' ) ); - } - - /** - * Register our shortcode and enqueue necessary files. - */ - function action_init() { - global $wordads; - - if ( empty( $wordads ) ) { - return null; - } - - add_shortcode( 'wordads', array( $this, 'wordads_shortcode' ) ); - } - - /** - * Our [wordads] shortcode. - * Prints a WordAds Ad. - * - * @param array $atts Array of shortcode attributes. - * @param string $content Post content. - * - * @return string HTML for WordAds shortcode. - */ - static function wordads_shortcode( $atts, $content = '' ) { - $atts = shortcode_atts( array(), $atts, 'wordads' ); - - return self::wordads_shortcode_html( $atts, $content ); - } - - /** - * The shortcode output - * - * @param array $atts Array of shortcode attributes. - * @param string $content Post content. - * - * @return string HTML output - */ - static function wordads_shortcode_html( $atts, $content = '' ) { - global $wordads; - - if ( empty( $wordads ) ) { - return '<div>' . __( 'The WordAds module is not active', 'jetpack' ) . '</div>'; - } - - $html = '<div class="jetpack-wordad" itemscope itemtype="https://schema.org/WPAdBlock"></div>'; - $html = $wordads->insert_inline_ad( $html ); - - return $html; - } -} - -new Jetpack_WordAds_Shortcode(); diff --git a/plugins/jetpack/modules/shortcodes/wufoo.php b/plugins/jetpack/modules/shortcodes/wufoo.php deleted file mode 100644 index fbe6fe70..00000000 --- a/plugins/jetpack/modules/shortcodes/wufoo.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php -/* -Plugin Name: Wufoo Shortcode Plugin -Description: Enables shortcode to embed Wufoo forms. Usage: [wufoo username="chriscoyier" formhash="x7w3w3" autoresize="true" height="458" header="show"] -Author: Chris Coyier / Wufoo, evansolomon - -Based on https://wordpress.org/extend/plugins/wufoo-shortcode/ -https://wufoo.com/docs/code-manager/wordpress-shortcode-plugin/ -*/ - - -function wufoo_shortcode( $atts ) { - $attr = shortcode_atts( - array( - 'username' => '', - 'formhash' => '', - 'autoresize' => true, - 'height' => '500', - 'header' => 'show', - ), - $atts - ); - - // Check username and formhash to ensure they only have alphanumeric characters or underscores, and aren't empty. - if ( ! preg_match( '/^[a-zA-Z0-9_]+$/', $attr['username'] ) || ! preg_match( '/^[a-zA-Z0-9_]+$/', $attr['formhash'] ) ) { - - /** - * Return an error to the users with instructions if one of these params is invalid - * They don't have default values because they are user/form-specific - */ - $return_error = sprintf( __( 'Something is wrong with your Wufoo shortcode. If you copy and paste it from the %1$sWufoo Code Manager%2$s, you should be golden.', 'jetpack' ), '<a href="https://wufoo.com/docs/code-manager/" target="_blank">', '</a>' ); - - return ' - <div style="border: 20px solid red; border-radius: 40px; padding: 40px; margin: 50px 0 70px;"> - <h3>Uh oh!</h3> - <p style="margin: 0;">' . $return_error . '</p> - </div>'; - } - - /** - * Placeholder which will tell Wufoo where to render the form. - */ - $js_embed_placeholder = '<div id="wufoo-' . $attr['formhash'] . '"></div>'; - - /** - * Required parameters are present. - * An error will be returned inside the form if they are invalid. - */ - $js_embed = '(function(){try{var wufoo_' . $attr['formhash'] . ' = new WufooForm();'; - $js_embed .= 'wufoo_' . $attr['formhash'] . '.initialize({'; - $js_embed .= "'userName':'" . $attr['username'] . "', "; - $js_embed .= "'formHash':'" . $attr['formhash'] . "', "; - $js_embed .= "'autoResize':" . (bool) ( $attr['autoresize'] ) . ','; - $js_embed .= "'height':'" . (int) $attr['height'] . "',"; - $js_embed .= "'header':'" . esc_js( $attr['header'] ) . "',"; - $js_embed .= "'ssl':true,'async':true});"; - $js_embed .= 'wufoo_' . $attr['formhash'] . '.display();'; - $js_embed .= '}catch(e){}})();'; - - /** - * iframe embed, loaded inside <noscript> tags. - */ - $iframe_embed = '<iframe '; - $iframe_embed .= 'height="' . (int) $attr['height'] . '" '; - $iframe_embed .= 'allowTransparency="true" frameborder="0" scrolling="no" style="width:100%;border:none;"'; - $iframe_embed .= 'src="https://' . $attr['username'] . '.wufoo.com/embed/' . $attr['formhash'] . '/">'; - $iframe_embed .= '<a href="https://' . $attr['username'] . '.wufoo.com/forms/' . $attr['formhash'] . '/" '; - $iframe_embed .= 'rel="nofollow" target="_blank">' . __( 'Fill out my Wufoo form!', 'jetpack' ) . '</a></iframe>'; - - wp_enqueue_script( - 'wufoo-form', - 'https://www.wufoo.com/scripts/embed/form.js', - array(), - false, - true - ); - - wp_add_inline_script( 'wufoo-form', $js_embed ); - - /** This action is already documented in modules/widgets/gravatar-profile.php */ - do_action( 'jetpack_stats_extra', 'embeds', 'wufoo' ); - - /** - * Return embed in JS and iframe. - */ - return "$js_embed_placeholder<noscript>$iframe_embed</noscript>"; -} - -add_shortcode( 'wufoo', 'wufoo_shortcode' ); diff --git a/plugins/jetpack/modules/shortcodes/youtube.php b/plugins/jetpack/modules/shortcodes/youtube.php deleted file mode 100644 index 048eb09b..00000000 --- a/plugins/jetpack/modules/shortcodes/youtube.php +++ /dev/null @@ -1,396 +0,0 @@ -<?php - -/** - * youtube shortcode - * - * Contains shortcode + some improvements over the Embeds syntax @ - * http://codex.wordpress.org/Embeds - * - * @example [youtube=http://www.youtube.com/watch?v=wq0rXGLs0YM&fs=1&hl=bg_BG] - */ - -/** - * Replaces YouTube embeds with YouTube shortcodes. - * - * @param string $content HTML content. - * @return string The content with YouTube embeds replaced with YouTube shortcodes. - */ -// 2008-07-15: -// <object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/bZBHZT3a-FA&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/bZBHZT3a-FA&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object> -// around 2008-06-06 youtube changed their old embed code to this: -// <object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/M1D30gS7Z8U&hl=en"></param><embed src="http://www.youtube.com/v/M1D30gS7Z8U&hl=en" type="application/x-shockwave-flash" width="425" height="344"></embed></object> -// old style was: -// <object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/dGY28Qbj76A&rel=0"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/dGY28Qbj76A&rel=0" type="application/x-shockwave-flash" wmode="transparent" width="425" height="344"></embed></object> -// 12-2010: -// <object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/3H8bnKdf654?fs=1&hl=en_GB"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/3H8bnKdf654?fs=1&hl=en_GB" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object> -// 01-2011: -// <iframe title="YouTube video player" class="youtube-player" type="text/html" width="640" height="390" src="http://www.youtube.com/embed/Qq9El3ki0_g" frameborder="0" allowFullScreen></iframe> -// <iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/VIDEO_ID" frameborder="0"></iframe> -function youtube_embed_to_short_code( $content ) { - if ( ! is_string( $content ) || false === strpos( $content, 'youtube.com' ) ) { - return $content; - } - - // older codes - $regexp = '!<object(.*?)>.*?<param\s+name=[\'"]movie[\'"]\s+value=[\'"](https?:)?//www\.youtube\.com/v/([^\'"]+)[\'"].*?>.*?</object>!i'; - $regexp_ent = htmlspecialchars( $regexp, ENT_NOQUOTES ); - $old_regexp = '!<embed(?:\s+\w+="[^"]*")*\s+src="https?(?:\:|�*58;)//www\.youtube\.com/v/([^"]+)"(?:\s+\w+="[^"]*")*\s*(?:/>|>\s*</embed>)!'; - $old_regexp_ent = str_replace( '&#0*58;', '&#0*58;|�*58;', htmlspecialchars( $old_regexp, ENT_NOQUOTES ) ); - - // new code - $ifr_regexp = '!<iframe((?:\s+\w+="[^"]*")*?)\s+src="(https?:)?//(?:www\.)*youtube.com/embed/([^"]+)".*?</iframe>!i'; - $ifr_regexp_ent = str_replace( '&#0*58;', '&#0*58;|�*58;', htmlspecialchars( $ifr_regexp, ENT_NOQUOTES ) ); - - foreach ( array( 'regexp', 'regexp_ent', 'old_regexp', 'old_regexp_ent', 'ifr_regexp', 'ifr_regexp_ent' ) as $reg ) { - if ( ! preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) { - continue; - } - - foreach ( $matches as $match ) { - // Hack, but '?' should only ever appear once, and - // it should be for the 1st field-value pair in query string, - // if it is present - // YouTube changed their embed code. - // Example of how it is now: - // <object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/aP9AaD4tgBY?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/aP9AaD4tgBY?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object> - // As shown at the start of function, previous YouTube didn't '?' - // the 1st field-value pair. - if ( in_array( $reg, array( 'ifr_regexp', 'ifr_regexp_ent', 'regexp', 'regexp_ent' ) ) ) { - $params = $match[1]; - - if ( in_array( $reg, array( 'ifr_regexp_ent', 'regexp_ent' ) ) ) { - $params = html_entity_decode( $params ); - } - - $params = wp_kses_hair( $params, array( 'http' ) ); - - $width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0; - $height = isset( $params['height'] ) ? (int) $params['height']['value'] : 0; - $wh = ''; - - if ( $width && $height ) { - $wh = "&w=$width&h=$height"; - } - - $url = esc_url_raw( "https://www.youtube.com/watch?v={$match[3]}{$wh}" ); - } else { - $match[1] = str_replace( '?', '&', $match[1] ); - - $url = esc_url_raw( 'https://www.youtube.com/watch?v=' . html_entity_decode( $match[1] ) ); - } - - $content = str_replace( $match[0], "[youtube $url]", $content ); - - /** - * Fires before the YouTube embed is transformed into a shortcode. - * - * @module shortcodes - * - * @since 1.2.0 - * - * @param string youtube Shortcode name. - * @param string $url YouTube video URL. - */ - do_action( 'jetpack_embed_to_shortcode', 'youtube', $url ); - } - } - - return $content; -} - -add_filter( 'pre_kses', 'youtube_embed_to_short_code' ); - -/** - * Replaces plain-text links to YouTube videos with YouTube embeds. - * - * @param string $content HTML content - * @return string The content with embeds instead of URLs - */ -function youtube_link( $content ) { - return jetpack_preg_replace_callback_outside_tags( '!(?:\n|\A)https?://(?:www\.)?(?:youtube.com/(?:v/|playlist|watch[/\#?])|youtu\.be/)[^\s]+?(?:\n|\Z)!i', 'youtube_link_callback', $content, 'youtube.com/' ); -} - -/** - * Callback function for the regex that replaces YouTube URLs with - * YouTube embeds. - */ -function youtube_link_callback( $matches ) { - return "\n" . youtube_id( $matches[0] ) . "\n"; -} - -/** - * Normalizes a YouTube URL to include a v= parameter and a query string free of encoded ampersands. - * - * @param string $url - * @return string The normalized URL - */ -if ( ! function_exists( 'youtube_sanitize_url' ) ) : - function youtube_sanitize_url( $url ) { - $url = trim( $url, ' "' ); - $url = trim( $url ); - $url = str_replace( array( 'youtu.be/', '/v/', '#!v=', '&', '&', 'playlist' ), array( 'youtu.be/?v=', '/?v=', '?v=', '&', '&', 'videoseries' ), $url ); - - // Replace any extra question marks with ampersands - the result of a URL like "http://www.youtube.com/v/9FhMMmqzbD8?fs=1&hl=en_US" being passed in. - $query_string_start = strpos( $url, '?' ); - - if ( false !== $query_string_start ) { - $url = substr( $url, 0, $query_string_start + 1 ) . str_replace( '?', '&', substr( $url, $query_string_start + 1 ) ); - } - - return $url; - } -endif; - -/* - * url can be: - * http://www.youtube.com/embed/videoseries?list=PL94269DA08231042B&hl=en_US - * http://www.youtube.com/watch#!v=H2Ncxw1xfck - * http://www.youtube.com/watch?v=H2Ncxw1xfck - * http://www.youtube.com/watch?v=H2Ncxw1xfck&w=320&h=240&fmt=1&rel=0&showsearch=1&hd=0 - * http://www.youtube.com/v/jF-kELmmvgA - * http://www.youtube.com/v/9FhMMmqzbD8?fs=1&hl=en_US - * http://youtu.be/Rrohlqeir5E - */ - -/** - * Converts a YouTube URL into an embedded YouTube video. - */ -function youtube_id( $url ) { - if ( ! $id = jetpack_get_youtube_id( $url ) ) { - return '<!--YouTube Error: bad URL entered-->'; - } - - $url = youtube_sanitize_url( $url ); - $url = parse_url( $url ); - - if ( ! isset( $url['query'] ) ) { - return false; - } - - if ( isset( $url['fragment'] ) ) { - wp_parse_str( $url['fragment'], $fargs ); - } else { - $fargs = array(); - } - wp_parse_str( $url['query'], $qargs ); - - $qargs = array_merge( $fargs, $qargs ); - - // calculate the width and height, taking content_width into consideration - global $content_width; - - $input_w = ( isset( $qargs['w'] ) && intval( $qargs['w'] ) ) ? intval( $qargs['w'] ) : 0; - $input_h = ( isset( $qargs['h'] ) && intval( $qargs['h'] ) ) ? intval( $qargs['h'] ) : 0; - - // If we have $content_width, use it. - if ( ! empty( $content_width ) ) { - $default_width = $content_width; - } else { - // Otherwise get default width from the old, now deprecated embed_size_w option. - $default_width = get_option( 'embed_size_w' ); - } - - // If we don't know those 2 values use a hardcoded width.h - if ( empty( $default_width ) ) { - $default_width = 640; - } - - if ( $input_w > 0 && $input_h > 0 ) { - $w = $input_w; - $h = $input_h; - } elseif ( 0 == $input_w && 0 == $input_h ) { - if ( isset( $qargs['fmt'] ) && intval( $qargs['fmt'] ) ) { - $w = ( ! empty( $content_width ) ? min( $content_width, 480 ) : 480 ); - } else { - $w = ( ! empty( $content_width ) ? min( $content_width, $default_width ) : $default_width ); - $h = ceil( ( $w / 16 ) * 9 ); - } - } elseif ( $input_w > 0 ) { - $w = $input_w; - $h = ceil( ( $w / 16 ) * 9 ); - } else { - if ( isset( $qargs['fmt'] ) && intval( $qargs['fmt'] ) ) { - $w = ( ! empty( $content_width ) ? min( $content_width, 480 ) : 480 ); - } else { - $w = ( ! empty( $content_width ) ? min( $content_width, $default_width ) : $default_width ); - $h = $input_h; - } - } - - /** - * Filter the YouTube player width. - * - * @module shortcodes - * - * @since 1.1.0 - * - * @param int $w Width of the YouTube player in pixels. - */ - $w = (int) apply_filters( 'youtube_width', $w ); - - /** - * Filter the YouTube player height. - * - * @module shortcodes - * - * @since 1.1.0 - * - * @param int $h Height of the YouTube player in pixels. - */ - $h = (int) apply_filters( 'youtube_height', $h ); - - $rel = ( isset( $qargs['rel'] ) && 0 == $qargs['rel'] ) ? 0 : 1; - $search = ( isset( $qargs['showsearch'] ) && 1 == $qargs['showsearch'] ) ? 1 : 0; - $info = ( isset( $qargs['showinfo'] ) && 0 == $qargs['showinfo'] ) ? 0 : 1; - $iv = ( isset( $qargs['iv_load_policy'] ) && 3 == $qargs['iv_load_policy'] ) ? 3 : 1; - - $fmt = ( isset( $qargs['fmt'] ) && intval( $qargs['fmt'] ) ) ? '&fmt=' . (int) $qargs['fmt'] : ''; - - if ( ! isset( $qargs['autohide'] ) || ( $qargs['autohide'] < 0 || 2 < $qargs['autohide'] ) ) { - $autohide = '&autohide=2'; - } else { - $autohide = '&autohide=' . absint( $qargs['autohide'] ); - } - - $start = 0; - if ( isset( $qargs['start'] ) ) { - $start = intval( $qargs['start'] ); - } elseif ( isset( $qargs['t'] ) ) { - $time_pieces = preg_split( '/(?<=\D)(?=\d+)/', $qargs['t'] ); - - foreach ( $time_pieces as $time_piece ) { - $int = (int) $time_piece; - switch ( substr( $time_piece, -1 ) ) { - case 'h': - $start += $int * 3600; - break; - case 'm': - $start += $int * 60; - break; - case 's': - $start += $int; - break; - } - } - } - - $start = $start ? '&start=' . $start : ''; - $end = ( isset( $qargs['end'] ) && intval( $qargs['end'] ) ) ? '&end=' . (int) $qargs['end'] : ''; - $hd = ( isset( $qargs['hd'] ) && intval( $qargs['hd'] ) ) ? '&hd=' . (int) $qargs['hd'] : ''; - - $vq = ( isset( $qargs['vq'] ) && in_array( $qargs['vq'], array( 'hd720', 'hd1080' ) ) ) ? '&vq=' . $qargs['vq'] : ''; - - $cc = ( isset( $qargs['cc_load_policy'] ) ) ? '&cc_load_policy=1' : ''; - $cc_lang = ( isset( $qargs['cc_lang_pref'] ) ) ? '&cc_lang_pref=' . preg_replace( '/[^_a-z0-9-]/i', '', $qargs['cc_lang_pref'] ) : ''; - - $wmode = ( isset( $qargs['wmode'] ) && in_array( strtolower( $qargs['wmode'] ), array( 'opaque', 'window', 'transparent' ) ) ) ? $qargs['wmode'] : 'transparent'; - - $theme = ( isset( $qargs['theme'] ) && in_array( strtolower( $qargs['theme'] ), array( 'dark', 'light' ) ) ) ? '&theme=' . $qargs['theme'] : ''; - - $autoplay = ''; - /** - * Allow YouTube videos to start playing automatically. - * - * @module shortcodes - * - * @since 2.2.2 - * - * @param bool false Enable autoplay for YouTube videos. - */ - if ( apply_filters( 'jetpack_youtube_allow_autoplay', false ) && isset( $qargs['autoplay'] ) ) { - $autoplay = '&autoplay=' . (int) $qargs['autoplay']; - } - - if ( ( isset( $url['path'] ) && '/videoseries' == $url['path'] ) || isset( $qargs['list'] ) ) { - $html = "<iframe class='youtube-player' type='text/html' width='$w' height='$h' src='" . esc_url( "https://www.youtube.com/embed/videoseries?list=$id&hl=en_US" ) . "' allowfullscreen='true' style='border:0;'></iframe>"; - } else { - $html = "<iframe class='youtube-player' type='text/html' width='$w' height='$h' src='" . esc_url( "https://www.youtube.com/embed/$id?version=3&rel=$rel&fs=1$fmt$autohide&showsearch=$search&showinfo=$info&iv_load_policy=$iv$start$end$hd&wmode=$wmode$theme$autoplay{$cc}{$cc_lang}" ) . "' allowfullscreen='true' style='border:0;'></iframe>"; - } - - // Let's do some alignment wonder in a span, unless we're producing a feed - if ( ! is_feed() ) { - $alignmentcss = 'text-align:center;'; - if ( isset( $qargs['align'] ) ) { - switch ( $qargs['align'] ) { - case 'left': - $alignmentcss = "float:left; width:{$w}px; height:{$h}px; margin-right:10px; margin-bottom: 10px;"; - break; - case 'right': - $alignmentcss = "float:right; width:{$w}px; height:{$h}px; margin-left:10px; margin-bottom: 10px;"; - break; - } - } - - $html = sprintf( - '<span class="embed-youtube" style="%s display: block;">%s</span>', - esc_attr( $alignmentcss ), - $html - ); - - } - - /** - * Filter the YouTube video HTML output. - * - * @module shortcodes - * - * @since 1.2.3 - * - * @param string $html YouTube video HTML output. - */ - $html = apply_filters( 'video_embed_html', $html ); - - return $html; -} - -function youtube_shortcode( $atts ) { - return youtube_id( ( isset( $atts[0] ) ) ? ltrim( $atts[0], '=' ) : shortcode_new_to_old_params( $atts ) ); -} - -add_shortcode( 'youtube', 'youtube_shortcode' ); - -/** - * For bare URLs on their own line of the form - * http://www.youtube.com/v/9FhMMmqzbD8?fs=1&hl=en_US - */ -function wpcom_youtube_embed_crazy_url( $matches, $attr, $url ) { - return youtube_id( $url ); -} - -function wpcom_youtube_embed_crazy_url_init() { - wp_embed_register_handler( 'wpcom_youtube_embed_crazy_url', '#https?://(?:www\.)?(?:youtube.com/(?:v/|playlist|watch[/\#?])|youtu\.be/).*#i', 'wpcom_youtube_embed_crazy_url' ); -} - -add_action( 'init', 'wpcom_youtube_embed_crazy_url_init' ); - -/** - * Allow oEmbeds in Jetpack's Comment form. - * - * @module shortcodes - * - * @since 2.8.0 - * - * @param int get_option('embed_autourls') Option to automatically embed all plain text URLs. - */ -if ( ! is_admin() && apply_filters( 'jetpack_comments_allow_oembed', true ) ) { - // We attach wp_kses_post to comment_text in default-filters.php with priority of 10 anyway, so the iframe gets filtered out. - // Higher priority because we need it before auto-link and autop get to it - add_filter( 'comment_text', 'youtube_link', 1 ); -} - -/** - * Core changes to do_shortcode (https://core.trac.wordpress.org/changeset/34747) broke "improper" shortcodes - * with the format [shortcode=http://url.com]. - * - * This removes the "=" from the shortcode so it can be parsed. - * - * @see https://github.com/Automattic/jetpack/issues/3121 - */ -function jetpack_fix_youtube_shortcode_display_filter( $content ) { - if ( strpos( $content, '[youtube=' ) !== false ) { - $content = preg_replace( '@\[youtube=(.*?)\]@', '[youtube $1]', $content ); - } - - return $content; -} -add_filter( 'the_content', 'jetpack_fix_youtube_shortcode_display_filter', 7 ); |