| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPSEO plugin file. |
| 4 |
* |
| 5 |
* @package WPSEO\Admin\Statistics |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Class WPSEO_Statistic_Integration. |
| 10 |
*/ |
| 11 |
class WPSEO_Statistic_Integration implements WPSEO_WordPress_Integration { |
| 12 |
|
| 13 |
/** |
| 14 |
* Adds hooks to clear the cache. |
| 15 |
* |
| 16 |
* @return void |
| 17 |
*/ |
| 18 |
public function register_hooks() { |
| 19 |
add_action( 'wp_insert_post', [ $this, 'clear_cache' ] ); |
| 20 |
add_action( 'delete_post', [ $this, 'clear_cache' ] ); |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* Clears the dashboard widget items cache. |
| 25 |
* |
| 26 |
* @return void |
| 27 |
*/ |
| 28 |
public function clear_cache() { |
| 29 |
// Bail if this is a multisite installation and the site has been switched. |
| 30 |
if ( is_multisite() && ms_is_switched() ) { |
| 31 |
return; |
| 32 |
} |
| 33 |
|
| 34 |
delete_transient( WPSEO_Statistics_Service::CACHE_TRANSIENT_KEY ); |
| 35 |
} |
| 36 |
} |
| 37 |
|