Skip to content

Commit 1a7e76b

Browse files
Thirdparty - add plugin RankMath SEO
1 parent d50dca5 commit 1a7e76b

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

thirdparty/entry.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
'Divi_Theme_Builder',
2626
'Facetwp',
2727
'LiteSpeed_Check',
28+
'Rank_Math',
2829
'Theme_My_Login',
2930
'User_Switching',
3031
'WCML',
@@ -52,3 +53,4 @@
5253
add_action('litespeed_init', 'LiteSpeed\Thirdparty\Elementor::preload');
5354
add_action('litespeed_init', 'LiteSpeed\Thirdparty\Gravity_Forms::preload');
5455
add_action('litespeed_init', 'LiteSpeed\Thirdparty\Perfmatters::preload');
56+
add_action('litespeed_init', 'LiteSpeed\Thirdparty\Rank_Math::preload');

thirdparty/rank-math.cls.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* The Third Party integration with the Rank Math SEO plugin.
4+
*
5+
* @since 7.9
6+
* @package Lit
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+
* Detects if Rank Math is active.
27+
*
28+
* @since 7.9
29+
* @return void
30+
*/
31+
public static function detect() {
32+
if ( ! defined( 'RANK_MATH_VERSION' ) ) {
33+
return;
34+
}
35+
}
36+
37+
/**
38+
* Preload hooks for Rank Math integration.
39+
*
40+
* @since 7.9
41+
* @access public
42+
* @return void
43+
*/
44+
public static function preload() {
45+
if ( ! defined( 'RANK_MATH_VERSION' ) ) {
46+
return;
47+
}
48+
add_action('litespeed_purged_post', __CLASS__ . '::invalidate_sitemap_cache');
49+
// add_action('litespeed_purged_all', __CLASS__ . '::invalidate_sitemap_cache');
50+
}
51+
52+
/**
53+
* Invalidates Rank Math's sitemap cache.
54+
*
55+
* @since 7.9
56+
* @return void
57+
*/
58+
public static function invalidate_sitemap_cache() {
59+
if (class_exists('\\RankMath\\Sitemap\\Cache')) {
60+
\RankMath\Sitemap\Cache::invalidate_storage();
61+
62+
do_action( 'litespeed_debug', '[3rd] Rank Math sitemap cache invalidated' );
63+
}
64+
}
65+
}

0 commit comments

Comments
 (0)