* * @wordpress plugin * Plugin Name: Canuck Category Widget * Plugin URI: http://kevinsspace.ca/canuckdemo/ * Description: A widget for the Canuck Theme that allows the user to remove categories from the list. * Version: 1.1.3 * Author: Kevin Archibald * Author URI: http://kevinsspace.ca/ * License: GPLv2 or later * License URI: http://www.gnu.org/licenses/gpl-2.0.txt */ /** * Use widgets_init action hook to execute custom function. */ add_action( 'widgets_init', 'canuck_register_archives_widget' ); /** * Register our widget. */ function canuck_register_archives_widget() { register_widget( 'Canuck_Archives_Widget' ); } /** * Archives widget class. */ class Canuck_Archives_Widget extends WP_Widget { /** * Sets up the widgets name etc. */ public function __construct() { $widget_ops = array( 'classname' => 'canuck_widget_archive_class', 'description' => esc_html__( 'A monthly archive of your Posts with excluded categories omitted.', 'canuck' ), 'customize_selective_refresh' => true, ); parent::__construct( 'canuck_archives', esc_html__( 'Canuck Archives Widget', 'canuck' ), $widget_ops); } /** * Outputs the content for the current Archives widget instance. * * @since 2.8.0 * * @param array $args Display arguments including 'before_title', 'after_title', * 'before_widget', and 'after_widget'. * @param array $instance Settings for the current Archives widget instance. */ public function widget( $args, $instance ) { $title = ! empty( $instance['title'] ) ? $instance['title'] : esc_html__( 'Archives', 'canuck' ); /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); $d = ! empty( $instance['dropdown'] ) ? '1' : '0'; echo $args['before_widget']; if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; } if ( $d ) { $dropdown_id = "{$this->id_base}-dropdown-{$this->number}"; ?> '', 'count' => 0, 'dropdown' => '') ); $instance['title'] = sanitize_text_field( $new_instance['title'] ); $instance['dropdown'] = $new_instance['dropdown'] ? 1 : 0; return $instance; } /** * Outputs the settings form for the Archives widget. * * @since 2.8.0 * * @param array $instance Current settings. */ public function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') ); $title = sanitize_text_field( $instance['title'] ); ?>

id="get_field_id('dropdown'); ?>" name="get_field_name('dropdown'); ?>" />