Opened 9 years ago
Last modified 16 months ago
#34093 new enhancement
New filter: `get_calendar_post_type` in get_calendar()
Reported by: | sebastian.pisula | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Widgets | Keywords: | has-patch needs-unit-tests |
Focuses: | Cc: |
Description
Filter for post type in calendar. If I want show posts from others post type
Attachments (7)
Change History (14)
#2
@
9 years ago
- Keywords needs-refresh removed
@swissspidy I've updated the patch with your requested changes. Please confirm if this is in order.
#4
follow-up:
↓ 5
@
8 years ago
Thanks for the ping, and sorry for missing it before!
Implementation-wise it looks OK, just needs a bit of a cleanup eventually (e.g. the spacing is wrong).
I wonder if we should go even one step further and allow passing an $args
param to get_calendar()
. That way you could configure the post type, whether it should echo
, etc. all when calling the function. Of course it should be backwards compatible.
Then, we could have 1 single get_calendar_args
filter for these arguments instead of one only for the post type. That means we could use 34093-3.patch to build upon.
@
8 years ago
Adding array args parameter with backwards compatibly for older argument types. Changing the filter to be applied to all args and not just the post type. Allow post type to be submitted as an argument. Also laying the foundation allowing for other arguments to be added in future.
@
8 years ago
Fixed bug where args are being used before filter. Also fix bug where args filter was assigning to $post_type variable and not $args.
#5
in reply to:
↑ 4
@
8 years ago
- Version set to trunk
Replying to swissspidy:
Thanks for the ping, and sorry for missing it before!
Implementation-wise it looks OK, just needs a bit of a cleanup eventually (e.g. the spacing is wrong).
I wonder if we should go even one step further and allow passing an
$args
param toget_calendar()
. That way you could configure the post type, whether it shouldecho
, etc. all when calling the function. Of course it should be backwards compatible.
Then, we could have 1 single
get_calendar_args
filter for these arguments instead of one only for the post type. That means we could use 34093-3.patch to build upon.
@swissspidy Please review the changes in 34093-5.diff. The code styling is updated along with the changes your requested.
#6
@
8 years ago
- Component changed from General to Widgets
- Keywords needs-unit-tests added
- Milestone changed from Awaiting Review to Future Release
- Version trunk deleted
Version
is for indicating when a bug was first introduced.
The patch is coming along nicely, thanks @dwainm!
I'm changing milestone to Future Release for now. Also changing the component as get_calendar()
is only used in the calendar widget right now. The patch might benefit from some unit tests.
At first glance, the function's docblock needs to be updated. $args
should probably be passed to the get_calendar
filter.
See https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/ for our PHP Documentation Standards.
I can see that this enhancement would be helpful.
Just please use
$wpdb->prepare
to sanitize the post type and check if$post_type
is indeed a valid (public) post type.