File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5252add_action ('litespeed_init ' , 'LiteSpeed\Thirdparty\Elementor::preload ' );
5353add_action ('litespeed_init ' , 'LiteSpeed\Thirdparty\Gravity_Forms::preload ' );
5454add_action ('litespeed_init ' , 'LiteSpeed\Thirdparty\Perfmatters::preload ' );
55+ add_action ('litespeed_init ' , 'LiteSpeed\Thirdparty\Rank_Math::preload ' );
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * The Third Party integration with the Rank Math SEO plugin.
4+ *
5+ * @since 7.9
6+ * @package LiteSpeed
7+ * @subpackage LiteSpeed_Cache\Thirdparty
8+ */
9+
10+ namespace LiteSpeed \Thirdparty ;
11+
12+ defined ('WPINC ' ) || exit ();
13+
14+ /**
15+ * Provides compatibility for the Rank Math SEO plugin.
16+ *
17+ * Rank Math maintains its own internal sitemap cache that can
18+ * occasionally fail to update when posts/pages are modified via
19+ * programmatic flows (page builders, duplicator plugins, etc.).
20+ * Tying its sitemap cache invalidation to LiteSpeed's "Purge All"
21+ * gives users a reliable way to force a refresh.
22+ */
23+ class Rank_Math {
24+
25+ /**
26+ * Preload hooks for Rank Math integration.
27+ *
28+ * @since 7.9
29+ * @access public
30+ * @return void
31+ */
32+ public static function preload () {
33+ if ( ! defined ( 'RANK_MATH_VERSION ' ) ) {
34+ return ;
35+ }
36+ add_action ('litespeed_purged_post ' , __CLASS__ . '::invalidate_sitemap_cache ' );
37+ // add_action('litespeed_purged_all', __CLASS__ . '::invalidate_sitemap_cache');
38+ }
39+
40+ /**
41+ * Invalidates Rank Math's sitemap cache.
42+ *
43+ * @since 7.9
44+ * @return void
45+ */
46+ public static function invalidate_sitemap_cache () {
47+ if (class_exists ('\\RankMath \\Sitemap \\Cache ' )) {
48+ \RankMath \Sitemap \Cache::invalidate_storage ();
49+
50+ do_action ( 'litespeed_debug ' , '[3rd] Rank Math sitemap cache invalidated ' );
51+ }
52+ }
53+ }
You can’t perform that action at this time.
0 commit comments