Guest User

Untitled

a guest
Mar 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. <?php
  2. function my_theme_customizer() {
  3. //add panel
  4. $wp_customize->add_panel('my_option_panel', array(
  5. 'priority' => 10,
  6. 'title' => 'my panel'
  7. ));
  8. }
  9. add_action('customize_register', 'my_theme_customizer');
  10.  
  11.  
  12.  
  13. //sanitize
  14. //select box
  15. function sanitize_choices($input, $setting) {
  16. global $wp_customize;
  17. $control = $wp_customize->get_control($setting->id);
  18. if(array_key_exists($input, $control->choices)) {
  19. return $input;
  20. } else {
  21. return $setting->default;
  22. }
  23. }
  24.  
  25. //check box
  26. function sanitize_checkbox($input) {
  27. if($input == true) {
  28. return true;
  29. } else {
  30. return false;
  31. }
  32. }
  33.  
  34. //text area
  35. if(class_exists('WP_Customize_Control')) : class Customize_Textarea_Control extends WP_Customize_Control {
  36. public $type = 'textarea';
  37. public function render_content() {
  38. ?>
  39. <label>
  40. <span class="customize-control-title"><?php echo esc_html($this->label); ?></span>
  41. <textarea rows="6" style="width: 100%" <?php $this->link(); ?>><?php echo esc_textarea($this->value()); ?></textarea>
  42. </label>
  43. <?php
  44. }
  45. }
  46. endif;
Add Comment
Please, Sign In to add comment