'widget_acw_recent_comments', 'description' => __( 'A comments widget with extended features.' ), 'customize_selective_refresh' => true, ); $control_options = array(); parent::__construct( 'acw-recent-comments', // $this->id_base __( 'Advanced Recent Comments' ), // $this->name $widget_options, // $this->widget_options $control_options // $this->control_options ); $this->alt_option_name = 'widget_acw_recent_comments'; } /** * Outputs the content for the current Recent Comments widget instance. * * Use 'widget_title' to filter the widget title. * Use 'acw_widget_comment_query_args' to filter the comment query args. * * @access public * * @since 1.0 * * @param array $args Display arguments including 'before_title', 'after_title', * 'before_widget', and 'after_widget'. * @param array $instance Settings for the current Recent Comments widget instance. */ public function widget( $args, $instance ) { if ( ! isset( $args['widget_id'] ) ){ $args['widget_id'] = $this->id; } $defaults = ACW_Recent_Comments_Utilities::instance_defaults(); $instance = wp_parse_args( (array) $instance, $defaults ); // build out the instance for plugin devs $instance['id_base'] = $this->id_base; $instance['widget_number'] = $this->number; $instance['widget_id'] = $this->id; // widget title $_title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : '' ; $_title = apply_filters( 'widget_title', $_title, $instance, $this->id_base ); // number of comments to show $_number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5 ; if ( ! $_number ) { $_number = 5; }; // order of display $_order = ( ! empty( $instance['order'] ) ) ? $instance['order'] : 'desc' ; // post type if( 'all' === $instance['post_type'] ) { $post_types = ACW_Recent_Comments_Utilities::get_post_types(); unset( $post_types['all'] ); $_post_types = array_keys( $post_types ); } else { $_post_types = $instance['post_type']; } // query $query_args = array( 'number' => $_number, 'status' => 'approve', 'post_status' => 'publish', 'post_type' => $_post_types, 'order' => $_order, ); if( ! empty( $instance['exclude_pings'] ) && $instance['exclude_pings'] ) { $query_args['type__not_in'] = 'pings'; } $query_args = apply_filters( "acw_widget_comment_query_args", $query_args, $instance ); $comments = get_comments( $query_args ); $comments = apply_filters( 'acw_comments', $comments, $instance ); ?>
ACW_Recent_Comments_Utilities::build_field_title( $instance, $this ), 'post_type' => ACW_Recent_Comments_Utilities::build_field_post_type( $instance, $this ), 'exclude_pings' => ACW_Recent_Comments_Utilities::build_field_pings( $instance, $this ), 'number' => ACW_Recent_Comments_Utilities::build_field_number( $instance, $this ), 'order' => ACW_Recent_Comments_Utilities::build_field_order( $instance, $this ), 'show_thumbs' => ACW_Recent_Comments_Utilities::build_field_show_thumbs( $instance, $this ), 'thumb_size' => ACW_Recent_Comments_Utilities::build_field_thumb_size( $instance, $this ), 'show_excerpt' => ACW_Recent_Comments_Utilities::build_field_show_excerpt( $instance, $this ), 'excerpt_length' => ACW_Recent_Comments_Utilities::build_field_excerpt_length( $instance, $this ), 'list_style' => ACW_Recent_Comments_Utilities::build_field_list_style( $instance, $this ), 'comment_format' => ACW_Recent_Comments_Utilities::build_field_comment_format( $instance, $this ), ); $acw_fields = apply_filters( 'acw_form_fields', $_fields, $instance, $this ); $acw_field_keys = array_keys( $acw_fields ); $first_field = reset( $acw_field_keys ); $last_field = end( $acw_field_keys ); foreach ( $acw_fields as $name => $field ) { if ( $first_field === $name ) { do_action( 'acw_form_before_fields', $instance, $this ); } do_action( "acw_form_before_field_{$name}", $instance, $this ); echo apply_filters( "acw_form_field_{$name}", $field, $instance, $this ) . "\n"; do_action( "acw_form_after_field_{$name}", $instance, $this ); if ( $last_field === $name ) { do_action( 'acw_form_after_fields', $instance, $this ); } } } }