Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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>';
    }
}
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
    
Yes you are right, $this -> link() does echo. Thanks –  tommyf Nov 19 '13 at 12:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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