Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
50.00% |
4 / 8 |
|
100.00% |
2 / 2 |
CRAP | n/a |
0 / 0 |
|
| jetpack_seo_dashboard_purge_sitemap | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
| jetpack_seo_dashboard_queue_sitemap_purge | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Module Name: SEO |
| 4 | * Module Description: Manage how your site appears in search engines, social previews, and AI tools from one page. |
| 5 | * Sort Order: 35 |
| 6 | * First Introduced: 16.5-a.6 |
| 7 | * Requires Connection: No |
| 8 | * Requires User Connection: No |
| 9 | * Auto Activate: Yes |
| 10 | * Module Tags: Traffic |
| 11 | * Feature: Traffic |
| 12 | * Additional Search Queries: seo, search engine optimization, sitemap, site verification, canonical urls, seo dashboard |
| 13 | * |
| 14 | * @package automattic/jetpack |
| 15 | */ |
| 16 | |
| 17 | if ( ! defined( 'ABSPATH' ) ) { |
| 18 | exit( 0 ); |
| 19 | } |
| 20 | |
| 21 | // A switch: the SEO package shows its page, and runs the SEO modules, while this is on. |
| 22 | |
| 23 | // Switching SEO starts or stops Jetpack's sitemap, so cached sitemap and robots.txt responses go stale. |
| 24 | add_action( 'jetpack_activate_module_seo-dashboard', 'jetpack_seo_dashboard_queue_sitemap_purge' ); |
| 25 | add_action( 'jetpack_deactivate_module_seo-dashboard', 'jetpack_seo_dashboard_purge_sitemap' ); |
| 26 | |
| 27 | /** |
| 28 | * Purge the cached sitemap index while Sitemaps, about to pause, is still loaded. |
| 29 | * |
| 30 | * @since $$next-version$$ |
| 31 | * |
| 32 | * @return void |
| 33 | */ |
| 34 | function jetpack_seo_dashboard_purge_sitemap() { |
| 35 | if ( class_exists( 'Jetpack_Sitemap_Manager', false ) ) { |
| 36 | Jetpack_Sitemap_Manager::callback_invalidate_index_cache(); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Have Sitemaps purge its cached index when it next loads, since it stays paused for this request. |
| 42 | * |
| 43 | * @since $$next-version$$ |
| 44 | * |
| 45 | * @return void |
| 46 | */ |
| 47 | function jetpack_seo_dashboard_queue_sitemap_purge() { |
| 48 | if ( Jetpack::is_module_active( 'sitemaps' ) && ! get_option( 'jetpack_sitemap_pending_cache_purge' ) ) { |
| 49 | update_option( 'jetpack_sitemap_pending_cache_purge', 'urls', true ); |
| 50 | } |
| 51 | } |