PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.3.6
Pods – Custom Content Types and Fields v3.3.6
trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / deprecated / deprecated.php
pods / deprecated Last commit date
classes 4 months ago deprecated.php 4 months ago list_filters.php 4 months ago
deprecated.php
492 lines
1 <?php
2
3 // Don't load directly.
4 if ( ! defined( 'ABSPATH' ) ) {
5 die( '-1' );
6 }
7
8 /**
9 * @package Pods\Deprecated
10 */
11
12 /**
13 *
14 */
15
16 /**
17 * Get the full URL of the current page
18 *
19 * @return string
20 * @since 1.9.6
21 *
22 * @deprecated 2.3.0
23 */
24 if ( ! function_exists( 'get_current_url' ) ) {
25 /**
26 * @return mixed|void
27 */
28 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
29 function get_current_url() {
30 $url = pods_current_url();
31
32 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
33 return apply_filters( 'get_current_url', $url );
34 }
35 }
36
37 /**
38 * Mapping function to new function name (following normalization of function names from pod_ to pods_)
39 *
40 * @since 1.x.x
41 * @deprecated 2.0.0
42 *
43 * @param string $sql SQL query.
44 * @param string $error Error message on failure.
45 * @param null|string $results_error Error message if results returned.
46 * @param null|string $no_results_error Error message if no results returned.
47 *
48 * @return array|bool|mixed|null|void Result of the query
49 */
50 function pod_query( $sql, $error = 'SQL failed', $results_error = null, $no_results_error = null ) {
51 pods_deprecated( 'pod_query', '2.0', 'pods_query' );
52 global $wpdb;
53
54 $sql = trim( $sql );
55
56 // Using @wp_users is deprecated! use $wpdb->users instead!
57 $sql = str_replace( '@wp_pod_tbl_', $wpdb->prefix . 'pods_', $sql );
58 $sql = str_replace( '@wp_users', $wpdb->users, $sql );
59 $sql = str_replace( '@wp_', $wpdb->prefix, $sql );
60 $sql = str_replace( '{prefix}', '@wp_', $sql );
61
62 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
63 $sql = apply_filters( 'pod_query', $sql, $error, $results_error, $no_results_error );
64
65 $result = pods_query( $sql, $error, $results_error, $no_results_error );
66
67 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
68 $result = apply_filters( 'pod_query_return', $result, $sql, $error, $results_error, $no_results_error );
69
70 return $result;
71 }
72
73 /**
74 * Include and Init the Pods class
75 *
76 * @since 1.x.x
77 * @deprecated 2.0.0
78 * @package Pods\Deprecated
79 */
80 class Pod {
81
82 private $new;
83
84 public static $deprecated_notice = true;
85
86 public $body_classes;
87
88 public $ui = array();
89
90 public $meta = array();
91
92 public $meta_properties = array();
93
94 public $meta_extra = '';
95
96 /**
97 * Pod constructor.
98 *
99 * @param null $type
100 * @param null $id
101 */
102 public function __construct( $type = null, $id = null ) {
103 if ( self::$deprecated_notice ) {
104 pods_deprecated( 'PodAPI (class)', '2.0', 'pods_api (function)' );
105 }
106
107 pods_deprecated( 'Pod (class)', '2.0', 'pods (function)' );
108
109 $this->new = pods( $type, $id );
110 }
111
112 /**
113 * Handle variables that have been deprecated
114 *
115 * @since 2.0.0
116 *
117 * @param string $name Property name.
118 *
119 * @return array|bool|int|mixed|PodsData
120 */
121 #[\ReturnTypeWillChange]
122 public function __get( $name ) {
123 $name = (string) $name;
124
125 if ( 'data' === $name ) {
126 if ( self::$deprecated_notice ) {
127 pods_deprecated( "Pods->{$name}", '2.0', 'Pods->row()' );
128 }
129
130 $var = $this->new->row();
131 } elseif ( '_data' === $name ) {
132 $var = $this->new->data;
133 } elseif ( 'total' === $name ) {
134 if ( self::$deprecated_notice ) {
135 pods_deprecated( "Pods->{$name}", '2.0', 'Pods->total()' );
136 }
137
138 $var = $this->new->total();
139 } elseif ( 'total_rows' === $name ) {
140 if ( self::$deprecated_notice ) {
141 pods_deprecated( "Pods->{$name}", '2.0', 'Pods->total_found()' );
142 }
143
144 $var = $this->new->total_found();
145 } elseif ( 'zebra' === $name ) {
146 if ( self::$deprecated_notice ) {
147 pods_deprecated( "Pods->{$name}", '2.0', 'Pods->zebra()' );
148 }
149
150 $var = $this->new->zebra();
151 } else {
152 $var = $this->new->{$name};
153 }//end if
154
155 return $var;
156 }
157
158 /**
159 * Handle variables that have been deprecated
160 *
161 * @since 2.0.0
162 *
163 * @param string $name Property name.
164 * @param mixed $value Property value to set.
165 */
166 public function __set( $name, $value ): void {
167 $name = (string) $name;
168
169 $this->new->{$name} = $value;
170 }
171
172 /**
173 * Handle methods that have been deprecated
174 *
175 * @since 2.0.0
176 *
177 * @param string $name Call name.
178 * @param array $arguments Call arguments.
179 *
180 * @return mixed
181 */
182 #[\ReturnTypeWillChange]
183 public function __call( $name, $arguments ) {
184 $name = (string) $name;
185
186 return call_user_func_array( array( $this->new, $name ), $arguments );
187 }
188
189 /**
190 * Handle variables that have been deprecated
191 *
192 * @since 2.0.0
193 *
194 * @param string $name Property name.
195 *
196 * @return bool
197 */
198 public function __isset( $name ): bool {
199 $name = (string) $name;
200
201 if ( in_array( $name, array( '_data', 'data', 'total', 'total_rows', 'zebra' ), true ) ) {
202 return true;
203 } elseif ( in_array( $name, array( 'meta', 'meta_properties', 'meta_extra' ), true ) ) {
204 return true;
205 } else {
206 return isset( $this->new->{$name} );
207 }
208 }
209 }
210
211 /**
212 * Include and Init the PodsAPI class
213 *
214 * @since 1.x.x
215 * @deprecated 2.0.0
216 * @package Pods\Deprecated
217 */
218 class PodAPI {
219
220 private $new;
221
222 public static $deprecated_notice = true;
223
224 /**
225 * PodAPI constructor.
226 *
227 * @param null $type
228 * @param null $format
229 */
230 public function __construct( $type = null, $format = null ) {
231 if ( self::$deprecated_notice ) {
232 pods_deprecated( 'PodAPI (class)', '2.0', 'pods_api (function)' );
233 }
234
235 $this->new = pods_api( $type, $format );
236 }
237
238 /**
239 * Handle variables that have been deprecated
240 *
241 * @since 2.0.0
242 *
243 * @param string $name Property name.
244 *
245 * @return null|mixed
246 */
247 #[\ReturnTypeWillChange]
248 public function __get( $name ) {
249 $name = (string) $name;
250
251 $var = $this->new->{$name};
252
253 return $var;
254 }
255
256 /**
257 * Handle methods that have been deprecated
258 *
259 * @since 2.0.0
260 *
261 * @param string $name Call name.
262 * @param array $arguments Call arguments.
263 *
264 * @return mixed
265 */
266 #[\ReturnTypeWillChange]
267 public function __call( $name, $arguments ) {
268 $name = (string) $name;
269
270 return call_user_func_array( array( $this->new, $name ), $arguments );
271 }
272 }
273
274 /**
275 * Include and Init the PodsUI class
276 *
277 * @since 2.0.0
278 * @deprecated 2.0.0
279 *
280 * @param Pods $obj Pods object.
281 *
282 * @return PodsUI
283 */
284 function pods_ui_manage( $obj ) {
285 pods_deprecated( 'pods_ui_manage', '2.0', 'pods_ui' );
286
287 return pods_ui( $obj, true );
288 }
289
290 /**
291 * Limit Access based on Field Value
292 *
293 * @since 1.x.x
294 * @deprecated 2.0.0
295 *
296 * @param Pods $object Pods object.
297 * @param array $access Access array.
298 * @param string $what Action name.
299 *
300 * @return bool
301 */
302 function pods_ui_access( $object, $access, $what ) {
303 pods_deprecated( 'pods_ui_access', '2.0' );
304 if ( is_array( $access ) ) {
305 foreach ( $access as $field => $match ) {
306 if ( is_array( $match ) ) {
307 $okay = false;
308 foreach ( $match as $the_field => $the_match ) {
309 if ( $object->get_field( $the_field ) == $the_match ) {
310 $okay = true;
311 }
312 }
313 if ( false === $okay ) {
314 return false;
315 }
316 } elseif ( $object->get_field( $field ) != $match ) {
317 return false;
318 }
319 }
320 }
321
322 return true;
323 }
324
325 /**
326 * Return a GET, POST, COOKIE, SESSION, or URI string segment
327 *
328 * @param mixed $key The variable name or URI segment position
329 * @param string $type (optional) "uri", "get", "post", "request", "server", "session", or "cookie"
330 *
331 * @return string The requested value, or null
332 * @since 1.6.2
333 * @deprecated 2.0.0
334 */
335 function pods_url_variable( $key = 'last', $type = 'url' ) {
336 $output = apply_filters( 'pods_url_variable', pods_var( $key, $type ), $key, $type );
337
338 return $output;
339 }
340
341 /**
342 * Generate form key - INTERNAL USE
343 *
344 * @since 1.2.0
345 * @deprecated 2.0.0
346 *
347 * @param string $datatype Pod name.
348 * @param string $uri_hash URI hash for session.
349 * @param array $columns List of columns.
350 * @param int $form_count Form counter.
351 *
352 * @return mixed|string|void
353 */
354 function pods_generate_key( $datatype, $uri_hash, $columns, $form_count = 1 ) {
355 $token = wp_create_nonce( 'pods-form-' . $datatype . '-' . (int) $form_count . '-' . $uri_hash . '-' . json_encode( $columns ) );
356 $token = apply_filters( 'pods_generate_key', $token, $datatype, $uri_hash, $columns, (int) $form_count );
357 $_SESSION[ 'pods_form_' . $token ] = $columns;
358
359 return $token;
360 }
361
362 /**
363 * Validate form key - INTERNAL USE
364 *
365 * @since 1.2.0
366 * @deprecated 2.0.0
367 *
368 * @param string $token Nonce token.
369 * @param string $datatype Pod name.
370 * @param string $uri_hash URI hash for session.
371 * @param null|array $columns List of columns.
372 * @param int $form_count Form counter.
373 *
374 * @return mixed|void
375 */
376 function pods_validate_key( $token, $datatype, $uri_hash, $columns = null, $form_count = 1 ) {
377 if ( null === $columns && ! empty( $_SESSION ) && isset( $_SESSION[ 'pods_form_' . $token ] ) ) {
378 $columns = $_SESSION[ 'pods_form_' . $token ];
379 }
380 $success = false;
381 if ( false !== wp_verify_nonce( $token, 'pods-form-' . $datatype . '-' . (int) $form_count . '-' . $uri_hash . '-' . json_encode( $columns ) ) ) {
382 $success = $columns;
383 }
384
385 return apply_filters( 'pods_validate_key', $success, $token, $datatype, $uri_hash, $columns, (int) $form_count );
386 }
387
388 /**
389 * Output a message in the WP Dashboard UI
390 *
391 * @param string $message
392 * @param bool $error Whether or not it is an error message
393 *
394 * @since 1.12
395 * @deprcated 2.3
396 */
397 function pods_ui_message( $message, $error = false ) {
398 pods_deprecated( 'pods_message', '2.3' );
399
400 pods_message( $message, ( $error ? 'error' : 'notice' ) );
401 }
402
403 /**
404 * Output an error in the WP Dashboard UI
405 *
406 * @param string $message
407 *
408 * @since 1.12
409 * @deprcated 2.3
410 */
411 function pods_ui_error( $message ) {
412 pods_deprecated( 'pods_message', '2.3' );
413
414 pods_message( $message, 'error' );
415 }
416
417 /**
418 * Get a Point value from a Pods Version number
419 *
420 * @since 1.10.1
421 * @deprcated 2.3
422 *
423 * @param string $point Version number with points.
424 *
425 * @return int|string
426 */
427 function pods_point_to_version( $point ) {
428 $version_tmp = explode( '.', $point );
429 $version = '';
430
431 for ( $x = 0; $x < 3; $x ++ ) {
432 // 3 points max - MAJOR.MINOR.PATCH
433 if ( ! isset( $version_tmp[ $x ] ) || strlen( $version_tmp[ $x ] ) < 1 ) {
434 $version_tmp[ $x ] = '000';
435 }
436
437 $version_temp = str_split( $version_tmp[ $x ] );
438
439 if ( 3 == count( $version_temp ) ) {
440 $version .= $version_tmp[ $x ];
441 } elseif ( 2 == count( $version_temp ) ) {
442 $version .= '0' . $version_tmp[ $x ];
443 } elseif ( 1 == count( $version_temp ) ) {
444 $version .= '00' . $version_tmp[ $x ];
445 }
446 }
447
448 $version = (int) $version;
449
450 return $version;
451 }
452
453 /**
454 * Get a Point value from a Pods Version number
455 *
456 * @since 1.10
457 * @deprcated 2.3
458 *
459 * @param string $version Version number string.
460 *
461 * @return array|string
462 */
463 function pods_version_to_point( $version ) {
464 $point_tmp = $version;
465
466 if ( strlen( $point_tmp ) < 9 ) {
467 if ( 8 == strlen( $point_tmp ) ) {
468 $point_tmp = '0' . $point_tmp;
469 }
470
471 if ( 7 == strlen( $point_tmp ) ) {
472 $point_tmp = '00' . $point_tmp;
473 }
474
475 if ( 3 == strlen( $version ) ) {
476 // older versions prior to 1.9.9
477 return implode( '.', str_split( $version ) );
478 }
479 }
480
481 $point_tmp = str_split( $point_tmp, 3 );
482 $point = array();
483
484 foreach ( $point_tmp as $the_point ) {
485 $point[] = (int) $the_point;
486 }
487
488 $point = implode( '.', $point );
489
490 return $point;
491 }
492