Last active
June 30, 2017 16:50
-
-
Save andy-kliman/3e275e0dcf43fa02e57d5d6fb39f1805 to your computer and use it in GitHub Desktop.
Wordpress customizer
This file contains hidden or 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 | |
// Добавить новую секцию | |
$wp_customize->add_section('themeName_sectionName', | |
array( | |
'title' => 'Название секции', | |
'priority' => 120, | |
) | |
); | |
Создать настройку | |
$wp_customize->add_setting('themeName_settingName'); | |
// вывод элемента управления типа radio | |
$wp_customize->add_control( 'themeName_settingName', | |
array( | |
'label' => __( 'Радиокнопки', 'themeName' ), | |
'section' => 'themeName_sectionName', | |
'settings' => 'themeName_settingName', | |
'type' => 'radio', | |
'choices' => array( | |
'value1' => 'Choice 1', | |
'value2' => 'Choice 2', | |
'value3' => 'Choice 3', | |
), | |
) | |
); | |
// вывод элемента управления типа checkbox | |
$wp_customize->add_setting('themeName_settingName', | |
array( | |
'capability' => 'edit_theme_options', | |
'type' => 'option', | |
) | |
); | |
$wp_customize->add_control('display_header_text', | |
array( | |
'settings' => 'themeName_settingName', | |
'label' => __('Display Header Text'), | |
'section' => 'themeName_sectionName', | |
'type' => 'checkbox', | |
)); | |
// вывод элемента управления типа select | |
$wp_customize->add_setting('themeName_settingName', | |
array( | |
'default' => 'value2', | |
'capability' => 'edit_theme_options', | |
'type' => 'option', | |
) | |
); | |
$wp_customize->add_control( 'example_select_box', | |
array( | |
'settings' => 'themeName_settingName', | |
'label' => 'Select Something:', | |
'section' => 'themeName_sectionName', | |
'type' => 'select', | |
'choices' => array( | |
'value1' => 'Choice 1', | |
'value2' => 'Choice 2', | |
'value3' => 'Choice 3', | |
), | |
) | |
); | |
// вывод элемента управления типа text input | |
$wp_customize->add_setting('themeName_settingName', | |
array( | |
'default' => 'Arse!', | |
'capability' => 'edit_theme_options', | |
'type' => 'option', | |
) | |
); | |
$wp_customize->add_control('themeName_text_test', | |
array( | |
'description' => 'text', | |
'label' => __('Text Test', 'themeName'), | |
'section' => 'themeName_sectionName', | |
'settings' => 'themeName_settingName', | |
) | |
); | |
// вывода элемента управления типа image upload | |
$wp_customize->add_setting('themeName_settingName', | |
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', 'themename'), | |
'section' => 'themeName_sectionName', | |
'settings' => 'themeName_settingName', | |
) | |
)); | |
// вывод элемента управления типа Color Picker | |
$wp_customize->add_setting('themeName_settingName', | |
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', 'themen ame'), | |
'section' => 'themeName_sectionName', | |
'settings' => 'themeName_settingName', | |
) | |
)); | |
// вывод элемента управления типа Page Dropdown | |
$wp_customize->add_setting('themeName_settingName', | |
array( | |
'capability' => 'edit_theme_options', | |
'type' => 'option', | |
) | |
); | |
$wp_customize->add_control('themename_page_test', | |
array( | |
'label' => __('Page Test', 'themename'), | |
'section' => 'themeName_sectionName', | |
'type' => 'dropdown-p ages', | |
'settings' => 'themeName_settingName', | |
) | |
); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment