css
2 years ago
images
2 years ago
img
2 years ago
js
2 years ago
archiveorg-book.php
5 years ago
archiveorg.php
5 years ago
archives.php
5 years ago
bandcamp.php
3 years ago
brightcove.php
5 years ago
cartodb.php
5 years ago
class.filter-embedded-html-objects.php
2 years ago
codepen.php
5 years ago
crowdsignal.php
2 years ago
dailymotion.php
3 years ago
descript.php
4 years ago
facebook.php
2 years ago
flatio.php
5 years ago
flickr.php
2 years ago
getty.php
2 years ago
gist.php
3 years ago
googleapps.php
2 years ago
googlemaps.php
2 years ago
googleplus.php
5 years ago
gravatar.php
2 years ago
houzz.php
5 years ago
inline-pdfs.php
4 years ago
instagram.php
3 years ago
kickstarter.php
3 years ago
mailchimp.php
3 years ago
medium.php
3 years ago
mixcloud.php
2 years ago
others.php
2 years ago
pinterest.php
2 years ago
presentations.php
2 years ago
quiz.php
4 years ago
recipe.php
2 years ago
scribd.php
5 years ago
sitemap.php
5 years ago
slideshare.php
5 years ago
slideshow.php
2 years ago
smartframe.php
3 years ago
soundcloud.php
3 years ago
spotify.php
2 years ago
ted.php
5 years ago
tweet.php
2 years ago
twitchtv.php
5 years ago
twitter-timeline.php
5 years ago
unavailable.php
3 years ago
untappd-menu.php
3 years ago
upcoming-events.php
3 years ago
ustream.php
5 years ago
videopress.php
4 years ago
vimeo.php
2 years ago
vine.php
5 years ago
vr.php
2 years ago
wordads.php
5 years ago
wufoo.php
3 years ago
youtube.php
1 year ago
twitter-timeline.php
77 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Twitter Timeline Shortcode. |
| 4 | * |
| 5 | * Examples: |
| 6 | * [twitter-timeline username=jetpack] |
| 7 | * |
| 8 | * @package automattic/jetpack |
| 9 | */ |
| 10 | |
| 11 | /** |
| 12 | * Render the Twitter shortcode. |
| 13 | * |
| 14 | * @param array $atts Shortcode attributes. |
| 15 | */ |
| 16 | function twitter_timeline_shortcode( $atts ) { |
| 17 | $default_atts = array( |
| 18 | 'username' => '', |
| 19 | 'id' => '', |
| 20 | 'width' => '450', |
| 21 | 'height' => '282', |
| 22 | ); |
| 23 | |
| 24 | $atts = shortcode_atts( $default_atts, $atts, 'twitter-timeline' ); |
| 25 | |
| 26 | $atts['username'] = preg_replace( '/[^A-Za-z0-9_]+/', '', $atts['username'] ); |
| 27 | |
| 28 | if ( empty( $atts['username'] ) && ! is_numeric( $atts['id'] ) ) { |
| 29 | return '<!-- ' . __( 'Must specify Twitter Timeline id or username.', 'jetpack' ) . ' -->'; |
| 30 | } |
| 31 | |
| 32 | $output = '<a class="twitter-timeline"'; |
| 33 | |
| 34 | /** This filter is documented in modules/shortcodes/tweet.php */ |
| 35 | $partner = apply_filters( 'jetpack_twitter_partner_id', 'jetpack' ); |
| 36 | if ( ! empty( $partner ) ) { |
| 37 | $output .= ' data-partner="' . esc_attr( $partner ) . '"'; |
| 38 | } |
| 39 | if ( is_numeric( $atts['width'] ) ) { |
| 40 | $output .= ' data-width="' . esc_attr( $atts['width'] ) . '"'; |
| 41 | } |
| 42 | if ( is_numeric( $atts['height'] ) ) { |
| 43 | $output .= ' data-height="' . esc_attr( $atts['height'] ) . '"'; |
| 44 | } |
| 45 | if ( is_numeric( $atts['id'] ) ) { |
| 46 | $output .= ' data-widget-id="' . esc_attr( $atts['id'] ) . '"'; |
| 47 | } |
| 48 | if ( ! empty( $atts['username'] ) ) { |
| 49 | $output .= ' href="' . esc_url( 'https://twitter.com/' . $atts['username'] ) . '"'; |
| 50 | } |
| 51 | |
| 52 | $output .= '>'; |
| 53 | |
| 54 | $output .= sprintf( |
| 55 | /* Translators: placeholder is a Twitter username. */ |
| 56 | __( 'Tweets by @%s', 'jetpack' ), |
| 57 | $atts['username'] |
| 58 | ); |
| 59 | |
| 60 | $output .= '</a>'; |
| 61 | |
| 62 | wp_enqueue_script( 'jetpack-twitter-timeline' ); |
| 63 | |
| 64 | return $output; |
| 65 | } |
| 66 | add_shortcode( 'twitter-timeline', 'twitter_timeline_shortcode' ); |
| 67 | |
| 68 | /** |
| 69 | * Enqueue the js used by the Twitter shortcode. |
| 70 | */ |
| 71 | function twitter_timeline_js() { |
| 72 | if ( is_customize_preview() ) { |
| 73 | wp_enqueue_script( 'jetpack-twitter-timeline' ); |
| 74 | } |
| 75 | } |
| 76 | add_action( 'wp_enqueue_scripts', 'twitter_timeline_js' ); |
| 77 |