function shortcode_twitter($attr) { extract(shortcode_atts(array('tweets' => 4, 'visible' => 2, 'before_widget' => "<div class='cws-widget'>", 'after_widget' => "</div>", 'before_title' => "<div class='widget-title'><span>", 'after_title' => "</span></div>", 'sidebar' => false, 'backlight' => false, 'title' => ''), $attr)); $visible = intval($visible); $tweets = intval($tweets); $out = ''; $name = cws_get_option('tw-api-name'); $twt_obj = cws_getTweets($name, $tweets); if ($twt_obj && is_array($twt_obj)) { if (!array_key_exists('error', $twt_obj)) { $is_carousel = $visible < $tweets ? true : false; $out .= $sidebar ? "" : $before_widget; $backlight_class = $backlight ? "backlight" : ""; $out .= "<div class='cws-widget-content {$backlight_class}'>"; if ($is_carousel) { $out .= "<div class='carousel_header clearfix'>"; $out .= count($twt_obj) ? "<div class='widget_carousel_nav'><i class='prev fa fa-angle-left'></i><i class='next fa fa-angle-right'></i></div>" : ""; } $out .= !empty($title) ? $before_title . $title . $after_title : ""; if ($is_carousel) { $out .= "</div>"; } if ($is_carousel) { $out .= "<div class='carousel_content'>"; } $out .= '<ul class="latest_tweets ' . ($is_carousel ? ' widget_carousel' : '') . '">'; if ($twt_obj) { $i = 0; foreach ($twt_obj as $tweets) { if ($i == 0) { $out .= '<li><ul>'; } //var_dump($tweets['tweets'][0]); //die; $strtime = strtotime($tweets['created_at']); $tweet_text = preg_replace('@(https?://([-\\w\\.]+)+(:\\d+)?(/([\\w/_\\.]*(\\?\\S+)?)?)?)@', '<a href="$1">$1</a>', $tweets['text']); $tweet_text = preg_replace('/#([\\d\\w]+)/', '<a href="http://twitter.com/search?q=%23$1&src=hash">$0</a>', $tweet_text); if (strlen($tweet_text) > 0) { $out .= '<li class="clearfix"><div class="icon_frame"><i class="fa fa-twitter fa-2x"></i></div><div>'; $out .= '<p>' . $tweet_text . '</p>'; $out .= '<span class = "date">' . date('M d, Y', $strtime) . '</span>'; $out .= '</div></li>'; } $i++; if ($i == $visible) { $out .= '</ul></li>'; $i = 0; } } if ($i != $visible && $i != 0) { $out .= '</ul></li>'; } } else { $out .= '<li>' . __('Twitter API keys and tokens are not set.', THEME_SLUG) . '</li>'; } $out .= '</ul>'; if ($is_carousel) { $out .= "</div>"; } $out .= '</div>'; $out .= $sidebar ? "" : $after_widget; } else { $out = $twt_obj['error']; } } else { $out = 'Twitter feed is currently turned off. You may turn it on and set the API Keys and Tokens using <a href="/wp-admin/admin.php?page=_options&tab=6" target="_blank">Theme Options -> Social Options: Enable Twitter Feed</a>.'; } return $out; }
function cws_pb_tweet_shortcode($args) { extract(shortcode_atts(array('items' => '4'), $args)); $output = ''; $twt_obj = cws_getTweets('', $items, false); if ($twt_obj && is_array($twt_obj)) { if (!array_key_exists('error', $twt_obj)) { $output .= '<ul>'; if ($twt_obj) { $i = 0; foreach ($twt_obj as $tweets) { $strtime = strtotime($tweets->created_at); $tweet_text = preg_replace('@(https?://([-\\w\\.]+)+(:\\d+)?(/([\\w/_\\.]*(\\?\\S+)?)?)?)@', '<a href="$1">$1</a>', $tweets->text); $tweet_text = preg_replace('/#([\\d\\w]+)/', '<a href="http://twitter.com/search?q=%23$1&src=hash">$0</a>', $tweet_text); if (strlen($tweet_text) > 0) { $output .= '<li>'; $output .= '<p>' . $tweet_text . '</p>'; $output .= '<span class = "date">' . date('M d, Y', $strtime) . '</span>'; $output .= '</li>'; } $i++; } } else { $output .= '<li>' . __('Twitter API keys and tokens are not set.', THEME_SLUG) . '</li>'; } $output .= '</ul>'; } else { $output = $twt_obj['error']; } } else { $output = 'Twitter feed is currently turned off. You may turn it on and set the API Keys and Tokens using <a href="/wp-admin/admin.php?page=_options&tab=6" target="_blank">Theme Options -> Social Options: Enable Twitter Feed</a>.'; } return $output; }
function shortcode_twitter($attr) { extract(shortcode_atts(array('tweets' => 4, 'visible' => 2, 'before_widget' => "<div class='cws-widget'>", 'after_widget' => "</div>", 'before_title' => "<div class='widget-title'><span>", 'after_title' => "</span></div>", 'sidebar' => false, 'title' => ''), $attr)); $visible = intval($visible); $tweets_n = intval($tweets); $out = ''; $twt_obj = cws_getTweets($tweets); if ($twt_obj && is_array($twt_obj)) { if (!array_key_exists('error', $twt_obj)) { $is_carousel = $visible < $tweets ? true : false; $out .= $sidebar ? "" : $before_widget; $out .= "<div class='cws-widget-content '>"; if ($is_carousel) { $out .= "<div class='carousel_header clearfix'>"; $out .= count($twt_obj) ? "<div class='widget_carousel_nav'><i class='prev fa fa-angle-left'></i><i class='next fa fa-angle-right'></i></div>" : ""; } $out .= !empty($title) ? $before_title . $title . $after_title : ""; if ($is_carousel) { $out .= "</div>"; } if ($is_carousel) { $out .= "<div class='carousel_content cws_tweets'>"; } $out .= '<ul class="latest_tweets ' . ($is_carousel ? ' widget_carousel' : '') . '">'; if ($twt_obj) { $i = 0; foreach ($twt_obj as $tweets) { if ($i == 0) { $out .= '<li><ul>'; } $strtime = strtotime($tweets['created_at']); $tweet_text = preg_replace('@(https?://([-\\w\\.]+)+(:\\d+)?(/([\\w/_\\.]*(\\?\\S+)?)?)?)@', '<a href="$1">$1</a>', $tweets['text']); $tweet_text = preg_replace('/#([\\d\\w]+)/', '<a href="http://twitter.com/search?q=%23$1&src=hash">$0</a>', $tweet_text); if (strlen($tweet_text) > 0) { $out .= '<li class="clearfix"><div class="icon_frame"><i class="fa fa-twitter fa-2x"></i></div><div>'; $out .= '<p>' . $tweet_text . '</p>'; $out .= '<span class = "date">' . date('M d, Y', $strtime) . '</span>'; $out .= '</div></li>'; } $i++; if ($i == $visible) { $out .= '</ul></li>'; $i = 0; } $tweets_n--; if (!$tweets_n) { break; } } if ($i != $visible && $i != 0) { $out .= '</ul></li>'; } } else { $out .= '<li>' . __('Twitter API keys and tokens are not set.', 'happykids') . '</li>'; } $out .= '</ul>'; if ($is_carousel) { $out .= "</div>"; } $out .= '</div>'; $out .= $sidebar ? "" : $after_widget; } else { $out = $twt_obj['error']; } } else { if (isset($twt_obj->errors)) { $out = $twt_obj->errors[0]->message; } else { $out = __('Twitter response: ', 'happykids') . $twt_obj; } } return $out; }