array(), ); /** * Check if this instance is the first load of the option class * * @since 1.9.3 * @var bool $firstLoad */ private static $firstLoad = true; /** * Constructor * * @param array $settings Option settings * @param string $owner Namespace * * @since 1.9.3 */ function __construct( $settings, $owner ) { parent::__construct( $settings, $owner ); mm_add_action_once( 'admin_enqueue_scripts', array( $this, 'load_select_scripts' ) ); //mm_add_action_once( 'customize_controls_enqueue_scripts', array( $this, 'load_select_scripts' ) ); mm_add_action_once( 'admin_head', array( $this, 'init_select_script' ) ); //mm_add_action_once( 'customize_controls_print_footer_scripts', array( $this, 'init_select_script' ) ); } /* * Display for options and meta */ public function display() { $this->echoOptionHeader(); $multiple = isset( $this->settings['multiple'] ) && true == $this->settings['multiple'] ? 'multiple' : ''; $name = $this->getID(); $val = (array) $this->getValue(); if ( ! empty( $multiple ) ) { $name = "{$name}[]"; } ?>echoOptionFooter(); } /** * Register and load the select2 script * * @since 1.9.3 * @return void */ public function load_select_scripts() { wp_enqueue_script( 'mm-select2', MobileMenuOptions::getURL( '../js/select2/select2.min.js', __FILE__ ), array( 'jquery' ), WP_MOBILE_MENU_VERSION, true ); wp_enqueue_style( 'mm-select2-style', MobileMenuOptions::getURL( '../css/select2/select2.min.css', __FILE__ ), null, WP_MOBILE_MENU_VERSION, 'all' ); wp_enqueue_style( 'mm-select-option-style', MobileMenuOptions::getURL( '../css/class-option-select.css', __FILE__ ), null, WP_MOBILE_MENU_VERSION, 'all' ); } /** * Initialize the select2 field * * @since 1.9.3 * @return void */ public function init_select_script() { if ( ! self::$firstLoad ) { return; } self::$firstLoad = false; ?> $label ) { // This is if we have option groupings. if ( is_array( $label ) ) { ?> %s', $value, in_array( $value, $val ) ? 'selected="selected"' : '', disabled( stripos( $value, '!' ), 0, false ), $label ); } } }