Last active
September 28, 2019 19:33
-
-
Save w3guy/084e7f983c4483d6444a28447085b665 to your computer and use it in GitHub Desktop.
WordPress customizer range control with indicator for selected value. http://w3guy.com/wordpress-customizer-range-control-selected-indicator/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
$(document).ready(function ($) { | |
$('input[data-input-type]').on('input change', function () { | |
var val = $(this).val(); | |
$(this).prev('.cs-range-value').html(val); | |
$(this).val(val); | |
}); | |
}) | |
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class WP_Customize_Range_Control extends WP_Customize_Control | |
{ | |
public $type = 'custom_range'; | |
public function enqueue() | |
{ | |
wp_enqueue_script( | |
'cs-range-control', | |
'path/to/range-control.js', | |
array('jquery'), | |
false, | |
true | |
); | |
} | |
public function render_content() | |
{ | |
?> | |
<label> | |
<?php if ( ! empty( $this->label )) : ?> | |
<span class="customize-control-title"><?php echo esc_html($this->label); ?></span> | |
<?php endif; ?> | |
<div class="cs-range-value"><?php echo esc_attr($this->value()); ?></div> | |
<input data-input-type="range" type="range" <?php $this->input_attrs(); ?> value="<?php echo esc_attr($this->value()); ?>" <?php $this->link(); ?> /> | |
<?php if ( ! empty( $this->description )) : ?> | |
<span class="description customize-control-description"><?php echo $this->description; ?></span> | |
<?php endif; ?> | |
</label> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
invalid value error on wp ?