'ut_widget_twitter', 'description' => __( 'Displays simple Twitter tweets', 'ut_lang') ); parent::__construct('lw_ut_twitter', __('UnitedThemes - Twitter', 'ut_lang'), $widget_ops); $this->alt_option_name = 'ut_widget_twitter'; } function form($instance) { if ( $instance ) { $title = esc_attr( $instance['title'] ); $twitter_count = esc_attr($instance['count']); $twitter_count = is_int($twitter_count) && (!$twitter_count) ? "5" : $twitter_count; } ?>

slug, $title ); if(empty($count) ) $count = 3; /** Set access tokens here - see: https://dev.twitter.com/apps/ **/ $settings = array( 'oauth_access_token' => $twitter_options['oauth_access_token'], 'oauth_access_token_secret' => $twitter_options['oauth_access_token_secret'], 'consumer_key' => $twitter_options['consumer_key'], 'consumer_secret' => $twitter_options['consumer_secret'] ); if( empty($twitter_options['oauth_access_token']) || empty($twitter_options['oauth_access_token_secret']) || empty($twitter_options['consumer_key']) || empty($twitter_options['consumer_secret']) ) { _e( 'Please make sure you have entered all necessary Twitter API Keys under Dashboard -> Settings -> Twitter' , 'ut_lang'); } else { $url = 'https://api.twitter.com/1.1/statuses/user_timeline.json'; $getfield = '?count='.$count; $requestMethod = 'GET'; $twitter = new TwitterAPIExchange($settings); $tweets = $twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest(); $tweets = json_decode( $tweets ); /* create twitter feed option */ if( !get_option('ut_twitter_feed') ) { add_option('ut_twitter_feed'); } /* update feeds */ if( !empty( $tweets ) && !isset( $tweets->errors[0]->code ) ) { update_option('ut_twitter_feed' , $tweets); } /* we have an error - let's use the cached feeds */ if( empty( $tweets ) || isset( $tweets->errors[0]->code ) ) { $tweets = get_option( 'ut_twitter_feed' ); } if( empty($tweets) ) { return '
'.__('An Error has occured, no Twitter Feeds are available','ut_lang').'
'; } else { /* fallback */ $title = (isset($title)) ? $before_title.do_shortcode($title).$after_title : ''; /* output */ echo $before_widget; echo $title; /* tweets */ ?>