0

I am setting up a textarea input for theme customizer. It seems to be working well apart from it outputting a line of text above the textarea label which I cannot find where it comes from and why.

Theme customizer settings

In this screenshot, above the label Säätiön toiminta, is the text data-customize-setting-link='textarea_setting' This is somehow being automatically generated.

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>';
    }
}
1

One ootion is that the HTML that you generate is broken and that is the reason something that should have been an html attribute is displayed.

Another is that $this->link() echos instead for returning a value.

  • Yes you are right, $this -> link() does echo. Thanks – tommyf Nov 19 '13 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.