* @copyright Copyright (c) 2015, Genbu Media * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ class AMPFORWP_Customize_Control_Sortable_Checkboxes extends WP_Customize_Control { /** * Control Type */ public $type = 'ampforwp-design-multicheck-sortable'; /** * Enqueue Scripts */ public function enqueue() { wp_enqueue_style( 'ampforwp-share-customize' ); wp_enqueue_script( 'ampforwp-share-customize' ); } /** * Render Settings */ public function render_content() { /* if no choices, bail. */ if ( empty( $this->choices ) ){ return; } ?> label ) ){ ?> label ); ?> description ) ){ ?> description; ?> value() ); $choices = $this->choices; /* If values exist, use it. */ $options = array(); if( $values ){ /* get individual item */ foreach( $values as $value ){ /* separate item with option */ $value = explode( ':', $value ); /* build the array. remove options not listed on choices. */ if ( array_key_exists( $value[0], $choices ) ){ $options[$value[0]] = $value[1] ? '1' : '0'; } } } /* if there's new options (not saved yet), add it in the end. */ foreach( $choices as $key => $val ){ /* if not exist, add it in the end. */ if ( ! array_key_exists( $key, $options ) ){ $options[$key] = '0'; // use zero to deactivate as default for new items. } } ?>