text_fields = array('magnitude-tabbed-popular-posts-title', 'magnitude-tabbed-latest-posts-title', 'magnitude-tabbed-categorised-posts-title', 'magnitude-excerpt-length', 'magnitude-posts-number'); $this->select_fields = array('magnitude-show-excerpt', 'magnitude-enable-categorised-tab', 'magnitude-select-category', 'magnitude-show-category'); $widget_ops = array( 'classname' => 'magnitude_tabbed_posts_widget', 'description' => __('Displays tabbed posts lists from selected settings.', 'magnitude'), 'customize_selective_refresh' => false, ); parent::__construct('magnitude_tabbed_posts', __('AFTM Tabbed Posts', 'magnitude'), $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::magnitude_sanitize_data($instance, $instance); $tab_id = 'tabbed-' . $this->number; /** This filter is documented in wp-includes/default-widgets.php */ $show_category = 'true'; $popular_title = isset($instance['magnitude-tabbed-popular-posts-title']) ? $instance['magnitude-tabbed-popular-posts-title'] : __('AFTM Popular', 'magnitude'); $latest_title = isset($instance['magnitude-tabbed-latest-posts-title']) ? $instance['magnitude-tabbed-latest-posts-title'] : __('AFTM Latest', 'magnitude'); $enable_categorised_tab = isset($instance['magnitude-enable-categorised-tab']) ? $instance['magnitude-enable-categorised-tab'] : 'true'; $categorised_title = isset($instance['magnitude-tabbed-categorised-posts-title']) ? $instance['magnitude-tabbed-categorised-posts-title'] : __('Trending', 'magnitude'); $category = isset($instance['magnitude-select-category']) ? $instance['magnitude-select-category'] : '0'; // open the widget container echo $args['before_widget']; ?>
form_instance = $instance; $enable_categorised_tab = array( 'true' => __('Yes', 'magnitude'), 'false' => __('No', 'magnitude') ); $options = array( 'true' => __('Yes', 'magnitude'), 'false' => __('No', 'magnitude'), ); // generate the text input for the title of the widget. Note that the first parameter matches text_fields array entry ?>