Advertisement
vincurekf

Wordpress Customizer Setup

Aug 22nd, 2019
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. add_action( 'customize_register', 'registerSection' );
  2.  
  3. function registerSection( $wp_customize ){
  4.  
  5.   $section_key = "custom_section_key";
  6.  
  7.   $wp_customize->add_section( $section_key, array(
  8.     'title'    => "Section Title",
  9.     'priority' => 160,
  10.   ) );
  11.  
  12.   $setting_id = "custom_setting_id";
  13.    
  14.   $wp_customize->add_setting( $setting_id, array(
  15.     'default'    => '',
  16.     'transport'  => 'refresh',
  17.     'capability' => 'manage_options',
  18.     'type'       => 'option',
  19.     'sanitize_callback' => 'sanitize_text_field'
  20.   ) );
  21.  
  22.   $wp_customize->add_control( $setting_id, array(
  23.     'label'    => 'Option Label',
  24.     'section'  => $section_key,
  25.     'settings' => $setting_id,
  26.     'type'     => 'text',
  27.     'active_callback' => function () { return true; },
  28.   ) );
  29. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement