[wp-trac] [WordPress Trac] #16979: Extra hooks needed in comment process

WordPress Trac wp-trac at lists.automattic.com
Sat Apr 16 03:52:53 UTC 2011


#16979: Extra hooks needed in comment process
-------------------------+-----------------------------
 Reporter:  dd32         |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Future Release
Component:  Comments     |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  needs-patch  |
-------------------------+-----------------------------

Comment (by dd32):

 > attachment 16979.diff  added

 First attempt at moving the ones that Impacted me to hooks.

 For example, If you'd like to allow Empty comments, and do not want to
 prevent duplicate comments from being posted:

 {{{
         add_action('pre_comment_on_post', array(&$this,
 'allow_blank_comments'));

         function allow_blank_comments( $post_id ) {
                 if ( 'my_cpt' == get_post_type($post_id) ) {
                         remove_filter( 'preprocess_comment',
 'disallow_empty_comments', 5);
                         remove_action( 'check_comment_flood',
 'check_comment_flood_duplicate', 10, 4 );
                 }
         }
 }}}

 This doesn't attempt to refactor the entire commenting process to handle
 passing error objects around, or to allow the theme to handle these errors
 by displaying that inline. I would prefer the comment process to be
 refactored, but doing so will require a bit more work than I've patched
 here.

 Additionally, not in the patch, is the fact that this moves the Empty
 comment check to within the comment processing code, which will cause a
 problem for XML-RPC as it currently allows blank comments. (It duplicates
 a few checks to avoid wp_die()'s).
 {{{
 if ( !isset($content_struct['content']) || '' ==
 $content_struct['content'] )
         return new IXR_Error( 403, __('Comment content is required') );
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16979#comment:6>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list