'small', // or medium or large 'placeholder' => '', // show this when blank 'min' => 0, 'max' => 1000, 'step' => 1, 'default' => 0, 'unit' => '', ); /** * Constructor * * @since 1.4 */ function __construct( $settings, $owner ) { parent::__construct( $settings, $owner ); mm_add_action_once( 'admin_enqueue_scripts', array( $this, 'enqueueSlider' ) ); mm_add_action_once( 'customize_controls_enqueue_scripts', array( $this, 'enqueueSlider' ) ); add_action( 'admin_head', array( __CLASS__, 'createSliderScript' ) ); } /** * Cleans up the serialized value before saving * * @param string $value The serialized value * @return string The cleaned value * @since 1.4 */ public function cleanValueForSaving( $value ) { if ( $value == '' ) { return 0; } return $value; } /** * Cleans the value for getOption * * @param string $value The raw value of the option * @return mixes The cleaned value * @since 1.4 */ public function cleanValueForGetting( $value ) { if ( $value == '' ) { return 0; } return $value; } /** * Enqueues the jQuery UI scripts * * @return void * @since 1.4 */ public function enqueueSlider() { wp_enqueue_script( 'jquery-ui-core' ); wp_enqueue_script( 'jquery-ui-slider' ); wp_enqueue_script( 'underscore' ); } /** * Prints out the script the initializes the jQuery slider * * @return void * @since 1.4 */ public static function createSliderScript() { ?> echoOptionHeader(); echo "
"; printf(' %s%s
', $this->settings['size'], $this->getID(), $this->settings['placeholder'], $this->getID(), esc_attr( $this->getValue() ), $this->settings['min'], $this->settings['max'], $this->settings['step'], $this->settings['unit'], $this->settings['desc'] ); $this->echoOptionFooter( false ); } }