Opened 11 years ago
Closed 14 months ago
#34093 closed task (blessed) (fixed)
New filter: `get_calendar_post_type` in get_calendar()
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.8 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Widgets | Keywords: | has-patch has-unit-tests |
| Focuses: | Cc: |
Description
Filter for post type in calendar. If I want show posts from others post type
Attachments (7)
Change History (35)
#2
@
10 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
@
10 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.
@
10 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.
@
10 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
@
10 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
$argsparam 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_argsfilter 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
@
10 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.
#7
@
3 years ago
This would be a very welcome addition to the calendar block/widget. I can imagine I just want to show posts from one category, like lectures or meetings or future/past events. For this kind of simple use it would remove the need for extra (events) plugins.
This ticket was mentioned in PR #8251 on WordPress/wordpress-develop by @sukhendu2002.
15 months ago
#8
- Keywords has-unit-tests added; needs-unit-tests removed
Trac ticket: https://core.trac.wordpress.org/ticket/34093
#9
@
15 months ago
Hi @swissspidy, This improvement looks quite valuable! I've refreshed the patch, would you be able to take a look? Thanks!
#10
@
15 months ago
- Milestone set to 6.8
Oh wow, my last comment here is from 8+ years ago! I don't remember any of that :-)
PR looks like a good start at first glance, but I don't have time for a proper review right now. Maybe @SergeyBiryukov or @audrasjb do.
Otherwise I suggest to bring it up in dev chat or so.
#11
@
15 months ago
- Owner set to audrasjb
- Status changed from new to reviewing
Thanks for the ping, @swissspidy!
Self assigning for review/test.
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
14 months ago
@audrasjb commented on PR #8251:
14 months ago
#13
I tested the changeset and it appears it works fine and respect the backward compatibility of this component.
#16
@
14 months ago
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening as phpunit tests are failing
This ticket was mentioned in PR #8446 on WordPress/wordpress-develop by @audrasjb.
14 months ago
#17
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
14 months ago
This ticket was mentioned in PR #8447 on WordPress/wordpress-develop by @peterwilsoncc.
14 months ago
#21
Trac ticket: https://core.trac.wordpress.org/ticket/34093
#22
@
14 months ago
I got interested and started writing some additional tests while looking at the date issue in the original tests.
It appears there are some caching issues as the post_type and initial parameters are not accounted for when generating the cache key, so there's a few minor fixes to the source code needed.
There's a couple of failing tests in the pull request linked to this ticket.
@audrasjb commented on PR #8446:
14 months ago
#23
Closing in favor of #8447.
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
14 months ago
#26
@
14 months ago
- Type changed from enhancement to task (blessed)
As the primary work on this enhancement has been committed and the remaining work is to resolve the failing PHPUnit tests, I'm going to convert this to a task to allow work to continue on resolving those tests during the 6.8 beta period.
@peterwilsoncc commented on PR #8447:
14 months ago
#27
Thanks, I've merged those changes. If you're happy I will commit in the next few hours.
The Chicago in me wants to say you were trying to say "Is youse" which is how "is y'all" would be translated.
It's the same translation down under, maaate. 🦐/BBQ
I can see that this enhancement would be helpful.
Just please use
$wpdb->prepareto sanitize the post type and check if$post_typeis indeed a valid (public) post type.