我正在为主题定制器设置textarea输入。除了在textarea标签上方输出一行文本之外,它似乎工作得很好,我找不到它的来源和原因。
在这个屏幕截图中,标签Sätiön toiminta上方是文本data-customize-setting-link=\'textarea_setting\'
这是自动生成的。
Function
function mytheme_customize_register( $wp_customize ) {
require_once(TEMPLATEPATH . \'/inc/customizer_classes/wp_customizer_textarea.php\');
$wp_customize->add_setting(\'textarea_setting\', array(
\'default\' => \'default text\',
\'transport\' => \'refresh\'
));
$wp_customize->add_section( \'Mytheme_content\' , array(
\'title\' => __( \'Site content\', \'Mytheme\' ),
\'priority\' => 30,
) );
$wp_customize->add_control(new Mytheme_Textarea_Control($wp_customize, \'textarea_setting\', array(
\'label\' => \'Säätiön toiminta\',
\'section\' => \'Mytheme_content\',
\'settings\' => \'textarea_setting\'
)));
}
add_action( \'customize_register\', \'mytheme_customize_register\' );
wp_customizer_textarea.php
class Mytheme_Textarea_Control extends WP_Customize_Control {
public $type = \'textarea\';
public function render_content() {
echo \'<label>
<span class="customize-control-title">\' . esc_html( $this->label ) . \'</span>
<textarea rows="5" style="width:100%;" \' . $this->link() . \'>\' . esc_textarea( $this->value() ) . \'</textarea>
</label>\';
}
}