* @copyright Copyright (c) 2012, Jesper Johansen * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ /** * Multiple Select customize control class. * * @since Cakifo 1.5.0 */ class Cakifo_Customize_Control_Multiple_Select extends WP_Customize_Control { /** * The type of customize control being rendered. * * @since Cakifo 1.5.0 */ public $type = 'multiple-select'; /** * Displays the multiple select on the customize screen. * * @since Cakifo 1.5.0 */ public function render_content() { if ( empty( $this->choices ) ) return; ?> by taxonomy * and the select is enhanced by Chosen.js. * * @since Cakifo 1.6.0 */ class Cakifo_Customize_Control_Multiple_Select_Headlines extends WP_Customize_Control { /** * The type of customize control being rendered. * * @since Cakifo 1.6.0 */ public $type = 'cakifo-headlines-multiple-select'; /** * Enqueue control related scripts/styles. * * @since Cakifo 1.6.0 */ public function enqueue() { wp_enqueue_script( 'jquery-ui-sortable' ); wp_enqueue_script( 'cakifo-theme-settings-chosen', get_template_directory_uri() . '/functions/admin/chosen.js', array( 'jquery', 'jquery-ui-sortable' ), '1.0' ); wp_enqueue_style( 'cakifo-theme-settings-chosen', get_template_directory_uri() . '/functions/admin/chosen.css', array(), '1.0' ); } /** * Displays the multiple select on the customize screen. * * @since Cakifo 1.6.0 */ public function render_content() { $get_selected_terms = $this->value(); $exclude_term_ids = array(); /* Get all the selected terms IDs in an array. */ foreach( $get_selected_terms as $term ) : // The Customizer stores the terms in a string in the `taxonomy:id` format if ( is_string( $term ) && strpos( $term, ':' ) !== false ) { $term = explode( ':', $term ); $exclude_term_ids[] = $term[1]; // Back-compat when only an ID is used. } elseif ( is_string( $term ) || is_int( $term ) ) { $exclude_term_ids[] = $term; // Normal array } else { $exclude_term_ids[] = $term[1]; } endforeach; $exclude_term_ids = wp_parse_id_list( $exclude_term_ids ); ?>