class-link-cleanup-transient.php 906 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\Links
  6. */
  7. /**
  8. * Represents the cleanup logic when the text link counter features has been disabled.
  9. */
  10. class WPSEO_Link_Cleanup_Transient implements WPSEO_WordPress_Integration {
  11. /**
  12. * Registers the hooks.
  13. */
  14. public function register_hooks() {
  15. add_action( 'update_option_wpseo', [ $this, 'remove_transients_on_updated_option' ], 10, 2 );
  16. }
  17. /**
  18. * Removes the transient when the option is updated.
  19. *
  20. * @param mixed $old_value The old value.
  21. * @param mixed $value The new value.
  22. *
  23. * @return void
  24. */
  25. public function remove_transients_on_updated_option( $old_value, $value ) {
  26. $option_name = 'enable_text_link_counter';
  27. if ( $value[ $option_name ] === false && $old_value[ $option_name ] !== $value[ $option_name ] ) {
  28. WPSEO_Link_Table_Accessible::cleanup();
  29. WPSEO_Meta_Table_Accessible::cleanup();
  30. }
  31. }
  32. }