Skip to content

Instantly share code, notes, and snippets.

@ramseyp
Last active November 20, 2024 12:14

Revisions

  1. ramseyp revised this gist Feb 4, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions custom_comments.php
    Original file line number Diff line number Diff line change
    @@ -33,11 +33,11 @@ function my_comment_form_defaults($defaults) {
    * @param array $args
    * @return $args
    */
    function my_comment_form_title ($args) {
    function my_comment_form_title ($defaults) {

    $args['title_reply'] = __( 'Post a new comment','my-text-domain' );
    $defaults['title_reply'] = __( 'Post a new comment','my-text-domain' );

    return $args;
    return $defaults;

    }

  2. ramseyp revised this gist Feb 4, 2014. 1 changed file with 17 additions and 3 deletions.
    20 changes: 17 additions & 3 deletions custom_comments.php
    Original file line number Diff line number Diff line change
    @@ -6,26 +6,40 @@
    // Customizes the text area - you have to do this here, rather than in comment_form_default_fields
    add_filter('comment_form_field_comment', 'my_comment_form_field_comment');

    // Customized the comment notes above the form fields and the comment form title
    // Customized the comment notes above the form fields
    add_filter( 'comment_form_defaults', 'my_comment_form_defaults' );

    // Customize the comments title
    add_filter('comment_form_defaults','my_comment_form_title');

    // Show the comments count in the comments title ( Genesis Child Theme )
    add_filter( 'genesis_title_comments', 'sp_genesis_title_comments' )

    /**
    * Customize the text prior to the comment form fields
    * @param string $defaults
    * @param array $defaults
    * @return $defaults
    */
    function my_comment_form_defaults($defaults) {

    $defaults['comment_notes_before'] = '<p class="comment-notes">'. __( 'Your email address will not be published. Required fields are marked','my-text-domain' ).'</p>';
    $defaults['title_reply'] = __( 'Post a new comment','my-text-domain' );

    return $defaults;

    }

    /**
    * Customize the Comments form title
    * @param array $args
    * @return $args
    */
    function my_comment_form_title ($args) {

    $args['title_reply'] = __( 'Post a new comment','my-text-domain' );

    return $args;

    }

    /**
    * Modify the comment form input fields
  3. ramseyp created this gist Feb 4, 2014.
    74 changes: 74 additions & 0 deletions custom_comments.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,74 @@
    <?php

    // Customized the comment form fields ( not the comment text area )
    add_filter('comment_form_default_fields', 'my_comment_form_args');

    // Customizes the text area - you have to do this here, rather than in comment_form_default_fields
    add_filter('comment_form_field_comment', 'my_comment_form_field_comment');

    // Customized the comment notes above the form fields and the comment form title
    add_filter( 'comment_form_defaults', 'my_comment_form_defaults' );

    // Show the comments count in the comments title ( Genesis Child Theme )
    add_filter( 'genesis_title_comments', 'sp_genesis_title_comments' )

    /**
    * Customize the text prior to the comment form fields
    * @param string $defaults
    * @return $defaults
    */
    function my_comment_form_defaults($defaults) {

    $defaults['comment_notes_before'] = '<p class="comment-notes">'. __( 'Your email address will not be published. Required fields are marked','my-text-domain' ).'</p>';
    $defaults['title_reply'] = __( 'Post a new comment','my-text-domain' );

    return $defaults;

    }


    /**
    * Modify the comment form input fields
    * @param $args http://codex.wordpress.org/Function_Reference/comment_form
    * $args['author']
    * $args['email']
    * $args['url']
    *
    * @return $args
    */
    function my_comment_form_args($args) {

    $args['author'] = '<p class="comment-form-author"><input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="40" tabindex="1" aria-required="true" title="'. __( 'Your Name (required)','my-text-domain' ) .'" placeholder="'. __( 'Your Name (required)','my-text-domain' ) .'" required /><!-- .comment-form-author .form-section --></p>';
    $args['email'] = '<p class="comment-form-email"><input id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="40" tabindex="2" aria-required="true" title="'. __( 'Email Address (required)','my-text-domain' ) .'" placeholder="'. __( 'Email Address (required)','my-text-domain' ) .'" required /><!-- .comment-form-email .form-section --></p>';
    $args['url'] = '<p class="comment-form-url"><input id="url" name="url" type="url" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="40" tabindex="3" aria-required="false" title="'. __( 'Website (url)','my-text-domain' ) .'" placeholder="'. __( 'Website (url)','my-text-domain' ) .'" required /><!-- .comment-form-url .form-section --></p>';

    return $args;
    }

    /**
    * Customize the comment form comment field
    * @param string $field
    * @return string
    */
    function my_comment_form_field_comment($field) {

    $field = '<p class="comment-form-comment"><textarea id="comment" name="comment" cols="45" rows="8" tabindex="4" title="' . __( 'Comment','my-text-domain' ) . '" placeholder="' . __( 'Comment','my-text-domain' ) . '" aria-required="true"></textarea><!-- #form-section-comment .form-section --></p>';

    return $field;

    }

    /**
    * Show how many comments there are in the commments title
    * @return string $title
    */
    function sp_genesis_title_comments() {

    global $post;
    $comment_count = wp_count_comments( $post->ID )->approved;
    $title = '<p class="comments_title"><b>'. __( 'Comments','austin' ) .' ('. $comment_count .')</b></p>';

    return $title;

    }