[wp-trac] [WordPress Trac] #45498: Wrong order of arguments in call_user_func() for Walker_Comment::start_el()

WordPress Trac noreply at wordpress.org
Thu Dec 6 16:52:14 UTC 2018


#45498: Wrong order of arguments in call_user_func() for Walker_Comment::start_el()
--------------------------+-----------------------------
 Reporter:  milana_cap    |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Comments      |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Arguments order for rendering all types of comments is `$comment, $depth,
 $args` except for the custom callback:

 `call_user_func( $args['callback'], $comment, $args, $depth );`

 This causes every custom callback to throw an error when you use `$args`
 and `$depth` as you'd expect.

 For example, `comment_reply_link()` inside callback can not be used like
 it's suppose to be used, like so:


 {{{#!php
 <?php
 comment_reply_link( array_merge( $args, array(
         'add_below' => 'div-comment',
         'depth'     => $depth,
         'max_depth' => $args['max_depth'],
         'before'    => '<div class="reply">',
         'after'     => '</div>'
 ) ) );
 }}}

 You need to replace `$depth` and `$args`, like so:

 {{{#!php
 <?php
 comment_reply_link( array_merge( $depth, array(
         'add_below' => 'div-comment',
         'depth'     => $args,
         'max_depth' => $depth['max_depth'],
         'before'    => '<div class="reply">',
         'after'     => '</div>'
 ) ) );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45498>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list