Last active
August 29, 2015 14:03
-
-
Save aiiddqd/caec3a1a756d3f1af3f3 to your computer and use it in GitHub Desktop.
Простая страница опций сайта
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 | |
/* | |
Короткий пример для использования Theme_Customization_API | |
http://casepress.org/kb/web/nastrojki-temy-wordpress-kak-dobavit-svoi-polya/ | |
*/ | |
/** | |
* Добавляет страницу настройки темы в админку Вордпресса | |
*/ | |
function mytheme_customize_register( $wp_customize ) { | |
/* | |
Добавляем секцию в настройки темы | |
*/ | |
$wp_customize->add_section( | |
// ID | |
'data_site_section', | |
// Arguments array | |
array( | |
'title' => 'Данные сайта', | |
'capability' => 'edit_theme_options', | |
'description' => "Тут можно указать данные сайта" | |
) | |
); | |
/* | |
Добавляем поле контактных данных | |
*/ | |
$wp_customize->add_setting( | |
// ID | |
'theme_contacttext', | |
// Arguments array | |
array( | |
'default' => '', | |
'type' => 'option' | |
) | |
); | |
$wp_customize->add_control( | |
// ID | |
'theme_contacttext_control', | |
// Arguments array | |
array( | |
'type' => 'text', | |
'label' => "Текст с контактной информацией", | |
'section' => 'data_site_section', | |
// This last one must match setting ID from above | |
'settings' => 'theme_contacttext' | |
) | |
); | |
/* | |
Добавляем поле телефона site_telephone | |
*/ | |
$wp_customize->add_setting( | |
// ID | |
'site_telephone', | |
// Arguments array | |
array( | |
'default' => '', | |
'type' => 'option' | |
) | |
); | |
$wp_customize->add_control( | |
// ID | |
'site_telephone_control', | |
// Arguments array | |
array( | |
'type' => 'text', | |
'label' => "Текст с телефоном", | |
'section' => 'data_site_section', | |
// This last one must match setting ID from above | |
'settings' => 'site_telephone' | |
) | |
); | |
} | |
add_action( 'customize_register', 'mytheme_customize_register' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment