class-statistics-integration.php 603 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\Statistics
  6. */
  7. /**
  8. * Class WPSEO_Statistic_Integration.
  9. */
  10. class WPSEO_Statistic_Integration implements WPSEO_WordPress_Integration {
  11. /**
  12. * Adds hooks to clear the cache.
  13. *
  14. * @return void
  15. */
  16. public function register_hooks() {
  17. add_action( 'wp_insert_post', [ $this, 'clear_cache' ] );
  18. add_action( 'delete_post', [ $this, 'clear_cache' ] );
  19. }
  20. /**
  21. * Clears the dashboard widget items cache.
  22. *
  23. * @return void
  24. */
  25. public function clear_cache() {
  26. delete_transient( WPSEO_Statistics_Service::CACHE_TRANSIENT_KEY );
  27. }
  28. }