Skip to content

Commit

Permalink
Move the 'wp_footer' hook to an else block
Browse files Browse the repository at this point in the history
As Jeremy mentioned,
this should not run for AMP endpoints.
  • Loading branch information
kienstra committed Nov 19, 2019
1 parent 46a25ca commit 37c1df7
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions modules/shortcodes/tweet.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,6 @@ public static function jetpack_tweet_shortcode( $atts ) {
}
}

if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
$width = ! empty( $attr['width'] ) ? $attr['width'] : 600;
$height = 480;
return 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 )
);
}

/*
* Fetch tweet.
*
Expand Down Expand Up @@ -215,12 +204,23 @@ public static function jetpack_tweet_shortcode( $atts ) {
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;
}

Expand Down

0 comments on commit 37c1df7

Please sign in to comment.