WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

#4964 closed enhancement (invalid)

Bring back the 4th parameter in comments_number()

Reported by: Viper007Bond Owned by:
Milestone: Priority: lowest
Severity: trivial Version: 2.3
Component: Template Keywords: has-patch 2nd-opinion
Focuses: Cc:

Description

#2687 removed it which is a shame as it was handy. Rather than replicating the whole dang function, I could just stick my own number in there (say true comment minus pingbacks) and it'd modify as needed.

Is there really any harm in having that parameter there?

Attachments (3)

comment-template.patch (706 bytes) - added by Viper007Bond 7 years ago.
comment-template.2.patch (701 bytes) - added by Viper007Bond 7 years ago.
A little safer check
comments-template.patch (1.0 KB) - added by Viper007Bond 7 years ago.
An even safer check (you know, like allow for 0 and stuff)

Download all attachments as: .zip

Change History (10)

Viper007Bond7 years ago

A little safer check

comment:1 Otto427 years ago

Correct me if I'm wrong, but it was deprecated because it never actually did anything. Your patch makes it do something new.

comment:2 follow-up: Viper007Bond7 years ago

  • Priority changed from normal to lowest
  • Severity changed from normal to trivial

It used to do something, but apparently it was much, much longer ago than I realized:

http://trac.wordpress.org/browser/trunk/wp-includes/template-functions-comment.php?rev=1960#L56

comment:3 Viper007Bond7 years ago

  • Cc wptrac@… added

Viper007Bond7 years ago

An even safer check (you know, like allow for 0 and stuff)

comment:4 in reply to: ↑ 2 Otto427 years ago

Replying to Viper007Bond:

It used to do something, but apparently it was much, much longer ago than I realized:

http://trac.wordpress.org/browser/trunk/wp-includes/template-functions-comment.php?rev=1960#L56

Again, correct me if I'm wrong, but it's not doing anything there either. No matter what you set it to as input to the function, $number gets replaced with something else.

comment:5 Viper007Bond7 years ago

Er, you're right, sorry, I had to go back even farther. I had been looking at really old code where it worked, but I went too far forward trying to find the actual change: [1185]

comment:6 ryan7 years ago

  • Milestone changed from 2.3 to 2.4

comment:7 darkdragon6 years ago

  • Milestone 2.4 deleted
  • Resolution set to invalid
  • Status changed from new to closed

Instead of replicating the entire function, just hook into 'get_comments_number', global the id, and return the number that would otherwise be used instead of $number parameter.

function change_comment_count($count)
{
    global $id;

    if($id === 1)
        return $count+1;

    return $count;
}

add_filter('get_comments_number', 'change_comment_count');

I think the whole point of the hook was to solve the old functionality while not completely replacing it.

Note: See TracTickets for help on using tickets.