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