Skip to content

Instantly share code, notes, and snippets.

@uptimizt
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uptimizt/caec3a1a756d3f1af3f3 to your computer and use it in GitHub Desktop.
Save uptimizt/caec3a1a756d3f1af3f3 to your computer and use it in GitHub Desktop.
Простая страница опций сайта
<?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