From 9c55d41efbd6f62e5fd15b0f403e2d860dffb3c9 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Wed, 8 Jun 2016 13:02:59 +0000 Subject: [PATCH 1/6] Shortcodes: Google Plus: Use script enqueuing for plusone API script Fixes issue where embed scripts would not be included in `/sites/%s/embeds/render` endpoint since the endpoint logic assumes any dependent scripts are enqueued. Merges r136943-wpcom. --- modules/shortcodes/googleplus.php | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/modules/shortcodes/googleplus.php b/modules/shortcodes/googleplus.php index 759d9b6257a04..134246e08ce8d 100644 --- a/modules/shortcodes/googleplus.php +++ b/modules/shortcodes/googleplus.php @@ -11,22 +11,10 @@ wp_embed_register_handler( 'googleplus', JETPACK_GOOGLEPLUS_EMBED_REGEX, 'jetpack_googleplus_embed_handler' ); function jetpack_googleplus_embed_handler( $matches, $attr, $url ) { - static $did_script; - - if ( ! $did_script ) { - $did_script = true; - add_action( 'wp_footer', 'jetpack_googleplus_add_script' ); - } - + wp_enqueue_script( 'jetpack-gplus-api', 'https://apis.google.com/js/plusone.js', array(), null, true ); return sprintf( '
', esc_url( $url ) ); } -function jetpack_googleplus_add_script() { - ?> - - Date: Thu, 26 May 2016 15:01:19 +0000 Subject: [PATCH 2/6] Slideshare: Apply a filter to the shortcode so it can be... filtered Merges r136446-wpcom. --- modules/shortcodes/slideshare.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/shortcodes/slideshare.php b/modules/shortcodes/slideshare.php index f2278935ad4e6..852d6e6099f89 100644 --- a/modules/shortcodes/slideshare.php +++ b/modules/shortcodes/slideshare.php @@ -111,5 +111,10 @@ function slideshare_shortcode( $atts ) { $player .= ' allowfullscreen webkitallowfullscreen mozallowfullscreen>'; - return $player; + /** + * Filter the returned shortcode. + * + * @param string $player The iframe to return. + */ + return apply_filters( 'slideshare_shortcode', $player ); } \ No newline at end of file From 5f6a9a127e65b2c5f940a38da45b89b6b89ef79c Mon Sep 17 00:00:00 2001 From: George Stephanis Date: Mon, 20 Feb 2017 15:11:32 -0500 Subject: [PATCH 3/6] Add documentation for the new shortcode. --- modules/shortcodes/slideshare.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/shortcodes/slideshare.php b/modules/shortcodes/slideshare.php index 852d6e6099f89..970ad14231b7b 100644 --- a/modules/shortcodes/slideshare.php +++ b/modules/shortcodes/slideshare.php @@ -114,6 +114,9 @@ function slideshare_shortcode( $atts ) { /** * Filter the returned shortcode. * + * @module shortcodes + * @since 4.8.0 + * * @param string $player The iframe to return. */ return apply_filters( 'slideshare_shortcode', $player ); From 320fea64f01cf2a00829c803eda799c06954f45b Mon Sep 17 00:00:00 2001 From: George Stephanis Date: Mon, 20 Feb 2017 15:12:29 -0500 Subject: [PATCH 4/6] Rename the shortcode to prefix, and add $atts When merging to WPCOM, be careful of responsive-videos.php which over there uses this filter. It is the only code to use it, though, that I could find. --- modules/shortcodes/slideshare.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/shortcodes/slideshare.php b/modules/shortcodes/slideshare.php index 970ad14231b7b..efe6c88b6d9d9 100644 --- a/modules/shortcodes/slideshare.php +++ b/modules/shortcodes/slideshare.php @@ -119,5 +119,5 @@ function slideshare_shortcode( $atts ) { * * @param string $player The iframe to return. */ - return apply_filters( 'slideshare_shortcode', $player ); -} \ No newline at end of file + return apply_filters( 'jetpack_slideshare_shortcode', $player, $atts ); +} From a6c12d31e613a9894f714f380512454fdd1ec151 Mon Sep 17 00:00:00 2001 From: George Stephanis Date: Mon, 20 Feb 2017 15:20:36 -0500 Subject: [PATCH 5/6] Some tidying up of the docblock. Thanks, @dereksmart! --- modules/shortcodes/slideshare.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/shortcodes/slideshare.php b/modules/shortcodes/slideshare.php index efe6c88b6d9d9..b457bca16da9c 100644 --- a/modules/shortcodes/slideshare.php +++ b/modules/shortcodes/slideshare.php @@ -115,9 +115,10 @@ function slideshare_shortcode( $atts ) { * Filter the returned shortcode. * * @module shortcodes - * @since 4.8.0 + * @since 4.7.0 * * @param string $player The iframe to return. + * @param array $atts The attributes specified in the shortcode. */ return apply_filters( 'jetpack_slideshare_shortcode', $player, $atts ); } From c73f25a8cd4602e93b7429ece7c6b1aee2d53bb6 Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Mon, 20 Feb 2017 22:21:06 +0100 Subject: [PATCH 6/6] SlideShare Shortcode: update docblock to avoid phpcs warnings. --- modules/shortcodes/slideshare.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/shortcodes/slideshare.php b/modules/shortcodes/slideshare.php index b457bca16da9c..72c94237559e9 100644 --- a/modules/shortcodes/slideshare.php +++ b/modules/shortcodes/slideshare.php @@ -112,13 +112,14 @@ function slideshare_shortcode( $atts ) { $player .= ' allowfullscreen webkitallowfullscreen mozallowfullscreen>'; /** - * Filter the returned shortcode. + * Filter the returned SlideShare shortcode. * * @module shortcodes + * * @since 4.7.0 * * @param string $player The iframe to return. - * @param array $atts The attributes specified in the shortcode. + * @param array $atts The attributes specified in the shortcode. */ return apply_filters( 'jetpack_slideshare_shortcode', $player, $atts ); }