Make WordPress Core

Opened 12 years ago

Closed 9 years ago

Last modified 9 years ago

#21364 closed enhancement (fixed)

Pass post type to count_user_posts()

Reported by: caspie's profile Caspie Owned by: boonebgorges's profile boonebgorges
Milestone: 4.1 Priority: normal
Severity: normal Version: 3.0
Component: Posts, Post Types Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

Add $post_type argument to count_user_posts(). Defaults to 'post', as it is hard-coded now.

Attachments (3)

21364.2.diff (898 bytes) - added by Caspie 12 years ago.
also pass to filter
get-user-post-count-post-type.21364.diff (2.0 KB) - added by engelen 10 years ago.
21364.diff (2.3 KB) - added by DrewAPicture 10 years ago.
+ unit test

Download all attachments as: .zip

Change History (18)

#1 follow-up: @kawauso
12 years ago

If we're doing that, should it be passed to the filter as well?

@Caspie
12 years ago

also pass to filter

#2 in reply to: ↑ 1 @Caspie
12 years ago

Replying to kawauso:

If we're doing that, should it be passed to the filter as well?

sure

#3 @iseulde
11 years ago

  • Component changed from General to Post Types

#4 @ocean90
10 years ago

#26991 was marked as a duplicate.

#5 @wonderboymusic
10 years ago

  • Keywords needs-refresh added

Patch is blowing up

#6 @engelen
10 years ago

  • Keywords needs-refresh removed

get-user-post-count-post-type.21364.diff adds an argument for the post type for both count_user_posts and get_the_author_posts.

#7 @F4rkie
10 years ago

  • Keywords needs-testing removed

Hi,

I've just tested this patch - works as intended.

#8 @engelen
10 years ago

  • Keywords needs-unit-tests added

@DrewAPicture
10 years ago

+ unit test

#9 @DrewAPicture
10 years ago

  • Keywords has-unit-tests added; needs-unit-tests removed

21364.diff adds a unit test. I also removed the changes to get_the_author_posts() as that falls out of the scope of this ticket.

#10 follow-up: @pbearne
9 years ago

Hi Guys

Should allow an array of post type to get passed in?

Paul

#11 @boonebgorges
9 years ago

  • Milestone changed from Awaiting Review to 4.1
  • Owner set to boonebgorges
  • Status changed from new to accepted

#12 in reply to: ↑ 10 @boonebgorges
9 years ago

Replying to pbearne:

Hi Guys

Should allow an array of post type to get passed in?

Paul

This is not a bad idea, but it's going to need modifications to the current patch that are non-trivial. I'd suggest that we go with what we've currently got for 4.1, and you should feel free to open another ticket if you'd like support for multiple post types.

#13 @boonebgorges
9 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 30322:

Introduce $post_type param for count_user_posts().

Props Caspie, engelen, DrewAPicture.
Fixes #21364.

#14 @pavelevap
9 years ago

There should be @since 4.1.0?

#15 @boonebgorges
9 years ago

In 30328:

Correct @since tag in count_user_posts() docs.

Props pavelevap, DrewAPicture.
See #21364.

Note: See TracTickets for help on using tickets.