From 4a0bf3605cec1ef85b24c581dd30ed8e420b0008 Mon Sep 17 00:00:00 2001 From: Prashant Baldha Date: Fri, 22 Aug 2025 12:38:23 +0530 Subject: [PATCH] =?UTF-8?q?Trigger=20the=20wp=5Fcron=20action=20from=20the?= =?UTF-8?q?=20shutdown=20hook=20instead=20of=20the=20init=20hook=20to=20re?= =?UTF-8?q?duce=20TTFB=20(=E2=8F=B1=EF=B8=8F=20Time=20To=20First=20Byte)?= =?UTF-8?q?=20and=20improve=20performance=20=F0=9F=93=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/wp-includes/class-wp-customize-manager.php | 2 +- src/wp-includes/default-filters.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index 6a656808ae5a1..8ea1c60dc9026 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -375,7 +375,7 @@ public function __construct( $args = array() ) { add_action( 'wp_loaded', array( $this, 'wp_loaded' ) ); // Do not spawn cron (especially the alternate cron) while running the Customizer. - remove_action( 'init', 'wp_cron' ); + remove_action( 'shutdown', 'wp_cron' ); // Do not run update checks when rendering the controls. remove_action( 'admin_init', '_maybe_update_core' ); diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 936bbb6a8673f..30761a1766a12 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -404,7 +404,7 @@ // WP Cron. if ( ! defined( 'DOING_CRON' ) ) { - add_action( 'init', 'wp_cron' ); + add_action( 'shutdown', 'wp_cron' ); } // HTTPS migration.