type . '-' . $this->id; $data['label'] = html_entity_decode( $this->label, ENT_QUOTES, get_bloginfo( 'charset' ) ); $data['value'] = $this->value(); $data['link'] = $this->get_link(); $data['choices'] = $this->choices; $data['columns'] = $this->columns; $data['defaultValue'] = $this->setting->default; $options = array(); if ( is_array( $this->choices ) && ! empty( $this->choices ) ) { foreach ( $this->choices as $key => $val ) { $options[] = "{$key}|||{$val}"; } } $data['options'] = $options; return $data; } /** * Enqueue scripts and styles. * * @since 1.0.0 */ public function enqueue() { wp_enqueue_style( 'nscu-controls' ); wp_enqueue_script( 'nscu-controls' ); } /** * Render JS template. * * @since 1.0.0 */ public function content_template() { ?> <# if ( ! data.choices ) { return; } #> <# if ( data.label ) { #> {{ data.label }} <# } #> <# if ( data.description ) { #> {{{ data.description }}} <# } #> <# var optionArr, optionKey, optionVal #>
<# _.each( data.options, function( option ) { #> <# optionArr = option.split( '|||' ) #> <# optionKey = optionArr[0] #> <# optionVal = optionArr[1] #> <# } ) #>