'',
'align' => 'none',
'width' => '',
'lang' => 'en',
'hide_thread' => 'false',
'hide_media' => 'false',
);
$attr = shortcode_atts( $default_atts, $atts );
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
*/
if ( empty( $attr['tweet'] ) && ! empty( $atts[0] ) ) {
$attr['tweet'] = $atts[0];
}
if ( ctype_digit( $attr['tweet'] ) ) {
$id = 'https://twitter.com/jetpack/status/' . $attr['tweet'];
$tweet_id = (int) $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] ) && (int) $urlbits[5] ) {
$id = 'https://twitter.com/' . $urlbits[3] . '/status/' . (int) $urlbits[5];
$tweet_id = (int) $urlbits[5];
} else {
return '';
}
}
// 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 );
/** 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(
'