'widget_tdd_posts_widget', 'description' => __('Shows the latest posts or the best posts (most viewed or most commented), with controls for the number of posts and the number of posts per row.', 'inaikas-posts-widget'), 'customize_selective_refresh' => true, ) ); } /** * Front-end output. * * @param array $args Sidebar arguments. * @param array $instance Widget settings. */ public function widget($args, $instance) { $instance = tdd_posts_widget_parse_args($instance); $html = tdd_posts_widget_render_list($instance); if ('' === $html) { return; } $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped if ('' !== trim((string) $title)) { echo $args['before_title'] . $title . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** * Admin form. * * @param array $instance Widget settings. */ public function form($instance) { $instance = tdd_posts_widget_parse_args($instance); ?>
$this->get_field_name('category'), 'id' => $this->get_field_id('category'), 'class' => 'widefat', 'selected' => (int) $instance['category'], 'show_option_all' => __('All categories', 'inaikas-posts-widget'), 'option_none_value' => '0', 'hide_empty' => false, 'hierarchical' => true, 'value_field' => 'term_id', ) ); ?>
>
>
>
>
isset($new_instance['title']) ? $new_instance['title'] : '', 'source' => isset($new_instance['source']) ? $new_instance['source'] : 'latest', 'best_by' => isset($new_instance['best_by']) ? $new_instance['best_by'] : 'views', 'count' => isset($new_instance['count']) ? $new_instance['count'] : 6, 'columns' => isset($new_instance['columns']) ? $new_instance['columns'] : 1, 'category' => isset($new_instance['category']) ? $new_instance['category'] : 0, 'show_thumbnail' => !empty($new_instance['show_thumbnail']), 'show_date' => !empty($new_instance['show_date']), 'show_comments' => !empty($new_instance['show_comments']), 'exclude_current' => !empty($new_instance['exclude_current']), ) ); } }