public function front_end($args, $instance) { // outputs the content of the widget if (!carbon_twitter_is_configured()) { return; //twitter settings are not configured } $instance = array('title' => Carbon_ACF_Widget::get_widget_meta($widget_id, 'title'), 'username' => Carbon_ACF_Widget::get_widget_meta($widget_id, 'username'), 'count' => Carbon_ACF_Widget::get_widget_meta($widget_id, 'count')); $tweets = TwitterHelper::get_tweets($instance['username'], $instance['count']); if (empty($tweets)) { return; //no tweets, or error while retrieving } if ($instance['title']) { $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); echo $args['before_title'] . $title . $args['after_title']; } ?> <div class="widget-body"> <ul> <?php foreach ($tweets as $tweet) { ?> <li><?php echo $tweet->tweet_text; ?> - <span><?php printf(__('%1$s ago', 'crb'), $tweet->time_distance); ?> </span></li> <?php } ?> </ul> </div><!-- /.widget-body --> <?php }
function carbon_twitter_widget_config_check() { if (!carbon_twitter_widget_registered() || !carbon_twitter_widget_activated()) { return; } if (!carbon_twitter_is_configured()) { add_action('admin_notices', 'carbon_twitter_widget_no_config_warning'); } elseif (!carbon_twitter_is_config_valid()) { add_action('admin_notices', 'carbon_twitter_widget_wrong_config_warning'); } }