/** * */ function widget($args, $instance) { global $shortname; extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Tweets', MISS_TEXTDOMAIN) : $instance['title'], $instance, $this->id_base); $tagline = apply_filters('widget_tagline', empty($instance['tagline']) ? __('Recent Tweets', MISS_TEXTDOMAIN) : $instance['tagline'], $instance, $this->id_base); $id = $instance['id']; if (!($number = (int) $instance['number'])) { $number = 5; } else { if ($number < 1) { $number = 1; } else { if ($number > 40) { $number = 40; } } } $username = isset($instance['id']) ? trim($instance['id']) : miss_get_setting('twitter_id'); $type = 'widget'; $miss_get_user_timeline = new miss_timeline_store($oauth_access_token = !empty($instance['oauth_access_token']) ? $instance['oauth_access_token'] : miss_get_setting('oauth_access_token'), $oauth_access_token_secret = !empty($instance['oauth_access_token_secret']) ? $instance['oauth_access_token_secret'] : miss_get_setting('oauth_access_token_secret'), $consumer_key = !empty($instance['consumer_key']) ? $instance['consumer_key'] : miss_get_setting('consumer_key'), $consumer_secret = !empty($instance['consumer_secret']) ? $instance['consumer_secret'] : miss_get_setting('consumer_secret'), $screen_name = $username, $count = $number); $results = $miss_get_user_timeline->returnTweet(); ?> <?php echo $before_widget; ?> <?php echo $before_title . $title . $after_title . '<h6>' . $tagline . '</h6>'; ?> <ul><?php if (isset($results) && is_array($results) && !empty($results)) { foreach ($results as $key => $tweet) { if ($key == "errors") { echo ''; /* echo '<li>'; echo $tweet[0]['message']; echo '</li>'; */ } else { echo '<li>'; echo '<a class="target_blank" target="_BLANK" href="http://twitter.com/1/status/' . $tweet['id_str'] . '" title="' . sprintf(esc_attr__('%1$s ago', MISS_TEXTDOMAIN), miss_relative_time(strtotime($tweet['created_at']))) . '">' . '<i class="im-icon-twitter pull-left"></i>' . miss_filter_tweet($tweet['text']) . '</a>'; echo '</li>'; } } } else { echo '<li>' . __('Tweets not found.', MISS_TEXTDOMAIN) . '</li>'; } ?> </ul><?php echo $after_widget; }
/** * Recent Tweets */ function miss_recent_tweets() { global $wp_query; $post_obj = $wp_query->get_queried_object(); if (!empty($post_obj) && !empty($post_obj->ID) && get_post_meta($post_obj->ID, '_disable_tweets', true)) { return; } $disable_tweets = apply_atomic('disable_tweets', miss_get_setting('disable_tweets')); //$disable_tweets = miss_get_setting( 'disable_tweets' ); if (!empty($disable_tweets)) { return; } $out = ''; $number = 10; $username = miss_get_setting('twitter_id'); $miss_get_user_timeline = new miss_timeline_store($oauth_access_token = miss_get_setting('oauth_access_token'), $oauth_access_token_secret = miss_get_setting('oauth_access_token_secret'), $consumer_key = miss_get_setting('consumer_key'), $consumer_secret = miss_get_setting('consumer_secret'), $screen_name = $username, $count = $number); $results = $miss_get_user_timeline->returnTweet(); if (isset($results) && is_array($results) && !empty($results)) { foreach ($results as $key => $tweet) { if ($key == "errors") { if (isset($tweet) && isset($tweet[0]) && isset($tweet[0]['message'])) { $out .= '<li> <div class="date">message</div> <div class="text">' . $tweet[0]['message'] . '</div> </li>'; } } else { $out .= '<li>'; $out .= '<div class="date">' . sprintf(esc_attr__(' %1$s ago ', MISS_TEXTDOMAIN), miss_relative_time(strtotime($tweet['created_at']))) . '</div>'; //$out .= '<span class="tw-icon"><i class="im-icon-twitter"></i></span>'; $out .= '<div class="text">' . miss_filter_tweet($tweet['text']) . '</div>'; $out .= '<div class="button_container"><a target="_BLANK" href="http://twitter.com/1/status/' . $tweet['id_str'] . '" class="btn ribbon-style">View details</a></div>'; $out .= '</li>'; } } } else { $out .= '<li>' . __('Tweets not found.', MISS_TEXTDOMAIN) . '</li>'; } $out = ' <div class="twitter-crousel"> <div id="lasttweet"> <!--div class="twitter_controls pull-right"><div class="twitter-prev"><i class="fa-icon-chevron-left"></i></div><div class="twitter-next"><i class="fa-icon-chevron-right"></i></div></div--> <ul class="tweet_holder">' . $out . '</ul> </div> <span class="tw-icon"><i class="im-icon-twitter"></i></span> </div>'; return $out; }
} $miss_get_user_timeline = new miss_timeline_store($oauth_access_token = miss_get_setting('oauth_access_token'), $oauth_access_token_secret = miss_get_setting('oauth_access_token_secret'), $consumer_key = miss_get_setting('consumer_key'), $consumer_secret = miss_get_setting('consumer_secret'), $screen_name = str_replace(array("@", "#"), array("", ""), $twitter), $count = "10", $json = true); ?> Application = {}; Application.Tweets = { init: function () { var a = { q: "<?php echo $twitter; ?> ", rpp: 10 }, c = <?php echo $miss_get_user_timeline->returnTweet(); ?> ; jQuery("#lasttweet #status").append("<li>Loading tweets for <?php print $twitter; ?> ...</li>").find(".loading").remove(); //jQuery.get("http://search.twitter.com/search.json", a, function (c) { if (c.length > 0) { var b = ""; jQuery("#lasttweet #status").remove(); jQuery.each(c, function (d, e) { e.user.name = e.user.name.replace(/([-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, function(url) { return '<a href="http://twitter.com/'+url+'">'+url+'</a>';
public function __construct($arr) { $this->services = $arr; // Building an array with queries: //Feedburner if (trim($arr['feedBurnerURL'])) { /* if (strpos($this->services['feedBurnerURL'], 'http') == false || strpos($this->services['feedBurnerURL'], 'http') == false) { $this->services['feedBurnerURL'] = "http://".$this->services['feedBurnerURL']; } $query = $arr['feedBurnerURL'] . "?format=xml"; $query = 'http://feedburner.google.com/api/awareness/1.0/GetFeedData?uri='.$arr['feedBurnerURL']; $profile = feedReader($query, "xml"); $this->rss = 1; //(string) $profile->feed->entry['circulation']; */ } //Twitter if (isset($arr['twitterName']) && trim($arr['twitterName'])) { $miss_get_user_timeline = new miss_timeline_store($oauth_access_token = miss_get_setting('oauth_access_token'), $oauth_access_token_secret = miss_get_setting('oauth_access_token_secret'), $consumer_key = miss_get_setting('consumer_key'), $consumer_secret = miss_get_setting('consumer_secret'), $screen_name = $arr['twitterName'], $count = 1); $results = $miss_get_user_timeline->returnTweet(); $this->twitter = $results[0]['user']['followers_count']; } //Facebook if (isset($arr['facebookFanPageURL']) && trim($arr['facebookFanPageURL'])) { $fb_id = basename($arr['facebookFanPageURL']); $query = 'http://graph.facebook.com/' . $fb_id; $data = wp_remote_get($query); $data = str_replace("({", "{", $data['body']); $data = str_replace("})", "}", $data); //print_r($result); $result = json_decode($data, true); //$result = feedReader($query, "json"); $this->facebook = isset($result["likes"]) ? $result["likes"] : (isset($result['followers_count']) ? $result['followers_count'] : 0); } //Pinterest if (isset($arr['pinterestURL']) && trim($arr['pinterestURL'])) { $pinterest_id = basename($arr['pinterestURL']); $query = 'http://api.pinterest.com/v1/urls/count.json?callback=&url=' . $arr['pinterestURL']; $data = wp_remote_get($query); $data = str_replace("({", "{", $data['body']); $data = str_replace("})", "}", $data); $result = json_decode($data, true); $this->pinterest = $result["count"]; } //Delicious $url = 'envato.com'; if (isset($arr['deliciousId']) && trim($arr['deliciousId'])) { $url = str_replace("http://", "", $arr['deliciousId']); $url = str_replace("https://", "", $url); $url = str_replace("feed://", "", $url); $url = str_replace("http//", "", $url); $url = str_replace("http:/", "", $url); $api_page = 'http://feeds.delicious.com/v2/json/urlinfo/data?url=' . $url; $json = wp_remote_get($api_page); //$json_output = json_decode($json, true); $result = json_decode($json['body'], true); $this->delicious = $result[0]['total_posts']; } if (!$this->delicious) { $this->delicious = "0"; } if (!$this->rss) { $this->rss = "0"; } if (!$this->twitter) { $this->twitter = "0"; } if (!$this->pinterest) { $this->pinterest = "0"; } if (!$this->facebook) { $this->facebook = "0"; } }