summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/shortcodes')
-rw-r--r--plugins/jetpack/modules/shortcodes/archiveorg-book.php6
-rw-r--r--plugins/jetpack/modules/shortcodes/archiveorg.php14
-rw-r--r--plugins/jetpack/modules/shortcodes/brightcove.php27
-rw-r--r--plugins/jetpack/modules/shortcodes/crowdsignal.php53
-rw-r--r--plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.min.css2
-rw-r--r--plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css2
-rw-r--r--plugins/jetpack/modules/shortcodes/email-subscribe.php6
-rw-r--r--plugins/jetpack/modules/shortcodes/getty.php44
-rw-r--r--plugins/jetpack/modules/shortcodes/googleapps.php62
-rw-r--r--plugins/jetpack/modules/shortcodes/googleplus.php11
-rw-r--r--plugins/jetpack/modules/shortcodes/gravatar.php14
-rw-r--r--plugins/jetpack/modules/shortcodes/hulu.php68
-rw-r--r--plugins/jetpack/modules/shortcodes/instagram.php88
-rw-r--r--plugins/jetpack/modules/shortcodes/kickstarter.php8
-rw-r--r--plugins/jetpack/modules/shortcodes/lytro.php296
-rw-r--r--plugins/jetpack/modules/shortcodes/mailchimp.php59
-rw-r--r--plugins/jetpack/modules/shortcodes/quiz.php41
-rw-r--r--plugins/jetpack/modules/shortcodes/sitemap.php2
-rw-r--r--plugins/jetpack/modules/shortcodes/slideshare.php7
-rw-r--r--plugins/jetpack/modules/shortcodes/tweet.php167
-rw-r--r--plugins/jetpack/modules/shortcodes/unavailable.php34
-rw-r--r--plugins/jetpack/modules/shortcodes/ustream.php88
-rw-r--r--plugins/jetpack/modules/shortcodes/wordads.php6
-rw-r--r--plugins/jetpack/modules/shortcodes/youtube.php6
24 files changed, 562 insertions, 549 deletions
diff --git a/plugins/jetpack/modules/shortcodes/archiveorg-book.php b/plugins/jetpack/modules/shortcodes/archiveorg-book.php
index 8eb73173..88ac328c 100644
--- a/plugins/jetpack/modules/shortcodes/archiveorg-book.php
+++ b/plugins/jetpack/modules/shortcodes/archiveorg-book.php
@@ -8,6 +8,8 @@
* [archiveorg id=goodytwoshoes00newyiala width=480 height=430]
* <iframe src='https://www.archive.org/stream/goodytwoshoes00newyiala?ui=embed#mode/1up' width='480px' height='430px' frameborder='0' ></iframe>
+ *
+ * @package Jetpack
*/
/**
@@ -15,7 +17,7 @@
*
* @since 4.5.0
*
- * @param $atts
+ * @param array $atts Shortcode attributes.
*
* @return int|string
*/
@@ -87,7 +89,7 @@ add_shortcode( 'archiveorg-book', 'jetpack_archiveorg_book_shortcode' );
*
* @since 4.5.0
*
- * @param string $content
+ * @param string $content Post content.
*
* @return mixed
*/
diff --git a/plugins/jetpack/modules/shortcodes/archiveorg.php b/plugins/jetpack/modules/shortcodes/archiveorg.php
index c8e95567..4a335b32 100644
--- a/plugins/jetpack/modules/shortcodes/archiveorg.php
+++ b/plugins/jetpack/modules/shortcodes/archiveorg.php
@@ -8,6 +8,8 @@
* [archiveorg id=Experime1940 width=640 height=480 autoplay=1]
* <iframe src="http://archive.org/embed/Experime1940&autoplay=1&poster=http://archive.org/images/map.png" width="640" height="480" frameborder="0" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen></iframe>
+ *
+ * @package Jetpack
*/
/**
@@ -15,7 +17,7 @@
*
* @since 4.5.0
*
- * @param array $atts
+ * @param array $atts Shortcode attributes.
*
* @return int|string
*/
@@ -102,7 +104,7 @@ add_shortcode( 'archiveorg', 'jetpack_archiveorg_shortcode' );
*
* @since 4.5.0
*
- * @param string $content
+ * @param string $content Post content.
*
* @return mixed
*/
@@ -121,9 +123,11 @@ function jetpack_archiveorg_embed_to_shortcode( $content ) {
$url = explode( '&amp;', $match[1] );
$id = 'id=' . $url[0];
- $autoplay = '';
- $poster = '';
- for ( $ii = 1; $ii < count( $url ); $ii++ ) {
+ $autoplay = '';
+ $poster = '';
+ $url_count = count( $url );
+
+ for ( $ii = 1; $ii < $url_count; $ii++ ) {
if ( 'autoplay=1' === $url[ $ii ] ) {
$autoplay = ' autoplay="1"';
}
diff --git a/plugins/jetpack/modules/shortcodes/brightcove.php b/plugins/jetpack/modules/shortcodes/brightcove.php
index 0b9b3c34..5eca5293 100644
--- a/plugins/jetpack/modules/shortcodes/brightcove.php
+++ b/plugins/jetpack/modules/shortcodes/brightcove.php
@@ -1,4 +1,4 @@
-<?php
+<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Brightcove shortcode.
@@ -18,7 +18,12 @@
* to the legacy code.
*/
class Jetpack_Brightcove_Shortcode {
- static $shortcode = 'brightcove';
+ /**
+ * Shortcode name.
+ *
+ * @var string
+ */
+ public static $shortcode = 'brightcove';
/**
* Parse shortcode arguments and render its output.
@@ -55,10 +60,20 @@ class Jetpack_Brightcove_Shortcode {
* @return array
*/
public static function normalize_attributes( $atts ) {
- if ( is_array( $atts ) && 1 == count( $atts ) ) { // this is the case we need to take care of.
+ 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 );
+
+ /**
+ * Filter the Brightcove shortcode parameters.
+ *
+ * @module shortcodes
+ *
+ * @since 4.5.0
+ *
+ * @param string $params String of shortcode parameters.
+ */
+ $params = apply_filters( 'brightcove_dimensions', $params );
parse_str( $params, $parsed_atts );
return $parsed_atts;
@@ -213,7 +228,9 @@ class Jetpack_Brightcove_Shortcode {
$flashvars = trim( add_query_arg( array_map( 'urlencode', $fv ), '' ), '?' );
- $width = $height = null;
+ $width = null;
+ $height = null;
+
if ( ! empty( $attr['w'] ) && ! empty( $attr['h'] ) ) {
$w = abs( (int) $attr['w'] );
$h = abs( (int) $attr['h'] );
diff --git a/plugins/jetpack/modules/shortcodes/crowdsignal.php b/plugins/jetpack/modules/shortcodes/crowdsignal.php
index 4359040c..e2078a68 100644
--- a/plugins/jetpack/modules/shortcodes/crowdsignal.php
+++ b/plugins/jetpack/modules/shortcodes/crowdsignal.php
@@ -124,6 +124,32 @@ CONTAINER;
global $post;
global $content_width;
+ /**
+ * Variables extracted from $atts.
+ *
+ * @var string $survey
+ * @var string $link_text
+ * @var string $poll
+ * @var string $rating
+ * @var string $unique_id
+ * @var string $item_id
+ * @var string $title
+ * @var string $permalink
+ * @var int $cb
+ * @var string $type
+ * @var string $body
+ * @var string $button
+ * @var string $text_color
+ * @var string $back_color
+ * @var string $align
+ * @var string $style
+ * @var int $width
+ * @var int $height
+ * @var int $delay
+ * @var string $visit
+ * @var string $domain
+ * @var string $id
+ */
extract( shortcode_atts( array(
'survey' => null,
'link_text' => 'Take Our Survey',
@@ -209,7 +235,9 @@ CONTAINER;
$item_id = esc_js( $item_id );
- if ( $inline ) {
+ if ( Jetpack_AMP_Support::is_amp_request() ) {
+ return sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $permalink ), esc_html( trim( $title ) ) );
+ } elseif ( $inline ) {
return <<<SCRIPT
<div class="cs-rating pd-rating" id="pd_rating_holder_{$rating}{$item_id}"></div>
<script type="text/javascript" charset="UTF-8"><!--//--><![CDATA[//><!--
@@ -242,12 +270,16 @@ CONTAINER;
}
} elseif ( intval( $poll ) > 0 ) { //poll embed
+ if ( empty( $title ) ) {
+ $title = __( 'Take Our Poll', 'jetpack' );
+ }
+
$poll = intval( $poll );
$poll_url = sprintf( 'https://poll.fm/%d', $poll );
$poll_js = sprintf( 'https://secure.polldaddy.com/p/%d.js', $poll );
- $poll_link = sprintf( '<a href="%s" target="_blank">Take Our Poll</a>', $poll_url );
+ $poll_link = sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $poll_url ), esc_html( $title ) );
- if ( $no_script ) {
+ if ( $no_script || Jetpack_AMP_Support::is_amp_request() ) {
return $poll_link;
} else {
if ( $type == 'slider' && !$inline ) {
@@ -359,7 +391,7 @@ CONTAINER;
$settings = array();
// Do we want a full embed code or a link?
- if ( $no_script || $inline || $infinite_scroll ) {
+ if ( $no_script || $inline || $infinite_scroll || Jetpack_AMP_Support::is_amp_request() ) {
return $survey_link;
}
@@ -554,6 +586,10 @@ new CrowdsignalShortcode();
if ( ! function_exists( 'crowdsignal_link' ) ) {
// http://polldaddy.com/poll/1562975/?view=results&msg=voted
function crowdsignal_link( $content ) {
+ if ( Jetpack_AMP_Support::is_amp_request() ) {
+ return $content;
+ }
+
return preg_replace( '!(?:\n|\A)https?://(polldaddy\.com/poll|poll\.fm)/([0-9]+?)(/.*)?(?:\n|\Z)!i', "\n<script type='text/javascript' charset='utf-8' src='//static.polldaddy.com/p/$2.js'></script><noscript> <a href='https://poll.fm/$2'>View Poll</a></noscript>\n", $content );
}
@@ -562,8 +598,13 @@ if ( ! function_exists( 'crowdsignal_link' ) ) {
add_filter( 'the_content_rss', 'crowdsignal_link', 1 );
}
-wp_oembed_add_provider( '#https?://(.+\.)?polldaddy\.com/.*#i', 'https://api.crowdsignal.com/oembed', true );
+ /**
+ * Note that Core has the oembed of '#https?://survey\.fm/.*#i' as of 5.1.
+ * This should be removed after Core has the current regex is in our minimum version.
+ *
+ * @see https://core.trac.wordpress.org/ticket/46467
+ * @todo Confirm patch landed and remove once 5.2 is the minimum version.
+ */
wp_oembed_add_provider( '#https?://.+\.survey\.fm/.*#i', 'https://api.crowdsignal.com/oembed', true );
-wp_oembed_add_provider( '#https?://poll\.fm/.*#i', 'https://api.crowdsignal.com/oembed', true );
}
diff --git a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.min.css b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.min.css
index 6341bcd6..4342c699 100644
--- a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.min.css
+++ b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode-rtl.min.css
@@ -1 +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
+.slideshow-window{background-color:#222;border:20px solid #222;border-radius:10px;height:0;margin-bottom:20px;overflow:hidden;padding-top:30px!important;padding-bottom:56.25%!important;position:relative;z-index:1}.slideshow-window.slideshow-white{background-color:#fff;border-color:#fff}.slideshow-window,.slideshow-window *{box-sizing:content-box}.slideshow-loading{height:100%;text-align:center;margin:auto}body div.slideshow-window * img{background-color:transparent!important;background-image:none!important;border-width:0!important;display:block;margin:0 auto;max-width:100%;max-height:100%;padding:0!important;position:relative;transform:translateY(-50%);top:50%}.slideshow-loading img{vertical-align:middle}.slideshow-slide{display:none;height:100%!important;right:0;margin:auto;position:absolute;text-align:center;top:0;width:100%!important}.slideshow-slide img{vertical-align:middle}.slideshow-line-height-hack{overflow:hidden;width:0;font-size:0}.slideshow-slide-caption{font-size:13px;font-family:"Helvetica Neue",sans-serif;color:#f7f7f7;text-shadow:#222 -1px 1px 2px;line-height:25px;height:25px;position:absolute;bottom:5px;right:0;z-index:100;width:100%;text-align:center}.slideshow-controls{z-index:1000;position:absolute;bottom:30px;margin:auto;text-align:center;width:100%;opacity:.5;direction:ltr;transition:.3s opacity ease-out}.slideshow-window:hover .slideshow-controls{opacity:1}body div div.slideshow-controls a,body div div.slideshow-controls a:hover{border:2px solid rgba(255,255,255,.1)!important;background-color:#000!important;background-color:rgba(0,0,0,.6)!important;background-image:url(../img/slideshow-controls.png)!important;background-repeat:no-repeat;background-size:142px 16px!important;background-position:-34px 8px!important;color:#222!important;margin:0 5px!important;padding:0!important;display:inline-block!important;zoom:1;height:32px!important;width:32px!important;line-height:32px!important;text-align:center!important;border-radius:10em!important;transition:.3s border-color ease-out}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body div div.slideshow-controls a,body div div.slideshow-controls a:hover{background-image:url(../img/slideshow-controls-2x.png)!important}}body div div.slideshow-controls a:hover{border-color:rgba(255,255,255,1)!important}body div div.slideshow-controls a:first-child{background-position:-76px 8px!important}body div div.slideshow-controls a:last-child{background-position:-117px 8px!important}body div div.slideshow-controls a:nth-child(2){background-position:-34px 8px!important}body div div.slideshow-controls a.running{background-position:-34px 8px!important}body div div.slideshow-controls a.paused{background-position:9px 8px!important}.slideshow-controls a img{border:50px dotted #f0f} \ No newline at end of file
diff --git a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css
index 6c445e46..9642a647 100644
--- a/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css
+++ b/plugins/jetpack/modules/shortcodes/css/slideshow-shortcode.min.css
@@ -1,2 +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
+.slideshow-window{background-color:#222;border:20px solid #222;border-radius:10px;height:0;margin-bottom:20px;overflow:hidden;padding-top:30px!important;padding-bottom:56.25%!important;position:relative;z-index:1}.slideshow-window.slideshow-white{background-color:#fff;border-color:#fff}.slideshow-window,.slideshow-window *{box-sizing:content-box}.slideshow-loading{height:100%;text-align:center;margin:auto}body div.slideshow-window * img{background-color:transparent!important;background-image:none!important;border-width:0!important;display:block;margin:0 auto;max-width:100%;max-height:100%;padding:0!important;position:relative;transform:translateY(-50%);top:50%}.slideshow-loading img{vertical-align:middle}.slideshow-slide{display:none;height:100%!important;left:0;margin:auto;position:absolute;text-align:center;top:0;width:100%!important}.slideshow-slide img{vertical-align:middle}.slideshow-line-height-hack{overflow:hidden;width:0;font-size:0}.slideshow-slide-caption{font-size:13px;font-family:"Helvetica Neue",sans-serif;color:#f7f7f7;text-shadow:#222 1px 1px 2px;line-height:25px;height:25px;position:absolute;bottom:5px;left:0;z-index:100;width:100%;text-align:center}.slideshow-controls{z-index:1000;position:absolute;bottom:30px;margin:auto;text-align:center;width:100%;opacity:.5;direction:ltr;transition:.3s opacity ease-out}.slideshow-window:hover .slideshow-controls{opacity:1}body div div.slideshow-controls a,body div div.slideshow-controls a:hover{border:2px solid rgba(255,255,255,.1)!important;background-color:#000!important;background-color:rgba(0,0,0,.6)!important;background-image:url(../img/slideshow-controls.png)!important;background-repeat:no-repeat;background-size:142px 16px!important;background-position:-34px 8px!important;color:#222!important;margin:0 5px!important;padding:0!important;display:inline-block!important;zoom:1;height:32px!important;width:32px!important;line-height:32px!important;text-align:center!important;border-radius:10em!important;transition:.3s border-color ease-out}@media only screen and (-webkit-min-device-pixel-ratio:1.5){body div div.slideshow-controls a,body div div.slideshow-controls a:hover{background-image:url(../img/slideshow-controls-2x.png)!important}}body div div.slideshow-controls a:hover{border-color:rgba(255,255,255,1)!important}body div div.slideshow-controls a:first-child{background-position:-76px 8px!important}body div div.slideshow-controls a:last-child{background-position:-117px 8px!important}body div div.slideshow-controls a:nth-child(2){background-position:-34px 8px!important}body div div.slideshow-controls a.running{background-position:-34px 8px!important}body div div.slideshow-controls a.paused{background-position:9px 8px!important}.slideshow-controls a img{border:50px dotted #f0f} \ No newline at end of file
diff --git a/plugins/jetpack/modules/shortcodes/email-subscribe.php b/plugins/jetpack/modules/shortcodes/email-subscribe.php
new file mode 100644
index 00000000..88c13090
--- /dev/null
+++ b/plugins/jetpack/modules/shortcodes/email-subscribe.php
@@ -0,0 +1,6 @@
+<?php
+/**
+ * Deprecated. No longer needed.
+ *
+ * @package Jetpack
+ */
diff --git a/plugins/jetpack/modules/shortcodes/getty.php b/plugins/jetpack/modules/shortcodes/getty.php
index c308ed0f..d473e726 100644
--- a/plugins/jetpack/modules/shortcodes/getty.php
+++ b/plugins/jetpack/modules/shortcodes/getty.php
@@ -4,6 +4,8 @@
*
* [getty src="82278805" width="$width" height="$height"]
* <div class="getty embed image" style="background-color:#fff;display:inline-block;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;color:#a7a7a7;font-size:11px;width:100%;max-width:462px;"><div style="padding:0;margin:0;text-align:left;"><a href="http://www.gettyimages.com/detail/82278805" target="_blank" style="color:#a7a7a7;text-decoration:none;font-weight:normal !important;border:none;display:inline-block;">Embed from Getty Images</a></div><div style="overflow:hidden;position:relative;height:0;padding:80.086580% 0 0 0;width:100%;"><iframe src="//embed.gettyimages.com/embed/82278805?et=jGiu6FXXSpJDGf1SnwLV2g&sig=TFVNFtqghwNw5iJQ1MFWnI8f4Y40_sfogfZLhai6SfA=" width="462" height="370" scrolling="no" frameborder="0" style="display:inline-block;position:absolute;top:0;left:0;width:100%;height:100%;"></iframe></div><p style="margin:0;"></p></div>
+ *
+ * @package Jetpack
*/
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
@@ -20,14 +22,14 @@ if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
*/
function jetpack_getty_enable_embeds() {
- // Support their oEmbed Endpoint
+ // Support their oEmbed Endpoint.
wp_oembed_add_provider( '#https?://www\.gettyimages\.com/detail/.*#i', 'https://embed.gettyimages.com/oembed/', true );
wp_oembed_add_provider( '#https?://(www\.)?gty\.im/.*#i', 'https://embed.gettyimages.com/oembed/', true );
- // Allow iframes to be filtered to short code (so direct copy+paste can be done)
+ // Allow iframes to be filtered to short code (so direct copy+paste can be done).
add_filter( 'pre_kses', 'wpcom_shortcodereverse_getty' );
- // Actually display the Getty Embed
+ // Actually display the Getty Embed.
add_shortcode( 'getty', 'jetpack_getty_shortcode' );
}
@@ -46,6 +48,11 @@ function jetpack_getty_enable_embeds() {
*/
add_filter( 'oembed_fetch_url', 'getty_add_oembed_endpoint_caller' );
+/**
+ * Filter the embeds to add a caller parameter.
+ *
+ * @param string $provider URL of the oEmbed provider.
+ */
function getty_add_oembed_endpoint_caller( $provider ) {
// By time filter is called, original provider URL has had url, maxwidth,
// maxheight query parameters added.
@@ -56,17 +63,17 @@ function getty_add_oembed_endpoint_caller( $provider ) {
// Set the caller argument to pass to Getty's oembed provider.
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
- // Only include caller for non-private sites
+ // Only include caller for non-private sites.
if ( ! function_exists( 'is_private_blog' ) || ! is_private_blog() ) {
- $host = parse_url( get_bloginfo( 'url' ), PHP_URL_HOST );
+ $host = wp_parse_url( get_bloginfo( 'url' ), PHP_URL_HOST );
}
- // Fall back to WordPress.com
+ // Fall back to WordPress.com.
if ( empty( $host ) ) {
$host = 'wordpress.com';
}
} else {
- $host = parse_url( get_home_url(), PHP_URL_HOST );
+ $host = wp_parse_url( get_home_url(), PHP_URL_HOST );
}
return add_query_arg( 'caller', $host, $provider );
@@ -77,7 +84,7 @@ function getty_add_oembed_endpoint_caller( $provider ) {
*
* @since 4.5.0
*
- * @param string $content
+ * @param string $content Post content.
*
* @return mixed
*/
@@ -89,19 +96,18 @@ function wpcom_shortcodereverse_getty( $content ) {
$regexp = '!<iframe\s+src=[\'"](https?:)?//embed\.gettyimages\.com/embed(/|/?\?assets=)([a-z0-9_-]+(,[a-z0-9_-]+)*)[^\'"]*?[\'"]((?:\s+\w+=[\'"][^\'"]*[\'"])*)((?:[\s\w]*))></iframe>!i';
$regexp_ent = str_replace( '&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:
+ // Markup pattern for 2017 embed syntax with significant differences from the prior pattern.
$regexp_2017 = '!<a.+?class=\'gie-(single|slideshow)\'.+?gie\.widgets\.load\({([^}]+)}\).+?embed-cdn\.gettyimages\.com/widgets\.js.+?</script>!';
$regexp_2017_ent = str_replace( '&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 ) {
- if ( ! preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) {
+ foreach ( compact( 'regexp_2017', 'regexp_2017_ent', 'regexp', 'regexp_ent' ) as $reg => $regexp ) {
+ if ( ! preg_match_all( $regexp, $content, $matches, PREG_SET_ORDER ) ) {
continue;
}
foreach ( $matches as $match ) {
if ( 'regexp_2017' === $reg || 'regexp_2017_ent' === $reg ) {
- // Extract individual keys from the matched JavaScript object
+ // Extract individual keys from the matched JavaScript object.
$params = $match[2];
if ( ! preg_match_all( '!(?P<key>\w+)\s*:\s*([\'"](?P<value>[^\'"]*?)(px)?[\'"])!', $params, $key_matches, PREG_SET_ORDER ) ) {
continue;
@@ -146,8 +152,10 @@ function wpcom_shortcodereverse_getty( $content ) {
if ( ! empty( $height ) ) {
$shortcode .= ' height="' . esc_attr( $height ) . '"';
}
- // While it does not appear to have any practical impact, Getty has
- // requested that we include TLD in the embed request
+ /*
+ * 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 ) . '"';
}
@@ -157,12 +165,12 @@ function wpcom_shortcodereverse_getty( $content ) {
}
}
- // strip out enclosing div and any other markup
+ // strip out enclosing div and any other markup.
$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 ) {
- if ( ! preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) {
+ foreach ( compact( 'regexp', 'regexp_ent' ) as $reg => $regexp ) {
+ if ( ! preg_match_all( $regexp, $content, $matches, PREG_SET_ORDER ) ) {
continue;
}
diff --git a/plugins/jetpack/modules/shortcodes/googleapps.php b/plugins/jetpack/modules/shortcodes/googleapps.php
index 8d40e2e5..55c4580e 100644
--- a/plugins/jetpack/modules/shortcodes/googleapps.php
+++ b/plugins/jetpack/modules/shortcodes/googleapps.php
@@ -1,5 +1,4 @@
<?php
-
/**
* Google Docs and Google Calendar Shortcode
*
@@ -33,6 +32,8 @@
*
* Generic
* <iframe src="https://docs.google.com/file/d/0B0SIdZW7iu-zX1RWREJpMXVHZVU/preview" width="640" height="480"></iframe>
+ *
+ * @package Jetpack
*/
add_filter( 'pre_kses', 'googleapps_embed_to_shortcode' );
@@ -43,12 +44,16 @@ add_shortcode( 'googleapps', 'googleapps_shortcode' );
*
* @since 4.5.0
*
- * @param string $content
+ * @param string $content Post content.
*
* @return mixed
*/
function googleapps_embed_to_shortcode( $content ) {
- if ( ! is_string( $content ) || false === stripos( $content, '<iframe' ) && false === stripos( $content, '.google.com' ) ) {
+ if (
+ ! is_string( $content )
+ || false === stripos( $content, '<iframe' )
+ && false === stripos( $content, '.google.com' )
+ ) {
return $content;
}
@@ -59,20 +64,22 @@ function googleapps_embed_to_shortcode( $content ) {
$regexp_noquot = '!<iframe(.*?)src=https://(docs|drive)\.google\.com/[-\.\w/]*?(viewer)\?(.*?)>(.*?)</iframe>!';
$regexp_ent_noquot = str_replace( '&amp;#0*58;', '&amp;#0*58;|&#0*58;', htmlspecialchars( $regexp_noquot, ENT_NOQUOTES ) );
- foreach ( array( 'regexp', 'regexp_ent', 'regexp_squot', 'regexp_ent_squot', 'regexp_noquot', 'regexp_ent_noquot' ) as $reg ) {
- if ( ! preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) {
+ foreach ( compact( 'regexp', 'regexp_ent', 'regexp_squot', 'regexp_ent_squot', 'regexp_noquot', 'regexp_ent_noquot' ) as $reg => $regexp ) {
+ if ( ! preg_match_all( $regexp, $content, $matches, PREG_SET_ORDER ) ) {
continue;
}
foreach ( $matches as $match ) {
$params = $match[1] . $match[5];
- if ( in_array( $reg, array( 'regexp_ent', 'regexp_ent_squot' ) ) ) {
+ if ( in_array( $reg, array( 'regexp_ent', 'regexp_ent_squot' ), true ) ) {
$params = html_entity_decode( $params );
}
$params = wp_kses_hair( $params, array( 'http' ) );
- $width = $height = 0;
+ $width = 0;
+ $height = 0;
+
if ( isset( $params['width'] ) ) {
$width = (int) $params['width']['value'];
}
@@ -81,14 +88,19 @@ function googleapps_embed_to_shortcode( $content ) {
$height = (int) $params['height']['value'];
}
- // allow the user to specify width greater than 200 inside text widgets
- if ( $width > 400 && isset( $_POST['widget-text'] ) ) {
+ // allow the user to specify width greater than 200 inside text widgets.
+ if (
+ $width > 400
+ // We don't need to check a nonce here. A nonce is already checked "further up" in most code paths.
+ // In the case where no nonce is ever checked, setting this $_POST parameter doesn't do anything the submitter couldn't already do (set the width/height).
+ && isset( $_POST['widget-text'] ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ ) {
$width = 200;
$height = 200;
}
$attributes = '';
- if ( isset( $params['width'] ) && '100%' == $params['width']['value'] ) {
+ if ( isset( $params['width'] ) && '100%' === $params['width']['value'] ) {
$width = '100%';
}
@@ -101,7 +113,7 @@ function googleapps_embed_to_shortcode( $content ) {
}
$domain = 'spreadsheets';
- if ( in_array( $match[2], array( 'docs', 'drive', 'www', 'calendar' ) ) ) {
+ if ( in_array( $match[2], array( 'docs', 'drive', 'www', 'calendar' ), true ) ) {
$domain = $match[2];
}
@@ -125,7 +137,7 @@ function googleapps_embed_to_shortcode( $content ) {
*
* @since 4.5.0
*
- * @param array $atts
+ * @param array $atts Shortcode attributes.
*
* @return string
*/
@@ -149,7 +161,7 @@ function googleapps_shortcode( $atts ) {
}
if ( isset( $content_width ) && '560' === $attr['height'] ) {
- $attr['height'] = $content_height = floor( $content_width * 3 / 4 );
+ $attr['height'] = floor( $content_width * 3 / 4 );
}
if ( isset( $atts[0] ) && $atts[0] ) {
@@ -187,28 +199,28 @@ function googleapps_shortcode( $atts ) {
*
* @since 4.5.0
*
- * @param string $domain
- * @param string $dir
+ * @param string $domain Google subdomain.
+ * @param string $dir Subdirectory of the shared URL.
*
* @return bool
*/
function googleapps_validate_domain_and_dir( $domain, $dir ) {
- if ( ! in_array( $domain, array( 'docs', 'drive', 'www', 'spreadsheets', 'calendar' ) ) ) {
+ if ( ! in_array( $domain, array( 'docs', 'drive', 'www', 'spreadsheets', 'calendar' ), true ) ) {
return false;
}
- // Calendars
+ // Calendars.
if ( ( 'www' === $domain || 'calendar' === $domain ) && 'calendar/' !== substr( $dir, 0, 9 ) ) {
return false;
}
- // Docs
- if ( in_array( $domain, array( 'docs', 'drive' ) ) && ! preg_match( '![-\.\w/]*(presentation/embed|presentation/d/(.*)|present/embed|document/pub|spreadsheets/d/(.*)|document/d/(e/)?[\w-]+/pub|file/d/[\w-]+/preview|viewer|forms/d/(.*)/viewform|spreadsheet/\w+)$!', $dir ) ) {
+ // Docs.
+ if ( in_array( $domain, array( 'docs', 'drive' ), true ) && ! preg_match( '![-\.\w/]*(presentation/embed|presentation/d/(.*)|present/embed|document/pub|spreadsheets/d/(.*)|document/d/(e/)?[\w-]+/pub|file/d/[\w-]+/preview|viewer|forms/d/(.*)/viewform|spreadsheet/\w+)$!', $dir ) ) {
return false;
}
- // Spreadsheets
- if ( 'spreadsheets' == $domain && ! preg_match( '!^([-\.\w/]+/pub|[-\.\w/]*embeddedform)$!', $dir ) ) {
+ // Spreadsheets.
+ if ( 'spreadsheets' === $domain && ! preg_match( '!^([-\.\w/]+/pub|[-\.\w/]*embeddedform)$!', $dir ) ) {
return false;
}
@@ -220,8 +232,8 @@ function googleapps_validate_domain_and_dir( $domain, $dir ) {
*
* @since 4.5.0
*
- * @param string $domain
- * @param string $dir
+ * @param string $domain Google subdomain.
+ * @param string $dir Subdirectory of the shared URL.
*
* @return string
*/
@@ -229,10 +241,10 @@ function googleapps_service_name( $domain, $dir ) {
switch ( $domain ) {
case 'drive':
case 'docs':
- $service_name = ( 'present/embed' == $dir ) ? 'googledocs_presentation' : 'googledocs_document';
+ $service_name = ( 'present/embed' === $dir ) ? 'googledocs_presentation' : 'googledocs_document';
break;
case 'spreadsheets':
- $service_name = ( 'embeddedform' == $dir ) ? 'googledocs_form' : 'googledocs_spreadsheet';
+ $service_name = ( 'embeddedform' === $dir ) ? 'googledocs_form' : 'googledocs_spreadsheet';
break;
case 'calendar':
default:
diff --git a/plugins/jetpack/modules/shortcodes/googleplus.php b/plugins/jetpack/modules/shortcodes/googleplus.php
index 950f217c..8c9118e1 100644
--- a/plugins/jetpack/modules/shortcodes/googleplus.php
+++ b/plugins/jetpack/modules/shortcodes/googleplus.php
@@ -2,18 +2,15 @@
/**
* Google+ embeds
+ * Google+ has shut down. Output the link for history's sake.
+ * Other than that, there's not much we can do.
*/
define( 'JETPACK_GOOGLEPLUS_EMBED_REGEX', '#^https?://plus\.(sandbox\.)?google\.com/(u/\d+/)?([^/]+)/posts/([^/]+)$#' );
// Example URL: https://plus.google.com/114986219448604314131/posts/LgHkesWCmJo
// Alternate example: https://plus.google.com/u/0/100004581596612508203/posts/2UKwN67MBQs (note the /u/0/)
-wp_embed_register_handler( 'googleplus', JETPACK_GOOGLEPLUS_EMBED_REGEX, 'jetpack_googleplus_embed_handler' );
-
-function jetpack_googleplus_embed_handler( $matches, $attr, $url ) {
- wp_enqueue_script( 'jetpack-gplus-api', 'https://apis.google.com/js/platform.js', array(), null, true );
- return sprintf( '<div class="g-post" data-href="%s"></div>', esc_url( $url ) );
-}
+wp_embed_register_handler( 'googleplus', JETPACK_GOOGLEPLUS_EMBED_REGEX, 'jetpack_deprecated_embed_handler' );
add_shortcode( 'googleplus', 'jetpack_googleplus_shortcode_handler' );
@@ -28,5 +25,5 @@ function jetpack_googleplus_shortcode_handler( $atts ) {
return;
}
- return $wp_embed->shortcode( $atts, $atts['url'] );
+ return sprintf( '<p>%s</p>', $wp_embed->shortcode( $atts, $atts['url'] ) );
}
diff --git a/plugins/jetpack/modules/shortcodes/gravatar.php b/plugins/jetpack/modules/shortcodes/gravatar.php
index ea248618..cb709af9 100644
--- a/plugins/jetpack/modules/shortcodes/gravatar.php
+++ b/plugins/jetpack/modules/shortcodes/gravatar.php
@@ -6,6 +6,8 @@
*
* [gravatar email="user@example.org" size="48"]
* [gravatar_profile who="user@example.org"]
+ *
+ * @package Jetpack
*/
add_shortcode( 'gravatar', 'jetpack_gravatar_shortcode' );
@@ -63,10 +65,10 @@ function jetpack_gravatar_shortcode( $atts ) {
* @return string
*/
function jetpack_gravatar_profile_shortcode( $atts ) {
- // Give each use of the shortcode a unique ID
+ // Give each use of the shortcode a unique ID.
static $instance = 0;
- // Process passed attributes
+ // Process passed attributes.
$atts = shortcode_atts(
array(
'who' => null,
@@ -75,7 +77,7 @@ function jetpack_gravatar_profile_shortcode( $atts ) {
'jetpack_gravatar_profile'
);
- // Can specify username, user ID, or email address
+ // Can specify username, user ID, or email address.
if ( is_numeric( $atts['who'] ) ) {
$user = get_user_by( 'id', (int) $atts['who'] );
} elseif ( is_email( $atts['who'] ) ) {
@@ -86,12 +88,12 @@ function jetpack_gravatar_profile_shortcode( $atts ) {
$user = false;
}
- // Bail if we don't have a user
+ // Bail if we don't have a user.
if ( false === $user ) {
return false;
}
- // Render the shortcode
+ // Render the shortcode.
$gravatar_url = set_url_scheme( 'http://gravatar.com/' . $user->user_login );
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
@@ -154,7 +156,7 @@ function jetpack_gravatar_profile_shortcode( $atts ) {
</div>
<?php
- // Increment and return the rendered profile
+ // Increment and return the rendered profile.
$instance++;
return ob_get_clean();
diff --git a/plugins/jetpack/modules/shortcodes/hulu.php b/plugins/jetpack/modules/shortcodes/hulu.php
index 93701099..38203d4c 100644
--- a/plugins/jetpack/modules/shortcodes/hulu.php
+++ b/plugins/jetpack/modules/shortcodes/hulu.php
@@ -13,11 +13,13 @@
* <param name="allowFullScreen" value="true"></param>
* <embed src="http://www.hulu.com/embed/gQ6Z0I990IWv_VFQI2J7Eg" type="application/x-shockwave-flash" width="512" height="288" allowFullScreen="true"></embed>
* </object>
+ *
+ * @package Jetpack
*/
if ( get_option( 'embed_autourls' ) ) {
- // Convert hulu URLS to shortcodes for old comments, saved before comments for shortcodes were enabled
+ // Convert hulu URLS to shortcodes for old comments, saved before comments for shortcodes were enabled.
add_filter( 'comment_text', 'jetpack_hulu_link', 1 );
}
@@ -35,13 +37,13 @@ add_shortcode( 'hulu', 'jetpack_hulu_shortcode' );
function jetpack_shortcode_get_hulu_id( $atts ) {
// This will catch an id explicitly defined as such, or assume any param without a label is the id. First found is used.
if ( isset( $atts['id'] ) ) {
- // First we check to see if [hulu id=369061] or [hulu id=gQ6Z0I990IWv_VFQI2J7Eg] was used
+ // First we check to see if [hulu id=369061] or [hulu id=gQ6Z0I990IWv_VFQI2J7Eg] was used.
$id = esc_attr( $atts['id'] );
} elseif ( isset( $atts[0] ) && preg_match( '|www\.hulu\.com/watch/(\d+)|i', $atts[0], $match ) ) {
- // this checks for [hulu http://www.hulu.com/watch/369061]
+ // this checks for [hulu http://www.hulu.com/watch/369061].
$id = (int) $match[1];
} elseif ( isset( $atts[0] ) ) {
- // This checks for [hulu 369061] or [hulu 65yppv6xqa45s5n7_m1wng]
+ // This checks for [hulu 369061] or [hulu 65yppv6xqa45s5n7_m1wng].
$id = esc_attr( $atts[0] );
} else {
$id = 0;
@@ -91,12 +93,18 @@ function jetpack_hulu_shortcode( $atts ) {
}
// check to see if $id is 76560 else we assume it's gQ6Z0I990IWv_VFQI2J7Eg
- // If id is numeric, we'll send it off to the hulu oembed api to get the embed URL (and non-numeric id)
+ // If id is numeric, we'll send it off to the hulu oembed api to get the embed URL (and non-numeric id).
if ( is_numeric( $id ) ) {
- $transient_key = "hulu-$id";
- if ( false === ( $transient_value = get_transient( $transient_key ) ) ) {
- // let's make a cross-site http request out to the hulu oembed api
- $response = wp_remote_get( 'http://www.hulu.com/api/oembed.json?url=' . urlencode( 'http://www.hulu.com/watch/' . esc_attr( $id ) ) );
+ $transient_key = "hulu-$id";
+ $transient_value = get_transient( $transient_key );
+
+ if ( false === $transient_value ) {
+ // let's make a cross-site http request out to the hulu oembed api.
+ $oembed_url = sprintf(
+ 'https://www.hulu.com/api/oembed.json?url=%s',
+ rawurlencode( 'https://www.hulu.com/watch/' . esc_attr( $id ) )
+ );
+ $response = wp_remote_get( $oembed_url );
$response_code = wp_remote_retrieve_response_code( $response );
$response_message = wp_remote_retrieve_response_message( $response );
if ( 200 !== $response_code && ! empty( $response_message ) ) {
@@ -107,9 +115,9 @@ function jetpack_hulu_shortcode( $atts ) {
$response_body = wp_remote_retrieve_body( $response );
$json = json_decode( $response_body );
- // Pull out id from embed url (from oembed API)
+ // Pull out id from embed url (from oembed API).
$embed_url_params = array();
- parse_str( parse_url( $json->embed_url, PHP_URL_QUERY ), $embed_url_params );
+ parse_str( wp_parse_url( $json->embed_url, PHP_URL_QUERY ), $embed_url_params );
if ( isset( $embed_url_params['eid'] ) ) {
$id = $embed_url_params['eid'];
@@ -126,14 +134,6 @@ function jetpack_hulu_shortcode( $atts ) {
return '<!-- Hulu Error: Not a Hulu video. -->';
}
- $width = intval( $attr['width'] );
- $height = round( ( $width / 640 ) * 360 );
-
- $iframe_url = 'http://www.hulu.com/embed.html';
- if ( is_ssl() ) {
- $iframe_url = 'https://secure.hulu.com/embed.html';
- }
-
$query_args = array();
$query_args['eid'] = esc_attr( $id );
if ( isset( $start_time ) ) {
@@ -146,7 +146,9 @@ function jetpack_hulu_shortcode( $atts ) {
$query_args['it'] = 'i' . intval( $thumbnail_frame );
}
- $iframe_url = add_query_arg( $query_args, $iframe_url );
+ $iframe_url = add_query_arg( $query_args, 'https://www.hulu.com/embed.html' );
+ $width = intval( $attr['width'] );
+ $height = round( ( $width / 640 ) * 360 );
$html = sprintf(
'<div class="embed-hulu" style="text-align: center;"><iframe src="%s" width="%s" height="%s" style="border:0;" scrolling="no" webkitAllowFullScreen
@@ -165,18 +167,17 @@ mozallowfullscreen allowfullscreen></iframe></div>',
*
* @since 4.5.0
*
- * @param array $matches
+ * @param array $matches Array of matches from regex.
*
* @return string
*/
function jetpack_hulu_link_callback( $matches ) {
$video_id = $matches[4];
- $src = is_ssl()
- ? 'https://secure.hulu.com'
- : 'http://www.hulu.com';
- // Make up an embed src to pass to the shortcode reversal function
- $attrs['src'] = $src . '/embed.html?eid=' . esc_attr( $video_id );
+ // Make up an embed src to pass to the shortcode reversal function.
+ $attrs = array(
+ 'src' => 'https://www.hulu.com/embed.html?eid=' . esc_attr( $video_id ),
+ );
return wpcom_shortcodereverse_huluhelper( $attrs );
}
@@ -186,7 +187,7 @@ function jetpack_hulu_link_callback( $matches ) {
*
* @since 4.5.0
*
- * @param string $content
+ * @param string $content Post content.
*
* @return string
*/
@@ -201,7 +202,7 @@ function jetpack_hulu_link( $content ) {
*
* @since 4.5.0
*
- * @param array $attrs
+ * @param array $attrs Shortcode attributes.
*
* @return string
*/
@@ -209,7 +210,7 @@ function wpcom_shortcodereverse_huluhelper( $attrs ) {
$attrs = wpcom_shortcodereverse_parseattr( $attrs );
$src_attributes = array();
- parse_str( parse_url( $attrs['src'], PHP_URL_QUERY ), $src_attributes );
+ parse_str( wp_parse_url( $attrs['src'], PHP_URL_QUERY ), $src_attributes );
$attrs = array_merge( $attrs, $src_attributes );
@@ -237,7 +238,7 @@ function wpcom_shortcodereverse_huluhelper( $attrs ) {
}
if ( $attrs['it'] ) {
- // the thumbnail frame attribute comes with an i in front of the value, so we've got to remove that
+ // the thumbnail frame attribute comes with an i in front of the value, so we've got to remove that.
$shortcode .= ' thumbnail_frame=' . intval( ltrim( $attrs['it'], 'i' ) );
}
$shortcode .= ']';
@@ -256,18 +257,19 @@ function wpcom_shortcodereverse_huluhelper( $attrs ) {
*
* @since 4.5.0
*
- * @param array $attrs
+ * @param array $attrs Shortcode attributes.
*
* @return string
*/
function wpcom_shortcodereverse_huluembed( $attrs ) {
$shortcode = wpcom_shortcodereverse_huluhelper( $attrs );
- if ( substr( $shortcode, 0, 1 ) == '[' ) {
+
+ if ( '[' === substr( $shortcode, 0, 1 ) ) {
/** This action is documented in modules/widgets/social-media-icons.php */
do_action( 'jetpack_bump_stats_extras', 'html_to_shortcode', 'hulu-embed' );
}
return $shortcode;
}
-Filter_Embedded_HTML_Objects::register( '#^http://www.hulu.com/embed.html#i', 'wpcom_shortcodereverse_huluembed', true );
+Filter_Embedded_HTML_Objects::register( '#^https?://www.hulu.com/embed.html#i', 'wpcom_shortcodereverse_huluembed', true );
diff --git a/plugins/jetpack/modules/shortcodes/instagram.php b/plugins/jetpack/modules/shortcodes/instagram.php
index fc164d82..656703bd 100644
--- a/plugins/jetpack/modules/shortcodes/instagram.php
+++ b/plugins/jetpack/modules/shortcodes/instagram.php
@@ -21,17 +21,17 @@ function jetpack_instagram_embed_reversal( $content ) {
$regexes = array();
- // new style js
- $regexes[] = '#<blockquote[^>]+?class="instagram-media"[^>](.+?)>(.+?)</blockquote><script[^>]+?src="(https?:)?//platform\.instagram\.com/(.+?)/embeds\.js"></script>#ix';
+ // new style js.
+ $regexes[] = '#<blockquote[^>]+?class="instagram-media"[^>].+?>(.+?)</blockquote><script[^>]+?src="(https?:)?//platform\.instagram\.com/(.+?)/embeds\.js"></script>#ix';
// Let's play nice with the visual editor too.
- $regexes[] = '#&lt;blockquote(?:[^&]|&(?!gt;))+?class="instagram-media"(?:[^&]|&(?!gt;))(.+?)&gt;(.+?)&lt;/blockquote&gt;&lt;script(?:[^&]|&(?!gt;))+?src="(https?:)?//platform\.instagram\.com/(.+?)/embeds\.js"(?:[^&]|&(?!gt;))*+&gt;&lt;/script&gt;#ix';
+ $regexes[] = '#&lt;blockquote(?:[^&]|&(?!gt;))+?class="instagram-media"(?:[^&]|&(?!gt;)).+?&gt;(.+?)&lt;/blockquote&gt;&lt;script(?:[^&]|&(?!gt;))+?src="(https?:)?//platform\.instagram\.com/(.+?)/embeds\.js"(?:[^&]|&(?!gt;))*+&gt;&lt;/script&gt;#ix';
- // old style iframe
- $regexes[] = '#<iframe[^>]+?src="(?:https?:)?//instagram\.com/p/([^"\'/]++)[^"\']*?"[^>]*+>\s*?</iframe>#i';
+ // old style iframe.
+ $regexes[] = '#<iframe[^>]+?src="((?:https?:)?//(?:www\.)?instagram\.com/p/([^"\'/]++)[^"\']*?)"[^>]*+>\s*?</iframe>#i';
// Let's play nice with the visual editor too.
- $regexes[] = '#&lt;iframe(?:[^&]|&(?!gt;))+?src="(?:https?:)?//instagram\.com/p/([^"\'/]++)[^"\']*?"(?:[^&]|&(?!gt;))*+&gt;\s*?&lt;/iframe&gt;#i';
+ $regexes[] = '#&lt;iframe(?:[^&]|&(?!gt;))+?src="((?:https?:)?//(?:www\.)instagram\.com/p/([^"\'/]++)[^"\']*?)"(?:[^&]|&(?!gt;))*+&gt;\s*?&lt;/iframe&gt;#i';
foreach ( $regexes as $regex ) {
if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) {
@@ -39,7 +39,7 @@ function jetpack_instagram_embed_reversal( $content ) {
}
foreach ( $matches as $match ) {
- if ( ! preg_match( '#(https?:)?//instagr(\.am|am\.com)/p/([^/]*)#i', $match[2], $url_matches ) ) {
+ if ( ! preg_match( '#(https?:)?//(?:www\.)?instagr(\.am|am\.com)/p/([^/]*)#i', $match[1], $url_matches ) ) {
continue;
}
@@ -59,11 +59,28 @@ function jetpack_instagram_embed_reversal( $content ) {
add_filter( 'pre_kses', 'jetpack_instagram_embed_reversal' );
/**
- * Instagram
+ * Instagram's custom Embed provider.
+ * We first remove 2 different embed providers, both registered by Core.
+ * - The first is the original provider,that only supports images.
+ * - The second is tne new provider that replaced the first one in Core when Core added support for videos. https://core.trac.wordpress.org/changeset/44486
+ *
+ * Once the core embed provider is removed (one or the other, depending on your version of Core), we declare our own.
*/
-wp_oembed_remove_provider( '#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i' ); // remove core's oEmbed support so we can override
-wp_embed_register_handler( 'jetpack_instagram', '#http(s?)://(www\.)?instagr(\.am|am\.com)/p/([^/]*)#i', 'jetpack_instagram_handler' );
+wp_oembed_remove_provider( '#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i' );
+wp_oembed_remove_provider( '#https?://(www\.)?instagr(\.am|am\.com)/(p|tv)/.*#i' );
+wp_embed_register_handler(
+ 'jetpack_instagram',
+ '#http(s?)://(www\.)?instagr(\.am|am\.com)/(p|tv)/([^\/]*)#i',
+ 'jetpack_instagram_handler'
+);
+/**
+ * Handle Instagram embeds (build embed from regex).
+ *
+ * @param array $matches Array of matches from the regex.
+ * @param array $atts The original unmodified attributes.
+ * @param string $url The original URL that was matched by the regex.
+ */
function jetpack_instagram_handler( $matches, $atts, $url ) {
global $content_width;
@@ -74,8 +91,24 @@ function jetpack_instagram_handler( $matches, $atts, $url ) {
$min_width = 320;
if ( is_feed() ) {
- $media_url = sprintf( 'http://instagr.am/p/%s/media/?size=l', $matches[4] );
- 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 ) );
+ // Instagram offers direct links to images, but not to videos.
+ if ( 'p' === $matches[1] ) {
+ $media_url = sprintf( 'http://instagr.am/p/%1$s/media/?size=l', $matches[2] );
+ return sprintf(
+ '<a href="%1$s" title="%2$s" target="_blank"><img src="%3$s" alt="%4$s" /></a>',
+ esc_url( $url ),
+ esc_attr__( 'View on Instagram', 'jetpack' ),
+ esc_url( $media_url ),
+ esc_html__( 'Instagram Photo', 'jetpack' )
+ );
+ } elseif ( 'tv' === $matches[1] ) {
+ return sprintf(
+ '<a href="%1$s" title="%2$s" target="_blank">%3$s</a>',
+ esc_url( $url ),
+ esc_attr__( 'View on Instagram', 'jetpack' ),
+ esc_html__( 'Instagram Video', 'jetpack' )
+ );
+ }
}
$atts = shortcode_atts(
@@ -166,13 +199,32 @@ function jetpack_instagram_handler( $matches, $atts, $url ) {
return '<!-- instagram error: no embed found -->';
}
-// filters instagram's username format to the expected format that matches the embed handler
-wp_embed_register_handler( 'jetpack_instagram_alternate_format', '#http(s?)://instagr(\.am|am\.com)/([^/]*)/p/([^/]*)#i', 'jetpack_instagram_alternate_format_handler' );
+/**
+ * Handle an alternate Instagram URL format, where the username is also part of the URL.
+ * We do not actually need that username for the embed.
+ */
+wp_embed_register_handler(
+ 'jetpack_instagram_alternate_format',
+ '#https?://(?:www\.)?instagr(?:\.am|am\.com)/(?:[^/]*)/(p|tv)/([^\/]*)#i',
+ 'jetpack_instagram_alternate_format_handler'
+);
+
+/**
+ * Handle alternate Instagram embeds (build embed from regex).
+ *
+ * @param array $matches Array of matches from the regex.
+ * @param array $atts The original unmodified attributes.
+ * @param string $url The original URL that was matched by the regex.
+ */
function jetpack_instagram_alternate_format_handler( $matches, $atts, $url ) {
- $url = esc_url_raw( 'https://instagram.com/p/' . $matches[4] );
- $matches[0] = $url;
- $matches[3] = $matches[4];
- unset( $matches[4] );
+ // Replace URL saved by original Instagram URL (no username).
+ $matches[0] = esc_url_raw(
+ sprintf(
+ 'https://www.instagram.com/%1$s/%2$s',
+ $matches[1],
+ $matches[2]
+ )
+ );
return jetpack_instagram_handler( $matches, $atts, $url );
}
diff --git a/plugins/jetpack/modules/shortcodes/kickstarter.php b/plugins/jetpack/modules/shortcodes/kickstarter.php
index cd59f940..1e6664bb 100644
--- a/plugins/jetpack/modules/shortcodes/kickstarter.php
+++ b/plugins/jetpack/modules/shortcodes/kickstarter.php
@@ -4,6 +4,8 @@
*
* Usage:
* [kickstarter url="https://www.kickstarter.com/projects/peaktoplateau/yak-wool-baselayers-from-tibet-to-the-world" width="480" height=""]
+ *
+ * @package Jetpack
*/
add_shortcode( 'kickstarter', 'jetpack_kickstarter_shortcode' );
@@ -24,7 +26,7 @@ function jetpack_kickstarter_shortcode( $atts ) {
}
$url = esc_url_raw( $atts['url'] );
- if ( ! preg_match( '#^(www\.)?kickstarter\.com$#i', parse_url( $url, PHP_URL_HOST ) ) ) {
+ if ( ! preg_match( '#^(www\.)?kickstarter\.com$#i', wp_parse_url( $url, PHP_URL_HOST ) ) ) {
return '<!-- Invalid Kickstarter URL -->';
}
@@ -49,7 +51,7 @@ function jetpack_kickstarter_embed_to_shortcode( $content ) {
}
$regexp = '!<iframe((?:\s+\w+=[\'"][^\'"]*[\'"])*)\s+src=[\'"](http://www\.kickstarter\.com/projects/[^/]+/[^/]+)/[^\'"]+[\'"]((?:\s+\w+=[\'"][^\'"]*[\'"])*)>[\s]*</iframe>!i';
- $regexp_ent = str_replace( '&amp;#0*58;', '&amp;#0*58;|&#0*58;', htmlspecialchars( $regexp, ENT_NOQUOTES ) );
+ $regexp_ent = str_replace( '&amp;#0*58;', '&amp;#0*58;|&#0*58;', htmlspecialchars( $regexp, ENT_NOQUOTES ) ); // phpcs:ignore
foreach ( array( 'regexp', 'regexp_ent' ) as $reg ) {
if ( ! preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) {
@@ -61,7 +63,7 @@ function jetpack_kickstarter_embed_to_shortcode( $content ) {
$params = $match[1] . $match[3];
- if ( 'regexp_ent' == $reg ) {
+ if ( 'regexp_ent' === $reg ) {
$params = html_entity_decode( $params );
}
diff --git a/plugins/jetpack/modules/shortcodes/lytro.php b/plugins/jetpack/modules/shortcodes/lytro.php
deleted file mode 100644
index 0e222fda..00000000
--- a/plugins/jetpack/modules/shortcodes/lytro.php
+++ /dev/null
@@ -1,296 +0,0 @@
-<?php
-/**
- * Lytro.com Short Code
- *
- * Format:
- * [lytro photo='202' show_arrow='true' show_border='true' show_first_time_user='true' allow_full_view='true']
- * [lytro username='lytroweb' photo='431119']
- *
- * Legend:
- * username: the lytro.com username for newer embed format
- * photo: the ID or the URL of the photo on lytro.com
- * show_arrow: set to false to force-hide the menu in the lower right (not used in v2)
- * show_border: set to true to force-show the border
- * show_first_time_user: set to false to force-disable the first-time user experience (not used in v2)
- * allow_full_view: set to true to allow an external site to have a full-zoom mode (not used in v2)
- * enable_help: set to false to hide the question mark/help popup
- *
- * Output:
- * <iframe width="400" height="415" src="https://www.lytro.com/living-pictures/202/embed?showArrow=true&showBorder=true&showFTU=true" frameborder="0" allowfullscreen></iframe>
- * <iframe width="400" height="415" src="http://pictures.lytro.com/lytroweb/pictures/431119/embed" frameborder="0" allowfullscreen="" scrolling="no"></iframe>
- */
-
-/**
- * Lytro.com Short Code Attributes Definition
- *
- * This helper function returns an array all available
- * shortcode attributes, their validation method, default
- * value and more.
- *
- * Keys:
- * validate: a callable function or regular expression used to validate the input
- * default: default value for shortcode attribute
- * query_arg: the related lytro query argument name
- *
- * @since 4.5.0
- */
-function jetpack_lytro_shortcode_attributes() {
- return array(
- 'username' => array(
- 'default' => '',
- ),
- 'photo' => array( // could be ID or URL, validated separately
- 'default' => 0,
- ),
- 'width' => array(
- 'validate' => '#^\d+$#',
- 'default' => 400,
- ),
- 'height' => array(
- 'validate' => '#^\d+$#',
- 'default' => 415,
- ),
- 'show_arrow' => array(
- 'query_arg' => 'showArrow',
- 'validate' => '#^(true|false)$#',
- 'default' => 'true',
- ),
- 'show_border' => array(
- 'query_arg' => 'showBorder',
- 'validate' => '#^(true|false)$#',
- 'default' => 'true',
- ),
- 'show_first_time_user' => array(
- 'query_arg' => 'showFTU',
- 'validate' => '#^(true|false)$#',
- 'default' => 'true',
- ),
- 'allow_full_view' => array(
- 'query_arg' => 'allowFullView',
- 'validate' => '#^(true|false)$#',
- 'default' => 'true',
- ),
- 'enable_help' => array(
- 'query_arg' => 'enableHelp',
- 'validate' => '#^(true|false)$#',
- 'default' => 'true',
- ),
- 'enable_attribution' => array(
- 'query_arg' => 'enableAttribution',
- 'validate' => '#^(true|false)$#',
- 'default' => 'true',
- ),
- 'enable_logo' => array(
- 'query_arg' => 'enableLogo',
- 'validate' => '#^(true|false)$#',
- 'default' => 'true',
- ),
- 'enable_fullscreen' => array(
- 'query_arg' => 'enableFullscreen',
- 'validate' => '#^(true|false)$#',
- 'default' => 'true',
- ),
- 'enable_play' => array(
- 'query_arg' => 'enablePlay',
- 'validate' => '#^(true|false)$#',
- 'default' => 'true',
- ),
- 'bg_color' => array(
- 'query_arg' => 'bgColor',
- 'validate' => '/^#(?:[0-9a-fA-F]{3}){1,2}$/',
- 'default' => '',
- ),
- );
-}
-
-/**
- * Lytro.com Shortcode
- *
- * Allows embedding Lytro "living pictures" using [lytro photo="200"] or
- * [lytro photo="http://www.lytro.com/..."]. Additional attributes
- * like show_border, show_arrow, etc have priority over the ones supplied
- * in the URL.
- *
- * @since 4.5.0
- *
- * @param array $atts Shortcode attributes
- *
- * @uses jetpack_lytro_shortcode_attributes()
- * @return string Embed HTML or a <!-- commented out error -->
- */
-function jetpack_lytro_shortcode_handler( $atts ) {
- $defaults = array();
- $attributes = jetpack_lytro_shortcode_attributes();
- foreach ( $attributes as $key => $attribute ) {
- if ( isset( $attribute['default'] ) ) {
- $defaults[ $key ] = $attribute['default'];
- }
- }
-
- $atts = shortcode_atts( $defaults, $atts );
-
- // There has to at least be a photo attribute.
- if ( empty( $atts['photo'] ) ) {
- return '<!-- Lytro Shortcode Error: No Photo ID/URL -->';
- }
-
- // The photo attribute might be a URL
- if ( ! is_numeric( $atts['photo'] ) ) {
- $atts = array_merge( $atts, jetpack_lytro_shortcode_url_to_atts( $atts['photo'] ) );
- }
-
- // Validate all attributes by callable function or regular expression.
- foreach ( $atts as $key => $value ) {
- $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 ];
- }
- }
- }
-
- // The photo attribute might have changed, make sure it's still valid.
- if ( ! is_numeric( $atts['photo'] ) || ! $atts['photo'] ) {
- return '<!-- Lytro Shortcode Error: Invalid Photo ID/URL -->';
- }
-
- // Build a query which is then appended to the iframe src.
- $query_args = array();
- foreach ( $atts as $key => $value ) {
- $attribute = $attributes[ $key ];
- if ( isset( $attribute['query_arg'] ) && ! empty( $attribute['query_arg'] ) && ! empty( $value ) ) {
- $query_args[ $attribute['query_arg'] ] = $value;
- }
- }
-
- if ( ! empty( $atts['username'] ) ) {
- $src = sprintf( 'https://pictures.lytro.com/%s/pictures/%d/embed', $atts['username'], $atts['photo'] );
- } else {
- $src = sprintf( 'https://pictures.lytro.com/pictures/%d/embed', $atts['photo'] );
- }
-
- // Add query args and build the iframe.
- $src = add_query_arg( $query_args, $src );
-
- return '<iframe width="' . esc_attr( $atts['width'] ) . '" height="' . esc_attr( $atts['height'] ) . '" src="' . esc_url( $src ) . '" frameborder="0" allowfullscreen scrolling="no"></iframe>';
-}
-
-add_shortcode( 'lytro', 'jetpack_lytro_shortcode_handler' );
-
-/**
- * Lytro Shortcode URL to Shortcode Attributes
- *
- * This helper function parses a Lytro.com URL
- * and returns an attributes array.
- *
- * @since 4.5.0
- *
- * @uses jetpack_lytro_shortcode_attributes()
- */
-function jetpack_lytro_shortcode_url_to_atts( $url ) {
- $attributes = jetpack_lytro_shortcode_attributes();
- $atts = array();
-
- $url = str_replace( '&amp;', '&', $url );
-
- if ( preg_match( '#^https?://(www\.)?lytro\.com/living-pictures/([0-9]+)/?#i', $url, $matches ) ) {
- $atts['photo'] = $matches[2];
- } elseif ( preg_match( '#^https?://(www\.)?pictures\.lytro\.com/([^/]+)/pictures/([0-9]+)/?#i', $url, $matches ) ) {
- $atts['username'] = $matches[2];
- $atts['photo'] = $matches[3];
- }
-
- $url = parse_url( $url );
- if ( isset( $url['query'] ) ) {
- parse_str( $url['query'], $qargs );
-
- // 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'] ];
- }
- }
- }
-
- return $atts;
-}
-
-/**
- * Lytro Shortcode Reversal
- *
- * Example
- * <iframe width="400" height="415" src="https://www.lytro.com/living-pictures/202/embed?showBorder=true" frameborder="0" allowfullscreen></iframe>
- * <iframe width="400" height="415" src="http://pictures.lytro.com/lytroweb/pictures/431128/embed" frameborder="0" allowfullscreen="" scrolling="no"></iframe>
- *
- * Converts to:
- * [lytro photo="202" show_border="true" width="400" height="415"]
- *
- * @since 4.5.0
- *
- * @uses jetpack_lytro_shortcode_url_to_atts()
- * @uses wpcom_shortcodereverse_parseattr()
- */
-function wpcom_shortcodereverse_lytro( $atts ) {
- $atts = wpcom_shortcodereverse_parseattr( $atts );
- $shortcode_atts = array();
-
- // Grab the src URL and convert to shortcode attributes
- if ( $atts['src'] ) {
- $shortcode_atts = jetpack_lytro_shortcode_url_to_atts( $atts['src'] );
- }
-
- // Width and height too
- if ( $atts['width'] ) {
- $shortcode_atts['width'] = $atts['width'];
- }
- if ( $atts['height'] ) {
- $shortcode_atts['height'] = $atts['height'];
- }
-
- // Generate the shortcode.
- $shortcode = '';
- foreach ( $shortcode_atts as $key => $value ) {
- $shortcode .= " $key='" . esc_attr( $value ) . "'";
- }
- $shortcode = "[lytro {$shortcode}]";
-
- return $shortcode;
-}
-
-Filter_Embedded_HTML_Objects::register( '#^https?://(www\.)?lytro\.com/living-pictures/#i', 'wpcom_shortcodereverse_lytro', true );
-Filter_Embedded_HTML_Objects::register( '#^https?://(www\.)?pictures\.lytro\.com/([^/]+)/pictures/([0-9]+)/embed#i', 'wpcom_shortcodereverse_lytro', true );
-
-/**
- * Register Embed Handler
- *
- * Registers a WordPress Embed handler to allow embedding
- * Lytro images by publishing the Lytro URL on a line by itself.
- *
- * @since 4.5.0
- *
- * @uses wp_embed_register_handler
- */
-function jetpack_lytro_register_embed_handler() {
- wp_embed_register_handler( 'lytro', '#^https?://(www\.)?lytro\.com/living-pictures/([0-9]+)/?#i', 'jetpack_lytro_embed_handler' );
- wp_embed_register_handler( 'lytro-v2', '#^https?://(www\.)?pictures\.lytro\.com/([^/]+)/pictures/([0-9]+)/?#i', 'jetpack_lytro_embed_handler' );
-}
-
-add_action( 'init', 'jetpack_lytro_register_embed_handler' );
-
-/**
- * Lytro Embed Handler
- *
- * The embed handler function which converts a Lytro URL
- * on a line by itself into an embedded Lytro image.
- *
- * @since 4.5.0
- *
- * @see jetpack_lytro_register_embed_handler
- * @uses jetpack_lytro_shortcode_url_to_atts
- * @uses jetpack_lytro_shortcode_handler
- */
-function jetpack_lytro_embed_handler( $matches, $attr, $url, $rawattr ) {
- return jetpack_lytro_shortcode_handler( jetpack_lytro_shortcode_url_to_atts( $url ) );
-}
diff --git a/plugins/jetpack/modules/shortcodes/mailchimp.php b/plugins/jetpack/modules/shortcodes/mailchimp.php
index 6e05a936..ce815673 100644
--- a/plugins/jetpack/modules/shortcodes/mailchimp.php
+++ b/plugins/jetpack/modules/shortcodes/mailchimp.php
@@ -1,4 +1,4 @@
-<?php
+<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* MailChimp Subscriber Popup Form shortcode
*
@@ -7,7 +7,6 @@
*
* Embed code example:
* <script type="text/javascript" src="//downloads.mailchimp.com/js/signup-forms/popup/unique-methods/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script><script type="text/javascript">window.dojoRequire(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us11.list-manage.com","uuid":"1ca7856462585a934b8674c71","lid":"2d24f1898b","uniqueMethods":true}) })</script>
- *
*/
/**
@@ -50,9 +49,9 @@ class MailChimp_Subscriber_Popup {
*
* @var array
*/
- static $reversal_regexes = array(
+ private static $reversal_regexes = array(
/* raw examplejs */
- '/<script type="text\/javascript" src="(https?:)?\/\/downloads\.mailchimp\.com\/js\/signup-forms\/popup\/unique-methods\/embed\.js" data-dojo-config="([^"]*?)"><\/script><script type="text\/javascript">window.dojoRequire\(\["mojo\/signup-forms\/Loader"\]\, function\(L\) { L\.start\({([^}]*?)}\) }\)<\/script>/s',
+ '/<script type="text\/javascript" src="(https?:)?\/\/downloads\.mailchimp\.com\/js\/signup-forms\/popup\/unique-methods\/embed\.js" data-dojo-config="([^"]*?)"><\/script><script type="text\/javascript">window.dojoRequire\(\["mojo\/signup-forms\/Loader"\]\, function\(L\) { L\.start\({([^}]*?)}\) }\)<\/script>/s', //phpcs:ignore
/* visual editor */
'/&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',
);
@@ -62,7 +61,7 @@ class MailChimp_Subscriber_Popup {
*
* @var array
*/
- static $allowed_config = array(
+ private static $allowed_config = array(
'usePlainJson' => 'true',
'isDebug' => 'false',
);
@@ -72,7 +71,7 @@ class MailChimp_Subscriber_Popup {
*
* @var array
*/
- static $allowed_js_vars = array(
+ private static $allowed_js_vars = array(
'baseUrl',
'uuid',
'lid',
@@ -83,12 +82,12 @@ class MailChimp_Subscriber_Popup {
*
* @since 4.5.0
*
- * @param string $content Post Content
+ * @param string $content Post Content.
*
* @return string Content with embeds replaced
*/
- static function reversal( $content ) {
- // Bail without the js src
+ public static function reversal( $content ) {
+ // Bail without the js src.
if ( ! is_string( $content ) || false === stripos( $content, 'downloads.mailchimp.com/js/signup-forms/popup/unique-methods/embed.js' ) ) {
return $content;
}
@@ -96,7 +95,7 @@ class MailChimp_Subscriber_Popup {
require_once ABSPATH . WPINC . '/class-json.php';
$wp_json = new Services_JSON();
- // loop through our rules and find valid embeds
+ // loop through our rules and find valid embeds.
foreach ( self::$reversal_regexes as $regex ) {
if ( ! preg_match_all( $regex, $content, $matches ) ) {
@@ -104,7 +103,7 @@ class MailChimp_Subscriber_Popup {
}
foreach ( $matches[3] as $index => $js_vars ) {
- // the regex rule for a specific embed
+ // the regex rule for a specific embed.
$replace_regex = sprintf( '#\s*%s\s*#', preg_quote( $matches[0][ $index ], '#' ) );
$attrs = $wp_json->decode( '{' . $js_vars . '}' );
@@ -112,7 +111,7 @@ class MailChimp_Subscriber_Popup {
if ( $matches[2][ $index ] ) {
$config_attrs = $wp_json->decode( '{' . $matches[2][ $index ] . '}' );
foreach ( $config_attrs as $key => $value ) {
- $attrs->$key = ( 1 == $value ) ? 'true' : 'false';
+ $attrs->$key = ( 1 === $value ) ? 'true' : 'false';
}
}
@@ -133,16 +132,19 @@ class MailChimp_Subscriber_Popup {
*
* @since 4.5.0
*
- * @param array $attrs A valid list of attributes (gets matched against self::$allowed_config and self::$allowed_js_vars)
+ * @param array $attrs A valid list of attributes (gets matched against self::$allowed_config and self::$allowed_js_vars).
*
* @return string
*/
- static function build_shortcode_from_reversal_attrs( $attrs ) {
+ private static function build_shortcode_from_reversal_attrs( $attrs ) {
$shortcode = '[mailchimp_subscriber_popup ';
foreach ( $attrs as $key => $value ) {
- // skip unsupported keys
- if ( ! in_array( $key, array_keys( self::$allowed_config ) ) && ! in_array( $key, self::$allowed_js_vars ) ) {
+ // skip unsupported keys.
+ if (
+ ! in_array( $key, array_keys( self::$allowed_config ), true )
+ && ! in_array( $key, self::$allowed_js_vars, true )
+ ) {
continue;
}
@@ -157,14 +159,14 @@ class MailChimp_Subscriber_Popup {
*
* @since 4.5.0
*
- * @param array $lcase_attrs
+ * @param array $lcase_attrs Lowercase shortcode attributes.
*
* @return string
*/
- static function shortcode( $lcase_attrs ) {
+ public static function shortcode( $lcase_attrs ) {
static $displayed_once = false;
- // Limit to one form per page load
+ // Limit to one form per page load.
if ( $displayed_once ) {
return '';
}
@@ -176,7 +178,7 @@ class MailChimp_Subscriber_Popup {
$defaults = array_fill_keys( self::$allowed_js_vars, '' );
$defaults = array_merge( $defaults, self::$allowed_config );
- // Convert $attrs back to proper casing since they come through in all lowercase
+ // Convert $attrs back to proper casing since they come through in all lowercase.
$attrs = array();
foreach ( $defaults as $key => $value ) {
if ( array_key_exists( strtolower( $key ), $lcase_attrs ) ) {
@@ -185,10 +187,21 @@ class MailChimp_Subscriber_Popup {
}
$attrs = array_map( 'esc_js', array_filter( shortcode_atts( $defaults, $attrs ) ) );
- // Split config & js vars
- $config_vars = $js_vars = array();
+ // Split config & js vars.
+ $js_vars = array();
+ $config_vars = array();
foreach ( $attrs as $key => $value ) {
- if ( in_array( $key, self::$allowed_js_vars ) ) {
+ if (
+ 'baseUrl' === $key
+ && (
+ ! preg_match( '#mc\.us\d+\.list-manage\d?\.com#', $value, $matches )
+ || $value !== $matches[0]
+ )
+ ) {
+ return '<!-- Invalid MailChimp baseUrl -->';
+ }
+
+ if ( in_array( $key, self::$allowed_js_vars, true ) ) {
$js_vars[ $key ] = $value;
} else {
$config_vars[] = "$key: $value";
diff --git a/plugins/jetpack/modules/shortcodes/quiz.php b/plugins/jetpack/modules/shortcodes/quiz.php
index 1abfdd54..fa4ed960 100644
--- a/plugins/jetpack/modules/shortcodes/quiz.php
+++ b/plugins/jetpack/modules/shortcodes/quiz.php
@@ -1,4 +1,4 @@
-<?php
+<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileNam
/**
* Quiz shortcode.
*
@@ -78,12 +78,12 @@ class Quiz_Shortcode {
* @since 4.5.0
*/
private static function enqueue_scripts() {
- wp_enqueue_style( 'quiz', plugins_url( 'css/quiz.css', __FILE__ ) );
+ wp_enqueue_style( 'quiz', plugins_url( 'css/quiz.css', __FILE__ ), array(), JETPACK__VERSION );
wp_enqueue_script(
'quiz',
Jetpack::get_file_url_for_environment( '_inc/build/shortcodes/js/quiz.min.js', 'modules/shortcodes/js/quiz.js' ),
array( 'jquery' ),
- null,
+ JETPACK__VERSION,
true
);
}
@@ -101,10 +101,12 @@ class Quiz_Shortcode {
}
if ( is_feed() ) {
- return self::$javascript_unavailable = true;
+ self::$javascript_unavailable = true;
+ return self::$javascript_unavailable;
}
- return self::$javascript_unavailable = false;
+ self::$javascript_unavailable = false;
+ return self::$javascript_unavailable;
}
/**
@@ -146,19 +148,19 @@ class Quiz_Shortcode {
public static function shortcode( $atts, $content = null ) {
// There's nothing to do if there's nothing enclosed.
- if ( null == $content ) {
+ if ( empty( $content ) ) {
return '';
}
$id = '';
if ( self::is_javascript_unavailable() ) {
- // in an e-mail print the question and the info sentence once per question, too
+ // in an e-mail print the question and the info sentence once per question, too.
self::$noscript_info_printed = false;
} else {
if ( ! self::$scripts_enqueued ) {
- // lazy enqueue cannot use the wp_enqueue_scripts action anymore
+ // lazy enqueue cannot use the wp_enqueue_scripts action anymore.
self::enqueue_scripts();
self::$scripts_enqueued = true;
}
@@ -194,21 +196,22 @@ class Quiz_Shortcode {
*
* @since 4.5.0
*
- * @param string $content
+ * @param string $content Post content.
*
* @return mixed|string
*/
private static function do_shortcode( $content ) {
- // strip autoinserted line breaks
+ // strip autoinserted line breaks.
$content = preg_replace( '#(<(?:br /|/?p)>\n?)*(\[/?[a-z]+\])(<(?:br /|/?p)>\n?)*#', '$2', $content );
- // Add internal parameter so it's only rendered when it has it
+ // Add internal parameter so it's only rendered when it has it.
$content = preg_replace( '/\[(question|answer|wrong|explanation)\]/i', '[$1 quiz_item="true"]', $content );
$content = do_shortcode( $content );
$content = wp_kses(
$content,
array(
'tt' => array(),
+ 'a' => array( 'href' => true ),
'pre' => array(),
'strong' => array(),
'i' => array(),
@@ -231,8 +234,8 @@ class Quiz_Shortcode {
*
* @since 4.5.0
*
- * @param array $atts
- * @param null $content
+ * @param array $atts Shortcode attributes.
+ * @param null $content Post content.
*
* @return string
*/
@@ -247,8 +250,8 @@ class Quiz_Shortcode {
*
* @since 4.5.0
*
- * @param array $atts
- * @param null $content
+ * @param array $atts Shortcode attributes.
+ * @param null $content Post content.
*
* @return string
*/
@@ -267,8 +270,8 @@ class Quiz_Shortcode {
*
* @since 4.5.0
*
- * @param array $atts
- * @param null $content
+ * @param array $atts Shortcode attributes.
+ * @param null $content Post content.
*
* @return string
*/
@@ -287,8 +290,8 @@ class Quiz_Shortcode {
*
* @since 4.5.0
*
- * @param array $atts
- * @param null $content
+ * @param array $atts Shortcode attributes.
+ * @param null $content Post content.
*
* @return string
*/
diff --git a/plugins/jetpack/modules/shortcodes/sitemap.php b/plugins/jetpack/modules/shortcodes/sitemap.php
index 963f90ce..d26210f0 100644
--- a/plugins/jetpack/modules/shortcodes/sitemap.php
+++ b/plugins/jetpack/modules/shortcodes/sitemap.php
@@ -3,6 +3,8 @@
* Sitemap shortcode.
*
* Usage: [sitemap]
+ *
+ * @package Jetpack
*/
add_shortcode( 'sitemap', 'jetpack_sitemap_shortcode' );
diff --git a/plugins/jetpack/modules/shortcodes/slideshare.php b/plugins/jetpack/modules/shortcodes/slideshare.php
index 42258814..898ae57e 100644
--- a/plugins/jetpack/modules/shortcodes/slideshare.php
+++ b/plugins/jetpack/modules/shortcodes/slideshare.php
@@ -1,10 +1,5 @@
<?php
-
-// guarantee use of https
-wp_oembed_remove_provider( '#https?://(www\.)?slideshare\.net/.*#i' );
-wp_oembed_add_provider( '#https?://(www\.)?slideshare\.net/.*#i', 'https://www.slideshare.net/api/oembed/2', true );
-
-/*
+/**
* Slideshare shortcode format:
* Old style (still compatible): [slideshare id=5342235&doc=camprock-101002163655-phpapp01&w=300&h=200]
* New style: [slideshare id=5342235&w=300&h=200&fb=0&mw=0&mh=0&sc=no]
diff --git a/plugins/jetpack/modules/shortcodes/tweet.php b/plugins/jetpack/modules/shortcodes/tweet.php
index 95a3dcdd..5d6acd29 100644
--- a/plugins/jetpack/modules/shortcodes/tweet.php
+++ b/plugins/jetpack/modules/shortcodes/tweet.php
@@ -1,4 +1,4 @@
-<?php
+<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Tweet shortcode.
* Params map to key value pairs, and all but tweet are optional:
@@ -14,13 +14,23 @@
*
* More parameters and another tweet syntax admitted:
* [tweet tweet="https://twitter.com/jack/statuses/20" align="left" width="350" align="center" lang="es"]
+ *
+ * @package Jetpack
*/
add_shortcode( 'tweet', array( 'Jetpack_Tweet', 'jetpack_tweet_shortcode' ) );
+/**
+ * Tweet Shortcode class.
+ */
class Jetpack_Tweet {
- static $provider_args;
+ /**
+ * Array of arguments about a tweet.
+ *
+ * @var array
+ */
+ public static $provider_args;
/**
* Parse shortcode arguments and render its output.
@@ -32,6 +42,8 @@ class Jetpack_Tweet {
* @return string
*/
public static function jetpack_tweet_shortcode( $atts ) {
+ global $wp_embed;
+
$default_atts = array(
'tweet' => '',
'align' => 'none',
@@ -45,33 +57,152 @@ class Jetpack_Tweet {
self::$provider_args = $attr;
- // figure out the tweet id for the requested tweet
- // supporting both omitted attributes and tweet="tweet_id"
- // and supporting both an id and a URL
+ /*
+ * figure out the tweet id for the requested tweet
+ * supporting both omitted attributes and tweet="tweet_id"
+ * and supporting both an id and a URL
+ */
if ( empty( $attr['tweet'] ) && ! empty( $atts[0] ) ) {
$attr['tweet'] = $atts[0];
}
if ( ctype_digit( $attr['tweet'] ) ) {
- $id = 'https://twitter.com/jetpack/status/' . $attr['tweet'];
+ $id = 'https://twitter.com/jetpack/status/' . $attr['tweet'];
+ $tweet_id = intval( $attr['tweet'] );
} else {
preg_match( '/^http(s|):\/\/twitter\.com(\/\#\!\/|\/)([a-zA-Z0-9_]{1,20})\/status(es)*\/(\d+)$/', $attr['tweet'], $urlbits );
if ( isset( $urlbits[5] ) && intval( $urlbits[5] ) ) {
- $id = 'https://twitter.com/' . $urlbits[3] . '/status/' . intval( $urlbits[5] );
+ $id = 'https://twitter.com/' . $urlbits[3] . '/status/' . intval( $urlbits[5] );
+ $tweet_id = intval( $urlbits[5] );
} else {
return '<!-- Invalid tweet id -->';
}
}
- // Add shortcode arguments to provider URL
- add_filter( 'oembed_fetch_url', array( 'Jetpack_Tweet', 'jetpack_tweet_url_extra_args' ), 10, 3 );
+ /*
+ * Fetch tweet.
+ *
+ * On WordPress.com, we also cache tweets for better performance and less requests.
+ */
+ if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
+ /*
+ * See if we have the tweet stored in our tweet store
+ * if not get_tweet_store queues up a job to request
+ */
+ $data = get_tweet_store( $tweet_id );
+ if ( $data ) {
+ $tweet_handler = new Tweet_Handler();
+
+ /*
+ * Replace Unicode characters with ther entities like Blackbird Pie v 0.3.2 did
+ * to store tweets from other languages (important for non-english bloggers)
+ */
+ $data->text = $tweet_handler->unicode_replace_entities( $data->text );
+ $data->user->screen_name = $tweet_handler->unicode_replace_entities( $data->user->screen_name );
+ $data->user->name = $tweet_handler->unicode_replace_entities( $data->user->name );
+
+ $tweet = esc_html( $data->text );
+ $tweet = $tweet_handler->expand_tco_links( $tweet, $data );
+
+ $tweet = $tweet_handler->autolink( $tweet );
+
+ $screen_name = esc_html( $data->user->screen_name );
+ $name = esc_html( $data->user->name );
+
+ $url = 'https://twitter.com/' . $screen_name . '/status/' . intval( $data->id );
- // Fetch tweet
- $output = wp_oembed_get( $id, $atts );
+ // Only show the user's real name if they set it to something different from their screename.
+ if ( $screen_name !== $name ) {
+ $real_name = '<br />' . $name;
+ } else {
+ $real_name = '<br />&nbsp;';
+ }
- // Clean up filter
- remove_filter( 'oembed_fetch_url', array( 'Jetpack_Tweet', 'jetpack_tweet_url_extra_args' ), 10 );
+ $time = strtotime( $data->created_at );
+ $human_readable = date( 'F d, Y', $time );
+ $data_datetime = date( 'Y-m-d\TH:i:sP', $time );
+
+ /*
+ * Additional params.
+ */
+
+ // align (float).
+ $extra_classes = '';
+ if ( in_array( $attr['align'], array( 'left', 'right', 'center' ), true ) ) {
+ $extra_classes = ' tw-align-' . $attr['align'];
+ }
+
+ if ( 'true' === $attr['hide_thread'] ) {
+ $extra_classes .= ' tw-hide-thread';
+ }
+
+ if ( 'true' === $attr['hide_media'] ) {
+ $extra_classes .= ' tw-hide-media';
+ }
+
+ // lang.
+ $lang = substr( $attr['lang'], 0, 2 );
+ if ( empty( $lang ) ) {
+ $lang = 'en';
+ }
+
+ // width.
+ $width_html = '';
+ $width = intval( $attr['width'] );
+ if ( $width > 100 ) {
+ $width_html = ' width="' . esc_attr( $width ) . '"';
+ }
+
+ // in reply to id (conversation tweets).
+ $in_reply_to_html = '';
+ $in_reply_to = intval( $data->in_reply_to_status_id );
+ if ( ! empty( $in_reply_to ) && 'false' === $attr['hide_thread'] ) {
+ $in_reply_to_html = ' data-in-reply-to="' . esc_attr( $in_reply_to ) . '"';
+ }
+
+ // Generate the HTML output.
+ $output = sprintf(
+ '<blockquote class="twitter-tweet%1$s"%2$s%3$s lang="%4$s"><p>%5$s</p>&mdash; %6$s (@%7$s) <a href="%8$s" data-datetime="%9$s">%10$s</a></blockquote>',
+ esc_attr( $extra_classes ),
+ $width_html,
+ $in_reply_to_html,
+ esc_attr( $lang ),
+ $tweet,
+ wp_kses( $real_name, array( 'br' => array() ) ),
+ esc_html( $screen_name ),
+ esc_url( $url ),
+ esc_attr( $data_datetime ),
+ esc_html( $human_readable )
+ );
+ } else {
+ /**
+ * Filter the default display when a tweet is not available in the store.
+ * Not available in Jetpack.
+ *
+ * @module shortcodes
+ *
+ * @since 5.1.0
+ *
+ * @param string $message Default display when a tweet is not available.
+ * @param string $id Twitter URL.
+ * @param array $attr Shortcode attributes.
+ */
+ return apply_filters( 'tweet_shortcode_pending_tweet', '', $id, $attr );
+ }
+ } else {
+ // Add shortcode arguments to provider URL.
+ add_filter( 'oembed_fetch_url', array( 'Jetpack_Tweet', 'jetpack_tweet_url_extra_args' ), 10, 3 );
+
+ /*
+ * In Jetpack, we use $wp_embed->shortcode() to return the tweet output.
+ * @see https://github.com/Automattic/jetpack/pull/11173
+ */
+ $output = $wp_embed->shortcode( $atts, $id );
+
+ // Clean up filter.
+ remove_filter( 'oembed_fetch_url', array( 'Jetpack_Tweet', 'jetpack_tweet_url_extra_args' ), 10 );
+ }
// Add Twitter widgets.js script to the footer.
add_action( 'wp_footer', array( 'Jetpack_Tweet', 'jetpack_tweet_shortcode_script' ) );
@@ -89,11 +220,11 @@ class Jetpack_Tweet {
*
* @param string $provider URL of provider that supplies the tweet we're requesting.
* @param string $url URL of tweet to embed.
- * @param array $args Parameters supplied to shortcode and passed to wp_oembed_get
+ * @param array $args Parameters supplied to shortcode and passed to wp_oembed_get.
*
* @return string
*/
- public static function jetpack_tweet_url_extra_args( $provider, $url, $args = array() ) {
+ public static function jetpack_tweet_url_extra_args( $provider, $url, $args = array() ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
foreach ( self::$provider_args as $key => $value ) {
switch ( $key ) {
case 'align':
@@ -105,10 +236,10 @@ class Jetpack_Tweet {
}
}
- // Disable script since we're enqueing it in our own way in the footer
+ // Disable script since we're enqueing it in our own way in the footer.
$provider = add_query_arg( 'omit_script', 'true', $provider );
- // Twitter doesn't support maxheight so don't send it
+ // Twitter doesn't support maxheight so don't send it.
$provider = remove_query_arg( 'maxheight', $provider );
/**
@@ -122,7 +253,7 @@ class Jetpack_Tweet {
*/
$partner = apply_filters( 'jetpack_twitter_partner_id', 'jetpack' );
- // Add Twitter partner ID to track embeds from Jetpack
+ // Add Twitter partner ID to track embeds from Jetpack.
if ( ! empty( $partner ) ) {
$provider = add_query_arg( 'partner', $partner, $provider );
}
diff --git a/plugins/jetpack/modules/shortcodes/unavailable.php b/plugins/jetpack/modules/shortcodes/unavailable.php
index 4d31c5b9..9a6bb201 100644
--- a/plugins/jetpack/modules/shortcodes/unavailable.php
+++ b/plugins/jetpack/modules/shortcodes/unavailable.php
@@ -1,4 +1,10 @@
-<?php
+<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+/**
+ * Display a message on the frontend when we retire a shortcode,
+ * explaining why the shortcode is not available anymore.
+ *
+ * @package Jetpack
+ */
/**
* Class Jetpack_Shortcode_Unavailable
@@ -20,7 +26,7 @@ class Jetpack_Shortcode_Unavailable {
* already claimed them, add a handler to nullify their output.
*/
public function add_shortcodes() {
- foreach ( $this->shortcodes as $shortcode => $message ) {
+ foreach ( array_keys( $this->shortcodes ) as $shortcode ) {
if ( ! shortcode_exists( $shortcode ) ) {
add_shortcode( $shortcode, array( $this, 'stub_shortcode' ) );
}
@@ -31,9 +37,10 @@ class Jetpack_Shortcode_Unavailable {
* Nullify the output of unavailable shortcodes. Includes a filter to make
* it easier to notify admins that a shortcode that they used is unavailable.
*
- * @param $atts
- * @param string $content
- * @param string $shortcode
+ * @param array $atts Shortcode attributes.
+ * @param string $content Post content.
+ * @param string $shortcode Shortcode name.
+ *
* @return mixed|void
*/
public function stub_shortcode( $atts, $content = '', $shortcode = '' ) {
@@ -57,8 +64,15 @@ class Jetpack_Shortcode_Unavailable {
}
}
-new Jetpack_Shortcode_Unavailable(
- array(
- 'blip.tv' => __( 'The Blip.tv service has been shut down since August 20th, 2015.', 'jetpack' ),
- )
-);
+/**
+ * Init class.
+ */
+function jetpack_init_shortcode_unavailable() {
+ new Jetpack_Shortcode_Unavailable(
+ array(
+ 'blip.tv' => __( 'The Blip.tv service has been shut down since August 20th, 2015.', 'jetpack' ),
+ 'lytro' => __( 'Lytro has been shut down since March 2019.', 'jetpack' ),
+ )
+ );
+}
+add_action( 'init', 'jetpack_init_shortcode_unavailable' );
diff --git a/plugins/jetpack/modules/shortcodes/ustream.php b/plugins/jetpack/modules/shortcodes/ustream.php
index f4d0c62e..0ab664c1 100644
--- a/plugins/jetpack/modules/shortcodes/ustream.php
+++ b/plugins/jetpack/modules/shortcodes/ustream.php
@@ -1,7 +1,6 @@
<?php
-
/**
- * ustream.tv shortcode
+ * Ustream.tv shortcode
*
* Example:
* [ustream id=1524 live=1]
@@ -9,6 +8,8 @@
*
* Embed code example, from http://www.ustream.tv/leolaporte
* <iframe src="http://www.ustream.tv/embed/recorded/1524?v=3&#038;wmode=direct" width="480" height="296" scrolling="no" frameborder="0" style="border: 0 none transparent;"></iframe>
+ *
+ * @package Jetpack
*/
add_shortcode( 'ustream', 'ustream_shortcode' );
@@ -19,7 +20,7 @@ add_shortcode( 'ustreamsocial', 'ustreamsocial_shortcode' );
*
* @since 4.5.0
*
- * @param $atts array of user-supplied arguments.
+ * @param array $atts array of user-supplied arguments.
*
* @return string HTML output.
*/
@@ -37,52 +38,59 @@ function ustream_shortcode( $atts ) {
'version' => 3,
'hwaccel' => 1,
);
+ $atts = array_map( 'intval', shortcode_atts( $defaults, $atts ) );
- $atts = array_map( 'intval', shortcode_atts( $defaults, $atts ) );
-
- $ustream_id = $atts['id'];
- $width = $atts['width'];
- $height = $atts['height'];
- $live = $atts['live'];
- $highlight = $atts['highlight'];
- $version = $atts['version'];
- $hwaccel = $atts['hwaccel'];
-
- $version = 'v=' . esc_attr( $version );
-
- if ( 0 >= $ustream_id ) {
+ if ( 0 >= $atts['id'] ) {
return '<!-- ustream error: bad video ID -->';
}
- if ( 0 >= $height ) {
+ if ( 0 >= $atts['height'] ) {
return '<!-- ustream error: height invalid -->';
}
- if ( 0 >= $width ) {
+ if ( 0 >= $atts['width'] ) {
return '<!-- ustream error: width invalid -->';
}
- if ( $live ) {
+ if ( $atts['live'] ) {
$recorded = '';
} else {
$recorded = 'recorded/';
}
- if ( ! $live && ( 0 < $highlight ) ) {
- $highlight = "/highlight/$highlight";
+ if ( ! $atts['live'] && ( 0 < $atts['highlight'] ) ) {
+ $highlight = sprintf( '/highlight/%d', esc_attr( $atts['highlight'] ) );
} else {
$highlight = '';
}
- if ( 0 < $hwaccel ) {
- $wmode = '&amp;wmode=direct';
- } else {
- $wmode = '';
+ $url_base = sprintf(
+ 'https://www.ustream.tv/embed/%s%d%s',
+ $recorded,
+ esc_attr( $atts['id'] ),
+ $highlight
+ );
+
+ $video_options = array(
+ 'html5ui' => 1,
+ 'v' => absint( $atts['version'] ),
+ );
+
+ if ( 0 < $atts['hwaccel'] ) {
+ $video_options['wmode'] = 'direct';
}
- $url = 'http://www.ustream.tv/embed/' . $recorded . esc_attr( $ustream_id ) . $highlight . '?' . $version . $wmode;
- $url = set_url_scheme( $url );
- $output = '<iframe src="' . esc_url( $url ) . '" width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '" scrolling="no" style="border: 0 none transparent;"></iframe>';
+ $url = add_query_arg(
+ $video_options,
+ $url_base
+ );
+
+ $output = sprintf(
+ '<iframe src="%1$s" width="%2$d" height="%3$d" scrolling="no" style="border: 0 none transparent;"></iframe>',
+ esc_url( $url ),
+ absint( $atts['width'] ),
+ absint( $atts['height'] )
+ );
return $output;
}
@@ -92,7 +100,7 @@ function ustream_shortcode( $atts ) {
*
* @since 4.5.0
*
- * @param $atts array of user-supplied arguments.
+ * @param array $atts array of user-supplied arguments.
*
* @return string HTML output.
*/
@@ -102,26 +110,26 @@ function ustreamsocial_shortcode( $atts ) {
'height' => 420,
'width' => 320,
);
+ $atts = array_map( 'intval', shortcode_atts( $defaults, $atts ) );
- $atts = array_map( 'intval', shortcode_atts( $defaults, $atts ) );
-
- $ustream_id = $atts['id'];
- $width = $atts['width'];
- $height = $atts['height'];
-
- if ( 0 >= $ustream_id ) {
+ if ( 0 >= $atts['id'] ) {
return '<!-- ustreamsocial error: bad social stream ID -->';
}
- if ( 0 >= $height ) {
+ if ( 0 >= $atts['height'] ) {
return '<!-- ustreamsocial error: height invalid -->';
}
- if ( 0 >= $width ) {
+ if ( 0 >= $atts['width'] ) {
return '<!-- ustreamsocial error: width invalid -->';
}
- $url = set_url_scheme( "http://www.ustream.tv/socialstream/$ustream_id" );
+ $url = 'https://www.ustream.tv/socialstream/' . esc_attr( $atts['id'] );
- return '<iframe id="SocialStream" class="" name="SocialStream" width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '" scrolling="no" allowtransparency="true" src="' . esc_url( $url ) . '" style="visibility: visible; margin-top: 0; margin-bottom: 0; border: 0;"></iframe>';
+ return sprintf(
+ '<iframe id="SocialStream" src="%1$s" class="" name="SocialStream" width="%2$d" height="%3$d" scrolling="no" allowtransparency="true" style="visibility: visible; margin-top: 0; margin-bottom: 0; border: 0;"></iframe>',
+ esc_url( $url ),
+ absint( $atts['width'] ),
+ absint( $atts['height'] )
+ );
}
diff --git a/plugins/jetpack/modules/shortcodes/wordads.php b/plugins/jetpack/modules/shortcodes/wordads.php
index 86d6b70c..bca6c48a 100644
--- a/plugins/jetpack/modules/shortcodes/wordads.php
+++ b/plugins/jetpack/modules/shortcodes/wordads.php
@@ -20,6 +20,7 @@ class Jetpack_WordAds_Shortcode {
if ( empty( $wordads ) ) {
return null;
}
+
add_shortcode( 'wordads', array( $this, 'wordads_shortcode' ) );
}
@@ -53,10 +54,7 @@ class Jetpack_WordAds_Shortcode {
return '<div>' . __( 'The WordAds module is not active', 'jetpack' ) . '</div>';
}
- $html = '<div class="jetpack-wordad" itemscope itemtype="https://schema.org/WPAdBlock">';
-
- $html .= '</div>';
-
+ $html = '<div class="jetpack-wordad" itemscope itemtype="https://schema.org/WPAdBlock"></div>';
$html = $wordads->insert_inline_ad( $html );
return $html;
diff --git a/plugins/jetpack/modules/shortcodes/youtube.php b/plugins/jetpack/modules/shortcodes/youtube.php
index 79af6f94..048eb09b 100644
--- a/plugins/jetpack/modules/shortcodes/youtube.php
+++ b/plugins/jetpack/modules/shortcodes/youtube.php
@@ -32,7 +32,7 @@ function youtube_embed_to_short_code( $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 = '!<object(.*?)>.*?<param\s+name=[\'"]movie[\'"]\s+value=[\'"](https?:)?//www\.youtube\.com/v/([^\'"]+)[\'"].*?>.*?</object>!i';
$regexp_ent = htmlspecialchars( $regexp, ENT_NOQUOTES );
$old_regexp = '!<embed(?:\s+\w+="[^"]*")*\s+src="https?(?:\:|&#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 ) );
@@ -55,10 +55,10 @@ function youtube_embed_to_short_code( $content ) {
// <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', 'regexp', 'regexp_ent' ) ) ) {
$params = $match[1];
- if ( 'ifr_regexp_ent' == $reg ) {
+ if ( in_array( $reg, array( 'ifr_regexp_ent', 'regexp_ent' ) ) ) {
$params = html_entity_decode( $params );
}