From 0905e57ae24ace1239370cc51ba19f8a6f857585 Mon Sep 17 00:00:00 2001 From: Rutvik Savsani <53530700+rutviksavsani@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:54:34 +0530 Subject: [PATCH] Sitemaps: Fix the Hook from init to wp_loaded for Sitemap URL handler. (#34269) * Update Init hook to WP for generating sitemap URLs and not all post types are registered while this is first initiated. * Fix hook name to wp_loaded * Add changelog --- .../jetpack/changelog/fix-action-hook-for-news-sitemap | 4 ++++ projects/plugins/jetpack/modules/sitemaps/sitemaps.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 projects/plugins/jetpack/changelog/fix-action-hook-for-news-sitemap diff --git a/projects/plugins/jetpack/changelog/fix-action-hook-for-news-sitemap b/projects/plugins/jetpack/changelog/fix-action-hook-for-news-sitemap new file mode 100644 index 0000000000000..3fd7234269a7f --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-action-hook-for-news-sitemap @@ -0,0 +1,4 @@ +Significance: patch +Type: compat + +Sitemaps: Use wp_loaded filter hook instead of init filter hook to load the permalinks for the sitemaps, Which will allow plugins and other hooks to load. diff --git a/projects/plugins/jetpack/modules/sitemaps/sitemaps.php b/projects/plugins/jetpack/modules/sitemaps/sitemaps.php index da0c092a4e659..1f0755858b417 100644 --- a/projects/plugins/jetpack/modules/sitemaps/sitemaps.php +++ b/projects/plugins/jetpack/modules/sitemaps/sitemaps.php @@ -95,7 +95,7 @@ public function __construct() { // Add callback for sitemap URL handler. add_action( - 'init', + 'wp_loaded', array( $this, 'callback_action_catch_sitemap_urls' ), defined( 'IS_WPCOM' ) && IS_WPCOM ? 100 : 10 );