class-yoast-onpage-ajax.php 829 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\Ajax
  6. */
  7. /**
  8. * Class Yoast_OnPage_Ajax.
  9. *
  10. * This class will catch the request to dismiss the Ryte notice and will store
  11. * the dismiss status as an user meta in the database.
  12. */
  13. class Yoast_OnPage_Ajax {
  14. /**
  15. * Initialize the hooks for the AJAX request.
  16. */
  17. public function __construct() {
  18. add_action( 'wp_ajax_wpseo_dismiss_onpageorg', [ $this, 'dismiss_notice' ] );
  19. }
  20. /**
  21. * Handles the dismiss notice request.
  22. */
  23. public function dismiss_notice() {
  24. check_ajax_referer( 'wpseo-dismiss-onpageorg' );
  25. $this->save_dismissed();
  26. wp_die( 'true' );
  27. }
  28. /**
  29. * Storing the dismissed value as an user option in the database.
  30. */
  31. private function save_dismissed() {
  32. update_user_meta( get_current_user_id(), WPSEO_OnPage::USER_META_KEY, 1 );
  33. }
  34. }