WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 6 months ago

#40790 new enhancement

Ability to filter $post_type in _get_last_post_time

Reported by: toddlevy Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7.5
Component: General Keywords: has-patch needs-testing dev-feedback
Focuses: Cc:
PR Number:

Description

This function starts on line 5610 of
https://github.com/WordPress/WordPress/blob/4.7.5/wp-includes/post.php

Currently, there is no way to filter the $post_type argument of the _get_last_post_time function.

This creates situations where it's impossible to filter/modify the default post type when _get_last_post_time is called without the $post_type argument.

Suggested enhancement is to add a _get_last_post_time_post_type filter inside the _get_last_post_time function, right after the $field is validated or the timezone gets lowercased.

Something like this...

$post_type = apply_filters( '_get_last_post_time_post_type', $post_type );

Thank you for considering this enhancement.

Attachments (1)

40790.patch (967 bytes) - added by keraweb 7 months ago.
Add filter _get_last_post_time_post_type

Download all attachments as: .zip

Change History (6)

@keraweb
7 months ago

Add filter _get_last_post_time_post_type

#1 @keraweb
7 months ago

  • Keywords has-patch needs-testing dev-feedback added

#2 @toddlevy
7 months ago

Thanks @keraweb! Any chance you can take a gander at this one too...

https://core.trac.wordpress.org/ticket/40789

#3 @keraweb
6 months ago

@toddlevy,
I see you already have suggested a solution. You can create a patch yourself and add it to your ticket!

#4 @keraweb
6 months ago

@toddlevy
Actually, looking at the code.. The patch in this issue would solve #40789 as well since get_lastpostdate() is merely an alias that adds a filter get_lastpostdate for the private function _get_last_post_type().

#5 @keraweb
6 months ago

#40789 was marked as a duplicate.

Note: See TracTickets for help on using tickets.