WordPress.org

Forums

Comment Guestbook
[resolved] changing comment textarea placeholder (3 posts)

  1. Averim
    Member
    Posted 10 months ago #

    I want to moddify the default text in the comment textarea to be the same as the comment label, though I can not find out how. Changing comment_field in the args section didn't help (I have succesfully changed 'logged in as' though).

    I have solved it (as a test) by changing the following function in comment_functions.php:

    public function comment_field_label_filter($comment_html) {
    		return preg_replace('/(<label.*>)(.*)(<\/label>)/i', '${1}'.$this->options->get('cgb_form_comment_label').'${3}', $comment_html, 1);
    	}

    to:

    public function comment_field_label_filter($comment_html) {
    		$comment_html = preg_replace('/(placeholder=")(.*)(")/i', '${1}'.$this->options->get('cgb_form_comment_label').'${3}', $comment_html, 1);
    		return preg_replace('/(<label.*>)(.*)(<\/label>)/i', '${1}'.$this->options->get('cgb_form_comment_label').'${3}', $comment_html, 1);
    	}

    This is, ofcourse, ugly and will break at the next plugin update.

    Is there a way to simulate this without editing the plugin directly? I didn't get it to work with a filter yet. Editing my functions.php with a hardcoded replacement for the placeholder would be okay for me, but I preferably either copy the text from the label or have another input field for the placeholder on the plugin page.

    https://wordpress.org/plugins/comment-guestbook/

  2. Averim
    Member
    Posted 10 months ago #

    ofcourse the placeholder preg_replace should have been:
    $comment_html = preg_replace('/(placeholder=")(.*?)(")/i', '${1}'.$this->options->get('cgb_form_comment_label').'${3}', $comment_html, 1);

  3. mibuthu
    Member
    Plugin Author

    Posted 6 months ago #

    I now had a look at this but I think that changing the placeholder texts is a very special thing that is not required by many users. So I decided not to implement a separate option for that.

    But you can still get your result by use of the "Comment form args" option.
    If you define the required html code for the comment_field you can set the placeholder to your requirements, e.g.:
    array('comment_field' => '<p class="comment-form-comment"><label for="comment">'._x('Comment', 'noun').'</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" placeholder="placeholder"></textarea></p>')

Reply

You must log in to post.

About this Plugin

  • Comment Guestbook
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.