public function widget($args, $instance) { echo $args['before_widget']; if ($instance['title']) { echo $args['before_title'] . $instance['title'] . $args['after_title']; } echo '<div class="twitter-feed-widget">'; $shortcode = '[timeline-twitter-feed'; if ($instance['terms']) { $shortcode .= ' terms="'; // backwards compatibility for user input from plugin version 0.9 if (false !== strpos($instance['terms'], 'OR')) { $shortcode .= esc_attr(trim($instance['terms'])); } else { $hashtags = Timeline_Twitter_Feed_Functions::str_split($instance['terms']); foreach ($hashtags as $hashtag) { $hashtag = esc_attr($hashtag); if (false === strpos($hashtag, '#')) { $hashtag = '#' . $hashtag; } $shortcode .= $hashtag . ' OR '; } $shortcode = rtrim($shortcode, ' OR '); } $shortcode .= '"'; } $shortcode .= ']'; echo do_shortcode($shortcode); echo '</div>'; echo $args['after_widget']; }
public function has_blocked_words($tweet) { $tweet = $tweet->user->screen_name . ' ' . $tweet->text; $keywords = Timeline_Twitter_Feed_Functions::str_split($this->other_options[Timeline_Twitter_Feed_Options::KEYWORD_FILTER]); $result = count(array_intersect($keywords, explode(' ', $tweet))); if ($result > 0) { return true; // skip this tweet, it has bad words } return false; }