twitter_timeline_shortcode

The WordPress Core twitter timeline shortcode function.

Description

twitter_timeline_shortcode( $atts ); 

Parameters (1)

0. $atts
The atts.

Usage

  1. if ( !function_exists( 'twitter_timeline_shortcode' ) ) { 
  2. require_once '/modules/shortcodes/twitter-timeline.php'; 
  3.  
  4. // The atts. 
  5. $atts = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = twitter_timeline_shortcode($atts); 
  9.  

Defined (1)

The function is defined in the following location(s).

/modules/shortcodes/twitter-timeline.php  
  1. function twitter_timeline_shortcode( $atts ) { 
  2. $default_atts = array( 
  3. 'username' => '',  
  4. 'id' => '',  
  5. 'width' => '450',  
  6. 'height' => '282',  
  7. ); 
  8.  
  9. $atts = shortcode_atts( $default_atts, $atts, 'twitter-timeline' ); 
  10.  
  11. $atts['username'] = preg_replace( '/[^A-Za-z0-9_]+/', '', $atts['username'] ); 
  12.  
  13. if ( empty( $atts['username'] ) && ! is_numeric( $atts['id'] ) ) { 
  14. return '<!-- ' . __( 'Must specify Twitter Timeline id or username.', 'jetpack' ) . ' -->'; 
  15.  
  16. $output = '<a class="twitter-timeline"'; 
  17.  
  18. /** This filter is documented in modules/shortcodes/tweet.php */ 
  19. $partner = apply_filters( 'jetpack_twitter_partner_id', 'jetpack' ); 
  20. if ( ! empty( $partner ) ) { 
  21. $output .= ' data-partner="' . esc_attr( $partner ) . '"'; 
  22. if ( is_numeric( $atts['width'] ) ) { 
  23. $output .= ' data-width="' . esc_attr( $atts['width'] ) . '"'; 
  24. if ( is_numeric( $atts['height'] ) ) { 
  25. $output .= ' data-height="' . esc_attr( $atts['height'] ) . '"'; 
  26. if ( is_numeric( $atts['id'] ) ) { 
  27. $output .= ' data-widget-id="' . esc_attr( $atts['id'] ) . '"'; 
  28. if ( ! empty( $atts['username'] ) ) { 
  29. $output .= ' href="' . esc_url( 'https://twitter.com/' . $atts['username'] ) . '"'; 
  30.  
  31. $output .= '>'; 
  32.  
  33. $output .= sprintf( __( 'Tweets by @%s', 'jetpack' ), $atts['username'] ); 
  34.  
  35. $output .= '</a>'; 
  36.  
  37. wp_enqueue_script( 'jetpack-twitter-timeline' ); 
  38.  
  39. return $output;