Widgets */ add_action( 'widgets_init', 'jetpack_twitter_timeline_widget_init' ); function jetpack_twitter_timeline_widget_init() { register_widget( 'Jetpack_Twitter_Timeline_Widget' ); } class Jetpack_Twitter_Timeline_Widget extends WP_Widget { /** * Register widget with WordPress. */ public function __construct() { parent::__construct( 'twitter_timeline', apply_filters( 'jetpack_widget_name', esc_html__( 'Twitter Timeline', 'jetpack' ) ), array( 'classname' => 'widget_twitter_timeline', 'description' => __( 'Display an official Twitter Embedded Timeline widget.', 'jetpack' ) ) ); if ( is_active_widget( false, false, $this->id_base ) || is_active_widget( false, false, 'monster' ) ) { wp_enqueue_script( 'twitter-widgets', '//platform.twitter.com/widgets.js', '', '', true ); } } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget( $args, $instance ) { $instance['lang'] = substr( strtoupper( get_locale() ), 0, 2 ); echo $args['before_widget']; if ( $instance['title'] ) echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title']; $data_attribs = array( 'widget-id', 'theme', 'link-color', 'border-color', 'chrome' ); $attribs = array( 'width', 'height', 'lang' ); // Start tag output echo '' . esc_html__( 'My Tweets', 'jetpack' ) . ''; // End tag output echo $args['after_widget']; do_action( 'jetpack_bump_stats_extras', 'widget', 'twitter_timeline' ); } /** * Sanitize widget form values as they are saved. * * @see WP_Widget::update() * * @param array $new_instance Values just sent to be saved. * @param array $old_instance Previously saved values from database. * * @return array Updated safe values to be saved. */ public function update( $new_instance, $old_instance ) { $non_hex_regex = '/[^a-f0-9]/'; $instance = array(); $instance['title'] = sanitize_text_field( $new_instance['title'] ); $instance['width'] = (int) $new_instance['width']; $instance['height'] = (int) $new_instance['height']; $instance['width'] = ( 0 !== (int) $instance['width'] ) ? (int) $instance['width'] : 225; $instance['height'] = ( 0 !== (int) $instance['height'] ) ? (int) $instance['height'] : 400; // If they entered something that might be a full URL, try to parse it out if ( is_string( $new_instance['widget-id'] ) ) { if ( preg_match( '#https?://twitter\.com/settings/widgets/(\d+)#s', $new_instance['widget-id'], $matches ) ) { $new_instance['widget-id'] = $matches[1]; } } $instance['widget-id'] = sanitize_text_field( $new_instance['widget-id'] ); $instance['widget-id'] = is_numeric( $instance['widget-id'] ) ? $instance['widget-id'] : ''; foreach ( array( 'link-color', 'border-color' ) as $color ) { $clean = preg_replace( $non_hex_regex, '', sanitize_text_field( $new_instance[$color] ) ); if ( $clean ) $instance[$color] = '#' . $clean; } $instance['theme'] = 'light'; if ( in_array( $new_instance['theme'], array( 'light', 'dark' ) ) ) $instance['theme'] = $new_instance['theme']; $instance['chrome'] = array(); if ( isset( $new_instance['chrome'] ) ) { foreach ( $new_instance['chrome'] as $chrome ) { if ( in_array( $chrome, array( 'noheader', 'nofooter', 'noborders', 'noscrollbar', 'transparent' ) ) ) { $instance['chrome'][] = $chrome; } } } return $instance; } /** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. */ public function form( $instance ) { $defaults = array( 'title' => esc_html__( 'Follow me on Twitter', 'jetpack' ), 'width' => '', 'height' => '400', 'widget-id' => '', 'link-color' => '#f96e5b', 'border-color' => '#e8e8e8', 'theme' => 'light', 'chrome' => array(), ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

create a widget at Twitter.com, and then enter your widget id (the long number found in the URL of your widget\'s config page) in the field below. Read more.', 'jetpack' ), 'https://twitter.com/settings/widgets/new/user', 'http://support.wordpress.com/widgets/twitter-timeline-widget/' ) ); ?>


id="get_field_id( 'chrome-noheader' ); ?>" name="get_field_name( 'chrome' ); ?>[]" value="noheader" />
id="get_field_id( 'chrome-nofooter' ); ?>" name="get_field_name( 'chrome' ); ?>[]" value="nofooter" />
id="get_field_id( 'chrome-noborders' ); ?>" name="get_field_name( 'chrome' ); ?>[]" value="noborders" />
id="get_field_id( 'chrome-noscrollbar' ); ?>" name="get_field_name( 'chrome' ); ?>[]" value="noscrollbar" />
id="get_field_id( 'chrome-transparent' ); ?>" name="get_field_name( 'chrome' ); ?>[]" value="transparent" />