defaults = array( 'title' => '', 'tweet' => '', 'content' => '', 'style' => 'default', 'link' => '', 'via' => '', 'related' => '', 'hide_on_mobile' => '', ); // Widget Slug. $widget_slug = 'socialsnap-ctt-widget'; // Widget basics. $widget_ops = array( 'classname' => $widget_slug, 'description' => _x( 'Displays Click to Tweet box.', 'Widget', 'socialsnap' ), ); // Widget controls. $control_ops = array( 'id_base' => $widget_slug, ); parent::__construct( $widget_slug, _x( 'Social Snap: Click to Tweet', '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' ) ); } echo do_shortcode( '[ss_click_to_tweet content="' . $instance['content'] . '" tweet="' . $instance['tweet'] . '" style="' . $instance['style'] . '" link="' . $instance['link'] . '" via="' . $instance['via'] . '"]' ); 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['tweet'] = isset( $new_instance['tweet'] ) ? wp_strip_all_tags( $new_instance['tweet'] ) : ''; $new_instance['content'] = isset( $new_instance['content'] ) ? wp_strip_all_tags( $new_instance['content'] ) : ''; $new_instance['style'] = isset( $new_instance['style'] ) ? $new_instance['style'] : 'default'; $new_instance['link'] = isset( $new_instance['link'] ) ? '1' : false; $new_instance['via'] = isset( $new_instance['via'] ) ? '1' : false; $new_instance['hide_on_mobile'] = isset( $new_instance['hide_on_mobile'] ) ? '1' : false; 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 ); ?>
>
>
>