's2_counter', 'description' => esc_html__( 'Subscriber Counter widget for Subscribe2', 'subscribe2' ), 'customize_selective_refresh' => true, ); $control_options = array( 'width' => 250, 'height' => 500, ); parent::__construct( 's2_counter', esc_html__( 'Subscribe2 Counter', 'subscribe2' ), $widget_options, $control_options ); } /** * Displays the Widget */ public function widget( $args, $instance ) { $title = empty( $instance['title'] ) ? 'Subscriber Count' : $instance['title']; $s2w_bg = empty( $instance['s2w_bg'] ) ? '#e3dacf' : $instance['s2w_bg']; $s2w_fg = empty( $instance['s2w_fg'] ) ? '#345797' : $instance['s2w_fg']; $s2w_width = empty( $instance['s2w_width'] ) ? '82' : $instance['s2w_width']; $s2w_height = empty( $instance['s2w_height'] ) ? '16' : $instance['s2w_height']; $s2w_font = empty( $instance['s2w_font'] ) ? '11' : $instance['s2w_font']; echo wp_kses_post( $args['before_widget'] ); if ( ! empty( $title ) ) { echo wp_kses_post( $args['before_title'] ) . esc_html( $title ) . wp_kses_post( $args['after_title'] ); } global $mysubscribe2; $registered = $mysubscribe2->get_registered(); $confirmed = $mysubscribe2->get_public(); $count = ( count( $registered ) + count( $confirmed ) ); echo wp_kses_post( ''; echo wp_kses_post( $args['after_widget'] ); } /** * Saves the widgets settings. */ public function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = wp_strip_all_tags( stripslashes( $new_instance['title'] ) ); $instance['s2w_bg'] = wp_strip_all_tags( stripslashes( $new_instance['s2w_bg'] ) ); $instance['s2w_fg'] = wp_strip_all_tags( stripslashes( $new_instance['s2w_fg'] ) ); $instance['s2w_width'] = wp_strip_all_tags( stripslashes( $new_instance['s2w_width'] ) ); $instance['s2w_height'] = wp_strip_all_tags( stripslashes( $new_instance['s2w_height'] ) ); $instance['s2w_font'] = wp_strip_all_tags( stripslashes( $new_instance['s2w_font'] ) ); return $instance; } /** * Creates the edit form for the widget. */ public function form( $instance ) { // set some defaults $options = get_option( 'widget_s2counter' ); if ( false === $options ) { $defaults = array( 'title' => 'Subscriber Count', 's2w_bg' => '#e3dacf', 's2w_fg' => '#345797', 's2w_width' => '82', 's2w_height' => '16', 's2w_font' => '11', ); } else { $defaults = array( 'title' => $options['title'], 's2w_bg' => $options['s2w_bg'], 's2w_fg' => $options['s2w_fg'], 's2w_width' => $options['s2w_width'], 's2w_height' => $options['s2w_height'], 's2w_font' => $options['s2w_font'], ); delete_option( 'widget_s2counter' ); } $instance = wp_parse_args( (array) $instance, $defaults ); // Be sure you format your options to be valid HTML attributes. $s2w_title = htmlspecialchars( $instance['title'], ENT_QUOTES ); $s2w_bg = htmlspecialchars( $instance['s2w_bg'], ENT_QUOTES ); $s2w_fg = htmlspecialchars( $instance['s2w_fg'], ENT_QUOTES ); $s2w_width = htmlspecialchars( $instance['s2w_width'], ENT_QUOTES ); $s2w_height = htmlspecialchars( $instance['s2w_height'], ENT_QUOTES ); $s2w_font = htmlspecialchars( $instance['s2w_font'], ENT_QUOTES ); echo '
' . "\r\n"; echo '
' . "\r\n"; echo '' . "\r\n"; echo '
' . "\r\n"; echo '
' . "\r\n"; echo '' . esc_html__( 'Color Scheme', 'subscribe2' ) . '' . "\r\n"; echo '
' . "\r\n"; echo '
' . "\r\n"; echo '
'; echo '
'; echo '
' . "\r\n"; echo '' . esc_html__( 'Width, Height and Font Size', 'subscribe2' ) . '' . "\r\n"; echo '' . "\r\n"; echo '' . "\r\n"; echo '' . "\r\n"; echo '' . "\r\n"; echo '' . "\r\n"; echo '' . "\r\n"; echo '' . "\r\n"; echo '
' . "\r\n"; } }// end S2_Counter_widget class