WordPress Theme Customizer

Optimize Your Website For Search Engines Right Now
Jul
16

WordPress Theme Customizer

07/16/2018 12:00 AM
<?php
function turbo_customize_register($wp_customize){
    
    $wp_customize->add_section('turbo_color_scheme', array(
        'title'    => __('Color Scheme', 'turbo'),
        'priority' => 120,
    ));
    //  =============================
    //  = Text Input                =
    //  =============================
    $wp_customize->add_setting('turbo_theme_options[text_test]', array(
        'default'        => 'Arse!',
        'capability'     => 'edit_theme_options',
        'type'           => 'option',
    ));
    $wp_customize->add_control('turbo_text_test', array(
        'label'      => __('Text Test', 'turbo'),
        'section'    => 'turbo_color_scheme',
        'settings'   => 'turbo_theme_options[text_test]',
    ));
    //  =============================
    //  = Radio Input               =
    //  =============================
    $wp_customize->add_setting('turbo_theme_options[color_scheme]', array(
        'default'        => 'value2',
        'capability'     => 'edit_theme_options',
        'type'           => 'option',
    ));
    $wp_customize->add_control('turbo_color_scheme', array(
        'label'      => __('Color Scheme', 'turbo'),
        'section'    => 'turbo_color_scheme',
        'settings'   => 'turbo_theme_options[color_scheme]',
        'type'       => 'radio',
        'choices'    => array(
            'value1' => 'Choice 1',
            'value2' => 'Choice 2',
            'value3' => 'Choice 3',
        ),
    ));
    //  =============================
    //  = Checkbox                  =
    //  =============================
    $wp_customize->add_setting('turbo_theme_options[checkbox_test]', array(
        'capability' => 'edit_theme_options',
        'type'       => 'option',
    ));
    $wp_customize->add_control('display_header_text', array(
        'settings' => 'turbo_theme_options[checkbox_test]',
        'label'    => __('Display Header Text'),
        'section'  => 'turbo_color_scheme',
        'type'     => 'checkbox',
    ));
    //  =============================
    //  = Select Box                =
    //  =============================
     $wp_customize->add_setting('turbo_theme_options[header_select]', array(
        'default'        => 'value2',
        'capability'     => 'edit_theme_options',
        'type'           => 'option',
    ));
    $wp_customize->add_control( 'example_select_box', array(
        'settings' => 'turbo_theme_options[header_select]',
        'label'   => 'Select Something:',
        'section' => 'turbo_color_scheme',
        'type'    => 'select',
        'choices'    => array(
            'value1' => 'Choice 1',
            'value2' => 'Choice 2',
            'value3' => 'Choice 3',
        ),
    ));
    //  =============================
    //  = Image Upload              =
    //  =============================
    $wp_customize->add_setting('turbo_theme_options[image_upload_test]', array(
        'default'           => 'image.jpg',
        'capability'        => 'edit_theme_options',
        'type'           => 'option',
    ));
    $wp_customize->add_control( new WP_Customize_Image_Control($wp_customize, 'image_upload_test', array(
        'label'    => __('Image Upload Test', 'turbo'),
        'section'  => 'turbo_color_scheme',
        'settings' => 'turbo_theme_options[image_upload_test]',
    )));
    //  =============================
    //  = File Upload               =
    //  =============================
    $wp_customize->add_setting('turbo_theme_options[upload_test]', array(
        'default'           => 'arse',
        'capability'        => 'edit_theme_options',
        'type'           => 'option',
    ));
    $wp_customize->add_control( new WP_Customize_Upload_Control($wp_customize, 'upload_test', array(
        'label'    => __('Upload Test', 'turbo'),
        'section'  => 'turbo_color_scheme',
        'settings' => 'turbo_theme_options[upload_test]',
    )));
    //  =============================
    //  = Color Picker              =
    //  =============================
    $wp_customize->add_setting('turbo_theme_options[link_color]', array(
        'default'           => '000',
        'sanitize_callback' => 'sanitize_hex_color',
        'capability'        => 'edit_theme_options',
        'type'           => 'option',
    ));
    $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'link_color', array(
        'label'    => __('Link Color', 'turbo'),
        'section'  => 'turbo_color_scheme',
        'settings' => 'turbo_theme_options[link_color]',
    )));
    //  =============================
    //  = Page Dropdown             =
    //  =============================
    $wp_customize->add_setting('turbo_theme_options[page_test]', array(
        'capability'     => 'edit_theme_options',
        'type'           => 'option',
    ));
    $wp_customize->add_control('turbo_page_test', array(
        'label'      => __('Page Test', 'turbo'),
        'section'    => 'turbo_color_scheme',
        'type'    => 'dropdown-pages',
        'settings'   => 'turbo_theme_options[page_test]',
    ));
	
	
	
$wp_customize->add_section('turbo_my_scheme', array(
        'title'    => __('My Scheme', 'turbo'),
        'priority' => 120,
    ));
    //  =============================
    //  = Text Input                =
    //  =============================
    $wp_customize->add_setting('turbo_theme_options[text_test]', array(
        'default'        => 'Arse!',
        'capability'     => 'edit_theme_options',
        'type'           => 'option',
    ));
    $wp_customize->add_control('turbo_text_test', array(
        'label'      => __('Text Test', 'turbo'),
        'section'    => 'turbo_my_scheme',
        'settings'   => 'turbo_theme_options[text_test]',
    ));
    //  =============================
    //  = Radio Input               =
    //  =============================
    $wp_customize->add_setting('turbo_theme_options[color_scheme]', array(
        'default'        => 'value2',
        'capability'     => 'edit_theme_options',
        'type'           => 'option',
    ));
    $wp_customize->add_control('turbo_my_scheme', array(
        'label'      => __('Color Scheme', 'turbo'),
        'section'    => 'turbo_my_scheme',
        'settings'   => 'turbo_theme_options[color_scheme]',
        'type'       => 'radio',
        'choices'    => array(
            'value1' => 'Choice 1',
            'value2' => 'Choice 2',
            'value3' => 'Choice 3',
        ),
    ));
    //  =============================
    //  = Checkbox                  =
    //  =============================
    $wp_customize->add_setting('turbo_theme_options[checkbox_test]', array(
        'capability' => 'edit_theme_options',
        'type'       => 'option',
    ));
    $wp_customize->add_control('display_header_text', array(
        'settings' => 'turbo_theme_options[checkbox_test]',
        'label'    => __('Display Header Text'),
        'section'  => 'turbo_my_scheme',
        'type'     => 'checkbox',
    ));
    //  =============================
    //  = Select Box                =
    //  =============================
     $wp_customize->add_setting('turbo_theme_options[header_select]', array(
        'default'        => 'value2',
        'capability'     => 'edit_theme_options',
        'type'           => 'option',
    ));
    $wp_customize->add_control( 'example_select_box', array(
        'settings' => 'turbo_theme_options[header_select]',
        'label'   => 'Select Something:',
        'section' => 'turbo_my_scheme',
        'type'    => 'select',
        'choices'    => array(
            'value1' => 'Choice 1',
            'value2' => 'Choice 2',
            'value3' => 'Choice 3',
        ),
    ));
    //  =============================
    //  = Image Upload              =
    //  =============================
    $wp_customize->add_setting('turbo_theme_options[image_upload_test]', array(
        'default'           => 'image.jpg',
        'capability'        => 'edit_theme_options',
        'type'           => 'option',
    ));
    $wp_customize->add_control( new WP_Customize_Image_Control($wp_customize, 'image_upload_test', array(
        'label'    => __('Image Upload Test', 'turbo'),
        'section'  => 'turbo_my_scheme',
        'settings' => 'turbo_theme_options[image_upload_test]',
    )));
    //  =============================
    //  = File Upload               =
    //  =============================
    $wp_customize->add_setting('turbo_theme_options[upload_test]', array(
        'default'           => 'arse',
        'capability'        => 'edit_theme_options',
        'type'           => 'option',
    ));
    $wp_customize->add_control( new WP_Customize_Upload_Control($wp_customize, 'upload_test', array(
        'label'    => __('Upload Test', 'turbo'),
        'section'  => 'turbo_my_scheme',
        'settings' => 'turbo_theme_options[upload_test]',
    )));
    //  =============================
    //  = Color Picker              =
    //  =============================
    $wp_customize->add_setting('turbo_theme_options[link_color]', array(
        'default'           => '000',
        'sanitize_callback' => 'sanitize_hex_color',
        'capability'        => 'edit_theme_options',
        'type'           => 'option',
    ));
    $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'link_color', array(
        'label'    => __('Link Color', 'turbo'),
        'section'  => 'turbo_my_scheme',
        'settings' => 'turbo_theme_options[link_color]',
    )));
    //  =============================
    //  = Page Dropdown             =
    //  =============================
    $wp_customize->add_setting('turbo_theme_options[page_test]', array(
        'capability'     => 'edit_theme_options',
        'type'           => 'option',
    ));
    $wp_customize->add_control('turbo_page_test', array(
        'label'      => __('Page Test', 'turbo'),
        'section'    => 'turbo_my_scheme',
        'type'    => 'dropdown-pages',
        'settings'   => 'turbo_theme_options[page_test]',
    ));
}
add_action('customize_register', 'turbo_customize_register');

Source: https://gist.github.com/Abban/2968549


SEO Tools For Mobile Device