";
//echo $ai_output;
}
return $ai_output;
}
/*
*AI Twitter Widget Widget
* enables the ability to use a widget to place the tweet feed in the widget areas
* of a theme.
*/
class AI_Twitter_Widget extends WP_Widget {
/*
* Register the widget for use in WordPress
*/
public function AI_Twitter_Widget(){
$this->options = array(
array(
'label' => '
AI Widget settings
',
'type' => 'separator'),
array(
'name' => 'ai_widget_title', 'label' => 'Widget title',
'type' => 'text', 'default' => 'Latest Tweets', 'tooltip' => 'Title of the widget'),
array(
'name' => 'ai_widget_username', 'label' => 'Username (Without the "@" symbol)',
'type' => 'text', 'default' => 'twitter', 'tooltip' => 'Twitter username for which you want to display tweets if widget type is set to Timeline'),
array(
'name' => 'ai_widget_count', 'label' => 'Tweet number',
'type' => 'text', 'default' => '5', 'tooltip' => 'Number of Tweets to display'),
);
/* Widget settings. */
$widget_options = array(
'classname' => 'ai_widget',
'description' => 'AI Simple Twitter Feed Widget, Displays your latest Tweet',
);
/* Widget control settings. */
$control_ops = array('width' => 250);
parent::WP_Widget('ai_widget','AI Twiiter Feeds',$widget_options,$control_ops);
}
public function widget($args, $instance) {
$ai_get_widget_twitteruser=$instance['ai_widget_username'] ? $instance['ai_widget_username'] : get_option('ai_consumer_screen_name');
$ai_get_widget_notweets=$instance['ai_widget_count'] ? $instance['ai_widget_count'] : get_option('ai_display_number_of_tweets');
$title = ($instance['ai_widget_title']) ? $instance['ai_widget_title'] : 'Latest Twitter Feeds';
$ai_wid_twitteruser = $ai_get_widget_twitteruser;
$ai_wid_notweets = $ai_get_widget_notweets;
extract($args, EXTR_SKIP);
$atts_arr=array('ai_username' => $ai_get_widget_twitteruser,
'ai_numberoftweets' => $ai_get_widget_notweets,
'ai_tweet_title' =>$title);
echo ai_get_twitter_feeds($atts_arr);
}
function update($new_instance, $old_instance) {
return $new_instance;
}
public function form($instance) {
if(empty($instance)) {
foreach($this->options as $val) {
if($val['type'] == 'separator') {
continue;
}
$instance[$val['name']] = $val['default'];
}
}
if(!is_callable('curl_init')) {
echo __('Your PHP doesn\'t have cURL extension enabled. Please contact your host and ask them to enable it.');
return;
}
foreach($this->options as $val) {
$title = '';
if(!empty($val['tooltip'])) {
$title = ' title="' . $val['tooltip'] . '"';
}
if($val['type'] == 'separator') {
echo $val['label'] . ' ';
} else if($val['type'] == 'text') {
$label = '';
$value = $val['default'];
if(isset($instance[$val['name']]))
$value = esc_attr($instance[$val['name']]);
echo '