'widget_apw_recent_posts advanced-posts-widget', 'description' => __( 'A recent posts widget with extended features.' ), 'customize_selective_refresh' => true, ); $control_options = array(); parent::__construct( 'advanced-posts-widget', // $this->id_base __( 'Advanced Recent Posts' ), // $this->name $widget_options, // $this->widget_options $control_options // $this->control_options ); $this->alt_option_name = 'widget_apw_recent_posts'; } /** * Outputs the content for the current widget instance. * * Use 'widget_title' to filter the widget title. * * @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 Posts widget instance. */ public function widget( $args, $instance ) { if ( ! isset( $args['widget_id'] ) ){ $args['widget_id'] = $this->id; } $_defaults = Advanced_Posts_Widget_Utils::instance_defaults(); $instance = wp_parse_args( (array) $instance, $_defaults ); // build out the instance for devs $instance['id_base'] = $this->id_base; $instance['widget_number'] = $this->number; $instance['widget_id'] = $this->id; // widget title $_title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); $r = Advanced_Posts_Widget_Utils::get_apw_posts( $instance, $this ); if ( $r && $r->have_posts() ) : echo $args['before_widget']; if( $_title ) { echo $args['before_title'] . $_title . $args['after_title']; }; do_action( 'apw_widget_title_after', $instance, $r ); /** * Prints out the css url only if in Customizer * * Actual stylesheet is enqueued if the user selects to use default styles * * @since 1.0 */ if( ! empty( $instance['css_default'] ) && is_customize_preview() ) { echo Advanced_Posts_Widget_Utils::css_preview( $instance, $this ); } ?>
id_base; $instance['widget_number'] = $this->number; $instance['widget_id'] = $this->id; $instance = apply_filters('apw_update_instance', $instance, $new_instance, $old_instance, $this ); do_action( 'apw_update_widget', $this, $instance, $new_instance, $old_instance ); return $instance; } /** * Outputs the settings form for the Posts widget. * * Applies 'apw_form_defaults' filter on form fields to allow extension by plugins. * * @access public * * @since 1.0 * * @param array $instance Current settings. */ public function form( $instance ) { $defaults = Advanced_Posts_Widget_Utils::instance_defaults(); $instance = wp_parse_args( (array) $instance, $defaults ); include( Advanced_Posts_Widget_Utils::get_apw_sub_path('inc') . 'widget-form.php' ); } }