array('Horizontal Large Menu', 'addthis_default_style addthis_32x32_style' ), 'hs' => array('Horizontal Small Menu', 'addthis_default_style'), 'vl' => array('Vertical Large Menu', 'addthis_vertical_style addthis_32x32_style'), 'vs' => array('Vertical Small Menu', 'addthis_vertical_style') ); // we can't set it now since we want to use bloginfo to autoset the RSS Feed var $buttons = array(); /** * Constructor */ function AddThisFollowSidebarWidget() { $widget_ops = array( 'classname' => 'atfollowwidget', 'description' => 'Connect fans and followers with your profiles on top social services' ); /* Widget control settings. */ $control_ops = array( 'width' => 490); /* Create the widget. */ $this->WP_Widget( 'addthis-follow-widget', 'AddThis Follow Widget', $widget_ops, $control_ops ); $this->buttons = array( 'facebook' => array( 'name' => 'Facebook', 'input' => 'http://www.facebook.com/ %s', 'placeholder' => 'YOUR-PROFILE' ), 'twitter' => array( 'name' => 'Twitter', 'input' => 'http://twitter.com/ %s', 'placeholder' => 'YOUR-USERNAME' ), 'youtube' => array( 'name' => 'YouTube', 'input' => 'http://www.youtube.com/user/ %s ', 'placeholder' => '' ), 'rss' => array( 'name' => 'RSS', 'input' => '%s', 'placeholder' => get_bloginfo('rss2_url') ), 'linkedin' => array( 'name' => 'LinkedIn', 'input' => 'http://www.linkedin.com/in/ %s', 'placeholder' => '' ), 'google' => array( 'name' => 'Google+', 'input' => 'https://plus.google.com/ %s', 'placeholder' => '' ), 'flickr' => array( 'name' => 'Flickr', 'input' => 'http://www.flickr.com/photos/ %s', 'placeholder' => '' ), 'vimeo' => array( 'name' => 'Vimoe', 'input' => 'http://www.vimeo.com/ %s ', 'placeholder' => '' ), 'pinterest' => array( 'name' => 'Pintrest', 'input' => 'http://www.pinterest.com/ %s', 'placeholder' => '' ), 'instagram' => array( 'name' => 'Instagram', 'input' => 'http://followgram.me/ %s', 'placeholder' => '' ), 'foursquare' => array( 'name' => 'Foursquare', 'input' => 'http://foursquare.com/ %s', 'placeholder' => '' ), 'tumblr' => array( 'name' => 'Tumblr', 'input' => 'http:// %s  .tumblr.com', 'placeholder' => '' ), ); } /** * Echo's out the content of our widget */ function widget($args, $instance) { extract ( $args ); $title = apply_filters('widget_title', $instance['title']); echo $before_widget; if ($title) echo $before_title . $title . $after_title; unset($instance['profile']); unset($instance['title']); $class = $this->styles[$instance['style']][1]; echo '
'; foreach($this->buttons as $id => $button){ if (isset($instance[$id]) && ! (empty($instance[$id])) && ( $id == 'rss' || $instance[$id] != $button['placeholder'] )){ echo ''; } } // end the div echo '
'; echo $after_widget; } /** * Update this instance */ function update($new_instance, $old_instance) { $instance = array(); global $addthis_addjs; if (isset( $new_instance['profile']) && substr($new_instance['profile'],0,2) != 'wp-' ) { $addthis_addjs->setProfileId( $new_instance['profile'] ); } foreach($this->buttons as $id => $button){ if (isset($new_instance[$id])) $instance[$id] = sanitize_text_field($new_instance[$id]); } $style = $new_instance['style']; if (isset($this->styles[$style]) ) { $instance['style'] = $style; } else { $instance['style'] = isset($this->styles[$style]); } $instance['title'] = sanitize_text_field($new_instance['title']); return $instance; } /** * The form with the widget options */ function form($instance) { global $addthis_addjs; if (empty($instance)) { $instance = array('style'=> 'hl' , 'title' => 'Follow Me'); } $addthis_options = get_option('addthis_settings'); $style = (empty( $instance['style'] ) ) ? 'hl' : esc_attr($instance['style']); $title = (empty( $instance['title'] ) ) ? '' : esc_attr($instance['title']); $profile = $addthis_addjs->getProfileID(); echo $addthis_addjs->getAtPluginPromoText(); echo '

'; echo '

'; // Style box echo '

Buttons

"; $count = 0; // Buttons foreach($this->buttons as $id => $button) { $class = ($count >= 4) ? 'atmore hidden' : ''; $value = (empty($instance[$id])) ? $button['placeholder'] : esc_attr($instance[$id]); echo '

'; $count++; } echo "" . __('More Options', 'addthis') . '"; } } // Setup our shared resources early add_action('init', 'addthis_follow_early', 1); function addthis_follow_early(){ global $addthis_addjs; if (! isset($addthis_addjs)){ require('includes/addthis_addjs.php'); $addthis_options = get_option('addthis_settings'); $addthis_addjs = new AddThis_addjs($addthis_options); } }