From 24128dfc902f6036d664015cd10943eba8fa9436 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Thu, 8 Oct 2015 05:57:25 +0000 Subject: [PATCH] Posts: Add the `pre_get_lastpostmodified` filter to `get_lastpostmodified()`. This allows `get_lastpostmodified()` to be short circuited when the site wants to avoid running the occasionally slow queries in `_get_last_post_time()`. Fixes #34205. Built from https://develop.svn.wordpress.org/trunk@34935 git-svn-id: http://core.svn.wordpress.org/trunk@34900 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post-functions.php | 16 ++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/wp-includes/post-functions.php b/wp-includes/post-functions.php index 6d5957b6c5..808e6d8bb6 100644 --- a/wp-includes/post-functions.php +++ b/wp-includes/post-functions.php @@ -5325,6 +5325,22 @@ function get_lastpostdate( $timezone = 'server', $post_type = 'any' ) { * @return string The timestamp. */ function get_lastpostmodified( $timezone = 'server', $post_type = 'any' ) { + /** + * Pre-filter the return value of get_lastpostmodified() before the query is run. + * + * @since 4.4.0 + * + * @param string $lastpostmodified Date the last post was modified. + * Returning anything other than false will short-circuit the function. + * @param string $timezone Location to use for getting the post modified date. + * See {@see get_lastpostdate()} for accepted `$timezone` values. + * @param string $post_type The post type to check. + */ + $lastpostmodified = apply_filters( 'pre_get_lastpostmodified', false, $timezone, $post_type ); + if ( false !== $lastpostmodified ) { + return $lastpostmodified; + } + $lastpostmodified = _get_last_post_time( $timezone, 'modified', $post_type ); $lastpostdate = get_lastpostdate($timezone); diff --git a/wp-includes/version.php b/wp-includes/version.php index cbc209d391..0945539ee3 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34934'; +$wp_version = '4.4-alpha-34935'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.