Skip to content
Snippets Groups Projects
Code owners
tag-dropdown-widget.php 20.90 KiB
<?php
/*
Plugin Name: Taxonomy Dropdown Widget
Plugin URI: http://www.ethitter.com/plugins/taxonomy-dropdown-widget/
Description: Creates a dropdown list of non-hierarchical taxonomies as an alternative to the term (tag) cloud. Widget provides numerous options to tailor the output to fit your site. Dropdown function can also be called directly for use outside of the widget. Formerly known as <strong><em>Tag Dropdown Widget</em></strong>.
Author: Erick Hitter
Version: 2.0.3
Author URI: http://www.ethitter.com/

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

/**
 ** TAXONOMY DROPDOWN WIDGET PLUGIN
 **/
class taxonomy_dropdown_widget_plugin {
	/*
	 * Class variables
	 */
	var $option_defaults = array(
		'taxonomy' => 'post_tag',
		'select_name' => 'Select Tag',
		'max_name_length' => 0,
		'cutoff' => '&hellip;',
		'limit' => 0,
		'order' => 'ASC',
		'orderby' => 'name',
		'threshold' => 0,
		'incexc' => 'exclude',
		'incexc_ids' => array(),
		'hide_empty' => true,
		'post_counts' => false
	);

	/*
	 * Register actions and activation/deactivation hooks
	 * @uses add_action, register_activation_hook, register_deactivation_hook
	 * @return null
	 */
	function __construct() {
		add_action( 'widgets_init', array( $this, 'action_widgets_init' ) );

		register_activation_hook( __FILE__, array( $this, 'activation_hook' ) );
		register_deactivation_hook( __FILE__, array( $this, 'deactivation_hook' ) );
	}

	/*
	 * Run plugin cleanup on activation
	 * @uses this::cleanup
	 * @hook activation
	 * @return null
	 */
	function activation_hook() {
		$this->cleanup();
	}

	/*
	 * Unregister widget when plugin is deactivated and run cleanup