Created
May 8, 2015 17:04
-
-
Save justintadlock/b257f76565fab2566348 to your computer and use it in GitHub Desktop.
Dropdown taxonomy terms customizer control
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* A dropdown taxonomy terms `<select>` customizer control class. | |
* | |
* @package Hybrid | |
* @subpackage Classes | |
* @author Justin Tadlock <justin@justintadlock.com> | |
* @copyright Copyright (c) 2008 - 2015, Justin Tadlock | |
* @link http://themehybrid.com/hybrid-core | |
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html | |
*/ | |
/** | |
* Dropdown terms customize control class. | |
* | |
* @since 3.0.0 | |
*/ | |
class Hybrid_Customize_Control_Dropdown_Terms extends WP_Customize_Control { | |
/** | |
* The type of customize control being rendered. | |
* | |
* @since 3.0.0 | |
* @var string | |
*/ | |
public $type = 'dropdown-terms'; | |
/** | |
* Custom arguments to pass into `wp_dropdown_categories()`. | |
* | |
* @since 3.0.0 | |
* @var string | |
*/ | |
public $args = array(); | |
/** | |
* Displays the control content. | |
* | |
* @since 3.0.0 | |
*/ | |
public function render_content() { | |
$defaults = array( | |
'show_option_none' => ' ', | |
'option_none_value' => '0', | |
); | |
$args = wp_parse_args( $defaults, $this->args ); | |
$args['name'] = '_customize-dropdown-terms-' . $this->id; | |
$args['selected'] = $this->value(); | |
$args['echo'] = false; ?> | |
<label> | |
<?php if ( !empty( $this->label ) ) : ?> | |
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> | |
<?php endif; ?> | |
<?php if ( !empty( $this->description ) ) : ?> | |
<span class="description customize-control-description"><?php echo $this->description; ?></span> | |
<?php endif; ?> | |
<?php echo str_replace( '<select', '<select ' . $this->get_link(), wp_dropdown_categories( $args ) ); ?> | |
</label> | |
<?php } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have been trying to craate child theme for "hybrid-base" theme, but the drop-downs is not working. I mean the menu does not call js. I used "dd_theme_support('drop-downs'), but it does not work either. One of the many blogs I have now setting up with "hybrid-core" framework is this: http://otsus.blog/
Thanks