text_fields = array('em-tabbed-popular-posts-title', 'em-tabbed-latest-posts-title', 'em-tabbed-categorised-posts-title'); $this->select_fields = array('em-show-excerpt', 'em-enable-categorised-tab', 'em-select-category'); $widget_ops = array( 'classname' => 'elegant_magazine_tabbed_posts_widget', 'description' => __('Displays tabbed posts lists from selected settings.', 'elegant-magazine'), 'customize_selective_refresh' => true, ); parent::__construct('elegant_magazine_tabbed_posts', __('EM Tabbed Posts', 'elegant-magazine'), $widget_ops); } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { $instance = parent::em_sanitize_data($instance, $instance); $tab_id = 'tabbed-' . $this->number; /** This filter is documented in wp-includes/default-widgets.php */ $show_excerpt = isset($instance['em-show-excerpt']) ? $instance['em-show-excerpt'] : 'true'; $excerpt_length = '20'; $number_of_posts = '5'; $popular_title = isset($instance['em-tabbed-popular-posts-title']) ? $instance['em-tabbed-popular-posts-title'] : __('EM Popular', 'elegant-magazine'); $latest_title = isset($instance['em-tabbed-latest-posts-title']) ? $instance['em-tabbed-latest-posts-title'] : __('EM Latest', 'elegant-magazine'); $enable_categorised_tab = isset($instance['em-enable-categorised-tab']) ? $instance['em-enable-categorised-tab'] : 'true'; $categorised_title = isset($instance['em-tabbed-categorised-posts-title']) ? $instance['em-tabbed-categorised-posts-title'] : __('EM Categorised', 'elegant-magazine'); $category = isset($instance['em-select-category']) ? $instance['em-select-category'] : '0'; // open the widget container echo $args['before_widget']; ?>
form_instance = $instance; $options = array( 'true' => __('Yes', 'elegant-magazine'), 'false' => __('No', 'elegant-magazine') ); // generate the text input for the title of the widget. Note that the first parameter matches text_fields array entry ?>