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