'Add_to_Circle_Widget', 'description' => 'Google+ add to Circle Badge.' ); /* Widget control settings. */ $control_ops = array( 'id_base' => 'add-to-circle-widget' ); /* Create the widget. */ $this->WP_Widget( 'add-to-circle-widget', 'Add to Circle Widget', $widget_ops, $control_ops ); } /** * How to display the widget on the screen. */ function widget( $args, $instance ) { extract( $args ); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title'] ); $google_page_id = $instance['google_page_id']; $badge_layout = $instance['badge_layout']; $badge_color = $instance['badge_color']; /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ if ( $title ) echo $before_title . $title . $after_title; /* Display name from widget settings if one was input. */ if ( $google_page_id || $badge_layout || $badge_color ) echo ""; /* After widget (defined by themes). */ echo $after_widget; } /** * Update the widget settings. */ function update( $new_instance, $old_instance ) { $instance = $old_instance; /* Strip tags for title and name to remove HTML (important for text inputs). */ $instance['title'] = strip_tags( $new_instance['title'] ); $instance['google_page_id'] = strip_tags( $new_instance['google_page_id'] ); /* No need to strip tags for sex and show_sex. */ $instance['badge_layout'] = $new_instance['badge_layout']; $instance['badge_color'] = $new_instance['badge_color']; return $instance; } /** * Displays the widget settings controls on the widget panel. * Make use of the get_field_id() and get_field_name() function * when creating your form elements. This handles the confusing stuff. */ function form( $instance ) { /* Set up some default widget settings. */ $defaults = array( 'title' => '', 'google_page_id' => '', 'badge_layout' => 'standard', 'badge_color' => 'light' ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

Did you like it:

'; echo '(function()'; echo '{var po = document.createElement("script");'; echo 'po.type = "text/javascript"; po.async = true;po.src = "https://apis.google.com/js/plusone.js";'; echo 'var s = document.getElementsByTagName("script")[0];'; echo 's.parentNode.insertBefore(po, s);'; echo '})();'; } add_action( 'wp_head', 'insert_google_script_in_head'); ?>