Posts: Fix back-compat for filters in get the modified time and date functions after [37738].

When no valid post exists for `get_the_modified_time` or `get_the_modified_date` calls, the result (`false`) is passed through the functions respective filters to maintain back-compat.

Introduces unit tests to ensure filters are applied and for the `get_the_modified_date` function.

Fixes #37059.


git-svn-id: https://develop.svn.wordpress.org/trunk@37866 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Wilson
2016-06-26 11:29:13 +00:00
parent 9853789382
commit 9ea1a7eb4f
2 changed files with 106 additions and 8 deletions
+6 -8
View File
@@ -2265,10 +2265,9 @@ function get_the_modified_date( $d = '', $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return false;
}
if ( empty( $d ) ) {
// For backward compatibility, failures go through the filter below.
$the_time = false;
} elseif ( empty( $d ) ) {
$the_time = get_post_modified_time( get_option( 'date_format' ), false, $post, true );
} else {
$the_time = get_post_modified_time( $d, false, $post, true );
@@ -2421,10 +2420,9 @@ function get_the_modified_time( $d = '', $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return false;
}
if ( empty( $d ) ) {
// For backward compatibility, failures go through the filter below.
$the_time = false;
} elseif ( empty( $d ) ) {
$the_time = get_post_modified_time( get_option( 'time_format' ), false, $post, true );
} else {
$the_time = get_post_modified_time( $d, false, $post, true );