Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function my_theme_customizer() {
- //add panel
- $wp_customize->add_panel('my_option_panel', array(
- 'priority' => 10,
- 'title' => 'my panel'
- ));
- }
- add_action('customize_register', 'my_theme_customizer');
- //sanitize
- //select box
- function sanitize_choices($input, $setting) {
- global $wp_customize;
- $control = $wp_customize->get_control($setting->id);
- if(array_key_exists($input, $control->choices)) {
- return $input;
- } else {
- return $setting->default;
- }
- }
- //check box
- function sanitize_checkbox($input) {
- if($input == true) {
- return true;
- } else {
- return false;
- }
- }
- //text area
- if(class_exists('WP_Customize_Control')) : class Customize_Textarea_Control extends WP_Customize_Control {
- public $type = 'textarea';
- public function render_content() {
- ?>
- <label>
- <span class="customize-control-title"><?php echo esc_html($this->label); ?></span>
- <textarea rows="6" style="width: 100%" <?php $this->link(); ?>><?php echo esc_textarea($this->value()); ?></textarea>
- </label>
- <?php
- }
- }
- endif;
Add Comment
Please, Sign In to add comment