summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2019-01-01 22:18:11 -0500
committerAnthony G. Basile <blueness@gentoo.org>2019-01-01 22:18:11 -0500
commit018bd442ec1e04ba78a6628763414eb60b359398 (patch)
tree448cde462397af33e5a964ba5d0803b73c65040e /plugins/jetpack/modules/shortcodes
parentUpdate easy-table 1.8 (diff)
downloadblogs-gentoo-018bd442ec1e04ba78a6628763414eb60b359398.tar.gz
blogs-gentoo-018bd442ec1e04ba78a6628763414eb60b359398.tar.bz2
blogs-gentoo-018bd442ec1e04ba78a6628763414eb60b359398.zip
Update jetpack 6.8.1
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'plugins/jetpack/modules/shortcodes')
-rw-r--r--plugins/jetpack/modules/shortcodes/archiveorg-book.php25
-rw-r--r--plugins/jetpack/modules/shortcodes/archiveorg.php33
-rw-r--r--plugins/jetpack/modules/shortcodes/archives.php24
-rw-r--r--plugins/jetpack/modules/shortcodes/bandcamp.php162
-rw-r--r--plugins/jetpack/modules/shortcodes/brightcove.php70
-rw-r--r--plugins/jetpack/modules/shortcodes/cartodb.php2
-rw-r--r--plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php65
-rw-r--r--plugins/jetpack/modules/shortcodes/crowdsignal.php569
-rw-r--r--plugins/jetpack/modules/shortcodes/css/blocks/vr-block.css16
-rw-r--r--plugins/jetpack/modules/shortcodes/css/rtl/slideshow-shortcode-rtl.css0
-rw-r--r--plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.css145
-rw-r--r--plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.min.css1
-rw-r--r--plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.css2
-rw-r--r--plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css2
-rw-r--r--plugins/jetpack/modules/shortcodes/dailymotion.php38
-rw-r--r--plugins/jetpack/modules/shortcodes/facebook.php5
-rw-r--r--plugins/jetpack/modules/shortcodes/flatio.php11
-rw-r--r--plugins/jetpack/modules/shortcodes/flickr.php6
-rw-r--r--plugins/jetpack/modules/shortcodes/getty.php35
-rw-r--r--plugins/jetpack/modules/shortcodes/gist.php49
-rw-r--r--plugins/jetpack/modules/shortcodes/googleapps.php5
-rw-r--r--plugins/jetpack/modules/shortcodes/googlemaps.php21
-rw-r--r--plugins/jetpack/modules/shortcodes/googleplus.php6
-rw-r--r--plugins/jetpack/modules/shortcodes/googlevideo.php12
-rw-r--r--plugins/jetpack/modules/shortcodes/gravatar.php31
-rw-r--r--plugins/jetpack/modules/shortcodes/houzz.php4
-rw-r--r--plugins/jetpack/modules/shortcodes/hulu.php15
-rw-r--r--plugins/jetpack/modules/shortcodes/instagram.php15
-rw-r--r--plugins/jetpack/modules/shortcodes/js/blocks/vr-block.js102
-rw-r--r--plugins/jetpack/modules/shortcodes/kickstarter.php2
-rw-r--r--plugins/jetpack/modules/shortcodes/lytro.php12
-rw-r--r--plugins/jetpack/modules/shortcodes/mailchimp.php43
-rw-r--r--plugins/jetpack/modules/shortcodes/medium.php20
-rw-r--r--plugins/jetpack/modules/shortcodes/mixcloud.php3
-rw-r--r--plugins/jetpack/modules/shortcodes/pinterest.php2
-rw-r--r--plugins/jetpack/modules/shortcodes/polldaddy.php581
-rw-r--r--plugins/jetpack/modules/shortcodes/presentations.php684
-rw-r--r--plugins/jetpack/modules/shortcodes/quiz.php38
-rw-r--r--plugins/jetpack/modules/shortcodes/recipe.php60
-rw-r--r--plugins/jetpack/modules/shortcodes/scribd.php17
-rw-r--r--plugins/jetpack/modules/shortcodes/sitemap.php12
-rw-r--r--plugins/jetpack/modules/shortcodes/slideshare.php3
-rw-r--r--plugins/jetpack/modules/shortcodes/slideshow.php29
-rw-r--r--plugins/jetpack/modules/shortcodes/soundcloud.php26
-rw-r--r--plugins/jetpack/modules/shortcodes/ted.php4
-rw-r--r--plugins/jetpack/modules/shortcodes/tweet.php6
-rw-r--r--plugins/jetpack/modules/shortcodes/twitchtv.php13
-rw-r--r--plugins/jetpack/modules/shortcodes/unavailable.php8
-rw-r--r--plugins/jetpack/modules/shortcodes/untappd-menu.php18
-rw-r--r--plugins/jetpack/modules/shortcodes/upcoming-events.php9
-rw-r--r--plugins/jetpack/modules/shortcodes/videopress.php8
-rw-r--r--plugins/jetpack/modules/shortcodes/vimeo.php17
-rw-r--r--plugins/jetpack/modules/shortcodes/vine.php15
-rw-r--r--plugins/jetpack/modules/shortcodes/vr.php60
-rw-r--r--plugins/jetpack/modules/shortcodes/wordads.php3
-rw-r--r--plugins/jetpack/modules/shortcodes/wufoo.php47
-rw-r--r--plugins/jetpack/modules/shortcodes/youtube.php125
57 files changed, 1797 insertions, 1539 deletions
diff --git a/plugins/jetpack/modules/shortcodes/archiveorg-book.php b/plugins/jetpack/modules/shortcodes/archiveorg-book.php
index 4a70b057..8eb73173 100644
--- a/plugins/jetpack/modules/shortcodes/archiveorg-book.php
+++ b/plugins/jetpack/modules/shortcodes/archiveorg-book.php
@@ -7,7 +7,7 @@
* [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>
+ * <iframe src='https://www.archive.org/stream/goodytwoshoes00newyiala?ui=embed#mode/1up' width='480px' height='430px' frameborder='0' ></iframe>
*/
/**
@@ -21,7 +21,7 @@
*/
function jetpack_shortcode_get_archiveorg_book_id( $atts ) {
if ( isset( $atts[0] ) ) {
- $atts[0] = trim( $atts[0] , '=' );
+ $atts[0] = trim( $atts[0], '=' );
if ( preg_match( '#archive.org/stream/(.+)/?$#i', $atts[0], $match ) ) {
$id = $match[1];
} else {
@@ -47,11 +47,14 @@ function jetpack_archiveorg_book_shortcode( $atts ) {
$atts['id'] = jetpack_shortcode_get_archiveorg_book_id( $atts );
}
- $atts = shortcode_atts( array(
- 'id' => '',
- 'width' => 480,
- 'height' => 430,
- ), $atts );
+ $atts = shortcode_atts(
+ array(
+ 'id' => '',
+ 'width' => 480,
+ 'height' => 430,
+ ),
+ $atts
+ );
if ( ! $atts['id'] ) {
return '<!-- error: missing archive.org book ID -->';
@@ -101,13 +104,13 @@ function jetpack_archiveorg_book_embed_to_shortcode( $content ) {
foreach ( $matches as $match ) {
$url = explode( '?', $match[3] );
- $id = $url[0];
+ $id = $url[0];
$params = $match[4];
$params = wp_kses_hair( $params, array( 'http' ) );
- $width = isset( $params['width'] ) ? absint( $params['width']['value'] ) : 0;
+ $width = isset( $params['width'] ) ? absint( $params['width']['value'] ) : 0;
$height = isset( $params['height'] ) ? absint( $params['height']['value'] ) : 0;
$wh = '';
@@ -116,10 +119,10 @@ function jetpack_archiveorg_book_embed_to_shortcode( $content ) {
}
$shortcode = '[archiveorg-book ' . $id . $wh . ']';
- $content = str_replace( $match[0], $shortcode, $content );
+ $content = str_replace( $match[0], $shortcode, $content );
}
return $content;
}
-add_filter( 'pre_kses', 'jetpack_archiveorg_book_embed_to_shortcode' ); \ No newline at end of file
+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
index 86357343..c8e95567 100644
--- a/plugins/jetpack/modules/shortcodes/archiveorg.php
+++ b/plugins/jetpack/modules/shortcodes/archiveorg.php
@@ -8,7 +8,7 @@
* [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>
-*/
+ */
/**
* Get ID of requested archive.org embed.
@@ -21,7 +21,7 @@
*/
function jetpack_shortcode_get_archiveorg_id( $atts ) {
if ( isset( $atts[0] ) ) {
- $atts[0] = trim( $atts[0] , '=' );
+ $atts[0] = trim( $atts[0], '=' );
if ( preg_match( '#archive.org/(details|embed)/(.+)/?$#i', $atts[0], $match ) ) {
$id = $match[2];
} else {
@@ -47,13 +47,16 @@ function jetpack_archiveorg_shortcode( $atts ) {
$atts['id'] = jetpack_shortcode_get_archiveorg_id( $atts );
}
- $atts = shortcode_atts( array(
- 'id' => '',
- 'width' => 640,
- 'height' => 480,
- 'autoplay' => 0,
- 'poster' => ''
- ), $atts );
+ $atts = shortcode_atts(
+ array(
+ 'id' => '',
+ 'width' => 640,
+ 'height' => 480,
+ 'autoplay' => 0,
+ 'poster' => '',
+ ),
+ $atts
+ );
if ( ! $atts['id'] ) {
return '<!-- error: missing archive.org ID -->';
@@ -116,17 +119,17 @@ function jetpack_archiveorg_embed_to_shortcode( $content ) {
foreach ( $matches as $match ) {
$url = explode( '&amp;', $match[1] );
- $id = 'id=' . $url[0];
+ $id = 'id=' . $url[0];
$autoplay = '';
- $poster = '';
+ $poster = '';
for ( $ii = 1; $ii < count( $url ); $ii++ ) {
- if ( 'autoplay=1' === $url[$ii] ) {
+ if ( 'autoplay=1' === $url[ $ii ] ) {
$autoplay = ' autoplay="1"';
}
$map_matches = array();
- if ( preg_match( '/^poster=(.+)$/', $url[$ii], $map_matches ) ) {
+ if ( preg_match( '/^poster=(.+)$/', $url[ $ii ], $map_matches ) ) {
$poster = " poster=\"{$map_matches[1]}\"";
}
}
@@ -135,7 +138,7 @@ function jetpack_archiveorg_embed_to_shortcode( $content ) {
$params = wp_kses_hair( $params, array( 'http' ) );
- $width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0;
+ $width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0;
$height = isset( $params['height'] ) ? (int) $params['height']['value'] : 0;
$wh = '';
@@ -144,7 +147,7 @@ function jetpack_archiveorg_embed_to_shortcode( $content ) {
}
$shortcode = '[archiveorg ' . $id . $wh . $autoplay . $poster . ']';
- $content = str_replace( $match[0], $shortcode, $content );
+ $content = str_replace( $match[0], $shortcode, $content );
}
return $content;
diff --git a/plugins/jetpack/modules/shortcodes/archives.php b/plugins/jetpack/modules/shortcodes/archives.php
index 9ebd7f6e..173bbbb1 100644
--- a/plugins/jetpack/modules/shortcodes/archives.php
+++ b/plugins/jetpack/modules/shortcodes/archives.php
@@ -46,15 +46,17 @@ function archives_shortcode( $atts ) {
$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,
- ) );
+ $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 ) ) );
@@ -63,9 +65,9 @@ function archives_shortcode( $atts ) {
// Check to see if there are any archives
if ( empty( $archives ) ) {
$archives = '<p>' . __( 'Your blog does not currently have any published posts.', 'jetpack' ) . '</p>';
- } else if ( 'option' === $attr['format'] ) {
+ } 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>';
- } else if ( 'html' === $attr['format'] ) {
+ } elseif ( 'html' === $attr['format'] ) {
$archives = '<ul>' . $archives . '</ul>';
}
diff --git a/plugins/jetpack/modules/shortcodes/bandcamp.php b/plugins/jetpack/modules/shortcodes/bandcamp.php
index 10a2ba5e..312418f7 100644
--- a/plugins/jetpack/modules/shortcodes/bandcamp.php
+++ b/plugins/jetpack/modules/shortcodes/bandcamp.php
@@ -9,39 +9,76 @@
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' );
+ $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 )
+ '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'];
@@ -66,8 +103,8 @@ function shortcode_handler_bandcamp( $atts ) {
$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";
+ $track = esc_attr( $attributes['video'] ); // videos are referenced by track id
+ $urlbase = '//bandcamp.com/EmbeddedPlayer/v=2';
$isVideo = true;
array_push( $argparts, "track={$track}" );
}
@@ -93,97 +130,100 @@ function shortcode_handler_bandcamp( $atts ) {
// 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 ) ) {
+ if ( isset( $attributes['width'] ) && preg_match( '|^([0-9]+)(%)?$|', $attributes['width'], $matches ) ) {
$width = $csswidth = $attributes['width'];
if ( sizeof( $matches ) < 3 ) {
- $csswidth .= "px";
+ $csswidth .= 'px';
}
}
- if ( isset( $attributes['height'] ) && preg_match( "|^([0-9]+)(%)?$|", $attributes['height'], $matches ) ) {
+ if ( isset( $attributes['height'] ) && preg_match( '|^([0-9]+)(%)?$|', $attributes['height'], $matches ) ) {
$height = $cssheight = $attributes['height'];
if ( sizeof( $matches ) < 3 ) {
- $cssheight .= "px";
+ $cssheight .= 'px';
}
}
if ( ! $height ) {
$height = $sizes[ $sizekey ]['height'];
- $cssheight = $height . "px";
+ $cssheight = $height . 'px';
}
if ( ! $width ) {
$width = $sizes[ $sizekey ]['width'];
- $csswidth = $width . "px";
+ $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'] ) ) {
+ } 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'] ) ) {
+ 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'] ) ) {
+ 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'] ) ) {
+ 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'] ) ) {
+ 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" );
+ 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" );
+ 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'] );
+ case 'false':
+ case 'none':
+ case 'small':
+ array_push( $argparts, 'artwork=' . $attributes['artwork'] );
break;
}
- if ( $attributes['minimal'] == "true" ) {
- array_push( $argparts, "minimal=true" );
+ if ( $attributes['minimal'] == 'true' ) {
+ array_push( $argparts, 'minimal=true' );
}
- if ( isset( $attributes['theme'] ) && preg_match( "|^[a-zA-Z_]+$|", $attributes['theme'] ) ) {
+ 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'] ) ) {
+ 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 );
+ $url = '//bandcamp.com/VideoEmbed?' . join( '&', $argparts );
$extraAttrs = " mozallowfullscreen='1' webkitallowfullscreen='1' allowfullscreen='1'";
} else {
- $url = "//bandcamp.com/EmbeddedPlayer/v=2/" . join( '/', $argparts ) . '/';
+ $url = '//bandcamp.com/EmbeddedPlayer/v=2/' . join( '/', $argparts ) . '/';
$extraAttrs = '';
}
- return "<iframe width='" . esc_attr( $width ) . "' height='" . esc_attr( $height ) . "' style='position: relative; display: block; width: " . esc_attr( $csswidth ) . "; height: " . esc_attr( $cssheight ) . ";' src='" . esc_url( $url ) . "' allowtransparency='true' frameborder='0'" . $extraAttrs . "></iframe>";
+ $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
index c774c915..0b9b3c34 100644
--- a/plugins/jetpack/modules/shortcodes/brightcove.php
+++ b/plugins/jetpack/modules/shortcodes/brightcove.php
@@ -16,10 +16,9 @@
* [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 {
- static $shortcode = 'brightcove';
+ static $shortcode = 'brightcove';
/**
* Parse shortcode arguments and render its output.
@@ -30,7 +29,7 @@ class Jetpack_Brightcove_Shortcode {
*
* @return string
*/
- static public function convert( $atts ) {
+ public static function convert( $atts ) {
$normalized_atts = self::normalize_attributes( $atts );
if ( empty( $atts ) ) {
@@ -55,11 +54,11 @@ class Jetpack_Brightcove_Shortcode {
*
* @return array
*/
- static public function normalize_attributes( $atts ) {
+ 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 );
- $params = apply_filters( 'brightcove_dimensions', $params );
+ $params = shortcode_new_to_old_params( $atts );
+ $params = apply_filters( 'brightcove_dimensions', $params );
parse_str( $params, $parsed_atts );
return $parsed_atts;
@@ -77,9 +76,9 @@ class Jetpack_Brightcove_Shortcode {
*
* @return bool
*/
- static public function has_legacy_atts( $atts ) {
- return ( isset( $atts[ 'vid' ] ) || isset( $atts[ 'vref' ] ) )
- && ( isset( $atts[ 'exp' ] ) || isset( $atts[ 'exp3' ] ) );
+ public static function has_legacy_atts( $atts ) {
+ return ( isset( $atts['vid'] ) || isset( $atts['vref'] ) )
+ && ( isset( $atts['exp'] ) || isset( $atts['exp3'] ) );
}
/**
@@ -91,7 +90,7 @@ class Jetpack_Brightcove_Shortcode {
*
* @return string
*/
- static public function convert_to_new_studio( $atts ) {
+ public static function convert_to_new_studio( $atts ) {
$defaults = array(
'account_id' => '',
'video_id' => '',
@@ -130,21 +129,24 @@ class Jetpack_Brightcove_Shortcode {
*
* @return string
*/
- static public function convert_to_legacy_studio( $atts ) {
- $attr = shortcode_atts( array(
- 'bg' => '',
- 'exp' => '',
- 'exp3' => '',
- 'h' => '',
- 'lbu' => '',
- 'pk' => '',
- 'pubid' => '',
- 's' => '',
- 'surl' => '',
- 'vid' => '',
- 'vref' => '',
- 'w' => '',
- ), $atts );
+ 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'] ) );
@@ -183,7 +185,8 @@ class Jetpack_Brightcove_Shortcode {
$fv['domain'] = 'embed';
$fv['videoID'] = intval( $attr['vid'] );
- $src = sprintf( '%s/viewer/federated_f9/%s?isVid=1&amp;isUI=1&amp;publisherID=%s',
+ $src = sprintf(
+ '%s/viewer/federated_f9/%s?isVid=1&amp;isUI=1&amp;publisherID=%s',
$attr['surl'],
$attr['exp3'],
$attr['pubid']
@@ -194,7 +197,7 @@ class Jetpack_Brightcove_Shortcode {
$src = 'http://services.brightcove.com/services/viewer/federated_f8/' . $attr['exp'];
if ( $attr['vid'] ) {
$fv['videoId'] = $attr['vid'];
- } else if ( $attr['vref'] ) {
+ } elseif ( $attr['vref'] ) {
$fv['videoRef'] = $attr['vref'];
}
@@ -236,9 +239,13 @@ class Jetpack_Brightcove_Shortcode {
20121127,
false
);
- wp_localize_script( 'brightcove-loader', 'brightcoveData', array(
- 'tld' => esc_js( $js_tld )
- ) );
+ wp_localize_script(
+ 'brightcove-loader',
+ 'brightcoveData',
+ array(
+ 'tld' => esc_js( $js_tld ),
+ )
+ );
return '
<object id="myExperience" class="BrightcoveExperience">
@@ -257,7 +264,8 @@ class Jetpack_Brightcove_Shortcode {
</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" />',
+ 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 ),
diff --git a/plugins/jetpack/modules/shortcodes/cartodb.php b/plugins/jetpack/modules/shortcodes/cartodb.php
index 6f9e4f5e..82c925d8 100644
--- a/plugins/jetpack/modules/shortcodes/cartodb.php
+++ b/plugins/jetpack/modules/shortcodes/cartodb.php
@@ -18,4 +18,4 @@
* 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 ); \ No newline at end of file
+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
index 8912c936..d5cfb956 100644
--- a/plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php
+++ b/plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php
@@ -22,12 +22,12 @@ add_filter( 'pre_kses', array( 'Filter_Embedded_HTML_Objects', 'maybe_create_lin
*/
class Filter_Embedded_HTML_Objects {
- static public $strpos_filters = array();
- static public $regexp_filters = array();
- static public $current_element = false;
+ 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();
+ static public $failed_embeds = array();
/**
* Store tokens found in Syntax Highlighter.
@@ -47,13 +47,13 @@ class Filter_Embedded_HTML_Objects {
*
* @return string
*/
- static public function sh_regexp_callback( $match ) {
- $token = '[prekses-filter-token-' . mt_rand() . '-' . md5( $match[0] ) . '-' . mt_rand() . ']';
- self::$sh_unfiltered_content_tokens[$token] = $match[0];
+ 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;
}
- static public function filter( $html ) {
+ public static function filter( $html ) {
if ( ! $html || ! is_string( $html ) ) {
return $html;
}
@@ -66,21 +66,22 @@ class Filter_Embedded_HTML_Objects {
'script' => '%<script[^>]*+>(?>[^<]*+(?><(?!/script>)[^<]*+)*)</script>%i',
);
- $unfiltered_content_tokens = array();
+ $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
+ $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;
}
@@ -111,7 +112,7 @@ class Filter_Embedded_HTML_Objects {
return $html;
}
- static public function regexp_entities( $regexp ) {
+ public static function regexp_entities( $regexp ) {
return preg_replace(
'/\[\^&([^\]]+)\]\*\+/',
'(?>[^&]*+(?>&(?!\1)[^&])*+)*+',
@@ -119,28 +120,28 @@ class Filter_Embedded_HTML_Objects {
);
}
- static public function register( $match, $callback, $is_regexp = false, $is_html_filter = false ) {
+ 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;
+ self::$html_regexp_filters[ $match ] = $callback;
} else {
- self::$html_strpos_filters[$match] = $callback;
+ self::$html_strpos_filters[ $match ] = $callback;
}
} else {
if ( $is_regexp ) {
- self::$regexp_filters[$match] = $callback;
+ self::$regexp_filters[ $match ] = $callback;
} else {
- self::$strpos_filters[$match] = $callback;
+ self::$strpos_filters[ $match ] = $callback;
}
}
}
- static public function unregister( $match ) {
+ 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] );
+ 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 ) {
@@ -154,7 +155,7 @@ class Filter_Embedded_HTML_Objects {
$attrs = self::get_attrs( $html );
if ( isset( $attrs['src'] ) ) {
$src = $attrs['src'];
- } else if ( isset( $attrs['movie'] ) ) {
+ } elseif ( isset( $attrs['movie'] ) ) {
$src = $attrs['movie'];
} else {
// no src found, search html
@@ -229,7 +230,7 @@ class Filter_Embedded_HTML_Objects {
}
foreach ( self::$failed_embeds as $entry ) {
- $html = sprintf( '<a href="%s">%s</a>', esc_url( $entry['src'] ), esc_url( $entry['src'] ) );
+ $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 );
@@ -247,12 +248,12 @@ class Filter_Embedded_HTML_Objects {
return array();
}
// We have to go through DOM, since it can load non-well-formed XML (i.e. HTML). SimpleXML cannot.
- $dom = new DOMDocument;
+ $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 );
+ libxml_use_internal_errors( true );
@$dom->loadHTML( $html ); // suppress parser warnings
- libxml_use_internal_errors( FALSE );
+ libxml_use_internal_errors( false );
$xml = false;
foreach ( $dom->childNodes as $node ) {
// find the root node (html)
@@ -273,18 +274,18 @@ class Filter_Embedded_HTML_Objects {
// <param> elements
foreach ( $xml->param as $param ) {
- $attrs[(string) $param['name']] = (string) $param['value'];
+ $attrs[ (string) $param['name'] ] = (string) $param['value'];
}
// <object> attributes
foreach ( $xml->attributes() as $name => $attr ) {
- $attrs[$name] = (string) $attr;
+ $attrs[ $name ] = (string) $attr;
}
// <embed> attributes
if ( $xml->embed ) {
foreach ( $xml->embed->attributes() as $name => $attr ) {
- $attrs[$name] = (string) $attr;
+ $attrs[ $name ] = (string) $attr;
}
}
diff --git a/plugins/jetpack/modules/shortcodes/crowdsignal.php b/plugins/jetpack/modules/shortcodes/crowdsignal.php
new file mode 100644
index 00000000..4359040c
--- /dev/null
+++ b/plugins/jetpack/modules/shortcodes/crowdsignal.php
@@ -0,0 +1,569 @@
+<?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[] = '#&lt;script(?:[^&]|&(?!gt;))+?src="https?://(secure|static)\.polldaddy\.com/p/([0-9]+)\.js"(?:[^&]|&(?!gt;))*+&gt;\s*?&lt;/script&gt;\r?\n?(&lt;noscript&gt;.*?&lt;/noscript&gt;)?#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;
+
+ 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 ( $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
+
+ $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">Take Our Poll</a>', $poll_url );
+
+ if ( $no_script ) {
+ 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 ) {
+ 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 ) {
+ 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 );
+}
+
+wp_oembed_add_provider( '#https?://(.+\.)?polldaddy\.com/.*#i', 'https://api.crowdsignal.com/oembed', true );
+wp_oembed_add_provider( '#https?://.+\.survey\.fm/.*#i', 'https://api.crowdsignal.com/oembed', true );
+wp_oembed_add_provider( '#https?://poll\.fm/.*#i', 'https://api.crowdsignal.com/oembed', true );
+
+}
diff --git a/plugins/jetpack/modules/shortcodes/css/blocks/vr-block.css b/plugins/jetpack/modules/shortcodes/css/blocks/vr-block.css
deleted file mode 100644
index 996d62fc..00000000
--- a/plugins/jetpack/modules/shortcodes/css/blocks/vr-block.css
+++ /dev/null
@@ -1,16 +0,0 @@
-.wp-block-jetpack-vr {
- position: relative;
- max-width: 525px;
- margin-left: auto;
- margin-right: auto;
- overflow: hidden;
-}
-
-iframe.wp-block-jetpack-vr {
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- height: 100%;
-} \ No newline at end of file
diff --git a/plugins/jetpack/modules/shortcodes/css/rtl/slideshow-shortcode-rtl.css b/plugins/jetpack/modules/shortcodes/css/rtl/slideshow-shortcode-rtl.css
deleted file mode 100644
index e69de29b..00000000
--- a/plugins/jetpack/modules/shortcodes/css/rtl/slideshow-shortcode-rtl.css
+++ /dev/null
diff --git a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.css b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.css
new file mode 100644
index 00000000..3defeb94
--- /dev/null
+++ b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.css
@@ -0,0 +1,145 @@
+/* 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
new file mode 100644
index 00000000..6341bcd6
--- /dev/null
+++ b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.min.css
@@ -0,0 +1 @@
+.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%;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";opacity:.5;direction:ltr;transition:.3s 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,.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;*display:inline;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
index b91505ea..2e416a44 100644
--- a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.css
+++ b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.css
@@ -85,7 +85,6 @@ body div.slideshow-window * img {
text-align: center;
}
-/* @noflip */
.slideshow-controls {
z-index: 1000;
position: absolute;
@@ -95,6 +94,7 @@ body div.slideshow-window * img {
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;
diff --git a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css
new file mode 100644
index 00000000..6c445e46
--- /dev/null
+++ b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css
@@ -0,0 +1,2 @@
+/* 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%;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";opacity:.5;direction:ltr;transition:.3s 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,.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;*display:inline;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/dailymotion.php b/plugins/jetpack/modules/shortcodes/dailymotion.php
index 2579f04a..af503394 100644
--- a/plugins/jetpack/modules/shortcodes/dailymotion.php
+++ b/plugins/jetpack/modules/shortcodes/dailymotion.php
@@ -10,7 +10,7 @@
* <embed height="270" type="application/x-shockwave-flash" width="480" src="http&#58;//www.dailymotion.com/swf/video/xekmrq?additionalInfos=0" wmode="opaque" pluginspage="http&#58;//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>
+ * <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:
@@ -80,18 +80,18 @@ add_filter( 'pre_kses', 'dailymotion_embed_to_shortcode' );
* 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], '=' );
+ $id = ltrim( $atts[0], '=' );
$atts['id'] = $id;
} else {
@@ -121,7 +121,9 @@ function dailymotion_shortcode( $atts ) {
'ui-logo' => 1, // int
'ui-start-screen-info' => 0, // int
'ui-theme' => '', // string
- ), $atts, 'dailymotion'
+ ),
+ $atts,
+ 'dailymotion'
);
if ( isset( $atts['id'] ) && ! empty( $atts['id'] ) ) {
@@ -131,8 +133,8 @@ function dailymotion_shortcode( $atts ) {
}
/*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 ;
+ $width = isset( $atts['width'] ) ? intval( $atts['width'] ) : 0;
+ $height = isset( $atts['height'] ) ? intval( $atts['height'] ) : 0;
if ( ! $width && ! $height ) {
if ( ! empty( $content_width ) ) {
@@ -202,7 +204,15 @@ function dailymotion_shortcode( $atts ) {
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>';
+ $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>';
}
}
@@ -221,7 +231,7 @@ add_shortcode( 'dailymotion', 'dailymotion_shortcode' );
function dailymotion_channel_shortcode( $atts ) {
$username = $atts['user'];
- switch( $atts['type'] ) {
+ 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;
@@ -243,7 +253,8 @@ function dailymotion_channel_reversal( $content ) {
return $content;
}
- /* Sample embed code:
+ /*
+ Sample embed code:
<iframe width="300px" height="360px" scrolling="no" frameborder="0" src="http://www.dailymotion.com/badge/user/Dailymotion?type=carousel"></iframe>
*/
@@ -256,7 +267,7 @@ function dailymotion_channel_reversal( $content ) {
foreach ( $regexes as $regex ) {
if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) {
- continue;
+ continue;
}
foreach ( $matches as $match ) {
@@ -264,13 +275,13 @@ function dailymotion_channel_reversal( $content ) {
if ( 'type=carousel' === $url_pieces['query'] ) {
$type = 'carousel';
- } else if ( 'type=grid' === $url_pieces['query'] ) {
+ } elseif ( 'type=grid' === $url_pieces['query'] ) {
$type = 'grid';
} else {
$type = 'badge';
}
- $shortcode = '[dailymotion-channel user=' . esc_attr( $url_pieces['path'] ) . ' type=' . esc_attr( $type ) . ']';
+ $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 );
}
@@ -293,7 +304,8 @@ function jetpack_dailymotion_embed_reversal( $content ) {
return $content;
}
- /* Sample embed code as of Sep 17th 2014:
+ /*
+ 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>
*/
diff --git a/plugins/jetpack/modules/shortcodes/facebook.php b/plugins/jetpack/modules/shortcodes/facebook.php
index 9f787539..9a7a53f8 100644
--- a/plugins/jetpack/modules/shortcodes/facebook.php
+++ b/plugins/jetpack/modules/shortcodes/facebook.php
@@ -59,13 +59,14 @@ add_shortcode( 'facebook', 'jetpack_facebook_shortcode_handler' );
function jetpack_facebook_shortcode_handler( $atts ) {
global $wp_embed;
- if ( empty( $atts['url'] ) )
+ 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'] ) ) {
+ && ! preg_match( JETPACK_FACEBOOK_VIDEO_ALTERNATE_EMBED_REGEX, $atts['url'] ) ) {
return;
}
diff --git a/plugins/jetpack/modules/shortcodes/flatio.php b/plugins/jetpack/modules/shortcodes/flatio.php
new file mode 100644
index 00000000..bc0a51a4
--- /dev/null
+++ b/plugins/jetpack/modules/shortcodes/flatio.php
@@ -0,0 +1,11 @@
+<?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
index 9fc9a0be..3669bbf0 100644
--- a/plugins/jetpack/modules/shortcodes/flickr.php
+++ b/plugins/jetpack/modules/shortcodes/flickr.php
@@ -58,7 +58,7 @@ function flickr_embed_to_shortcode( $content ) {
continue;
}
- $code_atts = array( 'video' => $flashvars['photo_id'], );
+ $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';
@@ -102,7 +102,9 @@ function flickr_shortcode_handler( $atts ) {
'w' => 400,
'h' => 300,
'secret' => 0,
- ), $atts, 'flickr'
+ ),
+ $atts,
+ 'flickr'
);
if ( ! empty( $atts['video'] ) ) {
diff --git a/plugins/jetpack/modules/shortcodes/getty.php b/plugins/jetpack/modules/shortcodes/getty.php
index cdca6859..c308ed0f 100644
--- a/plugins/jetpack/modules/shortcodes/getty.php
+++ b/plugins/jetpack/modules/shortcodes/getty.php
@@ -21,8 +21,8 @@ if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
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 );
+ 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' );
@@ -86,13 +86,12 @@ function wpcom_shortcodereverse_getty( $content ) {
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 = '!<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( '&amp;#0*58;', '&amp;#0*58;|&#0*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 = '!<a.+?class=\'gie-(single|slideshow)\'.+?gie\.widgets\.load\({([^}]+)}\).+?embed-cdn\.gettyimages\.com/widgets\.js.+?</script>!';
$regexp_2017_ent = str_replace( '&amp;#0*58;', '&amp;#0*58;|&#0*58;', htmlspecialchars( $regexp_2017, ENT_NOQUOTES ) );
foreach ( array( 'regexp_2017', 'regexp_2017_ent', 'regexp', 'regexp_ent' ) as $reg ) {
@@ -110,10 +109,18 @@ function wpcom_shortcodereverse_getty( $content ) {
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;
+ 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 {
@@ -123,8 +130,8 @@ function wpcom_shortcodereverse_getty( $content ) {
}
$params = wp_kses_hair( $params, array( 'http' ) );
- $ids = esc_html( $match[3] );
- $width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0;
+ $ids = esc_html( $match[3] );
+ $width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0;
$height = isset( $params['height'] ) ? (int) $params['height']['value'] : 0;
}
@@ -142,7 +149,7 @@ function wpcom_shortcodereverse_getty( $content ) {
// 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 .= ' tld="' . esc_attr( $tld ) . '"';
}
$shortcode .= ']';
@@ -151,7 +158,7 @@ function wpcom_shortcodereverse_getty( $content ) {
}
// strip out enclosing div and any other markup
- $regexp = '%<div class="getty\s[^>]*+>.*?<div[^>]*+>(\[getty[^\]]*+\])\s*</div>.*?</div>%is';
+ $regexp = '%<div class="getty\s[^>]*+>.*?<div[^>]*+>(\[getty[^\]]*+\])\s*</div>.*?</div>%is';
$regexp_ent = str_replace( array( '&amp;#0*58;', '[^&gt;]' ), array( '&amp;#0*58;|&#0*58;', '[^&]' ), htmlspecialchars( $regexp, ENT_NOQUOTES ) );
foreach ( array( 'regexp', 'regexp_ent' ) as $reg ) {
@@ -196,7 +203,7 @@ function jetpack_getty_shortcode( $atts, $content = '' ) {
$params = array(
'width' => isset( $atts['width'] ) ? (int) $atts['width'] : null,
- 'height' => isset( $atts['height'] ) ? (int) $atts['height'] : null
+ 'height' => isset( $atts['height'] ) ? (int) $atts['height'] : null,
);
if ( ! empty( $atts['tld'] ) ) {
diff --git a/plugins/jetpack/modules/shortcodes/gist.php b/plugins/jetpack/modules/shortcodes/gist.php
index 072014ef..968e9e75 100644
--- a/plugins/jetpack/modules/shortcodes/gist.php
+++ b/plugins/jetpack/modules/shortcodes/gist.php
@@ -54,6 +54,49 @@ function github_gist_shortcode( $atts, $content = '' ) {
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' ),
@@ -75,8 +118,8 @@ function github_gist_shortcode( $atts, $content = '' ) {
// 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'] ) {
+ if ( isset( $_POST['type'] ) && 'embed' === $_POST['type'] &&
+ isset( $_POST['action'] ) && 'parse-embed' === $_POST['action'] ) {
return github_gist_simple_embed( $id );
}
@@ -95,4 +138,4 @@ function github_gist_shortcode( $atts, $content = '' ) {
function github_gist_simple_embed( $id ) {
$id = str_replace( 'json', 'js', $id );
return '<script type="text/javascript" src="https://gist.github.com/' . $id . '"></script>';
-} \ No newline at end of file
+}
diff --git a/plugins/jetpack/modules/shortcodes/googleapps.php b/plugins/jetpack/modules/shortcodes/googleapps.php
index 3ef65aa4..8d40e2e5 100644
--- a/plugins/jetpack/modules/shortcodes/googleapps.php
+++ b/plugins/jetpack/modules/shortcodes/googleapps.php
@@ -140,7 +140,8 @@ function googleapps_shortcode( $atts ) {
'dir' => 'document',
'query' => '',
'src' => '',
- ), $atts
+ ),
+ $atts
);
if ( isset( $content_width ) && is_numeric( $attr['width'] ) && $attr['width'] > $content_width ) {
@@ -174,7 +175,7 @@ function googleapps_shortcode( $atts ) {
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"></iframe>',
+ '<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'] )
diff --git a/plugins/jetpack/modules/shortcodes/googlemaps.php b/plugins/jetpack/modules/shortcodes/googlemaps.php
index 5518d44c..21d86088 100644
--- a/plugins/jetpack/modules/shortcodes/googlemaps.php
+++ b/plugins/jetpack/modules/shortcodes/googlemaps.php
@@ -7,7 +7,7 @@
*/
function jetpack_googlemaps_embed_to_short_code( $content ) {
- if ( ! is_string( $content ) || ( false === strpos( $content, 'maps.google.' ) && 1 !== preg_match( '@google\.[^/]+/maps?@', $content ) ) ){
+ if ( ! is_string( $content ) || ( false === strpos( $content, 'maps.google.' ) && 1 !== preg_match( '@google\.[^/]+/maps?@', $content ) ) ) {
return $content;
}
@@ -29,14 +29,14 @@ 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;
+ $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;
+ $height = absint( $height[1] ) . $percent;
} else {
$height = 350;
}
@@ -59,12 +59,13 @@ add_filter( 'pre_kses', 'jetpack_googlemaps_embed_to_short_code' );
* [googlemaps https://mapsengine.google.com/map/embed?mid=zbBhkou4wwtE.kUmp8K6QJ7SA&w=640&h=480]
*/
function jetpack_googlemaps_shortcode( $atts ) {
- if ( !isset($atts[0]) )
+ if ( ! isset( $atts[0] ) ) {
return '';
+ }
$params = ltrim( $atts[0], '=' );
- $width = 425;
+ $width = 425;
$height = 350;
if ( preg_match( '!^https?://(www|maps|mapsengine)\.google(\.co|\.com)?(\.[a-z]+)?/.*?(\?.+)!i', $params, $match ) ) {
@@ -72,25 +73,27 @@ function jetpack_googlemaps_shortcode( $atts ) {
$params = str_replace( '&amp;', '&', $params );
parse_str( $params, $arg );
- if ( isset( $arg['hq'] ) )
+ 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;
+ $width = (int) $value . $percent;
} elseif ( 'h' == $key ) {
$height = (int) $value;
} else {
- $key = str_replace( '_', '.', $key );
+ $key = str_replace( '_', '.', $key );
$url .= esc_attr( "$key=$value&amp;" );
}
}
$url = substr( $url, 0, -5 );
- if( is_ssl() )
+ if ( is_ssl() ) {
$url = str_replace( 'http://', 'https://', $url );
+ }
$css_class = 'googlemaps';
diff --git a/plugins/jetpack/modules/shortcodes/googleplus.php b/plugins/jetpack/modules/shortcodes/googleplus.php
index 0a8ae294..950f217c 100644
--- a/plugins/jetpack/modules/shortcodes/googleplus.php
+++ b/plugins/jetpack/modules/shortcodes/googleplus.php
@@ -20,11 +20,13 @@ add_shortcode( 'googleplus', 'jetpack_googleplus_shortcode_handler' );
function jetpack_googleplus_shortcode_handler( $atts ) {
global $wp_embed;
- if ( empty( $atts['url'] ) )
+ if ( empty( $atts['url'] ) ) {
return;
+ }
- if ( ! preg_match( JETPACK_GOOGLEPLUS_EMBED_REGEX, $atts['url'] ) )
+ if ( ! preg_match( JETPACK_GOOGLEPLUS_EMBED_REGEX, $atts['url'] ) ) {
return;
+ }
return $wp_embed->shortcode( $atts, $atts['url'] );
}
diff --git a/plugins/jetpack/modules/shortcodes/googlevideo.php b/plugins/jetpack/modules/shortcodes/googlevideo.php
index cbd709c9..bf3ad707 100644
--- a/plugins/jetpack/modules/shortcodes/googlevideo.php
+++ b/plugins/jetpack/modules/shortcodes/googlevideo.php
@@ -6,23 +6,25 @@
*/
function googlevideo_shortcode( $atts ) {
- if ( !isset( $atts[0] ) )
+ 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] ) )
+ 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 );
+ $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>";
}
diff --git a/plugins/jetpack/modules/shortcodes/gravatar.php b/plugins/jetpack/modules/shortcodes/gravatar.php
index 8d1c4ee1..ea248618 100644
--- a/plugins/jetpack/modules/shortcodes/gravatar.php
+++ b/plugins/jetpack/modules/shortcodes/gravatar.php
@@ -21,10 +21,13 @@ add_shortcode( 'gravatar_profile', 'jetpack_gravatar_profile_shortcode' );
* @return bool|string
*/
function jetpack_gravatar_shortcode( $atts ) {
- $atts = shortcode_atts( array(
- 'email' => '',
- 'size' => 96,
- ), $atts );
+ $atts = shortcode_atts(
+ array(
+ 'email' => '',
+ 'size' => 96,
+ ),
+ $atts
+ );
if ( empty( $atts['email'] ) || ! is_email( $atts['email'] ) ) {
return false;
@@ -64,9 +67,13 @@ function jetpack_gravatar_profile_shortcode( $atts ) {
static $instance = 0;
// Process passed attributes
- $atts = shortcode_atts( array(
- 'who' => null,
- ), $atts, 'jetpack_gravatar_profile' );
+ $atts = shortcode_atts(
+ array(
+ 'who' => null,
+ ),
+ $atts,
+ 'jetpack_gravatar_profile'
+ );
// Can specify username, user ID, or email address
if ( is_numeric( $atts['who'] ) ) {
@@ -85,7 +92,7 @@ function jetpack_gravatar_profile_shortcode( $atts ) {
}
// Render the shortcode
- $gravatar_url = set_url_scheme( 'http://gravatar.com/' . $user->user_login );
+ $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 );
@@ -132,7 +139,10 @@ function jetpack_gravatar_profile_shortcode( $atts ) {
<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; ?>
+ <?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">
@@ -141,7 +151,8 @@ function jetpack_gravatar_profile_shortcode( $atts ) {
</div>
<span class="grofile-clear">&nbsp;</span>
</div>
- </div><?php
+ </div>
+ <?php
// Increment and return the rendered profile
$instance++;
diff --git a/plugins/jetpack/modules/shortcodes/houzz.php b/plugins/jetpack/modules/shortcodes/houzz.php
index 7e31c50e..9d9b3131 100644
--- a/plugins/jetpack/modules/shortcodes/houzz.php
+++ b/plugins/jetpack/modules/shortcodes/houzz.php
@@ -14,8 +14,8 @@
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 );
+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'];
diff --git a/plugins/jetpack/modules/shortcodes/hulu.php b/plugins/jetpack/modules/shortcodes/hulu.php
index 1236917f..93701099 100644
--- a/plugins/jetpack/modules/shortcodes/hulu.php
+++ b/plugins/jetpack/modules/shortcodes/hulu.php
@@ -13,7 +13,7 @@
* <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>
-*/
+ */
if ( get_option( 'embed_autourls' ) ) {
@@ -28,7 +28,7 @@ add_shortcode( 'hulu', 'jetpack_hulu_shortcode' );
*
* @since 4.5.0
*
- * @param array $atts Shortcode parameters.
+ * @param array $atts Shortcode parameters.
*
* @return string $id Hulu video ID.
*/
@@ -37,10 +37,10 @@ function jetpack_shortcode_get_hulu_id( $atts ) {
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'] );
- } else if ( isset( $atts[0] ) && preg_match( '|www\.hulu\.com/watch/(\d+)|i', $atts[0], $match ) ) {
+ } 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];
- } else if ( isset( $atts[0] ) ) {
+ } elseif ( isset( $atts[0] ) ) {
// This checks for [hulu 369061] or [hulu 65yppv6xqa45s5n7_m1wng]
$id = esc_attr( $atts[0] );
} else {
@@ -69,8 +69,9 @@ function jetpack_hulu_shortcode( $atts ) {
'width' => $content_width ? $content_width : 640,
'start_time' => '',
'end_time' => '',
- 'thumbnail_frame' => ''
- ), $atts
+ 'thumbnail_frame' => '',
+ ),
+ $atts
);
$id = jetpack_shortcode_get_hulu_id( $atts );
@@ -170,7 +171,7 @@ mozallowfullscreen allowfullscreen></iframe></div>',
*/
function jetpack_hulu_link_callback( $matches ) {
$video_id = $matches[4];
- $src = is_ssl()
+ $src = is_ssl()
? 'https://secure.hulu.com'
: 'http://www.hulu.com';
diff --git a/plugins/jetpack/modules/shortcodes/instagram.php b/plugins/jetpack/modules/shortcodes/instagram.php
index 13eeacfb..fc164d82 100644
--- a/plugins/jetpack/modules/shortcodes/instagram.php
+++ b/plugins/jetpack/modules/shortcodes/instagram.php
@@ -5,6 +5,7 @@
* 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 ) {
@@ -12,7 +13,8 @@ function jetpack_instagram_embed_reversal( $content ) {
return $content;
}
- /* Sample embed code:
+ /*
+ 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>
*/
@@ -76,10 +78,13 @@ function jetpack_instagram_handler( $matches, $atts, $url ) {
return sprintf( '<a href="%s" title="%s" target="_blank"><img src="%s" alt="Instagram Photo" /></a>', esc_url( $url ), esc_attr__( 'View on Instagram', 'jetpack' ), esc_url( $media_url ) );
}
- $atts = shortcode_atts( array(
- 'width' => isset( $content_width ) ? $content_width : $max_width,
- 'hidecaption' => false,
- ), $atts );
+ $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 ) {
diff --git a/plugins/jetpack/modules/shortcodes/js/blocks/vr-block.js b/plugins/jetpack/modules/shortcodes/js/blocks/vr-block.js
deleted file mode 100644
index 9466a671..00000000
--- a/plugins/jetpack/modules/shortcodes/js/blocks/vr-block.js
+++ /dev/null
@@ -1,102 +0,0 @@
-'use strict';
-
-/* global wp */
-/* eslint react/react-in-jsx-scope: 0 */
-
-(function (blocks, components, i18n) {
- var registerBlockType = blocks.registerBlockType,
- UrlInput = blocks.UrlInput;
- var Placeholder = components.Placeholder,
- SelectControl = components.SelectControl;
- var __ = i18n.__;
-
-
- registerBlockType('jetpack/vr', {
- title: __('VR Image', 'jetpack'),
- icon: 'embed-photo',
- category: 'embed',
- support: {
- html: false
- },
- attributes: {
- url: {
- type: 'string'
- },
- view: {
- type: 'string'
- }
- },
-
- edit: function edit(props) {
- var attributes = props.attributes;
-
- var onSetUrl = function onSetUrl(value) {
- return props.setAttributes({ url: value });
- };
- var onSetView = function onSetView(value) {
- return props.setAttributes({ view: value });
- };
-
- var renderEdit = function renderEdit() {
- if (attributes.url && attributes.view) {
- return wp.element.createElement(
- 'div',
- { className: props.className },
- wp.element.createElement('iframe', {
- title: __('VR Image', 'jetpack'),
- allowFullScreen: 'true',
- frameBorder: '0',
- width: '100%',
- height: '300',
- src: 'https://vr.me.sh/view/?view=' + encodeURIComponent(attributes.view) + '&url=' + encodeURIComponent(attributes.url)
- })
- );
- }
- return wp.element.createElement(
- 'div',
- null,
- wp.element.createElement(
- Placeholder,
- {
- key: 'placeholder',
- instructions: __('Enter URL to VR image', 'jetpack'),
- icon: 'format-image',
- label: __('VR Image', 'jetpack'),
- className: props.className
- },
- wp.element.createElement(UrlInput, {
- value: attributes.url,
- onChange: onSetUrl
- }),
- wp.element.createElement(
- 'div',
- { style: { marginTop: '10px' } },
- wp.element.createElement(SelectControl, {
- label: __('View Type', 'jetpack'),
- value: attributes.view,
- onChange: onSetView,
- options: [{ label: '', value: '' }, { label: __('360', 'jetpack'), value: '360' }, { label: __('Cinema', 'jetpack'), value: 'cinema' }]
- })
- )
- )
- );
- };
-
- return renderEdit();
- },
- save: function save(props) {
- return wp.element.createElement(
- 'div',
- { className: props.className },
- wp.element.createElement('iframe', {
- title: __('VR Image', 'jetpack'),
- allowFullScreen: 'true',
- frameBorder: '0',
- width: '100%',
- height: '300',
- src: 'https://vr.me.sh/view/?view=' + encodeURIComponent(props.attributes.view) + '&url=' + encodeURIComponent(props.attributes.url)
- })
- );
- }
- });
-})(wp.blocks, wp.components, wp.i18n); \ No newline at end of file
diff --git a/plugins/jetpack/modules/shortcodes/kickstarter.php b/plugins/jetpack/modules/shortcodes/kickstarter.php
index ae9f40a9..cd59f940 100644
--- a/plugins/jetpack/modules/shortcodes/kickstarter.php
+++ b/plugins/jetpack/modules/shortcodes/kickstarter.php
@@ -75,4 +75,4 @@ function jetpack_kickstarter_embed_to_shortcode( $content ) {
}
return $content;
-} \ No newline at end of file
+}
diff --git a/plugins/jetpack/modules/shortcodes/lytro.php b/plugins/jetpack/modules/shortcodes/lytro.php
index b1a179a4..0e222fda 100644
--- a/plugins/jetpack/modules/shortcodes/lytro.php
+++ b/plugins/jetpack/modules/shortcodes/lytro.php
@@ -123,7 +123,7 @@ function jetpack_lytro_shortcode_handler( $atts ) {
$attributes = jetpack_lytro_shortcode_attributes();
foreach ( $attributes as $key => $attribute ) {
if ( isset( $attribute['default'] ) ) {
- $defaults[$key] = $attribute['default'];
+ $defaults[ $key ] = $attribute['default'];
}
}
@@ -141,12 +141,12 @@ function jetpack_lytro_shortcode_handler( $atts ) {
// Validate all attributes by callable function or regular expression.
foreach ( $atts as $key => $value ) {
- $attribute = $attributes[$key];
+ $attribute = $attributes[ $key ];
if ( isset( $attribute['validate'] ) ) {
$validate = $attribute['validate'];
$valid = is_callable( $validate ) ? call_user_func( $validate, $value ) : preg_match( $validate, $value );
if ( ! $valid ) {
- $atts[$key] = $defaults[$key];
+ $atts[ $key ] = $defaults[ $key ];
}
}
}
@@ -159,9 +159,9 @@ function jetpack_lytro_shortcode_handler( $atts ) {
// Build a query which is then appended to the iframe src.
$query_args = array();
foreach ( $atts as $key => $value ) {
- $attribute = $attributes[$key];
+ $attribute = $attributes[ $key ];
if ( isset( $attribute['query_arg'] ) && ! empty( $attribute['query_arg'] ) && ! empty( $value ) ) {
- $query_args[$attribute['query_arg']] = $value;
+ $query_args[ $attribute['query_arg'] ] = $value;
}
}
@@ -209,7 +209,7 @@ function jetpack_lytro_shortcode_url_to_atts( $url ) {
// Get the attributes with query_args and fill in the $atts array
foreach ( $attributes as $key => $attribute ) {
if ( isset( $attribute['query_arg'] ) && in_array( $attribute['query_arg'], array_keys( $qargs ) ) ) {
- $atts[$key] = $qargs[$attribute['query_arg']];
+ $atts[ $key ] = $qargs[ $attribute['query_arg'] ];
}
}
}
diff --git a/plugins/jetpack/modules/shortcodes/mailchimp.php b/plugins/jetpack/modules/shortcodes/mailchimp.php
index 2cbbefac..6e05a936 100644
--- a/plugins/jetpack/modules/shortcodes/mailchimp.php
+++ b/plugins/jetpack/modules/shortcodes/mailchimp.php
@@ -6,7 +6,7 @@
* [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/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script><script type="text/javascript">require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us11.list-manage.com","uuid":"1ca7856462585a934b8674c71","lid":"2d24f1898b"}) })</script>
+ * <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>
*
*/
@@ -16,14 +16,20 @@
* @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'
- ) );
+ 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 ) {
@@ -46,9 +52,9 @@ class MailChimp_Subscriber_Popup {
*/
static $reversal_regexes = array(
/* raw examplejs */
- '/<script type="text\/javascript" src="(https?:)?\/\/downloads\.mailchimp\.com\/js\/signup-forms\/popup\/embed\.js" data-dojo-config="([^"]*?)"><\/script><script type="text\/javascript">require\(\["mojo\/signup-forms\/Loader"\]\, function\(L\) { L\.start\({([^}]*?)}\) }\)<\/script>/s',
+ '/<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',
/* visual editor */
- '/&lt;script type="text\/javascript" src="(https?:)?\/\/downloads\.mailchimp\.com\/js\/signup-forms\/popup\/embed\.js" data-dojo-config="([^"]*?)"&gt;&lt;\/script&gt;&lt;script type="text\/javascript"&gt;require\(\["mojo\/signup-forms\/Loader"]\, function\(L\) { L\.start\({([^}]*?)}\) }\)&lt;\/script&gt;/s',
+ '/&lt;script type="text\/javascript" src="(https?:)?\/\/downloads\.mailchimp\.com\/js\/signup-forms\/popup\/unique-methods\/embed\.js" data-dojo-config="([^"]*?)"&gt;&lt;\/script&gt;&lt;script type="text\/javascript"&gt;window.dojoRequire\(\["mojo\/signup-forms\/Loader"]\, function\(L\) { L\.start\({([^}]*?)}\) }\)&lt;\/script&gt;/s',
);
/**
@@ -83,11 +89,11 @@ class MailChimp_Subscriber_Popup {
*/
static function reversal( $content ) {
// Bail without the js src
- if ( ! is_string( $content ) || false === stripos( $content, 'downloads.mailchimp.com/js/signup-forms/popup/embed.js' ) ) {
+ 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' );
+ require_once ABSPATH . WPINC . '/class-json.php';
$wp_json = new Services_JSON();
// loop through our rules and find valid embeds
@@ -99,12 +105,12 @@ class MailChimp_Subscriber_Popup {
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], '#' ) );
+ $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] . '}' );
+ if ( $matches[2][ $index ] ) {
+ $config_attrs = $wp_json->decode( '{' . $matches[2][ $index ] . '}' );
foreach ( $config_attrs as $key => $value ) {
$attrs->$key = ( 1 == $value ) ? 'true' : 'false';
}
@@ -194,11 +200,14 @@ class MailChimp_Subscriber_Popup {
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/embed.js", function( data, textStatus, jqxhr ) { require(["mojo/signup-forms/Loader"], function(L) { L.start(' . wp_json_encode( $js_vars ) . ') }); window.define.amd = undefined; } );</script>' . "\n\n";
+ 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
index fc0bab5c..02d02aaf 100644
--- a/plugins/jetpack/modules/shortcodes/medium.php
+++ b/plugins/jetpack/modules/shortcodes/medium.php
@@ -12,7 +12,7 @@
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 = jetpack_embed_medium_args( $attr );
$attr['url'] = $url;
return jetpack_embed_medium_embed_html( $attr );
@@ -50,7 +50,7 @@ function jetpack_embed_medium_get_embed_type( $url ) {
$url_path = parse_url( $url, PHP_URL_PATH );
if ( preg_match( '/^\/@[\.\w]+$/', $url_path ) ) {
return 'profile';
- } else if ( preg_match( '/^\/[\da-zA-Z-]+$/', $url_path ) ) {
+ } elseif ( preg_match( '/^\/[\da-zA-Z-]+$/', $url_path ) ) {
return 'collection';
}
@@ -58,10 +58,14 @@ function jetpack_embed_medium_get_embed_type( $url ) {
}
function jetpack_embed_medium_args( $atts ) {
- return shortcode_atts( array(
- 'url' => '',
- 'width' => '400',
- 'border' => true,
- 'collapsed' => false,
- ), $atts, 'medium' );
+ 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
index ac5c3f01..3580a924 100644
--- a/plugins/jetpack/modules/shortcodes/mixcloud.php
+++ b/plugins/jetpack/modules/shortcodes/mixcloud.php
@@ -53,7 +53,8 @@ function mixcloud_shortcode( $atts, $content = null ) {
'mini' => false,
'hide_followers' => false,
'hide_artwork' => false,
- ), $atts
+ ),
+ $atts
);
// remove falsey values
diff --git a/plugins/jetpack/modules/shortcodes/pinterest.php b/plugins/jetpack/modules/shortcodes/pinterest.php
index 36e66806..caecc619 100644
--- a/plugins/jetpack/modules/shortcodes/pinterest.php
+++ b/plugins/jetpack/modules/shortcodes/pinterest.php
@@ -22,7 +22,7 @@ wp_embed_register_handler(
function pinterest_embed_handler( $matches, $attr, $url ) {
// Pinterest's JS handles making the embed
- $script_src = '//assets.pinterest.com/js/pinit.js';
+ $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 );
diff --git a/plugins/jetpack/modules/shortcodes/polldaddy.php b/plugins/jetpack/modules/shortcodes/polldaddy.php
index 609794ff..10a62d65 100644
--- a/plugins/jetpack/modules/shortcodes/polldaddy.php
+++ b/plugins/jetpack/modules/shortcodes/polldaddy.php
@@ -1,579 +1,4 @@
<?php
-
-if ( ! class_exists( 'PolldaddyShortcode' ) ) {
- /**
-* Class wrapper for polldaddy shortcodes
-*/
-
-class PolldaddyShortcode {
-
- static $add_script = false;
- static $scripts = false;
-
- /**
- * Add all the actions & resgister the shortcode
- */
- function __construct() {
- if ( defined( 'GLOBAL_TAGS' ) == false ) {
- add_shortcode( 'polldaddy', array( $this, 'polldaddy_shortcode' ) );
- add_filter( 'pre_kses', array( $this, 'polldaddy_embed_to_shortcode' ) );
- }
- add_action( 'wp_enqueue_scripts', array( $this, 'check_infinite' ) );
- add_action( 'infinite_scroll_render', array( $this, 'polldaddy_shortcode_infinite' ), 11 );
- }
-
- private function get_async_code( array $settings, $survey_link ) {
- $embed_src = 'http://i0.poll.fm/survey.js';
- $embed_src_ssl = 'https://polldaddy.com/survey.js';
-
- $include = <<<CONTAINER
-( function( d, c, j ) {
- if ( !d.getElementById( j ) ) {
- var pd = d.createElement( c ), s;
- pd.id = j;
- pd.src = ( 'https:' == d.location.protocol ) ? '{$embed_src_ssl}' : '{$embed_src}';
- 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="pd-embed" data-settings="'
- . esc_attr( json_encode( $settings ) )
- . '"></div>';
- if ( 'button' === $settings['type'] ) {
- $placeholder =
- '<a class="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;
- }
-
- /*
- * Polldaddy 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 [polldaddy poll=...] shortcode format
- */
- function polldaddy_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[] = '#&lt;script(?:[^&]|&(?!gt;))+?src="https?://(secure|static)\.polldaddy\.com/p/([0-9]+)\.js"(?:[^&]|&(?!gt;))*+&gt;\s*?&lt;/script&gt;\r?\n?(&lt;noscript&gt;.*?&lt;/noscript&gt;)?#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], " [polldaddy poll=$id]", $content );
- /** This action is documented in modules/shortcodes/youtube.php */
- do_action( 'jetpack_embed_to_shortcode', 'polldaddy', $id );
- }
- }
- }
-
- return $content;
- }
-
- /**
- * Shortcode for polldadddy
- * [polldaddy poll|survey|rating="123456"]
- *
- * */
- function polldaddy_shortcode( $atts ) {
- global $post;
- global $content_width;
-
- 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, 'polldaddy' ) );
-
- if ( ! is_array( $atts ) ) {
- return '<!-- Polldaddy 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 ( is_ssl() ) {
- $rating_js_file = "https://polldaddy.com/js/rating/rating.js";
- } else {
- $rating_js_file = "http://i0.poll.fm/js/rating/rating.js";
- }
-
- if ( $inline ) {
- return <<<SCRIPT
-<div class="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="{$rating_js_file}"></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="pd-rating" id="pd_rating_holder_{$rating}{$item_id}" data-settings="{$data}"></div>
-CONTAINER;
- } else {
- return <<<CONTAINER
-<div class="pd-rating" id="pd_rating_holder_{$rating}{$item_id}"></div>
-CONTAINER;
- }
- }
- } elseif ( intval( $poll ) > 0 ) { //poll embed
-
- $poll = intval( $poll );
- $poll_url = sprintf( 'http://polldaddy.com/poll/%d', $poll );
- $poll_js = sprintf( '%s.polldaddy.com/p/%d.js', ( is_ssl() ? 'https://secure' : 'http://static' ), $poll );
- $poll_link = sprintf( '<a href="%s" target="_blank">Take Our Poll</a>', $poll_url );
-
- if ( $no_script ) {
- 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="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="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( "http://polldaddy.com/s/{$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 ) {
- 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( "http://{$domain}.polldaddy.com/s/{$id}" );
- $auto_src = parse_url( $auto_src );
-
- if ( ! is_array( $auto_src ) || count( $auto_src ) == 0 ) {
- return '<!-- no polldaddy output -->';
- }
-
- if ( ! isset( $auto_src['host'] ) || ! isset( $auto_src['path'] ) ) {
- return '<!-- no polldaddy output -->';
- }
-
- $domain = $auto_src['host'].'/s/';
- $id = str_ireplace( '/s/', '', $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 polldaddy output -->';
- }
-
- return $this->get_async_code( $settings, $survey_link );
- }
- } else {
- return '<!-- no polldaddy output -->';
- }
- }
-
- function generate_scripts() {
- $script = '';
-
- if ( is_array( self::$scripts ) ) {
- if ( is_ssl() ) {
- $rating_js_file = "https://polldaddy.com/js/rating/rating.js";
- } else {
- $rating_js_file = "http://i0.poll.fm/js/rating/rating.js";
- }
-
- 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='{$rating_js_file}'></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 polldaddy_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 PolldaddyShortcode();
-
-if ( ! function_exists( 'polldaddy_link' ) ) {
- // http://polldaddy.com/poll/1562975/?view=results&msg=voted
- function polldaddy_link( $content ) {
- return jetpack_preg_replace_outside_tags( '!(?:\n|\A)http://polldaddy.com/poll/([0-9]+?)/(.+)?(?:\n|\Z)!i', "\n<script type='text/javascript' charset='utf-8' async src='//static.polldaddy.com/p/$1.js'></script><noscript> <a href='http://polldaddy.com/poll/$1/'>View Poll</a></noscript>\n", $content, 'polldaddy.com/poll' );
- }
-
- // higher priority because we need it before auto-link and autop get to it
- add_filter( 'the_content', 'polldaddy_link', 1 );
- add_filter( 'the_content_rss', 'polldaddy_link', 1 );
-}
-
-wp_oembed_add_provider( '#http://poll\.fm/.*#i', 'http://polldaddy.com/oembed/', true );
-
-}
+/**
+ * Deprecated alias for Crowdsignal.
+ */
diff --git a/plugins/jetpack/modules/shortcodes/presentations.php b/plugins/jetpack/modules/shortcodes/presentations.php
index 9c9c568b..77089189 100644
--- a/plugins/jetpack/modules/shortcodes/presentations.php
+++ b/plugins/jetpack/modules/shortcodes/presentations.php
@@ -49,8 +49,8 @@ presentation unless overridden by individual slides.
- 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
+ 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
@@ -62,400 +62,404 @@ presentation unless overridden by individual slides.
- 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"
+ "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.
+ - 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
+ - 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
+ - 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 {
+ class Presentations {
- private $presentation_settings;
- private $presentation_initialized;
- private $scripts_and_style_included;
+ private $presentation_settings;
+ private $presentation_initialized;
+ private $scripts_and_style_included;
- /**
- * Constructor
- */
- function __construct() {
- $this->presentation_initialized = false;
- $this->scripts_and_style_included = false;
+ /**
+ * Constructor
+ */
+ function __construct() {
+ $this->presentation_initialized = false;
+ $this->scripts_and_style_included = false;
- // Registers shortcodes
- add_action( 'wp_head', array( &$this, 'add_scripts' ), 1 );
+ // 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' ) );
- }
+ add_shortcode( 'presentation', array( &$this, 'presentation_shortcode' ) );
+ add_shortcode( 'slide', array( &$this, 'slide_shortcode' ) );
+ }
- function add_scripts() {
- $this->scripts_and_style_included = false;
+ function add_scripts() {
+ $this->scripts_and_style_included = false;
- if ( empty( $GLOBALS['posts'] ) || ! is_array( $GLOBALS['posts'] ) ) {
- return;
- }
+ 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;
+ 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;
+ 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
+ );
}
- $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'
+ );
- 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'];
- }
+ $this->presentation_settings = array(
+ 'transition' => 'down',
+ 'scale' => 1,
+ 'rotate' => 0,
+ 'fade' => 'on',
+ 'fadebullets' => 0,
+ 'last' => array(
+ 'x' => 0,
+ 'y' => 0,
+ 'scale' => 1,
+ 'rotate' => 0,
+ ),
+ );
- if ( '' != trim( $atts['scale'] ) ) {
- $this->presentation_settings['scale'] = floatval( $atts['scale'] );
- }
+ // Set the presentation-wide settings
+ if ( '' != trim( $atts['transition'] ) ) {
+ $this->presentation_settings['transition'] = $atts['transition'];
+ }
- if ( '' != trim( $atts['rotate'] ) ) {
- $this->presentation_settings['rotate'] = floatval( $atts['rotate'] );
- }
+ if ( '' != trim( $atts['scale'] ) ) {
+ $this->presentation_settings['scale'] = floatval( $atts['scale'] );
+ }
- if ( '' != trim( $atts['fade'] ) ) {
- $this->presentation_settings['fade'] = $atts['fade'];
- }
+ if ( '' != trim( $atts['rotate'] ) ) {
+ $this->presentation_settings['rotate'] = floatval( $atts['rotate'] );
+ }
- if ( '' != trim( $atts['fadebullets'] ) ) {
- $this->presentation_settings['fadebullets'] = $atts['fadebullets'];
- }
+ if ( '' != trim( $atts['fade'] ) ) {
+ $this->presentation_settings['fade'] = $atts['fade'];
+ }
- // Set any settings the slides don't care about
- if ( '' != trim( $atts['duration'] ) ) {
- $duration = floatval( $atts['duration'] ) . 's';
- } else {
- $duration = '1s';
- }
+ if ( '' != trim( $atts['fadebullets'] ) ) {
+ $this->presentation_settings['fadebullets'] = $atts['fadebullets'];
+ }
- // 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;
- }
+ // Set any settings the slides don't care about
+ if ( '' != trim( $atts['duration'] ) ) {
+ $duration = floatval( $atts['duration'] ) . 's';
+ } else {
+ $duration = '1s';
+ }
- if ( '' != trim( $atts['height'] ) ) {
- $this->presentation_settings['height'] = intval( $atts['height'] );
- } else {
- $this->presentation_settings['height'] = 370;
- }
+ // 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;
+ }
- // 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] ) . '");';
- } else if ( '' != trim( $atts['bgcolor'] ) ) {
- $style .= ' background-color: ' . esc_attr( $atts['bgcolor'] ) . ';';
- } else {
- $style .= ' background-color: #fff;';
- }
+ if ( '' != trim( $atts['height'] ) ) {
+ $this->presentation_settings['height'] = intval( $atts['height'] );
+ } else {
+ $this->presentation_settings['height'] = 370;
+ }
- // 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>';
+ // 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;';
}
- $out .= do_shortcode( $content );
+ // 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;
}
- $out .= '</section>';
+ function slide_shortcode( $atts, $content = '' ) {
+ // Bail out unless wrapped by a [presentation] shortcode
+ if ( ! $this->presentation_initialized ) {
+ return $content;
+ }
- $this->presentation_initialized = false;
+ $atts = shortcode_atts(
+ array(
+ 'transition' => '',
+ 'scale' => '',
+ 'rotate' => '',
+ 'fade' => '',
+ 'fadebullets' => '',
+ 'bgcolor' => '',
+ 'bgimg' => '',
+ ),
+ $atts,
+ 'slide'
+ );
- return $out;
- }
+ // Determine positioning based on transition
+ if ( '' == trim( $atts['transition'] ) ) {
+ $atts['transition'] = $this->presentation_settings['transition'];
+ }
- function slide_shortcode( $atts, $content = '' ) {
- // Bail out unless wrapped by a [presentation] shortcode
- if ( ! $this->presentation_initialized ) {
- return $content;
- }
+ // Setting the content scale
+ if ( '' == trim( $atts['scale'] ) ) {
+ $atts['scale'] = $this->presentation_settings['scale'];
+ }
- $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'];
- }
+ if ( '' == trim( $atts['scale'] ) ) {
+ $scale = 1;
+ } else {
+ $scale = floatval( $atts['scale'] );
+ }
- // Setting the content scale
- if ( '' == trim( $atts['scale'] ) ) {
- $atts['scale'] = $this->presentation_settings['scale'];
- }
+ if ( $scale < 0 ) {
+ $scale *= -1;
+ }
- if ( '' == trim( $atts['scale'] ) ) {
- $scale = 1;
- } else {
- $scale = floatval( $atts['scale'] );
- }
+ // Setting the content rotation
+ if ( '' == trim( $atts['rotate'] ) ) {
+ $atts['rotate'] = $this->presentation_settings['rotate'];
+ }
- if ( $scale < 0 ) {
- $scale *= -1;
- }
+ if ( '' == trim( $atts['rotate'] ) ) {
+ $rotate = 0;
+ } else {
+ $rotate = floatval( $atts['rotate'] );
+ }
- // Setting the content rotation
- if ( '' == trim( $atts['rotate'] ) ) {
- $atts['rotate'] = $this->presentation_settings['rotate'];
- }
+ // Setting if the content should fade
+ if ( '' == trim( $atts['fade'] ) ) {
+ $atts['fade'] = $this->presentation_settings['fade'];
+ }
- if ( '' == trim( $atts['rotate'] ) ) {
- $rotate = 0;
- } else {
- $rotate = floatval( $atts['rotate'] );
- }
+ if ( 'on' == $atts['fade'] || 'true' == $atts['fade'] ) {
+ $fade = 'fade';
+ } else {
+ $fade = '';
+ }
- // Setting if the content should fade
- if ( '' == trim( $atts['fade'] ) ) {
- $atts['fade'] = $this->presentation_settings['fade'];
- }
+ // Setting if bullets should fade on step changes
+ if ( '' == trim( $atts['fadebullets'] ) ) {
+ $atts['fadebullets'] = $this->presentation_settings['fadebullets'];
+ }
- if ( 'on' == $atts['fade'] || 'true' == $atts['fade'] ) {
- $fade = 'fade';
- } else {
- $fade = '';
- }
+ if ( 'on' == $atts['fadebullets'] || 'true' == $atts['fadebullets'] ) {
+ $fadebullets = 'fadebullets';
+ } else {
+ $fadebullets = '';
+ }
- // Setting if bullets should fade on step changes
- if ( '' == trim( $atts['fadebullets'] ) ) {
- $atts['fadebullets'] = $this->presentation_settings['fadebullets'];
- }
+ $coords = $this->get_coords(
+ array(
+ 'transition' => $atts['transition'],
+ 'scale' => $scale,
+ 'rotate' => $rotate,
+ )
+ );
- if ( 'on' == $atts['fadebullets'] || 'true' == $atts['fadebullets'] ) {
- $fadebullets = 'fadebullets';
- } else {
- $fadebullets = '';
- }
+ $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 = '';
+ }
- $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] ) . '");';
- } else if ( '' != 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 )
+ );
- // 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;
- }
+ $out .= '<div class="slide-content">';
+ $out .= do_shortcode( $content );
+ $out .= '</div></div>';
- /**
- * 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;
+ return $out;
}
- $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'];
- }
+ /**
+ * 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;
+ }
- switch ( trim( $args['transition'] ) ) {
- case 'none':
- break;
+ $width = $this->presentation_settings['width'];
+ $height = $this->presentation_settings['height'];
+ $last = $this->presentation_settings['last'];
+ $scale = $last['scale'];
- case 'left':
- $next['x'] -= $totalHorizDisp;
- break;
+ $next = array(
+ 'x' => $last['x'],
+ 'y' => $last['y'],
+ 'scale' => $args['scale'],
+ 'rotate' => $args['rotate'],
+ );
- case 'right':
- $next['x'] += $totalHorizDisp;
- break;
+ // 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'];
+ }
- case 'up':
- $next['y'] -= $totalVertDisp;
- break;
+ switch ( trim( $args['transition'] ) ) {
+ case 'none':
+ break;
- case 'down':
- default:
- $next['y'] += $totalVertDisp;
- break;
- }
+ case 'left':
+ $next['x'] -= $totalHorizDisp;
+ break;
+
+ case 'right':
+ $next['x'] += $totalHorizDisp;
+ break;
- $this->presentation_settings['last'] = $next;
+ case 'up':
+ $next['y'] -= $totalVertDisp;
+ break;
- return $next;
+ case 'down':
+ default:
+ $next['y'] += $totalVertDisp;
+ break;
+ }
+
+ $this->presentation_settings['last'] = $next;
+
+ return $next;
+ }
}
-}
-$GLOBALS['presentations'] = new Presentations();
+ $GLOBALS['presentations'] = new Presentations();
endif;
diff --git a/plugins/jetpack/modules/shortcodes/quiz.php b/plugins/jetpack/modules/shortcodes/quiz.php
index 063f9a42..1abfdd54 100644
--- a/plugins/jetpack/modules/shortcodes/quiz.php
+++ b/plugins/jetpack/modules/shortcodes/quiz.php
@@ -165,24 +165,23 @@ class Quiz_Shortcode {
$default_atts = self::is_wpcom()
? array(
- 'trackid' => '',
+ '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 ( ! empty( self::$quiz_params['trackid'] ) ) {
+ $id .= ' data-trackid="' . esc_attr( self::$quiz_params['trackid'] ) . '"';
}
- if ( self::is_wpcom() && ! empty( self::$quiz_params[ 'a8ctraining' ] ) ) {
+ 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 ) . '"';
+ $id .= ' data-a8ctraining="' . esc_attr( self::$quiz_params['a8ctraining'] ) . '" data-username="' . esc_attr( self::$username ) . '"';
}
}
@@ -206,15 +205,24 @@ class Quiz_Shortcode {
// 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(),
- '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 ),
- ) );
+ $content = wp_kses(
+ $content,
+ array(
+ 'tt' => array(),
+ '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;
}
diff --git a/plugins/jetpack/modules/shortcodes/recipe.php b/plugins/jetpack/modules/shortcodes/recipe.php
index f6dd17fb..7846b154 100644
--- a/plugins/jetpack/modules/shortcodes/recipe.php
+++ b/plugins/jetpack/modules/shortcodes/recipe.php
@@ -37,7 +37,7 @@ class Jetpack_Recipes {
array(
'class' => array(),
'itemprop' => array(),
- 'datetime' => array(),
+ 'datetime' => array(),
)
);
}
@@ -47,9 +47,9 @@ class Jetpack_Recipes {
$allowedtags,
'div',
array(
- 'class' => array(),
+ 'class' => array(),
'itemscope' => array(),
- 'itemtype' => array(),
+ 'itemtype' => array(),
)
);
endif;
@@ -140,7 +140,7 @@ class Jetpack_Recipes {
'jetpack_recipes_vars',
array(
'pageTitle' => $title_var,
- 'loadCSS' => $print_css_var,
+ 'loadCSS' => $print_css_var,
)
);
}
@@ -166,7 +166,9 @@ class Jetpack_Recipes {
'sourceurl' => '', // string.
'image' => '', // string.
'description' => '', // string.
- ), $atts, 'recipe'
+ ),
+ $atts,
+ 'recipe'
);
return self::recipe_shortcode_html( $atts, $content );
@@ -305,9 +307,13 @@ class Jetpack_Recipes {
* @return string HTML for recipe notes shortcode.
*/
static function recipe_notes_shortcode( $atts, $content = '' ) {
- $atts = shortcode_atts( array(
- 'title' => '', // string.
- ), $atts, 'recipe-notes' );
+ $atts = shortcode_atts(
+ array(
+ 'title' => '', // string.
+ ),
+ $atts,
+ 'recipe-notes'
+ );
$html = '';
@@ -340,9 +346,13 @@ class Jetpack_Recipes {
* @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' );
+ $atts = shortcode_atts(
+ array(
+ 'title' => esc_html_x( 'Ingredients', 'recipe', 'jetpack' ), // string.
+ ),
+ $atts,
+ 'recipe-ingredients'
+ );
$html = '<div class="jetpack-recipe-ingredients">';
@@ -381,12 +391,12 @@ class Jetpack_Recipes {
$html = '';
switch ( $type ) {
- case 'directions' :
+ case 'directions':
$list_item_replacement = '<li class="jetpack-recipe-directions">${1}</li>';
$itemprop = ' itemprop="recipeInstructions"';
$listtype = 'ol';
break;
- case 'ingredients' :
+ case 'ingredients':
$list_item_replacement = '<li class="jetpack-recipe-ingredient" itemprop="recipeIngredient">${1}</li>';
$itemprop = '';
$listtype = 'ul';
@@ -401,11 +411,11 @@ class Jetpack_Recipes {
if (
strpos( $content, '&#8211;' ) !== false ||
strpos( $content, '&#8212;' ) !== false ||
- strpos( $content, '-' ) !== false ||
- strpos( $content, '*' ) !== false ||
- strpos( $content, '#' ) !== false ||
- strpos( $content, '–' ) !== false || // ndash.
- strpos( $content, '—' ) !== false || // mdash.
+ 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.
@@ -421,10 +431,10 @@ class Jetpack_Recipes {
if ( 0 !== count( $ul_matches[0] ) || 0 !== count( $ol_matches[0] ) ) {
if ( 0 !== count( $ol_matches[0] ) ) {
- $listtype = 'ol';
+ $listtype = 'ol';
$list_item_pattern = $ol_pattern;
} else {
- $listtype = 'ul';
+ $listtype = 'ul';
$list_item_pattern = $ul_pattern;
}
$html .= '<' . $listtype . $itemprop . '>';
@@ -433,7 +443,7 @@ class Jetpack_Recipes {
// 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 );
+ $html = preg_replace( $empty_p_pattern, '', $html );
} else {
$html .= do_shortcode( $content );
}
@@ -455,9 +465,13 @@ class Jetpack_Recipes {
* @return string HTML for recipe directions shortcode.
*/
static function recipe_directions_shortcode( $atts, $content = '' ) {
- $atts = shortcode_atts( array(
+ $atts = shortcode_atts(
+ array(
'title' => esc_html_x( 'Directions', 'recipe', 'jetpack' ), // string.
- ), $atts, 'recipe-directions' );
+ ),
+ $atts,
+ 'recipe-directions'
+ );
$html = '<div class="jetpack-recipe-directions">';
diff --git a/plugins/jetpack/modules/shortcodes/scribd.php b/plugins/jetpack/modules/shortcodes/scribd.php
index 2f745daf..1810c2fa 100644
--- a/plugins/jetpack/modules/shortcodes/scribd.php
+++ b/plugins/jetpack/modules/shortcodes/scribd.php
@@ -1,6 +1,7 @@
<?php
-/* Scribd Short Code
+/*
+ Scribd Short Code
Author: Nick Momrik
[scribd id=DOCUMENT_ID key=DOCUMENT_KEY mode=MODE]
@@ -12,11 +13,15 @@ MODE can be 'list', 'book', 'slide', 'slideshow', or 'tile'
*/
function scribd_shortcode_handler( $atts ) {
- $atts = shortcode_atts( array(
- 'id' => 0,
- 'key' => 0,
- 'mode' => '',
- ), $atts, 'scribd' );
+ $atts = shortcode_atts(
+ array(
+ 'id' => 0,
+ 'key' => 0,
+ 'mode' => '',
+ ),
+ $atts,
+ 'scribd'
+ );
$modes = array( 'list', 'book', 'slide', 'slideshow', 'tile' );
diff --git a/plugins/jetpack/modules/shortcodes/sitemap.php b/plugins/jetpack/modules/shortcodes/sitemap.php
index f9efe10e..963f90ce 100644
--- a/plugins/jetpack/modules/shortcodes/sitemap.php
+++ b/plugins/jetpack/modules/shortcodes/sitemap.php
@@ -15,11 +15,13 @@ add_shortcode( 'sitemap', 'jetpack_sitemap_shortcode' );
* @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,
- ) );
+ $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
index 72c94237..42258814 100644
--- a/plugins/jetpack/modules/shortcodes/slideshare.php
+++ b/plugins/jetpack/modules/shortcodes/slideshare.php
@@ -44,7 +44,8 @@ function slideshare_shortcode( $atts ) {
'sc' => '',
'pro' => '',
'style' => '',
- ), $arguments
+ ),
+ $arguments
);
// check that the Slideshare ID contains letters, numbers and query strings
diff --git a/plugins/jetpack/modules/shortcodes/slideshow.php b/plugins/jetpack/modules/shortcodes/slideshow.php
index e9046b6c..43428dc8 100644
--- a/plugins/jetpack/modules/shortcodes/slideshow.php
+++ b/plugins/jetpack/modules/shortcodes/slideshow.php
@@ -119,7 +119,9 @@ class Jetpack_Slideshow_Shortcode {
'exclude' => '',
'autostart' => true,
'size' => '',
- ), $attr, 'slideshow'
+ ),
+ $attr,
+ 'slideshow'
);
if ( 'rand' == strtolower( $attr['order'] ) ) {
@@ -178,11 +180,11 @@ class Jetpack_Slideshow_Shortcode {
$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,
+ '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',
);
}
@@ -228,7 +230,7 @@ class Jetpack_Slideshow_Shortcode {
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 );
+ $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'] );
}
@@ -296,15 +298,18 @@ class Jetpack_Slideshow_Shortcode {
* - 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',
- ) )
+ 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;
+ new Jetpack_Slideshow_Shortcode();
}
}
diff --git a/plugins/jetpack/modules/shortcodes/soundcloud.php b/plugins/jetpack/modules/shortcodes/soundcloud.php
index bb986e9f..71f281c3 100644
--- a/plugins/jetpack/modules/shortcodes/soundcloud.php
+++ b/plugins/jetpack/modules/shortcodes/soundcloud.php
@@ -27,7 +27,8 @@ 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
+/*
+ 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 );
*/
@@ -59,8 +60,9 @@ function soundcloud_shortcode( $atts, $content = null ) {
}
$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.
+ /*
+ 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'];
@@ -128,7 +130,8 @@ function soundcloud_shortcode( $atts, $content = null ) {
$options['params'] = array_merge(
array(
'url' => $options['url'],
- ), $options['params']
+ ),
+ $options['params']
);
// Return html embed code
@@ -232,12 +235,20 @@ function soundcloud_flash_widget( $options ) {
$height = isset( $options['height'] ) && $options['height'] !== 0 ? $options['height'] : ( soundcloud_url_has_tracklist( $options['url'] ) ? '255' : '81' );
return preg_replace(
- '/\s\s+/', '', sprintf(
+ '/\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
+ </object>',
+ $width,
+ $height,
+ $url,
+ $width,
+ $height,
+ $url
)
);
}
@@ -257,7 +268,8 @@ function jetpack_soundcloud_embed_reversal( $content ) {
return $content;
}
- /* Sample embed code:
+ /*
+ 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&amp;auto_play=false&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false&amp;visual=true"></iframe>
*/
diff --git a/plugins/jetpack/modules/shortcodes/ted.php b/plugins/jetpack/modules/shortcodes/ted.php
index d5386109..f66f77d5 100644
--- a/plugins/jetpack/modules/shortcodes/ted.php
+++ b/plugins/jetpack/modules/shortcodes/ted.php
@@ -45,9 +45,9 @@ function shortcode_ted( $atts ) {
$args = array();
if ( is_numeric( $atts['width'] ) ) {
$args['width'] = $atts['width'];
- } else if ( $embed_size_w = get_option( 'embed_size_w' ) ) {
+ } elseif ( $embed_size_w = get_option( 'embed_size_w' ) ) {
$args['width'] = $embed_size_w;
- } else if ( ! empty( $GLOBALS['content_width'] ) ) {
+ } elseif ( ! empty( $GLOBALS['content_width'] ) ) {
$args['width'] = (int) $GLOBALS['content_width'];
} else {
$args['width'] = 500;
diff --git a/plugins/jetpack/modules/shortcodes/tweet.php b/plugins/jetpack/modules/shortcodes/tweet.php
index 44bca5fd..95a3dcdd 100644
--- a/plugins/jetpack/modules/shortcodes/tweet.php
+++ b/plugins/jetpack/modules/shortcodes/tweet.php
@@ -31,7 +31,7 @@ class Jetpack_Tweet {
*
* @return string
*/
- static public function jetpack_tweet_shortcode( $atts ) {
+ public static function jetpack_tweet_shortcode( $atts ) {
$default_atts = array(
'tweet' => '',
'align' => 'none',
@@ -93,7 +93,7 @@ class Jetpack_Tweet {
*
* @return string
*/
- static public function jetpack_tweet_url_extra_args( $provider, $url, $args = array() ) {
+ public static function jetpack_tweet_url_extra_args( $provider, $url, $args = array() ) {
foreach ( self::$provider_args as $key => $value ) {
switch ( $key ) {
case 'align':
@@ -135,7 +135,7 @@ class Jetpack_Tweet {
*
* @since 4.5.0
*/
- static public function jetpack_tweet_shortcode_script() {
+ 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' );
diff --git a/plugins/jetpack/modules/shortcodes/twitchtv.php b/plugins/jetpack/modules/shortcodes/twitchtv.php
index 6b86f6eb..a5439d05 100644
--- a/plugins/jetpack/modules/shortcodes/twitchtv.php
+++ b/plugins/jetpack/modules/shortcodes/twitchtv.php
@@ -7,7 +7,7 @@
/**
* (Live URL) http://www.twitch.tv/paperbat
- *
+ *
* <iframe src="https://player.twitch.tv/?autoplay=false&#038;muted=false&#038;channel=paperbat" width="620" height="378" frameborder="0" scrolling="no" allowfullscreen></iframe>
*
* (Archive URL) http://www.twitch.tv/paperbat/v/323486192
@@ -26,8 +26,9 @@ function wpcom_twitchtv_shortcode( $atts ) {
'url' => '',
'autoplay' => 'false',
'muted' => 'false',
- 'time' => null
- ), $atts
+ 'time' => null,
+ ),
+ $atts
);
if ( empty( $attr['url'] ) ) {
@@ -39,11 +40,11 @@ function wpcom_twitchtv_shortcode( $atts ) {
$url_args = array(
'autoplay' => ( false !== $attr['autoplay'] && 'false' !== $attr['autoplay'] ) ? 'true' : 'false',
'muted' => ( false !== $attr['muted'] && 'false' !== $attr['muted'] ) ? 'true' : 'false',
- 'time' => $attr['time']
+ 'time' => $attr['time'],
);
- $width = intval( $attr['width'] );
- $height = intval( $attr['height'] );
+ $width = intval( $attr['width'] );
+ $height = intval( $attr['height'] );
$user_id = $match[1];
$video_id = 0;
diff --git a/plugins/jetpack/modules/shortcodes/unavailable.php b/plugins/jetpack/modules/shortcodes/unavailable.php
index 2ca01cd2..4d31c5b9 100644
--- a/plugins/jetpack/modules/shortcodes/unavailable.php
+++ b/plugins/jetpack/modules/shortcodes/unavailable.php
@@ -57,6 +57,8 @@ class Jetpack_Shortcode_Unavailable {
}
}
-new Jetpack_Shortcode_Unavailable( array(
- 'blip.tv' => __( 'The Blip.tv service has been shut down since August 20th, 2015.', 'jetpack' ),
-) );
+new Jetpack_Shortcode_Unavailable(
+ array(
+ 'blip.tv' => __( 'The Blip.tv service has been shut down since August 20th, 2015.', 'jetpack' ),
+ )
+);
diff --git a/plugins/jetpack/modules/shortcodes/untappd-menu.php b/plugins/jetpack/modules/shortcodes/untappd-menu.php
index 834c2c77..f8f62f0b 100644
--- a/plugins/jetpack/modules/shortcodes/untappd-menu.php
+++ b/plugins/jetpack/modules/shortcodes/untappd-menu.php
@@ -1,6 +1,7 @@
<?php
/**
* Untappd Shortcodes
+ *
* @author kraftbj
*
* [untappd-menu location="123" theme="123"]
@@ -21,22 +22,25 @@ class Jetpack_Untappd {
/**
* [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') ){
+ 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' );
+ $atts = shortcode_atts(
+ array(
+ 'location' => '',
+ 'theme' => '',
+ ),
+ $atts,
+ 'untappd-menu'
+ );
// We're going to clean the user input.
$atts = array_map( 'absint', $atts );
@@ -53,7 +57,7 @@ class Jetpack_Untappd {
$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 .= 'PreloadEmbedMenu( "menu-container-untappd-' . $untappd_menu . '",' . $atts['location'] . ',' . $atts['theme'] . ' )});' . PHP_EOL;
$html .= '</script>';
$untappd_menu++;
diff --git a/plugins/jetpack/modules/shortcodes/upcoming-events.php b/plugins/jetpack/modules/shortcodes/upcoming-events.php
index 82b07725..02f6dda1 100644
--- a/plugins/jetpack/modules/shortcodes/upcoming-events.php
+++ b/plugins/jetpack/modules/shortcodes/upcoming-events.php
@@ -11,7 +11,14 @@ class Upcoming_Events_Shortcode {
public static function shortcode( $atts = array() ) {
jetpack_require_lib( 'icalendar-reader' );
- $atts = shortcode_atts( array( 'url' => '', 'number' => 0 ), $atts, 'upcomingevents' );
+ $atts = shortcode_atts(
+ array(
+ 'url' => '',
+ 'number' => 0,
+ ),
+ $atts,
+ 'upcomingevents'
+ );
$args = array(
'context' => 'shortcode',
'number' => absint( $atts['number'] ),
diff --git a/plugins/jetpack/modules/shortcodes/videopress.php b/plugins/jetpack/modules/shortcodes/videopress.php
index ebe9e894..a4bfd167 100644
--- a/plugins/jetpack/modules/shortcodes/videopress.php
+++ b/plugins/jetpack/modules/shortcodes/videopress.php
@@ -8,9 +8,11 @@
if ( ! Jetpack::is_module_active( 'videopress' ) ) {
- Jetpack::dns_prefetch( array(
- '//v0.wordpress.com',
- ) );
+ 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
index 4dc46b54..91492d9c 100644
--- a/plugins/jetpack/modules/shortcodes/vimeo.php
+++ b/plugins/jetpack/modules/shortcodes/vimeo.php
@@ -46,7 +46,8 @@ function vimeo_shortcode( $atts ) {
'height' => 0,
'autoplay' => 0,
'loop' => 0,
- ), $atts
+ ),
+ $atts
)
);
@@ -251,7 +252,7 @@ function vimeo_link( $content ) {
* [vimeo 12345]
* [vimeo http://vimeo.com/12345]
*/
- $shortcode = "(?:\[vimeo\s+[^0-9]*)([0-9]+)(?:\])";
+ $shortcode = '(?:\[vimeo\s+[^0-9]*)([0-9]+)(?:\])';
/**
* http://vimeo.com/12345
@@ -269,10 +270,10 @@ function vimeo_link( $content ) {
$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'
+ sprintf( '#%s|%s#i', $shortcode, $plain_url ),
+ 'vimeo_link_callback',
+ $content,
+ 'vimeo'
);
}
@@ -285,11 +286,11 @@ function vimeo_link( $content ) {
* @return string The Vimeo HTML embed code.
*/
function vimeo_link_callback( $matches ) {
- $id = isset( $matches[ 2 ] ) ? $matches[ 2 ] : $matches[ 1 ];
+ $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 ];
+ return $matches[0];
}
/** This filter is documented in modules/shortcodes/youtube.php */
diff --git a/plugins/jetpack/modules/shortcodes/vine.php b/plugins/jetpack/modules/shortcodes/vine.php
index 0c233c0f..444b9999 100644
--- a/plugins/jetpack/modules/shortcodes/vine.php
+++ b/plugins/jetpack/modules/shortcodes/vine.php
@@ -21,11 +21,12 @@ function vine_embed_video( $matches, $attr, $url, $rawattr ) {
static $vine_flag_embedded_script;
$max_height = 300;
- $type = 'simple';
+ $type = 'simple';
// Only allow 'postcard' or 'simple' types
- if ( isset( $rawattr['type'] ) && $rawattr['type'] === 'postcard' )
+ if ( isset( $rawattr['type'] ) && $rawattr['type'] === 'postcard' ) {
$type = 'postcard';
+ }
$vine_size = Jetpack::get_content_width();
@@ -39,11 +40,11 @@ function vine_embed_video( $matches, $attr, $url, $rawattr ) {
$vine_size = $max_height;
}
- $url = 'https://vine.co/v/' . $matches[1] . '/embed/' . $type;
+ $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_html .= '<script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>';
$vine_flag_embedded_script = true;
}
@@ -54,11 +55,13 @@ wp_embed_register_handler( 'jetpack_vine', '#https?://vine.co/v/([a-z0-9]+).*#i'
function vine_shortcode( $atts ) {
global $wp_embed;
- if ( empty( $atts['url'] ) )
+ if ( empty( $atts['url'] ) ) {
return '';
+ }
- if ( ! preg_match( '#https?://vine.co/v/([a-z0-9]+).*#i', $atts['url'] ) )
+ if ( ! preg_match( '#https?://vine.co/v/([a-z0-9]+).*#i', $atts['url'] ) ) {
return '';
+ }
return $wp_embed->shortcode( $atts, $atts['url'] );
}
diff --git a/plugins/jetpack/modules/shortcodes/vr.php b/plugins/jetpack/modules/shortcodes/vr.php
index 12835b8a..0df06a4d 100644
--- a/plugins/jetpack/modules/shortcodes/vr.php
+++ b/plugins/jetpack/modules/shortcodes/vr.php
@@ -6,6 +6,7 @@
/**
* 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
@@ -31,7 +32,7 @@ function jetpack_vr_viewer_get_viewer_url_params( $params ) {
if ( isset( $params['url'] ) ) {
return array_merge( $url_params, array( 'url' => $params['url'] ) );
- } else if ( isset( $params['guid'] ) ) {
+ } elseif ( isset( $params['guid'] ) ) {
return array_merge( $url_params, array( 'guid' => $params['guid'] ) );
}
@@ -40,6 +41,7 @@ function jetpack_vr_viewer_get_viewer_url_params( $params ) {
/**
* Get padding for IFRAME depending on view type
+ *
* @param view - string cinema, 360 - default cinema
* @return css padding
*/
@@ -55,6 +57,7 @@ function jetpack_vr_viewer_iframe_padding( $view ) {
* 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
@@ -70,11 +73,11 @@ function jetpack_vr_viewer_get_html( $url_params ) {
// set some defaults
$maxwidth = ( isset( $content_width ) ) ? $content_width : 720;
- $view = ( isset( $url_params['view'] ) ) ? $url_params['view'] : 'cinema';
+ $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 .= '<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>';
@@ -97,20 +100,23 @@ function jetpack_vr_viewer_get_html( $url_params ) {
* @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 );
+ $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];
- } else if ( $params['src'] ) {
+ } elseif ( $params['src'] ) {
$params['url'] = $params['src'];
}
@@ -128,29 +134,3 @@ function jetpack_vr_viewer_shortcode( $atts ) {
}
add_shortcode( 'vr', 'jetpack_vr_viewer_shortcode' );
-
-// Gutenberg!
-add_action( 'admin_init', 'jetpack_register_block_type_vr' );
-function jetpack_register_block_type_vr() {
- if ( ! function_exists( 'register_block_type' ) ) {
- return;
- }
-
- wp_register_script(
- 'jetpack_vr_viewer_shortcode_editor_script',
- Jetpack::get_file_url_for_environment( '_inc/build/shortcodes/js/blocks/vr-block.min.js', 'modules/shortcodes/js/blocks/vr-block.js' ),
- array( 'wp-blocks', 'wp-element', 'wp-i18n' )
- );
-
- wp_register_style(
- 'jetpack_vr_viewer_shortcode_editor_style',
- plugins_url( 'modules/shortcodes/css/blocks/vr-block.css', JETPACK__PLUGIN_FILE ),
- array( 'wp-edit-blocks' )
- );
-
- register_block_type( 'jetpack/vr', array(
- 'editor_script' => 'jetpack_vr_viewer_shortcode_editor_script',
- 'editor_style' => 'jetpack_vr_viewer_shortcode_editor_style',
- 'render_callback' => 'jetpack_vr_viewer_shortcode',
- ) );
-} \ No newline at end of file
diff --git a/plugins/jetpack/modules/shortcodes/wordads.php b/plugins/jetpack/modules/shortcodes/wordads.php
index 7306eb77..86d6b70c 100644
--- a/plugins/jetpack/modules/shortcodes/wordads.php
+++ b/plugins/jetpack/modules/shortcodes/wordads.php
@@ -2,7 +2,6 @@
/**
* Embed WordAds 'ad' in post
- *
*/
class Jetpack_WordAds_Shortcode {
@@ -34,7 +33,7 @@ class Jetpack_WordAds_Shortcode {
* @return string HTML for WordAds shortcode.
*/
static function wordads_shortcode( $atts, $content = '' ) {
- $atts = shortcode_atts( array(), $atts, 'wordads');
+ $atts = shortcode_atts( array(), $atts, 'wordads' );
return self::wordads_shortcode_html( $atts, $content );
}
diff --git a/plugins/jetpack/modules/shortcodes/wufoo.php b/plugins/jetpack/modules/shortcodes/wufoo.php
index 6638f70f..fbe6fe70 100644
--- a/plugins/jetpack/modules/shortcodes/wufoo.php
+++ b/plugins/jetpack/modules/shortcodes/wufoo.php
@@ -1,11 +1,11 @@
<?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" ssl="true"]
+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/
-http://wufoo.com/docs/code-manager/wordpress-shortcode-plugin/
+https://wufoo.com/docs/code-manager/wordpress-shortcode-plugin/
*/
@@ -17,8 +17,8 @@ function wufoo_shortcode( $atts ) {
'autoresize' => true,
'height' => '500',
'header' => 'show',
- 'ssl' => '',
- ), $atts
+ ),
+ $atts
);
// Check username and formhash to ensure they only have alphanumeric characters or underscores, and aren't empty.
@@ -28,7 +28,7 @@ function wufoo_shortcode( $atts ) {
* 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 %sWufoo Code Manager%s, you should be golden.', 'jetpack' ), '<a href="http://wufoo.com/docs/code-manager/" target="_blank">', '</a>' );
+ $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;">
@@ -38,45 +38,52 @@ function wufoo_shortcode( $atts ) {
}
/**
+ * 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 = '<script type="text/javascript">var host = (("https:" == document.location.protocol) ? "https://secure." : "http://");document.write(unescape("%3Cscript src=\'" + host + "wufoo.com/scripts/embed/form.js\' type=\'text/javascript\'%3E%3C/script%3E"));</script>';
- $js_embed .= "<script type='text/javascript'>";
- $js_embed .= 'var wufoo_' . $attr['formhash'] . ' = new WufooForm();';
- $js_embed .= 'wufoo_' . $attr['formhash'] . ' .initialize({';
+ $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'] ) . "' ";
-
- /**
- * Only output SSL value if passes as param.
- * Lower tier plans don't show this param (don't offer SSL).
- */
- $js_embed .= ( $attr['ssl'] ) ? ",'ssl':" . (bool) $attr['ssl'] : '';
- $js_embed .= '});';
+ $js_embed .= "'header':'" . esc_js( $attr['header'] ) . "',";
+ $js_embed .= "'ssl':true,'async':true});";
$js_embed .= 'wufoo_' . $attr['formhash'] . '.display();';
- $js_embed .= '</script>';
+ $js_embed .= '}catch(e){}})();';
/**
* iframe embed, loaded inside <noscript> tags.
*/
- $iframe_embed = '<iframe ';
+ $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 <noscript> $iframe_embed </noscript>";
+ 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
index 3820319d..79af6f94 100644
--- a/plugins/jetpack/modules/shortcodes/youtube.php
+++ b/plugins/jetpack/modules/shortcodes/youtube.php
@@ -16,9 +16,9 @@
* @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>
+// <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>
+// <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:
@@ -26,25 +26,25 @@
// 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 width="\d+" height="\d+"><param name="movie" value="https?://www\.youtube\.com/v/([^"]+)"></param>(?:<param name="\w+" value="[^"]*"></param>)*<embed src="https?://www\.youtube\.com/v/(.+)" type="application/x-shockwave-flash"(?: \w+="[^"]*")* width="\d+" height="\d+"></embed></object>!i';
- $regexp_ent = htmlspecialchars( $regexp, ENT_NOQUOTES );
- $old_regexp = '!<embed(?:\s+\w+="[^"]*")*\s+src="https?(?:\:|&#0*58;)//www\.youtube\.com/v/([^"]+)"(?:\s+\w+="[^"]*")*\s*(?:/>|>\s*</embed>)!';
+ // older codes
+ $regexp = '!<object width="\d+" height="\d+"><param name="movie" value="https?://www\.youtube\.com/v/([^"]+)"></param>(?:<param name="\w+" value="[^"]*"></param>)*<embed src="https?://www\.youtube\.com/v/(.+)" type="application/x-shockwave-flash"(?: \w+="[^"]*")* width="\d+" height="\d+"></embed></object>!i';
+ $regexp_ent = htmlspecialchars( $regexp, ENT_NOQUOTES );
+ $old_regexp = '!<embed(?:\s+\w+="[^"]*")*\s+src="https?(?:\:|&#0*58;)//www\.youtube\.com/v/([^"]+)"(?:\s+\w+="[^"]*")*\s*(?:/>|>\s*</embed>)!';
$old_regexp_ent = str_replace( '&amp;#0*58;', '&amp;#0*58;|&#0*58;', htmlspecialchars( $old_regexp, ENT_NOQUOTES ) );
- //new code
- $ifr_regexp = '!<iframe((?:\s+\w+="[^"]*")*?)\s+src="(https?:)?//(?:www\.)*youtube.com/embed/([^"]+)".*?</iframe>!i';
+ // new code
+ $ifr_regexp = '!<iframe((?:\s+\w+="[^"]*")*?)\s+src="(https?:)?//(?:www\.)*youtube.com/embed/([^"]+)".*?</iframe>!i';
$ifr_regexp_ent = str_replace( '&amp;#0*58;', '&amp;#0*58;|&#0*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 ) )
+ if ( ! preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) {
continue;
+ }
foreach ( $matches as $match ) {
// Hack, but '?' should only ever appear once, and
@@ -52,29 +52,31 @@ function youtube_embed_to_short_code( $content ) {
// 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&amp;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&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>
+ // <object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/aP9AaD4tgBY?fs=1&amp;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&amp;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' ) ) ) {
+ if ( in_array( $reg, array( 'ifr_regexp', 'ifr_regexp_ent' ) ) ) {
$params = $match[1];
- if ( 'ifr_regexp_ent' == $reg )
+ if ( 'ifr_regexp_ent' == $reg ) {
$params = html_entity_decode( $params );
+ }
$params = wp_kses_hair( $params, array( 'http' ) );
- $width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0;
+ $width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0;
$height = isset( $params['height'] ) ? (int) $params['height']['value'] : 0;
- $wh = '';
+ $wh = '';
- if ( $width && $height )
+ 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] ) );
+ $url = esc_url_raw( 'https://www.youtube.com/watch?v=' . html_entity_decode( $match[1] ) );
}
$content = str_replace( $match[0], "[youtube $url]", $content );
@@ -123,20 +125,20 @@ function youtube_link_callback( $matches ) {
* @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=', '&amp;', '&#038;', 'playlist' ), array( 'youtu.be/?v=', '/?v=', '?v=', '&', '&', 'videoseries' ), $url );
+ function youtube_sanitize_url( $url ) {
+ $url = trim( $url, ' "' );
+ $url = trim( $url );
+ $url = str_replace( array( 'youtu.be/', '/v/', '#!v=', '&amp;', '&#038;', '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, "?" );
+ // 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 ) );
- }
+ if ( false !== $query_string_start ) {
+ $url = substr( $url, 0, $query_string_start + 1 ) . str_replace( '?', '&', substr( $url, $query_string_start + 1 ) );
+ }
- return $url;
-}
+ return $url;
+ }
endif;
/*
@@ -154,14 +156,16 @@ endif;
* Converts a YouTube URL into an embedded YouTube video.
*/
function youtube_id( $url ) {
- if ( ! $id = jetpack_get_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'] ) )
+ if ( ! isset( $url['query'] ) ) {
return false;
+ }
if ( isset( $url['fragment'] ) ) {
wp_parse_str( $url['fragment'], $fargs );
@@ -183,7 +187,7 @@ function youtube_id( $url ) {
$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');
+ $default_width = get_option( 'embed_size_w' );
}
// If we don't know those 2 values use a hardcoded width.h
@@ -199,11 +203,11 @@ function youtube_id( $url ) {
$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 ) + 30;
+ $h = ceil( ( $w / 16 ) * 9 );
}
} elseif ( $input_w > 0 ) {
$w = $input_w;
- $h = ceil( ( $w / 16 ) * 9 ) + 30;
+ $h = ceil( ( $w / 16 ) * 9 );
} else {
if ( isset( $qargs['fmt'] ) && intval( $qargs['fmt'] ) ) {
$w = ( ! empty( $content_width ) ? min( $content_width, 480 ) : 480 );
@@ -235,12 +239,12 @@ function youtube_id( $url ) {
*/
$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;
+ $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'] : '';
+ $fmt = ( isset( $qargs['fmt'] ) && intval( $qargs['fmt'] ) ) ? '&fmt=' . (int) $qargs['fmt'] : '';
if ( ! isset( $qargs['autohide'] ) || ( $qargs['autohide'] < 0 || 2 < $qargs['autohide'] ) ) {
$autohide = '&autohide=2';
@@ -251,37 +255,37 @@ function youtube_id( $url ) {
$start = 0;
if ( isset( $qargs['start'] ) ) {
$start = intval( $qargs['start'] );
- } else if ( isset( $qargs['t'] ) ) {
+ } 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;
+ 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'] : '';
+ $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'] : '';
+ $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'] ) : '';
+ $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';
+ $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'] : '';
+ $theme = ( isset( $qargs['theme'] ) && in_array( strtolower( $qargs['theme'] ), array( 'dark', 'light' ) ) ) ? '&theme=' . $qargs['theme'] : '';
$autoplay = '';
/**
@@ -293,13 +297,14 @@ function youtube_id( $url ) {
*
* @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 ( 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( set_url_scheme( "http://www.youtube.com/embed/videoseries?list=$id&hl=en_US" ) ) . "' allowfullscreen='true' style='border:0;'></iframe>";
+ $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( set_url_scheme( "http://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>";
+ $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
@@ -339,7 +344,7 @@ function youtube_id( $url ) {
}
function youtube_shortcode( $atts ) {
- return youtube_id( ( isset ( $atts[0] ) ) ? ltrim( $atts[0] , '=' ) : shortcode_new_to_old_params( $atts ) );
+ return youtube_id( ( isset( $atts[0] ) ) ? ltrim( $atts[0], '=' ) : shortcode_new_to_old_params( $atts ) );
}
add_shortcode( 'youtube', 'youtube_shortcode' );