defaults = array( 'title' => __( 'Recent Posts', 'advance-widget-pack' ), 'post_count' => '5', 'show_image' => '0', 'show_date' => '0', 'show_author' => '0', 'show_category' => '0', 'show_comment_number' => '0', 'show_excerpt' => '0', ); $widget_ops = array( 'classname' => 'awp_recent_posts awp_widget', 'description' => __( 'Widget to display recent posts.', 'advance-widget-pack' ), ); $control_ops = array( 'id_base' => 'awp_recent_posts', 'width' => 200, 'height' => 250, ); parent::__construct( 'awp_recent_posts', __( 'AWP Recent Posts', 'advance-widget-pack' ), $widget_ops, $control_ops ); } public function widget( $args, $instance ) { $instance = wp_parse_args( (array) $instance, $this->defaults ); $title = apply_filters( 'widget_title', $instance['title'] ); $post_count = absint( $instance['post_count'] ); echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- sidebar-provided wrapper markup, trusted per WP core convention. if ( ! empty( $title ) ) { echo $args['before_title'] . esc_html( $title ) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- title text is esc_html()'d; before/after_title are sidebar-provided wrapper markup. } $post_ids = self::get_post_ids( $post_count ); if ( $post_ids ) { awp_is_rendering( true ); echo '
id="get_field_id( 'show_image' ) ); ?>" name="get_field_name( 'show_image' ) ); ?>" />
id="get_field_id( 'show_date' ) ); ?>" name="get_field_name( 'show_date' ) ); ?>" />
id="get_field_id( 'show_author' ) ); ?>" name="get_field_name( 'show_author' ) ); ?>" />
id="get_field_id( 'show_category' ) ); ?>" name="get_field_name( 'show_category' ) ); ?>" />
id="get_field_id( 'show_comment_number' ) ); ?>" name="get_field_name( 'show_comment_number' ) ); ?>" />
id="get_field_id( 'show_excerpt' ) ); ?>" name="get_field_name( 'show_excerpt' ) ); ?>" />