Created
June 30, 2017 18:36
-
-
Save andy-kliman/f859bdc953c38c90e97a056680d95eb9 to your computer and use it in GitHub Desktop.
Edit Shortcuts в кастомайзере
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
add_action('customize_register', 'dco_customize_register'); | |
function dco_customize_register($wp_customize) { | |
//FOOTER | |
$wp_customize->add_section('footer', array( | |
'title' => 'Подвал', | |
'priority' => 1, | |
)); | |
//footer text | |
$setting_name = 'footer_text'; | |
$wp_customize->add_setting($setting_name, array( | |
'default' => '', | |
'sanitize_callback' => 'sanitize_textarea_field', | |
'transport' => 'postMessage' | |
)); | |
$wp_customize->add_control($setting_name, array( | |
'section' => 'footer', | |
'type' => 'textarea', | |
'label' => 'Текст в подвале', | |
)); | |
$wp_customize->selective_refresh->add_partial($setting_name, array( | |
'selector' => '.footer-desc', | |
'render_callback' => function() use ($setting_name) { | |
return nl2br(get_theme_mod($setting_name)); | |
} | |
)); | |
} | |
И в шаблоне footer.php в нужном месте вывести | |
<div class="footer-desc"><?php echo nl2br(get_theme_mod('footer_text')); ?></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment