defaults = array( 'title' => '', 'networks' => '', 'total_followers' => socialsnap_settings( 'ss_sf_total_followers' ), 'button_followers' => socialsnap_settings( 'ss_sf_button_followers' ), 'size' => socialsnap_settings( 'ss_sf_button_size' ), 'spacing' => socialsnap_settings( 'ss_sf_button_spacing' ), 'columns' => socialsnap_settings( 'ss_sf_button_columns' ), 'vertical' => socialsnap_settings( 'ss_sf_button_vertical' ), 'labels' => socialsnap_settings( 'ss_sf_button_labels' ), 'scheme' => socialsnap_settings( 'ss_sf_button_scheme' ), ); // Widget Slug. $widget_slug = 'socialsnap-social-followers-widget'; // Widget basics. $widget_ops = array( 'classname' => $widget_slug, 'description' => _x( 'Displays social follow links with follower counts.', 'Widget', 'socialsnap' ), ); // Widget controls. $control_ops = array( 'id_base' => $widget_slug, ); parent::__construct( $widget_slug, _x( 'Social Snap: Social Followers', 'Widget', 'socialsnap' ), $widget_ops, $control_ops ); } /** * Outputs the HTML for this widget. * * @since 1.0.0 * @param array $args An array of standard parameters for widgets in this theme. * @param array $instance An array of settings for this widget instance. */ public function widget( $args, $instance ) { // Merge with defaults. $instance = wp_parse_args( (array) $instance, $this->defaults ); echo wp_kses( $args['before_widget'], socialsnap_get_allowed_html_tags( 'post' ) ); // Title. if ( ! empty( $instance['title'] ) ) { echo wp_kses( $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'], socialsnap_get_allowed_html_tags( 'post' ) ); } // Build social follow shortcode. $shortcode = '[ss_social_follow'; $instance['networks'] = isset( $instance['networks'] ) ? $instance['networks'] : ''; $instance['networks'] = preg_replace( '/ |\t/', '', $instance['networks'] ); $instance['networks'] = preg_replace( '/\n/', ';', $instance['networks'] ); $instance['networks'] = strtolower( $instance['networks'] ); if ( '' != $instance['networks'] ) { $shortcode .= ' networks="' . $instance['networks'] . '"'; } $shortcode .= ' total_followers="' . $instance['total_followers'] . '"'; $shortcode .= ' button_followers="' . $instance['button_followers'] . '"'; $shortcode .= ' size="' . $instance['size'] . '"'; $shortcode .= ' spacing="' . $instance['spacing'] . '"'; $shortcode .= ' columns="' . $instance['columns'] . '"'; $shortcode .= ' vertical="' . $instance['vertical'] . '"'; $shortcode .= ' scheme="' . $instance['scheme'] . '"'; $shortcode .= ' labels="' . $instance['labels'] . '"'; $shortcode .= ']'; echo do_shortcode( $shortcode ); echo wp_kses( $args['after_widget'], socialsnap_get_allowed_html_tags( 'post' ) ); } /** * Deals with the settings when they are saved by the admin. Here is * where any validation should be dealt with. * * @since 1.0.0 * @param array $new_instance An array of new settings as submitted by the admin. * @param array $old_instance An array of the previous settings. * @return array The validated and (if necessary) amended settings */ public function update( $new_instance, $old_instance ) { $new_instance['title'] = wp_strip_all_tags( $new_instance['title'] ); $new_instance['networks'] = isset( $new_instance['networks'] ) ? sanitize_text_field( $new_instance['networks'] ) : ''; $new_instance['total_followers'] = isset( $new_instance['total_followers'] ) && $new_instance['total_followers'] ? '1' : false; $new_instance['button_followers'] = isset( $new_instance['button_followers'] ) && $new_instance['button_followers'] ? '1' : false; $new_instance['spacing'] = isset( $new_instance['spacing'] ) && $new_instance['spacing'] ? '1' : false; $new_instance['vertical'] = isset( $new_instance['vertical'] ) && $new_instance['vertical'] ? '1' : false; $new_instance['labels'] = isset( $new_instance['labels'] ) && $new_instance['labels'] ? '1' : false; $new_instance['size'] = isset( $new_instance['size'] ) ? $new_instance['size'] : socialsnap_settings( 'ss_sf_button_size' ); $new_instance['columns'] = isset( $new_instance['columns'] ) ? $new_instance['columns'] : socialsnap_settings( 'ss_sf_button_columns' ); $new_instance['scheme'] = isset( $new_instance['scheme'] ) ? $new_instance['scheme'] : socialsnap_settings( 'ss_sf_button_scheme' ); return $new_instance; } /** * Displays the form for this widget on the Widgets page of the WP Admin area. * * @since 1.0.0 * @param array $instance An array of the current settings for this widget. * @return void */ public function form( $instance ) { // Merge with defaults. $instance = wp_parse_args( (array) $instance, $this->defaults ); ?>
here.', 'socialsnap' ), socialsnap_get_allowed_html_tags() ); ?>
>
>
>
>
>