Sunday, September 25, 2022
HomeWordPress DevelopmentMost well-liked technique to get remark reply hyperlink for feedback with a...

Most well-liked technique to get remark reply hyperlink for feedback with a depth of 0


There isn’t any such factor as a depth 0 remark, and it ought to by no means occur, right here is your downside:

    operate start_el(&$output, $merchandise, $depth = 0, $args = array(), $id = 0) {
        $output .= var_dump($depth);

No depth incrementing is occurring so it’s at all times 0. start_el has a number of duties as a part of the strolling, and for remark loop setup.

If we have a look at the start_el technique of the Walker_Comment class, the very first thing it does is increment the depth and set the mandatory international variables:

    public operate start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) {
        // Restores the extra descriptive, particular title to be used inside this technique.
        $remark = $data_object;

        $depth++;
        $GLOBALS['comment_depth'] = $depth;
        $GLOBALS['comment']       = $remark;

Since yours would not do that, $depth won’t ever be incremented irrespective of how deep the walker goes, and can at all times stay on the default 0. You must also anticipate numerous PHP warnings because of the globals being undefined.

Nonetheless, if applied accurately, $depth will at all times be 1 or greater, and get_comment_reply_link won’t ever obtain a 0 worth.

This and different features have to do a number of different issues as effectively to behave accurately as a remark walker. As a rule of thumb, copy paste everything of the strategy you are changing in your customized walker, then modify it, however do not delete it solely and begin from scratch.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments