From 38090730db1c445b94adef28c4ccd27ffe9df1b1 Mon Sep 17 00:00:00 2001
From: Jared
Date: Tue, 23 Jul 2013 10:35:52 -0400
Subject: [PATCH] Added twitter timeline widget
---
changelog.txt | 5 +
functions.php | 2 +-
.../espresso-widget-twitter-timeline.php | 218 ++++++++++++++++++
.../grinder/beans/espresso-widget-twitter.php | 12 +-
style.css | 2 +-
5 files changed, 230 insertions(+), 9 deletions(-)
create mode 100644 hopper/grinder/beans/espresso-widget-twitter-timeline.php
diff --git a/changelog.txt b/changelog.txt
index 6550e56..603067a 100755
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,6 +1,11 @@
Espresso Change Log
This will hopefully allow for some basic transparency regarding what gets changed in espresso. Anything we add to the framework will be listed here.
+
+1.0.9
+-------------------------------------
+- Added twitter timeline widget clone from JetPack.
+
1.0.6
-------------------------------------
- fixed an issue with the amazon plugin AND portfolio slideshow pro that caused the body classes to disappear
diff --git a/functions.php b/functions.php
index c8c5067..4d700c3 100755
--- a/functions.php
+++ b/functions.php
@@ -5,7 +5,7 @@
*
**/
define('PARENT_THEME_NAME', 'Espresso');
-define('PARENT_THEME_VERSION', '1.0.8');
+define('PARENT_THEME_VERSION', '1.0.9');
define('PARENT_THEME_RELEASE_DATE', date_i18n('F j, Y', '1297144800'));
define('ESPRESSO_NO_CLASS', 'enoclass' );
/**
diff --git a/hopper/grinder/beans/espresso-widget-twitter-timeline.php b/hopper/grinder/beans/espresso-widget-twitter-timeline.php
new file mode 100644
index 0000000..fc2a548
--- /dev/null
+++ b/hopper/grinder/beans/espresso-widget-twitter-timeline.php
@@ -0,0 +1,218 @@
+ Widgets
+ */
+add_action( 'widgets_init', 'espresso_twitter_timeline_widget_init' );
+
+function espresso_twitter_timeline_widget_init() {
+ register_widget( 'espresso_Twitter_Timeline_Widget' );
+}
+
+class espresso_Twitter_Timeline_Widget extends WP_Widget {
+ /**
+ * Register widget with WordPress.
+ */
+ public function __construct() {
+ parent::__construct(
+ 'twitter_timeline',
+ apply_filters( 'espresso_widget_name', esc_html__( apply_filters('espresso-widget-title', 'Espresso Twitter Timeline'), 'espresso' ) ),
+ array(
+ 'classname' => 'widget_twitter_timeline',
+ 'description' => __( 'Display an official Twitter Embedded Timeline widget.', 'espresso' )
+ )
+ );
+
+ 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 '';
+ // End tag output
+
+ echo $args['after_widget'];
+
+ do_action( 'espresso_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', 'espresso' ),
+ '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 .', 'espresso' ),
+ '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" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ >
+
+
+ 200 ) // Twitter paginates at 200 max tweets. update() should not have accepted greater than 20
$show = 200;
-
+
$hidereplies = (bool) $instance['hidereplies'];
$include_retweets = (bool) $instance['includeretweets'];
$link_title = (bool) $instance['linktitle'];
-
+
if(false !== $link_title){
echo "{$before_widget}{$before_title}" . esc_html($title) . " {$after_title}";
} else{
echo "{$before_widget}{$before_title}". esc_html($title) . "{$after_title}";
}
-
+
if ( false === ( $tweets = get_transient( 'widget-twitter-' . $this->number ) ) ) {
$params = array(
'screen_name'=>$account, // Twitter account name
@@ -113,7 +113,7 @@ function widget( $args, $instance ) {
$params['count'] = $show;
if ( $include_retweets )
$params['include_rts'] = true;
- $twitter_json_url = esc_url_raw( 'http://api.twitter.com/1/statuses/user_timeline.json?' . http_build_query( $params ), array( 'http', 'https' ) );
+ $twitter_json_url = esc_url_raw( 'http://api.twitter.com/1.1/statuses/user_timeline.json?' . http_build_query( $params ), array( 'http', 'https' ) );
unset( $params );
$response = wp_remote_get( $twitter_json_url, array( 'User-Agent' => 'Espresso Twitter Widget' ) );
$response_code = wp_remote_retrieve_response_code( $response );
@@ -227,9 +227,7 @@ function form( $instance ) {
if ( $link_title )
echo ' checked="checked"';
echo ' /> ' . esc_html__( 'Link Title to Twitter Page', 'espresso' ) . '
';
-
-
-
+
echo'' . esc_html__( 'Maximum number of tweets to show:', 'espresso' ) . '
';
diff --git a/style.css b/style.css
index 9bea613..75b2145 100755
--- a/style.css
+++ b/style.css
@@ -4,7 +4,7 @@ Theme URI: http://themebrewers.com/
Description: Espresso is a light weight, high powered Framework for WordPress. It is recommended that you not modify the stylesheets for this theme.
Author: ThemeBrewers.com
Author URI: http://themebrewers.com
-Version: 1.0.8
+Version: 1.0.9
Tags: one-column, two-columns, three-columns, left-sidebar, right-sidebar,custom-background,custom-colors,custom-header,custom-menu