ldc-sbv/wp-content/plugins/wordpress-seo/admin/statistics/class-statistics-integration.php

37 lines
743 B
PHP
Raw Normal View History

2021-09-21 15:01:08 +02:00
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Statistics
*/
/**
2021-09-21 15:05:30 +02:00
* Class WPSEO_Statistic_Integration.
2021-09-21 15:01:08 +02:00
*/
class WPSEO_Statistic_Integration implements WPSEO_WordPress_Integration {
2021-09-21 15:05:30 +02:00
2021-09-21 15:01:08 +02:00
/**
* Adds hooks to clear the cache.
*
* @return void
*/
public function register_hooks() {
2021-09-21 15:05:30 +02:00
add_action( 'wp_insert_post', [ $this, 'clear_cache' ] );
add_action( 'delete_post', [ $this, 'clear_cache' ] );
2021-09-21 15:01:08 +02:00
}
/**
* Clears the dashboard widget items cache.
*
* @return void
*/
public function clear_cache() {
2021-09-21 15:05:30 +02:00
// Bail if this is a multisite installation and the site has been switched.
if ( is_multisite() && ms_is_switched() ) {
return;
}
2021-09-21 15:01:08 +02:00
delete_transient( WPSEO_Statistics_Service::CACHE_TRANSIENT_KEY );
}
}