class-acf-ajax-user-setting.php 916 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. exit; // Exit if accessed directly
  4. }
  5. if ( ! class_exists( 'ACF_Ajax_User_Setting' ) ) :
  6. class ACF_Ajax_User_Setting extends ACF_Ajax {
  7. /** @var string The AJAX action name. */
  8. var $action = 'acf/ajax/user_setting';
  9. /** @var bool Prevents access for non-logged in users. */
  10. var $public = true;
  11. /**
  12. * get_response
  13. *
  14. * Returns the response data to sent back.
  15. *
  16. * @date 31/7/18
  17. * @since 5.7.2
  18. *
  19. * @param array $request The request args.
  20. * @return mixed The response data or WP_Error.
  21. */
  22. function get_response( $request ) {
  23. // update
  24. if ( $this->has( 'value' ) ) {
  25. return acf_update_user_setting( $this->get( 'name' ), $this->get( 'value' ) );
  26. // get
  27. } else {
  28. return acf_get_user_setting( $this->get( 'name' ) );
  29. }
  30. }
  31. }
  32. acf_new_instance( 'ACF_Ajax_User_Setting' );
  33. endif; // class_exists check