* * @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.2.0 * 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_category_widget' ); /** * Register our widget. */ function canuck_register_category_widget() { register_widget( 'Canuck_Category_Widget' ); } /** * Categories widget class */ class Canuck_Category_Widget extends WP_Widget { /** * Sets up the widgets name etc. */ public function __construct() { $widget_ops = array( 'classname' => 'canuck_category_widget_class', 'description' => esc_html__( 'Display selected categories', 'canuck' ), ); parent::__construct( 'canuck_category_widget', esc_html__( 'Canuck Category Widget', 'canuck' ), $widget_ops ); } /** * Outputs the options form on admin. * * @param array $instance The widget options. */ public function form( $instance ) { $canuck_category_defaults = array( 'canuck_title' => esc_html__( 'Categories', 'canuck' ), 'canuck_count' => false, 'canuck_hierarchical' => false, 'canuck_dropdown' => false, ); $instance = wp_parse_args( (array) $instance, $canuck_category_defaults ); $title = $instance['canuck_title']; $count = $instance['canuck_count']; $hierarchical = $instance['canuck_hierarchical']; $dropdown = $instance['canuck_dropdown']; // Validate data. if ( true !== $count ) { $count = false; } if ( true !== $hierarchical ) { $hierarchical = false; } if ( true !== $dropdown ) { $dropdown = false; } ?>
/>
/>
/>