CanVas
@CanVas
Веб-мастер

Форма textarea в Wordpress в шаблонах — как работает?

Есть код:
//6 section - problem
       //1. Объявляем раздел в настройках
       $wp_customize->add_section( 'bootstrapcanvaswp_section_6',
           array(
               'title' => 'Шестая секция', //Visible title of section
               'priority' => 6, //Determines what order this appears in
               'capability' => 'edit_theme_options', //Capability needed to tweak
               'description' => 'хотите создать надёжную', //Descriptive tooltip
           )
       );
       $wp_customize->add_setting( 'section_6_header', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
           array(
               'default' => '', //Default setting/value to save
               'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
               'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
               'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
               'sanitize_callback' => 'sanitize_text_field',
           )
       );
       //3. Добавляем данный параметр к разделу
       $wp_customize->add_control( new WP_Customize_Control( //Instantiate the text control class
           $wp_customize, //Pass the $wp_customize object (required)
           'bootstrapcanvaswp_section_6_header', //Set a unique ID for the control
           array(
               'label' => 'Заголовок', //Admin-visible name of the control
               'section' => 'bootstrapcanvaswp_section_6', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
               'settings' => 'section_6_header', //Which setting to load and manipulate (serialized is okay)
               'priority' => 1, //Determines the order this control appears in for the specified section
               'type' => 'textarea',
           )
       ) );

Так вот - на выходе я получаю строку (смотрел var_dump) без переносов \n и пр. Даже пробовал навешать функцию nl2br
<?php echo nl2br(get_theme_mod( 'section_6_header', '' )); ?>

Но и она ничего не нашла. Зачем WP вводили этот параметр, но ни документации, ни функционала не сделали?
Доки что нашёл: codex.wordpress.org очень скудные.
Или подскажите как можно сделать многостраничный ввод текста в шаблоне. Просто делать куча input type=text это как то дико.
  • Вопрос задан
  • 600 просмотров
Решения вопроса 1
wppanda5
@wppanda5 Куратор тега WordPress
WordPress Mедведь
у вас
'sanitize_callback' => 'sanitize_text_field',


sanitize_text_field() — удаляет все HTML символы, переносы строк, табуляции и HTML сущности
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы