summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/shortcodes/tweet.php')
-rw-r--r--plugins/jetpack/modules/shortcodes/tweet.php17
1 files changed, 14 insertions, 3 deletions
diff --git a/plugins/jetpack/modules/shortcodes/tweet.php b/plugins/jetpack/modules/shortcodes/tweet.php
index 5d6acd29..435195b6 100644
--- a/plugins/jetpack/modules/shortcodes/tweet.php
+++ b/plugins/jetpack/modules/shortcodes/tweet.php
@@ -204,12 +204,23 @@ class Jetpack_Tweet {
remove_filter( 'oembed_fetch_url', array( 'Jetpack_Tweet', 'jetpack_tweet_url_extra_args' ), 10 );
}
- // Add Twitter widgets.js script to the footer.
- add_action( 'wp_footer', array( 'Jetpack_Tweet', 'jetpack_tweet_shortcode_script' ) );
-
/** This action is documented in modules/widgets/social-media-icons.php */
do_action( 'jetpack_bump_stats_extras', 'embeds', 'tweet' );
+ if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
+ $width = ! empty( $attr['width'] ) ? $attr['width'] : 600;
+ $height = 480;
+ $output = sprintf(
+ '<amp-twitter data-tweetid="%1$s" layout="responsive" width="%2$d" height="%3$d"></amp-twitter>',
+ esc_attr( $tweet_id ),
+ absint( $width ),
+ absint( $height )
+ );
+ } else {
+ // Add Twitter widgets.js script to the footer.
+ add_action( 'wp_footer', array( 'Jetpack_Tweet', 'jetpack_tweet_shortcode_script' ) );
+ }
+
return $output;
}