Skip to content

Instantly share code, notes, and snippets.

@andy-kliman
Created June 30, 2017 15:09
Show Gist options
  • Save andy-kliman/f96b098757cd6248f56dedd215a71d93 to your computer and use it in GitHub Desktop.
Save andy-kliman/f96b098757cd6248f56dedd215a71d93 to your computer and use it in GitHub Desktop.
Customizer WordPress
<?php
// Нужно добавить в functions.php -> require get_template_directory() . '/inc/customizer.php';
// Функция, регистрирующая новые panel, sections и setting в Customizer
function yoursitename_new_customizer_settings($wp_customize) {
// Создать настройку логотипа
$wp_customize->add_setting('yoursitename_logo');
// Добавить настройку логотипа в секцию "свойства сайта"
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'yoursitename_logo',
array(
'label' => 'Логотип',
'section' => 'title_tagline',
)
));
// Добавить новую секцию "Контакты"
$wp_customize->add_section('yoursitename_contacts',
array(
'title' => 'Контакты',
'priority' => 120,
)
);
// Создать настройку номера
$wp_customize->add_setting('yoursitename_phone');
// Добавить настройку номера в секцию "Контакты"
$wp_customize->add_control('yoursitename_phone',
array(
'label' => 'Телефон',
'description' => 'Ваш контактный телефон, который будет выводиться на сайте',
'section' => 'yoursitename_contacts',
)
);
}
add_action('customize_register', 'yoursitename_new_customizer_settings');
?>
<p><?php echo get_theme_mod('yoursitename_phone'); ?></p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment