function twitter_messages($username = '', $num = 1, $list = false, $update = true, $linked = '#', $hyperlinks = true, $twitter_users = true, $encode_utf8 = false) { global $twitter_options; $messages = fetch_feed('http://twitter.com/statuses/user_timeline/' . $username . '.rss'); if ($list) { echo '<ul class="twitter">'; } if ($username == '') { if ($list) { echo '<li>'; } echo 'RSS not configured'; if ($list) { echo '</li>'; } } else { $feed_count = $messages->get_item_quantity(); if (empty($feed_count)) { if ($list) { echo '<li>'; } echo 'No public Twitter messages.'; if ($list) { echo '</li>'; } } else { $i = 0; foreach ($messages->get_items() as $message) { $desc = $message->get_description(); $date = $message->get_date(); $msg = " " . substr(strstr($desc, ': '), 2, strlen($desc)) . " "; if ($encode_utf8) { $msg = utf8_encode($msg); } $link = $message->get_link(); if ($list) { echo '<li class="twitter-item">'; } elseif ($num != 1) { echo '<p class="twitter-message">'; } if ($hyperlinks) { $msg = hyperlinks($msg); } if ($twitter_users) { $msg = twitter_users($msg); } if ($linked != '' || $linked != false) { if ($linked == 'all') { $msg = '<a href="' . $link . '" class="twitter-link">' . $msg . '</a>'; // Puts a link to the status of each tweet } else { $msg = $msg . '<a href="' . $link . '" class="twitter-link">' . $linked . '</a>'; // Puts a link to the status of each tweet } } echo $msg; if ($update) { $time = strtotime($date); if (abs(time() - $time) < 86400) { $h_time = sprintf(__('%s ago'), human_time_diff($time)); } else { $h_time = date(__('Y/m/d'), $time); } echo sprintf(__('%s', 'twitter-for-wordpress'), ' <span class="twitter-timestamp"><abbr title="' . date(__('Y/m/d H:i:s'), $time) . '">' . $h_time . '</abbr></span>'); } if ($list) { echo '</li>'; } elseif ($num != 1) { echo '</p>'; } $i++; if ($i >= $num) { break; } } } } if ($list) { echo '</ul>'; } }
function twitter_messages($username = '', $num = 1, $list = false, $update = true, $linked = false, $hyperlinks = true, $twitter_users = true, $encode_utf8 = false) { global $twitter_options; include_once ABSPATH . WPINC . '/rss.php'; $messages = fetch_rss('http://twitter.com/statuses/user_timeline/' . $username . '.rss'); if ($list) { echo '<ul class="tweets">'; } if ($username == '') { if ($list) { echo '<li>'; } echo '<strong class="flash error">Tweets could not be loaded</strong>'; if ($list) { echo '</li>'; } } else { if (empty($messages->items)) { if ($list) { echo '<li>'; } echo 'No public Twitter messages.'; if ($list) { echo '</li>'; } } else { $i = 0; foreach ($messages->items as $message) { $msg = " " . substr(strstr($message['description'], ': '), 2, strlen($message['description'])) . " "; if ($encode_utf8) { $msg = utf8_encode($msg); } $link = $message['link']; if ($list) { echo '<li class="tweet">'; } elseif ($num != 1) { echo '<article class="tweet">'; } if ($hyperlinks) { $msg = hyperlinks($msg); } if ($twitter_users) { $msg = twitter_users($msg); } if ($linked != '' || $linked != false) { if ($linked == 'all') { $msg = '<a href="' . $link . '" class="tweet-link">' . $msg . '</a>'; // Puts a link to the status of each tweet } else { $msg = $msg . '<a href="' . $link . '" class="tweet-link">' . $linked . '</a>'; // Puts a link to the status of each tweet } } echo $msg; if ($update) { $time = strtotime($message['pubdate']); if (abs(time() - $time) < 86400) { $h_time = sprintf(__('%s ago'), human_time_diff($time)); } else { $h_time = date(__('Y/m/d'), $time); } echo sprintf(__('%s', 'twitter-for-wordpress'), ' <time datatime="' . date(__('c'), $time) . '" pubdate>' . $h_time . '</time>'); } if ($list) { echo '</li>'; } elseif ($num != 1) { echo '</article>'; } $i++; if ($i >= $num) { break; } } } } if ($list) { echo '</ul>'; } }
/** * 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) { extract($args); /* Our variables from the widget settings. */ $this->twitter_title = apply_filters('widget_title', $instance['title']); $this->twitter_username = $instance['username']; $this->twitter_postcount = $instance['postcount']; $this->twitter_follow_text = $instance['tweettext']; require_once FRAMEWORK_DIRECTORY . 'twitteroauth/twitteroauth.php'; $twitterConnection = new TwitterOAuth('tc2iNQtyrZzxTmSmEDsmCQ', 'Yyz2DXrHX9Iu1fpnjHOvzPFOZGduGoybodEoDm0jQ', '104864700-ICb7swORTkLJEWbjT3kssrWlfGK3gtg4wnqPKj7c', 'pc870Aw5jGBcyIBSpHmGjEO90BuqpVTgPsLaCE1QpqVuM'); $twitterData = $twitterConnection->get('statuses/user_timeline', array('screen_name' => $this->twitter_username, 'count' => $this->twitter_postcount, 'exclude_replies' => false)); /* Before widget (defined by themes). */ echo $before_widget; ?> <div class="twitter_box"><?php /* Display the widget title if one was input (before and after defined by themes). */ if ($this->twitter_title) { echo $before_title . $this->twitter_title . $after_title; } /* Display Latest Tweets */ ?> <?php if (!empty($twitterData) || !isset($twitterData['error'])) { $i = 0; $hyperlinks = true; $encode_utf8 = false; $twitter_users = true; $update = true; echo '<ul class="twitter_update_list">'; foreach ($twitterData as $item) { $msg = $item->text; $permalink = 'http://twitter.com/#!/' . $this->twitter_username . '/status/' . $item->id_str; if ($encode_utf8) { $msg = utf8_encode($msg); } $link = $permalink; echo '<li class="twitter-item">'; if ($hyperlinks) { $msg = hyperlinks($msg); } if ($twitter_users) { $msg = twitter_users($msg); } echo $msg; if ($update) { $time = strtotime($item->created_at); if (abs(time() - $time) < 86400) { $h_time = sprintf(__('%s ago', 'sn'), human_time_diff($time)); } else { $h_time = date(__('Y/m/d', 'sn'), $time); } echo sprintf(__('%s', 'sn'), ' <span class="twitter-timestamp"><abbr title="' . date(__('Y/m/d H:i:s', 'sn'), $time) . '">' . $h_time . '</abbr></span>'); } echo '</li>'; $i++; if ($i >= $this->twitter_postcount) { break; } } echo '</ul>'; } ?> <a href="https://twitter.com/<?php echo $this->twitter_username; ?> " class="twitter-follow-button" data-show-count="true" data-lang="en">Follow @<?php echo $this->twitter_username; ?> </a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> </div> <?php /* After widget (defined by themes). */ echo $after_widget; }
function wpzoom_twitter_messages($username = '', $num = 1, $list = false, $update = true, $linked = '#', $hyperlinks = true, $twitter_users = true, $encode_utf8 = false) { require_once ABSPATH . WPINC . '/class-simplepie.php'; $messages = get_transient('wpzoom_twitter_messages'); if (!$messages) { $feed = new SimplePie(); $feed->set_feed_url('http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=' . $username . '&count=' . $num); $feed->enable_cache(false); $feed->init(); $messages = $feed->get_items(); set_transient('wpzoom_twitter_messages', $messages, 360); } if ($list) { echo '<ul class="twitter-list">'; } if ($username == '') { if ($list) { echo '<li>'; } echo 'RSS not configured'; if ($list) { echo '</li>'; } } else { if (!$messages) { if ($list) { echo '<li>'; } echo 'No Twitter messages.'; if ($list) { echo '</li>'; } } else { $i = 0; foreach ($messages as $message) { $msg = " " . substr(strstr($message->get_content(), ': '), 2, strlen($message->get_content())) . " "; if ($encode_utf8) { $msg = utf8_encode($msg); } $link = $message->get_permalink(); if ($list) { echo '<li class="twitter-item">'; } elseif ($num != 1) { echo '<p class="twitter-message">'; } if ($hyperlinks) { $msg = hyperlinks($msg); } if ($twitter_users) { $msg = twitter_users($msg); } if ($linked != '' || $linked != false) { if ($linked == 'all') { $msg = '<a href="' . $link . '" class="twitter-link">' . $msg . '</a>'; // Puts a link to the status of each tweet } else { if ($linked) { $msg = $msg . '<a href="' . $link . '" class="twitter-link">' . $linked . '</a>'; // Puts a link to the status of each tweet } } } echo $msg; if ($update) { $time = strtotime($message->get_date()); if (abs(time() - $time) < 86400) { $h_time = sprintf(__('%s ago', 'wpzoom'), human_time_diff($time)); } else { $h_time = date('M j, Y', $time); } echo sprintf(__('%s', 'wpzoom'), ' <em class="twitter-timestamp">' . $h_time . '</em>'); } if ($list) { echo '</li>'; } elseif ($num != 1) { echo '</p>'; } $i++; if ($i >= $num) { break; } } } } if ($list) { echo '</ul>'; } }
function twitter_messages($username = '', $num = 1, $list = false, $update = true, $linked = '#', $hyperlinks = true, $twitter_users = true, $encode_utf8 = false) { global $twitter_options; include_once ABSPATH . WPINC . '/rss.php'; $messages = fetch_rss('https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=' . $username); if ($list) { echo '<ul class="twitter">'; } if ($username == '') { if ($list) { echo '<li>'; } echo 'RSS not configured'; if ($list) { echo '</li>'; } } else { if (empty($messages->items)) { if ($list) { echo '<li>'; } echo 'No public Twitter messages.'; if ($list) { echo '</li>'; } } else { $i = 0; foreach ($messages->items as $message) { $msg = " " . substr(strstr($message['description'], ': '), 2, strlen($message['description'])) . " "; if ($encode_utf8) { $msg = utf8_encode($msg); } $link = $message['link']; if ($list) { echo '<li class="twitter-item">'; } elseif ($num != 1) { echo '<p class="twitter-message">'; } if ($hyperlinks) { $msg = hyperlinks($msg); } if ($twitter_users) { $msg = twitter_users($msg); } if ($linked != '' || $linked != false) { if ($linked == 'all') { $msg = '<a href="' . $link . '" class="twitter-link">' . $msg . '</a>'; // Puts a link to the status of each tweet } else { $msg = $msg . '<a href="' . $link . '" class="twitter-link">' . $linked . '</a>'; // Puts a link to the status of each tweet } } echo $msg; if ($update) { $time = strtotime($message['pubdate']); if (abs(time() - $time) < 86400) { $h_time = sprintf(__('%s ago'), human_time_diff($time)); } else { $h_time = date(__('Y/m/d'), $time); } echo sprintf(__('%s', 'twitter-for-wordpress'), ' <span class="twitter-timestamp"><abbr title="' . date(__('Y/m/d H:i:s'), $time) . '">' . $h_time . '</abbr></span>'); } if ($list) { echo '</li>'; } elseif ($num != 1) { echo '</p>'; } $i++; if ($i >= $num) { break; } } } } if ($list) { echo '</ul>'; } }
function twitter_parse_cache_feed($args = '') { /* Set up the default arguments for the twitter. */ $defaults = array('username' => '', 'limit' => '', 'encode_utf8' => 'false', 'twitter_cons_key' => '', 'twitter_cons_secret' => '', 'twitter_oauth_token' => '', 'twitter_oauth_secret' => ''); $args = apply_filters('twitter_parse_cache_feed_args', $args); $args = wp_parse_args($args, $defaults); $out = ''; global $twitter_options; if (!(require_once FRAMEWORK_DIR . 'includes/twitteroauth.php')) { $out .= '<strong>Couldn\'t find twitteroauth.php!</strong>'; return; } $connection = getConnectionWithAccessToken($args['twitter_cons_key'], $args['twitter_cons_secret'], $args['twitter_oauth_token'], $args['twitter_oauth_secret']); $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $args['username'] . "&count=" . $args['limit'] . "") or die('Couldn\'t retrieve tweets! Wrong username?'); //print_r($tweets); if (!empty($tweets->errors)) { if ($tweets->errors[0]->message == 'Invalid or expired token') { $out .= '<strong>' . $tweets->errors[0]->message . '!</strong><br />You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!' . $after_widget; } else { $out .= '<strong>' . $tweets->errors[0]->message . '</strong>'; } return; } $out .= '<ul class="tweet">'; for ($i = 0; $i <= count($tweets); $i++) { if (!empty($tweets[$i])) { $out .= '<li><i class="icon-twitter"></i>'; $msg = " " . $tweets[$i]->text . " "; if ($args['encode_utf8']) { $msg = utf8_encode($msg); } //$link = $message->get_link(); $time = $tweets[$i]->created_at; $msg = hyperlinks($msg); $msg = twitter_users($msg); $out .= $msg; $out .= '<span> - ' . relativeTime($time) . '</span>'; $out .= '</li>'; } } $out .= '</ul>'; echo $out; }
function pi_twitter_plugin($username = '', $num = 1, $list = false, $update = true, $linked = '#', $hyperlinks = true, $twitter_users = true, $encode_utf8 = false) { include_once ABSPATH . WPINC . '/rss.php'; $messages = fetch_rss('http://twitter.com/statuses/user_timeline/' . $username . '.rss'); if ($list) { echo '<ul class="twitter-list">'; } if ($username == '') { if ($list) { echo '<li>'; } echo 'RSS sin configurar'; if ($list) { echo '</li>'; } } else { if (empty($messages->items)) { if ($list) { echo '<li>'; } echo 'No hay mensajes de Twitter.'; if ($list) { echo '</li>'; } } else { $i = 0; foreach ($messages->items as $message) { $msg = " " . substr(strstr($message['description'], ': '), 2, strlen($message['description'])) . " "; if ($encode_utf8) { $msg = utf8_encode($msg); } $link = $message['link']; if ($list) { echo '<li class="twitter-item">'; } elseif ($num != 1) { echo '<p class="twitter-message">'; } if ($hyperlinks) { $msg = hyperlinks($msg); } if ($twitter_users) { $msg = twitter_users($msg); } if ($linked != '' || $linked != false) { if ($linked == 'all') { $msg = '<a href="' . $link . '" class="twitter-link">' . $msg . '</a>'; } else { if ($linked) { $msg = $msg . '<a href="' . $link . '" class="twitter-link">' . $linked . '</a>'; } } } echo $msg; if ($update) { $time = strtotime($message['pubdate']); if (abs(time() - $time) < 86400) { $h_time = sprintf(__('%s ago'), human_time_diff($time)); } else { $h_time = date(__('Y/m/d'), $time); } echo sprintf(__('%s', 'twitter-for-wordpress'), ' <em class="twitter-timestamp">' . $h_time . '</em>'); } if ($list) { echo '</li>'; } elseif ($num != 1) { echo '</p>'; } $i++; if ($i >= $num) { break; } } } } if ($list) { echo '</ul>'; } }
function delicious_twitter_carousel($atts, $content = null) { extract(shortcode_atts(array("twitter_username" => '', "twitter_postcount" => '', "twitter_consumer_key" => '', "twitter_consumer_secret" => '', "twitter_access_token" => '', "twitter_access_token_secret" => ''), $atts)); $transName = 'list_tweets'; $cacheTime = 20; if (false === ($twitterData = get_transient($transName))) { require_once 'includes/twitteroauth.php'; $twitterConnection = new TwitterOAuth($twitter_consumer_key, $twitter_consumer_secret, $twitter_access_token, $twitter_access_token_secret); $twitterData = $twitterConnection->get('statuses/user_timeline', array('screen_name' => $twitter_username, 'count' => $twitter_postcount, 'exclude_replies' => false)); if ($twitterConnection->http_code != 200) { $twitterData = get_transient($transName); } // Save our new transient. set_transient($transName, $twitterData, 60 * $cacheTime); } if (!empty($twitterData) || !isset($twitterData['error'])) { $i = 0; $hyperlinks = true; $encode_utf8 = false; $twitter_users = true; $update = true; echo '<div class="twitter-carousel">'; echo '<ul class="tweet_list owl-carousel" id="owl-twitter">'; foreach ($twitterData as $item) { $msg = $item->text; $permalink = 'http://twitter.com/#!/' . $twitter_username . '/status/' . $item->id_str; $retweet = 'http://twitter.com/intent/retweet?tweet_id=' . $item->id_str; $tweet_reply = 'http://twitter.com/intent/tweet?in_reply_to=' . $item->id_str; $tweet_favorite = 'http://twitter.com/intent/favorite?tweet_id=' . $item->id_str; if ($encode_utf8) { $msg = utf8_encode($msg); } $msg = encode_tweet($msg); $link = $permalink; echo '<li>'; if ($hyperlinks) { $msg = hyperlinks($msg); } if ($twitter_users) { $msg = twitter_users($msg); } if ($update) { $time = strtotime($item->created_at); if (abs(time() - $time) < 86400) { $h_time = sprintf(__('%s ago', 'delicious'), human_time_diff($time)); } else { $h_time = time_elapsed_string($time); } echo '<span class="tweet_time">' . $h_time . '</span>'; echo '<span class="tweet_text">' . $msg . '</span>'; echo '<a class="tweet_action tweet_reply" href="' . $tweet_reply . '"><i class="fa fa-reply"></i> ' . __('Reply', 'delicious') . '</a>'; echo '<a class="tweet_action tweet_retweet" href="' . $retweet . '"><i class="fa fa-retweet"></i> ' . __('Retweet', 'delicious') . '</a>'; echo '<a class="tweet_action tweet_favorite" href="' . $tweet_favorite . '"><i class="fa fa-star"></i> ' . __('Favorite', 'delicious') . '</a>'; } echo '</li>'; $i++; if ($i >= $twitter_postcount) { break; } } echo '</ul>'; echo '</div>'; } }
function sn_shortcode_tweet($atts) { extract(shortcode_atts(array('username' => 'envato', 'wrap' => 'ul', 'wrapitem' => 'li', 'count' => 1, 'hidereplies' => false, 'hyperlinks' => 'true', 'users' => 'true', 'update' => 'true'), $atts)); if ($hidereplies === 'true') { $hidereplies = true; } require_once FRAMEWORK_DIRECTORY . 'twitteroauth/twitteroauth.php'; $twitterConnection = new TwitterOAuth('tc2iNQtyrZzxTmSmEDsmCQ', 'Yyz2DXrHX9Iu1fpnjHOvzPFOZGduGoybodEoDm0jQ', '104864700-ICb7swORTkLJEWbjT3kssrWlfGK3gtg4wnqPKj7c', 'pc870Aw5jGBcyIBSpHmGjEO90BuqpVTgPsLaCE1QpqVuM'); $twitterData = $twitterConnection->get('statuses/user_timeline', array('screen_name' => $username, 'count' => $count, 'exclude_replies' => $hidereplies)); /* Display Latest Tweets */ if (!empty($twitterData) || !isset($twitterData['error'])) { $i = 0; $encode_utf8 = false; $twitter_users = $users; ob_start(); echo '<' . $wrap . ' class="box-twitter">'; foreach ($twitterData as $item) { $msg = $item->text; $permalink = 'http://twitter.com/#!/' . $username . '/status/' . $item->id_str; if ($encode_utf8) { $msg = utf8_encode($msg); } $link = $permalink; echo '<' . $wrapitem . ' class="twitter-item">'; if ($hyperlinks === 'true') { $msg = hyperlinks($msg); } if ($twitter_users === 'true') { $msg = twitter_users($msg); } echo $msg; if ($update === 'true') { $time = strtotime($item->created_at); if (abs(time() - $time) < 86400) { $h_time = sprintf(__('%s ago', 'sn'), human_time_diff($time)); } else { $h_time = date(__('Y/m/d', 'sn'), $time); } echo sprintf(__('%s', 'sn'), ' <span class="twitter-timestamp"><abbr title="' . date(__('Y/m/d H:i:s', 'sn'), $time) . '">' . $h_time . '</abbr></span>'); } echo '</' . $wrapitem . '>'; $i++; if ($i >= $count) { break; } } echo '</' . $wrap . '>'; $output = ob_get_contents(); ob_end_clean(); return $output; } }