Date/Time: Reduce explicit local current_time( 'timestamp' ) usage in favor of native PHP functions.

Timestamps don't carry any timezone information, using the intended format directly simplifies the logic and makes the code less confusing.

Props Rarst, jdgrimes.
See #40657.

git-svn-id: https://develop.svn.wordpress.org/trunk@44809 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2019-03-07 09:11:37 +00:00
parent 79a3abcb2a
commit 4b10390b7d
7 changed files with 31 additions and 32 deletions

View File

@@ -470,7 +470,7 @@ function get_attachment_link( $post = null, $leavename = false ) {
function get_year_link( $year ) {
global $wp_rewrite;
if ( ! $year ) {
$year = gmdate( 'Y', current_time( 'timestamp' ) );
$year = current_time( 'Y' );
}
$yearlink = $wp_rewrite->get_year_permastruct();
if ( ! empty( $yearlink ) ) {
@@ -505,10 +505,10 @@ function get_year_link( $year ) {
function get_month_link( $year, $month ) {
global $wp_rewrite;
if ( ! $year ) {
$year = gmdate( 'Y', current_time( 'timestamp' ) );
$year = current_time( 'Y' );
}
if ( ! $month ) {
$month = gmdate( 'm', current_time( 'timestamp' ) );
$month = current_time( 'm' );
}
$monthlink = $wp_rewrite->get_month_permastruct();
if ( ! empty( $monthlink ) ) {
@@ -546,13 +546,13 @@ function get_month_link( $year, $month ) {
function get_day_link( $year, $month, $day ) {
global $wp_rewrite;
if ( ! $year ) {
$year = gmdate( 'Y', current_time( 'timestamp' ) );
$year = current_time( 'Y' );
}
if ( ! $month ) {
$month = gmdate( 'm', current_time( 'timestamp' ) );
$month = current_time( 'm' );
}
if ( ! $day ) {
$day = gmdate( 'j', current_time( 'timestamp' ) );
$day = current_time( 'j' );
}
$daylink = $wp_rewrite->get_day_permastruct();