mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-05 05:04:31 +00:00
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:
@@ -2005,7 +2005,6 @@ function get_calendar( $initial = true, $echo = true ) {
|
||||
}
|
||||
// week_begins = 0 stands for Sunday
|
||||
$week_begins = (int) get_option( 'start_of_week' );
|
||||
$ts = current_time( 'timestamp' );
|
||||
|
||||
// Let's figure out when we are
|
||||
if ( ! empty( $monthnum ) && ! empty( $year ) ) {
|
||||
@@ -2025,8 +2024,8 @@ function get_calendar( $initial = true, $echo = true ) {
|
||||
$thismonth = zeroise( (int) substr( $m, 4, 2 ), 2 );
|
||||
}
|
||||
} else {
|
||||
$thisyear = gmdate( 'Y', $ts );
|
||||
$thismonth = gmdate( 'm', $ts );
|
||||
$thisyear = current_time( 'Y' );
|
||||
$thismonth = current_time( 'm' );
|
||||
}
|
||||
|
||||
$unixmonth = mktime( 0, 0, 0, $thismonth, 1, $thisyear );
|
||||
@@ -2136,9 +2135,9 @@ function get_calendar( $initial = true, $echo = true ) {
|
||||
}
|
||||
$newrow = false;
|
||||
|
||||
if ( $day == gmdate( 'j', $ts ) &&
|
||||
$thismonth == gmdate( 'm', $ts ) &&
|
||||
$thisyear == gmdate( 'Y', $ts ) ) {
|
||||
if ( $day == current_time( 'j' ) &&
|
||||
$thismonth == current_time( 'm' ) &&
|
||||
$thisyear == current_time( 'Y' ) ) {
|
||||
$calendar_output .= '<td id="today">';
|
||||
} else {
|
||||
$calendar_output .= '<td>';
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -518,7 +518,7 @@ function wpmu_validate_user_signup( $user_name, $user_email ) {
|
||||
$signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name ) );
|
||||
if ( $signup != null ) {
|
||||
$registered_at = mysql2date( 'U', $signup->registered );
|
||||
$now = current_time( 'timestamp', true );
|
||||
$now = time();
|
||||
$diff = $now - $registered_at;
|
||||
// If registered more than two days ago, cancel registration and let this signup go through.
|
||||
if ( $diff > 2 * DAY_IN_SECONDS ) {
|
||||
@@ -530,7 +530,7 @@ function wpmu_validate_user_signup( $user_name, $user_email ) {
|
||||
|
||||
$signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email ) );
|
||||
if ( $signup != null ) {
|
||||
$diff = current_time( 'timestamp', true ) - mysql2date( 'U', $signup->registered );
|
||||
$diff = time() - mysql2date( 'U', $signup->registered );
|
||||
// If registered more than two days ago, cancel registration and let this signup go through.
|
||||
if ( $diff > 2 * DAY_IN_SECONDS ) {
|
||||
$wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) );
|
||||
@@ -688,7 +688,7 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
|
||||
// Has someone already signed up for this domain?
|
||||
$signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path ) ); // TODO: Check email too?
|
||||
if ( ! empty( $signup ) ) {
|
||||
$diff = current_time( 'timestamp', true ) - mysql2date( 'U', $signup->registered );
|
||||
$diff = time() - mysql2date( 'U', $signup->registered );
|
||||
// If registered more than two days ago, cancel registration and let this signup go through.
|
||||
if ( $diff > 2 * DAY_IN_SECONDS ) {
|
||||
$wpdb->delete(
|
||||
|
||||
Reference in New Issue
Block a user