PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.9.1
Secure Custom Fields v6.9.1
6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / includes / ajax / class-acf-ajax-query.php
secure-custom-fields / includes / ajax Last commit date
class-acf-ajax-check-screen.php 1 month 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 3 months ago class-acf-ajax-upgrade.php 1 month 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-query.php
155 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 if ( ! class_exists( 'ACF_Ajax_Query' ) ) :
8
9 class ACF_Ajax_Query extends ACF_Ajax {
10
11 /** @var boolean Prevents access for non-logged in users. */
12 var $public = true;
13
14 /** @var integer The page of results to return. */
15 var $page = 1;
16
17 /** @var integer The number of results per page. */
18 var $per_page = 20;
19
20 /** @var boolean Signifies whether or not this AJAX query has more pages to load. */
21 var $more = false;
22
23 /** @var string The searched term. */
24 var $search = '';
25
26 /** @var boolean Signifies whether the current query is a search. */
27 var $is_search = false;
28
29 /** @var (int|string) The post_id being edited. */
30 var $post_id = 0;
31
32 /** @var array The ACF field related to this query. */
33 var $field = false;
34
35 /**
36 * get_response
37 *
38 * Returns the response data to sent back.
39 *
40 * @date 31/7/18
41 * @since ACF 5.7.2
42 *
43 * @param array $request The request args.
44 * @return (array|WP_Error) The response data or WP_Error.
45 */
46 function get_response( $request ) {
47
48 // Init request.
49 $this->init_request( $request );
50
51 // Get query args.
52 $args = $this->get_args( $request );
53
54 // Get query results.
55 $results = $this->get_results( $args );
56 if ( is_wp_error( $results ) ) {
57 return $results;
58 }
59
60 // Return response.
61 return array(
62 'results' => $results,
63 'more' => $this->more,
64 );
65 }
66
67 /**
68 * init_request
69 *
70 * Called at the beginning of a request to setup properties.
71 *
72 * @date 23/5/19
73 * @since ACF 5.8.1
74 *
75 * @param array $request The request args.
76 * @return void
77 */
78 function init_request( $request ) {
79
80 // Get field for this query.
81 if ( isset( $request['field_key'] ) ) {
82 $this->field = acf_get_field( $request['field_key'] );
83 }
84
85 // Update query properties.
86 if ( isset( $request['page'] ) ) {
87 $this->page = intval( $request['page'] );
88 }
89 if ( isset( $request['per_page'] ) ) {
90 $this->per_page = intval( $request['per_page'] );
91 }
92 if ( isset( $request['search'] ) && acf_not_empty( $request['search'] ) ) {
93 $this->search = sanitize_text_field( $request['search'] );
94 $this->is_search = true;
95 }
96
97 if ( isset( $request['s'] ) && acf_not_empty( $request['s'] ) ) {
98 $this->search = sanitize_text_field( $request['s'] );
99 $this->is_search = true;
100 }
101
102 if ( isset( $request['post_id'] ) ) {
103 $this->post_id = $request['post_id'];
104 }
105 }
106
107 /**
108 * Returns an array of args for this query.
109 *
110 * @since ACF 5.7.2
111 *
112 * @param array $request The request args.
113 * @return array
114 */
115 public function get_args( $request ) {
116 /**
117 * We return an empty array here as subclasses should implement
118 * their own allow list of parameters for security.
119 */
120 return array();
121 }
122
123 /**
124 * get_results
125 *
126 * Returns an array of results for the given args.
127 *
128 * @date 31/7/18
129 * @since ACF 5.7.2
130 *
131 * @param array $args The query args.
132 * @return array
133 */
134 function get_results( $args ) {
135 return array();
136 }
137
138 /**
139 * get_result
140 *
141 * Returns a single result for the given item object.
142 *
143 * @date 31/7/18
144 * @since ACF 5.7.2
145 *
146 * @param mixed $item A single item from the queried results.
147 * @return array An array containing "id" and "text".
148 */
149 function get_result( $item ) {
150 return false;
151 }
152 }
153
154 endif; // class_exists check
155