Commit 45816337ec for wordpress.org

commit 45816337ec33a4a2825c1d484d530b9e6a2acb84
Author: Weston Ruter <weston@xwp.co>
Date:   Thu Nov 27 17:06:45 2025 +0000

    Cron API: Restore spawning cron at `wp_loaded` when using alternate WP Cron (`ALTERNATE_WP_CRON`).

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

    Follow-up to [60925].

    Props karl94, peterwilsoncc, parthvataliya, johnbillion, westonruter.
    See #63858.
    Fixes #64315.

    Built from https://develop.svn.wordpress.org/trunk@61313


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

diff --git a/wp-includes/cron.php b/wp-includes/cron.php
index 5ada670278..afea4bce97 100644
--- a/wp-includes/cron.php
+++ b/wp-includes/cron.php
@@ -984,10 +984,17 @@ function spawn_cron( $gmt_time = 0 ) {
  * @since 2.1.0
  * @since 5.1.0 Return value added to indicate success or failure.
  * @since 5.7.0 Functionality moved to _wp_cron() to which this becomes a wrapper.
- * @since 6.9.0 The _wp_cron() callback is moved from {@see 'wp_loaded'} to the {@see 'shutdown'} action; the function always returns void.
+ * @since 6.9.0 The _wp_cron() callback is moved from {@see 'wp_loaded'} to the {@see 'shutdown'} action,
+ *              unless `ALTERNATE_WP_CRON` is enabled; the function now always returns void.
  */
 function wp_cron(): void {
-	if ( doing_action( 'shutdown' ) ) {
+	if ( defined( 'ALTERNATE_WP_CRON' ) && ALTERNATE_WP_CRON ) {
+		if ( did_action( 'wp_loaded' ) ) {
+			_wp_cron();
+		} else {
+			add_action( 'wp_loaded', '_wp_cron', 20 );
+		}
+	} elseif ( doing_action( 'shutdown' ) ) {
 		_wp_cron();
 	} else {
 		add_action( 'shutdown', '_wp_cron' );
diff --git a/wp-includes/version.php b/wp-includes/version.php
index f15962f1b2..d93619165c 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.0-alpha-61312';
+$wp_version = '7.0-alpha-61313';

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