Commit 67de64d0bb for wordpress.org

commit 67de64d0bb424afce18c0cfbd8f54d18f3b81fc2
Author: SergeyBiryukov <sergeybiryukov@git.wordpress.org>
Date:   Wed Sep 23 21:40:45 2026 +0000

    General: Avoid repeated `current_time()` calls in `get_calendar()`.

    The current date values are constant for the duration of the call. Resolving them once before the loop avoids the overhead of extra function calls and filter applications.

    Developed in https://github.com/WordPress/wordpress-develop/pull/13615.

    Follow-up to r44809.

    Props mukesh27.
    Fixes #66141.
    Built from https://develop.svn.wordpress.org/trunk@63903


    git-svn-id: http://core.svn.wordpress.org/trunk@63072 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php
index 2f37fbae50..6df509fbf5 100644
--- a/wp-includes/general-template.php
+++ b/wp-includes/general-template.php
@@ -2662,6 +2662,9 @@ function get_calendar( $args = array() ) {
 	// week_begins = 0 stands for Sunday.
 	$week_begins = (int) get_option( 'start_of_week' );

+	// Read the current date.
+	list( $current_year, $current_month, $current_day ) = array_map( 'intval', explode( '-', current_time( 'Y-m-j' ) ) );
+
 	// Let's figure out when we are.
 	if ( ! empty( $monthnum ) && ! empty( $year ) ) {
 		$thismonth = (int) $monthnum;
@@ -2686,8 +2689,8 @@ function get_calendar( $args = array() ) {
 			$thismonth = (int) substr( $m, 4, 2 );
 		}
 	} else {
-		$thisyear  = (int) current_time( 'Y' );
-		$thismonth = (int) current_time( 'm' );
+		$thisyear  = $current_year;
+		$thismonth = $current_month;
 	}

 	$unixmonth = mktime( 0, 0, 0, $thismonth, 1, $thisyear );
@@ -2793,9 +2796,9 @@ function get_calendar( $args = array() ) {

 		$newrow = false;

-		if ( (int) current_time( 'j' ) === $day
-			&& (int) current_time( 'm' ) === $thismonth
-			&& (int) current_time( 'Y' ) === $thisyear
+		if ( $current_day === $day
+			&& $current_month === $thismonth
+			&& $current_year === $thisyear
 		) {
 			$calendar_output .= '<td id="today">';
 		} else {
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 354ef92de1..271c9c59f7 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.2-alpha-63902';
+$wp_version = '7.2-alpha-63903';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.