twitter_timeline_shortcode

The Jetpack by WordPress.com twitter timeline shortcode function.

Description

twitter_timeline_shortcode( $attr ); 

Parameters (1)

0. $attr
The attr.

Usage

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

Defined (1)

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

/modules/shortcodes/twitter-timeline.php  
  1. function twitter_timeline_shortcode( $attr ) { 
  2.  
  3. $default_atts = array( 
  4. 'username' => '',  
  5. 'id' => '',  
  6. 'height' => 282,  
  7. 'width' => 450,  
  8.  
  9. ); 
  10.  
  11. $attr = shortcode_atts( $default_atts, $attr, 'twitter-timeline' ); 
  12.  
  13. if ( $attr['username'] != preg_replace( '/[^A-Za-z0-9_]+/', '', $attr['username'] ) ) 
  14. return '<!--' . __( 'Invalid username', jetpack ) . '-->'; 
  15.  
  16. if ( ! is_numeric( $attr['id'] ) ) 
  17. return '<!--' . __( 'Invalid id', jetpack ) . '-->'; 
  18.  
  19. $tweets_by = sprintf( __( 'Tweets by @%s', jetpack ), $attr['username'] ); 
  20. $output = '<a class="twitter-timeline" width="' . (int)$attr['width'] . '" height="' . (int)$attr['height'] . '" href="' . esc_url( 'https://twitter.com/'. $attr['username'] ) . '" data-widget-id="' . esc_attr( $attr['id'] ) . '">' . esc_html( $tweets_by ) . '</a>'; 
  21. add_action( 'wp_footer', 'twitter_timeline_js' ); 
  22.  
  23. return $output;