PluginProbe
Advanced Custom Fields (ACF®) / 5.6.6
Advanced Custom Fields (ACF®) v5.6.6
6.8.9 6.8.8 6.8.7 6.8.6 6.8.5 6.8.4 6.8.3 6.8.2 6.8.1 5.8.5 5.8.6 5.8.7 5.8.8 5.8.9 5.9.0 5.9.1 5.9.2 5.9.3 5.9.4 5.9.5 5.9.6 5.9.7 5.9.8 5.9.9 6.0.0 All 230 releases
advanced-custom-fields / includes / ajax.php
ajax.php
86 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * ACF AJAX Class
5 *
6 * All the logic for misc AJAX functionality
7 *
8 * @class acf_ajax
9 * @package ACF
10 * @subpackage Core
11 */
12
13 if( ! class_exists('acf_ajax') ) :
14
15 class acf_ajax {
16
17
18 /*
19 * __construct
20 *
21 * This function will setup the class functionality
22 *
23 * @type function
24 * @date 5/03/2014
25 * @since 5.0.0
26 *
27 * @param n/a
28 * @return n/a
29 */
30
31 function __construct() {
32
33 // acf/update_user_setting
34 add_action( 'wp_ajax_acf/update_user_setting', array($this, 'update_user_setting') );
35 add_action( 'wp_ajax_nopriv_acf/update_user_setting', array($this, 'update_user_setting') );
36
37 }
38
39
40 /*
41 * update_user_setting
42 *
43 * This function will update a user setting
44 *
45 * @type function
46 * @date 15/07/2014
47 * @since 5.0.0
48 *
49 * @param $post_id (int)
50 * @return $post_id (int)
51 */
52
53 function update_user_setting() {
54
55 // options
56 $options = wp_parse_args( $_POST, array(
57 'name' => '',
58 'value' => '',
59 'nonce' => '',
60 ));
61
62
63 // validate
64 if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') || empty($options['name']) ) {
65
66 die('0');
67
68 }
69
70
71 // upadte setting
72 acf_update_user_setting( $options['name'], $options['value'] );
73
74
75 // return
76 die('1');
77
78 }
79
80 }
81
82 new acf_ajax();
83
84 endif;
85
86 ?>