class-acf-ajax-check-screen.php
2 months ago
class-acf-ajax-local-json-diff.php
1 year ago
class-acf-ajax-query-users.php
3 months ago
class-acf-ajax-query.php
4 months ago
class-acf-ajax-upgrade.php
2 months ago
class-acf-ajax-user-setting.php
1 year ago
class-acf-ajax.php
1 year ago
index.php
1 year ago
class-acf-ajax-user-setting.php
54 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; // Exit if accessed directly |
| 5 | } |
| 6 | |
| 7 | if ( ! class_exists( 'ACF_Ajax_User_Setting' ) ) : |
| 8 | |
| 9 | class ACF_Ajax_User_Setting extends ACF_Ajax { |
| 10 | |
| 11 | /** |
| 12 | * The AJAX action name. |
| 13 | * |
| 14 | * @var string |
| 15 | */ |
| 16 | public $action = 'acf/ajax/user_setting'; |
| 17 | |
| 18 | /** |
| 19 | * Prevents access for non-logged in users. |
| 20 | * |
| 21 | * @var boolean |
| 22 | */ |
| 23 | public $public = false; |
| 24 | |
| 25 | /** |
| 26 | * get_response |
| 27 | * |
| 28 | * Returns the response data to sent back. |
| 29 | * |
| 30 | * @date 31/7/18 |
| 31 | * @since ACF 5.7.2 |
| 32 | * |
| 33 | * @param array $request The request args. |
| 34 | * @return mixed The response data or WP_Error. |
| 35 | */ |
| 36 | public function get_response( $request ) { |
| 37 | if ( ! acf_current_user_can_admin() ) { |
| 38 | return new WP_Error( 'acf_invalid_permissions', __( 'Sorry, you do not have permission to do that.', 'secure-custom-fields' ) ); |
| 39 | } |
| 40 | |
| 41 | // update |
| 42 | if ( $this->has( 'value' ) ) { |
| 43 | return acf_update_user_setting( $this->get( 'name' ), $this->get( 'value' ) ); |
| 44 | |
| 45 | // get |
| 46 | } else { |
| 47 | return acf_get_user_setting( $this->get( 'name' ) ); |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | acf_new_instance( 'ACF_Ajax_User_Setting' ); |
| 53 | endif; // class_exists check |
| 54 |