This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * Pods Field class for common type-specific methods. |
||
5 | * |
||
6 | * @package Pods |
||
7 | */ |
||
8 | class PodsField { |
||
9 | |||
10 | /** |
||
11 | * Whether this field is running under 1.x deprecated forms |
||
12 | * |
||
13 | * @var bool |
||
14 | * @since 2.0 |
||
15 | */ |
||
16 | public static $deprecated = false; |
||
17 | |||
18 | /** |
||
19 | * Field Type Identifier |
||
20 | * |
||
21 | * @var string |
||
22 | * @since 2.0 |
||
23 | */ |
||
24 | public static $type = 'text'; |
||
25 | |||
26 | /** |
||
27 | * Field Type Label |
||
28 | * |
||
29 | * @var string |
||
30 | * @since 2.0 |
||
31 | */ |
||
32 | public static $label = 'Unknown'; |
||
33 | |||
34 | /** |
||
35 | * Field Type Preparation |
||
36 | * |
||
37 | * @var string |
||
38 | * @since 2.0 |
||
39 | */ |
||
40 | public static $prepare = '%s'; |
||
41 | |||
42 | /** |
||
43 | * Pod Types supported on (true for all, false for none, or give array of specific types supported) |
||
44 | * |
||
45 | * @var array|bool |
||
46 | * @since 2.1 |
||
47 | */ |
||
48 | public static $pod_types = true; |
||
49 | |||
50 | /** |
||
51 | * API caching for fields that need it during validate/save |
||
52 | * |
||
53 | * @var \PodsAPI |
||
54 | * @since 2.3 |
||
55 | */ |
||
56 | private static $api; |
||
0 ignored issues
–
show
|
|||
57 | |||
58 | /** |
||
59 | * Initial setup of class object. |
||
60 | * |
||
61 | * @since 2.0 |
||
62 | */ |
||
63 | public function __construct() { |
||
64 | |||
65 | // Run any setup needed. |
||
66 | $this->setup(); |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * Do things like register/enqueue scripts+stylesheets, set labels, etc. |
||
71 | * |
||
72 | * @since 2.7.2 |
||
73 | */ |
||
74 | public function setup() { |
||
75 | |||
76 | // Subclasses utilize this method if needed. |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * Add admin_init actions. |
||
81 | * |
||
82 | * @since 2.3 |
||
83 | */ |
||
84 | public function admin_init() { |
||
85 | |||
86 | // Add admin actions here. |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Add options and set defaults for field type, shows in admin area |
||
91 | * |
||
92 | * @return array $options |
||
93 | * |
||
94 | * @since 2.0 |
||
95 | * @see PodsField::ui_options |
||
96 | */ |
||
97 | public function options() { |
||
98 | |||
99 | $options = array(); |
||
100 | |||
101 | /* |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
42% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
102 | 'option_name' => array( |
||
103 | 'label' => 'Option Label', |
||
104 | 'depends-on' => array( 'another_option' => 'specific-value' ), |
||
105 | 'default' => 'default-value', |
||
106 | 'type' => 'field_type', |
||
107 | 'data' => array( |
||
108 | 'value1' => 'Label 1', |
||
109 | |||
110 | // Group your options together |
||
111 | 'Option Group' => array( |
||
112 | 'gvalue1' => 'Option Label 1', |
||
113 | 'gvalue2' => 'Option Label 2' |
||
114 | ), |
||
115 | |||
116 | // below is only if the option_name above is the "{$fieldtype}_format_type" |
||
117 | 'value2' => array( |
||
118 | 'label' => 'Label 2', |
||
119 | 'regex' => '[a-zA-Z]' // Uses JS regex validation for the value saved if this option selected |
||
120 | ) |
||
121 | ), |
||
122 | |||
123 | // below is only for a boolean group |
||
124 | 'group' => array( |
||
125 | 'option_boolean1' => array( |
||
126 | 'label' => 'Option boolean 1?', |
||
127 | 'default' => 1, |
||
128 | 'type' => 'boolean' |
||
129 | ), |
||
130 | 'option_boolean2' => array( |
||
131 | 'label' => 'Option boolean 2?', |
||
132 | 'default' => 0, |
||
133 | 'type' => 'boolean' |
||
134 | ) |
||
135 | ) |
||
136 | ) |
||
137 | */ |
||
138 | |||
139 | return $options; |
||
140 | |||
141 | } |
||
142 | |||
143 | /** |
||
144 | * Options for the Admin area, defaults to $this->options() |
||
145 | * |
||
146 | * @return array $options |
||
147 | * |
||
148 | * @since 2.0 |
||
149 | * @see PodsField::options |
||
150 | */ |
||
151 | public function ui_options() { |
||
152 | |||
153 | return $this->options(); |
||
154 | |||
155 | } |
||
156 | |||
157 | /** |
||
158 | * Define the current field's schema for DB table storage |
||
159 | * |
||
160 | * @param array|null $options Field options. |
||
161 | * |
||
162 | * @return string|false |
||
163 | * |
||
164 | * @since 2.0 |
||
165 | */ |
||
166 | public function schema( $options = null ) { |
||
167 | |||
168 | $schema = 'VARCHAR(255)'; |
||
169 | |||
170 | return $schema; |
||
171 | |||
172 | } |
||
173 | |||
174 | /** |
||
175 | * Define the current field's preparation for sprintf |
||
176 | * |
||
177 | * @param array|null $options Field options. |
||
178 | * |
||
179 | * @return string |
||
180 | * |
||
181 | * @since 2.0 |
||
182 | */ |
||
183 | public function prepare( $options = null ) { |
||
184 | |||
185 | $format = self::$prepare; |
||
186 | |||
187 | return $format; |
||
188 | |||
189 | } |
||
190 | |||
191 | /** |
||
192 | * Check if the field is empty. |
||
193 | * |
||
194 | * @param mixed $value Field value. |
||
195 | * |
||
196 | * @return bool |
||
197 | * |
||
198 | * @since 2.7 |
||
199 | */ |
||
200 | public function is_empty( $value ) { |
||
201 | |||
202 | $is_empty = false; |
||
203 | |||
204 | if ( is_string( $value ) ) { |
||
205 | $value = trim( $value ); |
||
206 | } |
||
207 | |||
208 | if ( empty( $value ) ) { |
||
209 | $is_empty = true; |
||
210 | } |
||
211 | |||
212 | return $is_empty; |
||
213 | |||
214 | } |
||
215 | |||
216 | /** |
||
217 | * Check if the field values are empty. |
||
218 | * |
||
219 | * @param array|mixed $values Field values. |
||
220 | * @param boolean $strict Whether to check if any of the values are non-empty in an array. |
||
221 | * |
||
222 | * @return bool |
||
223 | * |
||
224 | * @since 2.7 |
||
225 | */ |
||
226 | public function values_are_empty( $values, $strict = true ) { |
||
227 | |||
228 | $is_empty = false; |
||
229 | |||
230 | if ( is_array( $values ) && isset( $values[0] ) ) { |
||
231 | if ( $strict ) { |
||
232 | foreach ( $values as $value ) { |
||
233 | $is_empty = true; |
||
234 | |||
235 | if ( ! $this->is_empty( $value ) ) { |
||
236 | $is_empty = false; |
||
237 | |||
238 | break; |
||
239 | } |
||
240 | } |
||
241 | } elseif ( empty( $values ) ) { |
||
242 | $is_empty = true; |
||
243 | } |
||
244 | } else { |
||
245 | $is_empty = $this->is_empty( $values ); |
||
246 | } |
||
247 | |||
248 | return $is_empty; |
||
249 | |||
250 | } |
||
251 | |||
252 | /** |
||
253 | * Change the value of the field |
||
254 | * |
||
255 | * @param mixed|null $value Current value. |
||
256 | * @param string|null $name Field name. |
||
257 | * @param array|null $options Field options. |
||
258 | * @param array|null $pod Pod information. |
||
259 | * @param int|string|null $id Current item ID. |
||
260 | * |
||
261 | * @return mixed|null|string |
||
262 | * |
||
263 | * @since 2.3 |
||
264 | */ |
||
265 | public function value( $value = null, $name = null, $options = null, $pod = null, $id = null ) { |
||
266 | |||
267 | return $value; |
||
268 | |||
269 | } |
||
270 | |||
271 | /** |
||
272 | * Change the way the value of the field is displayed with Pods::get |
||
273 | * |
||
274 | * @param mixed|null $value Current value. |
||
275 | * @param string|null $name Field name. |
||
276 | * @param array|null $options Field options. |
||
277 | * @param array|null $pod Pod information. |
||
278 | * @param int|string|null $id Current item ID. |
||
279 | * |
||
280 | * @return mixed|null|string |
||
281 | * |
||
282 | * @since 2.0 |
||
283 | */ |
||
284 | public function display( $value = null, $name = null, $options = null, $pod = null, $id = null ) { |
||
285 | |||
286 | return $value; |
||
287 | |||
288 | } |
||
289 | |||
290 | /** |
||
291 | * Reformat a number to the way the value of the field is displayed. |
||
292 | * |
||
293 | * @param mixed|null $value Current value. |
||
294 | * @param string|null $name Field name. |
||
295 | * @param array|null $options Field options. |
||
296 | * @param array|null $pod Pod information. |
||
297 | * @param int|string|null $id Current item ID. |
||
298 | * |
||
299 | * @return string|null |
||
300 | * @since 2.0 |
||
301 | */ |
||
302 | public function format( $value = null, $name = null, $options = null, $pod = null, $id = null ) { |
||
303 | |||
304 | return $value; |
||
305 | |||
306 | } |
||
307 | |||
308 | /** |
||
309 | * Customize output of the form field |
||
310 | * |
||
311 | * @param string|null $name Field name. |
||
312 | * @param mixed|null $value Current value. |
||
313 | * @param array|null $options Field options. |
||
314 | * @param array|null $pod Pod information. |
||
315 | * @param int|string|null $id Current item ID. |
||
316 | * |
||
317 | * @since 2.0 |
||
318 | */ |
||
319 | public function input( $name, $value = null, $options = null, $pod = null, $id = null ) { |
||
320 | |||
321 | $options = (array) $options; |
||
322 | |||
323 | $form_field_type = PodsForm::$field_type; |
||
324 | |||
325 | if ( is_array( $value ) ) { |
||
326 | $value = implode( ' ', $value ); |
||
327 | } |
||
328 | |||
329 | pods_view( PODS_DIR . 'ui/fields/text.php', compact( array_keys( get_defined_vars() ) ) ); |
||
330 | |||
331 | /* |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
42% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
332 | * @todo Eventually use this code |
||
333 | $options = (array) $options; |
||
334 | |||
335 | $type = pods_v( 'type', $options, static::$type ); |
||
336 | |||
337 | $args = compact( array_keys( get_defined_vars() ) ); |
||
338 | $args = (object) $args; |
||
339 | |||
340 | $this->render_input_script( $args ); |
||
341 | */ |
||
342 | |||
343 | } |
||
344 | |||
345 | /** |
||
346 | * Render input script for Pods DFV |
||
347 | * |
||
348 | * @param array|object $args { |
||
349 | * Field information arguments. |
||
350 | * |
||
351 | * @type string $name Field name. |
||
352 | * @type string $type Field type. |
||
353 | * @type array $options Field options. |
||
354 | * @type mixed $value Current value. |
||
355 | * @type array $pod Pod information. |
||
356 | * @type int|string $id Current item ID. |
||
357 | * @type string $form_field_type HTML field type. |
||
358 | * } |
||
359 | */ |
||
360 | public function render_input_script( $args ) { |
||
361 | |||
362 | if ( is_array( $args ) ) { |
||
363 | $args = (object) $args; |
||
364 | } |
||
365 | |||
366 | $script_content = wp_json_encode( $this->build_dfv_field_data( $args ), JSON_HEX_TAG ); |
||
367 | ?> |
||
368 | <div class="pods-form-ui-field pods-dfv-field"> |
||
369 | <?php // @codingStandardsIgnoreLine ?> |
||
370 | <script type="application/json" class="pods-dfv-field-data"><?php echo $script_content; ?></script> |
||
371 | </div> |
||
372 | <?php |
||
373 | |||
374 | } |
||
375 | |||
376 | /** |
||
377 | * Build field data for Pods DFV |
||
378 | * |
||
379 | * @param object $args { |
||
380 | * Field information arguments. |
||
381 | * |
||
382 | * @type string $name Field name. |
||
383 | * @type string $type Field type. |
||
384 | * @type array $options Field options. |
||
385 | * @type mixed $value Current value. |
||
386 | * @type array $pod Pod information. |
||
387 | * @type int|string $id Current item ID. |
||
388 | * @type string $form_field_type HTML field type. |
||
389 | * } |
||
390 | * |
||
391 | * @return array |
||
392 | */ |
||
393 | public function build_dfv_field_data( $args ) { |
||
394 | |||
395 | // Handle DFV options. |
||
396 | $args->options = $this->build_dfv_field_options( $args->options, $args ); |
||
397 | |||
398 | // Handle DFV attributes. |
||
399 | $attributes = PodsForm::merge_attributes( array(), $args->name, $args->type, $args->options ); |
||
400 | $attributes = $this->build_dfv_field_attributes( $attributes, $args ); |
||
401 | $attributes = array_map( 'esc_attr', $attributes ); |
||
402 | |||
403 | // Build DFV field data. |
||
404 | $data = array( |
||
405 | 'htmlAttr' => array( |
||
406 | 'id' => $attributes['id'], |
||
407 | 'class' => $attributes['class'], |
||
408 | 'name' => $attributes['name'], |
||
409 | 'name_clean' => $attributes['data-name-clean'], |
||
410 | ), |
||
411 | 'fieldType' => $args->type, |
||
412 | 'fieldItemData' => $this->build_dfv_field_item_data( $args ), |
||
413 | 'fieldConfig' => $this->build_dfv_field_config( $args ), |
||
414 | ); |
||
415 | |||
416 | /** |
||
417 | * Filter Pods DFV field data to further customize functionality. |
||
418 | * |
||
419 | * @since 2.7 |
||
420 | * |
||
421 | * @param array $data DFV field data |
||
422 | * @param object $args { |
||
423 | * Field information arguments. |
||
424 | * |
||
425 | * @type string $name Field name. |
||
426 | * @type string $type Field type. |
||
427 | * @type array $options Field options. |
||
428 | * @type mixed $value Current value. |
||
429 | * @type array $pod Pod information. |
||
430 | * @type int|string $id Current item ID. |
||
431 | * @type string $form_field_type HTML field type. |
||
432 | * } |
||
433 | * |
||
434 | * @param array $attributes HTML attributes |
||
435 | */ |
||
436 | $data = apply_filters( 'pods_field_dfv_data', $data, $args, $attributes ); |
||
437 | |||
438 | return $data; |
||
439 | |||
440 | } |
||
441 | |||
442 | /** |
||
443 | * Build field options and handle any validation/customization for Pods DFV |
||
444 | * |
||
445 | * @param array $options Field options. |
||
446 | * @param object $args { |
||
447 | * Field information arguments. |
||
448 | * |
||
449 | * @type string $name Field name. |
||
450 | * @type string $type Field type. |
||
451 | * @type array $options Field options. |
||
452 | * @type mixed $value Current value. |
||
453 | * @type array $pod Pod information. |
||
454 | * @type int|string $id Current item ID. |
||
455 | * @type string $form_field_type HTML field type. |
||
456 | * } |
||
457 | * |
||
458 | * @return array |
||
459 | */ |
||
460 | public function build_dfv_field_options( $options, $args ) { |
||
461 | |||
462 | return $options; |
||
463 | |||
464 | } |
||
465 | |||
466 | /** |
||
467 | * Build field HTML attributes for Pods DFV. |
||
468 | * |
||
469 | * @param array $attributes Default HTML attributes from field and PodsForm::merge_attributes. |
||
470 | * @param object $args { |
||
471 | * Field information arguments. |
||
472 | * |
||
473 | * @type string $name Field name. |
||
474 | * @type string $type Field type. |
||
475 | * @type array $options Field options. |
||
476 | * @type mixed $value Current value. |
||
477 | * @type array $pod Pod information. |
||
478 | * @type int|string $id Current item ID. |
||
479 | * @type string $form_field_type HTML field type. |
||
480 | * } |
||
481 | * |
||
482 | * @return array |
||
483 | */ |
||
484 | public function build_dfv_field_attributes( $attributes, $args ) { |
||
485 | |||
486 | return $attributes; |
||
487 | |||
488 | } |
||
489 | |||
490 | /** |
||
491 | * Build field config for Pods DFV using field options. |
||
492 | * |
||
493 | * This is for customizing the options and adding output-specific config values. |
||
494 | * |
||
495 | * @param object $args { |
||
496 | * Field information arguments. |
||
497 | * |
||
498 | * @type string $name Field name. |
||
499 | * @type string $type Field type. |
||
500 | * @type array $options Field options. |
||
501 | * @type mixed $value Current value. |
||
502 | * @type array $pod Pod information. |
||
503 | * @type int|string $id Current item ID. |
||
504 | * @type string $form_field_type HTML field type. |
||
505 | * } |
||
506 | * |
||
507 | * @return array |
||
0 ignored issues
–
show
|
|||
508 | */ |
||
509 | public function build_dfv_field_config( $args ) { |
||
510 | |||
511 | $config = $args->options; |
||
512 | |||
513 | unset( $config['data'] ); |
||
514 | |||
515 | $config['item_id'] = (int) $args->id; |
||
516 | |||
517 | return $config; |
||
518 | |||
519 | } |
||
520 | |||
521 | /** |
||
522 | * Build array of item data for Pods DFV. |
||
523 | * |
||
524 | * @param object $args { |
||
525 | * Field information arguments. |
||
526 | * |
||
527 | * @type string $name Field name. |
||
528 | * @type string $type Field type. |
||
529 | * @type array $options Field options. |
||
530 | * @type mixed $value Current value. |
||
531 | * @type array $pod Pod information. |
||
532 | * @type int|string $id Current item ID. |
||
533 | * @type string $form_field_type HTML field type. |
||
534 | * } |
||
535 | * |
||
536 | * @return array |
||
537 | */ |
||
538 | public function build_dfv_field_item_data( $args ) { |
||
539 | |||
540 | $data = array(); |
||
541 | |||
542 | if ( ! empty( $args->options['data'] ) && is_array( $args->options['data'] ) ) { |
||
543 | $data = $args->options['data']; |
||
544 | } |
||
545 | |||
546 | return $data; |
||
547 | |||
548 | } |
||
549 | |||
550 | /** |
||
551 | * Get the data from the field. |
||
552 | * |
||
553 | * @param string|null $name Field name. |
||
554 | * @param mixed|null $value Current value. |
||
555 | * @param array|null $options Field options. |
||
556 | * @param array|null $pod Pod information. |
||
557 | * @param int|string|null $id Current item ID. |
||
558 | * @param boolean $in_form Whether we are in the form context. |
||
559 | * |
||
560 | * @return array Array of possible field data. |
||
561 | * |
||
562 | * @since 2.0 |
||
563 | */ |
||
564 | public function data( $name, $value = null, $options = null, $pod = null, $id = null, $in_form = true ) { |
||
565 | |||
566 | return (array) $value; |
||
567 | |||
568 | } |
||
569 | |||
570 | /** |
||
571 | * Build regex necessary for JS validation. |
||
572 | * |
||
573 | * @param mixed|null $value Current value. |
||
574 | * @param string|null $name Field name. |
||
575 | * @param array|null $options Field options. |
||
576 | * @param array|null $pod Pod information. |
||
577 | * @param int|string|null $id Current item ID. |
||
578 | * |
||
579 | * @return string|false |
||
580 | * |
||
581 | * @since 2.0 |
||
582 | */ |
||
583 | public function regex( $value = null, $name = null, $options = null, $pod = null, $id = null ) { |
||
584 | |||
585 | return false; |
||
586 | |||
587 | } |
||
588 | |||
589 | /** |
||
590 | * Validate a value before it's saved. |
||
591 | * |
||
592 | * @param mixed|null $value Current value. |
||
593 | * @param string|null $name Field name. |
||
594 | * @param array|null $options Field options. |
||
595 | * @param array|null $fields Pod fields. |
||
596 | * @param array|null $pod Pod information. |
||
597 | * @param int|string|null $id Current item ID. |
||
598 | * @param array|null $params Additional parameters. |
||
599 | * |
||
600 | * @return bool |
||
601 | * |
||
602 | * @since 2.0 |
||
603 | */ |
||
604 | public function validate( $value, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) { |
||
605 | |||
606 | return true; |
||
607 | |||
608 | } |
||
609 | |||
610 | /** |
||
611 | * Change the value or perform actions after validation but before saving to the DB |
||
612 | * |
||
613 | * @param mixed|null $value Current value. |
||
614 | * @param int|string|null $id Current Item ID. |
||
615 | * @param string|null $name Field name. |
||
616 | * @param array|null $options Field options. |
||
617 | * @param array|null $fields Pod fields. |
||
618 | * @param array|null $pod Pod information. |
||
619 | * @param array|null $params Additional parameters. |
||
620 | * |
||
621 | * @return mixed |
||
622 | * |
||
623 | * @since 2.0 |
||
624 | */ |
||
625 | public function pre_save( $value, $id = null, $name = null, $options = null, $fields = null, $pod = null, $params = null ) { |
||
626 | |||
627 | return $value; |
||
628 | |||
629 | } |
||
630 | |||
631 | /** |
||
632 | * Save the value to the DB |
||
633 | * |
||
634 | * @param mixed|null $value Current value. |
||
635 | * @param int|string|null $id Current Item ID. |
||
636 | * @param string|null $name Field name. |
||
637 | * @param array|null $options Field options. |
||
638 | * @param array|null $fields Pod fields. |
||
639 | * @param array|null $pod Pod information. |
||
640 | * @param array|null $params Additional parameters. |
||
641 | * |
||
642 | * @return bool|null Whether the value was saved, returning null means no save needed to occur |
||
643 | * |
||
644 | * @since 2.3 |
||
645 | */ |
||
646 | public function save( $value, $id = null, $name = null, $options = null, $fields = null, $pod = null, $params = null ) { |
||
647 | |||
648 | return null; |
||
649 | |||
650 | } |
||
651 | |||
652 | /** |
||
653 | * Perform actions after saving to the DB |
||
654 | * |
||
655 | * @param mixed|null $value Current value. |
||
656 | * @param int|string|null $id Current Item ID. |
||
657 | * @param string|null $name Field name. |
||
658 | * @param array|null $options Field options. |
||
659 | * @param array|null $fields Pod fields. |
||
660 | * @param array|null $pod Pod information. |
||
661 | * @param array|null $params Additional parameters. |
||
662 | * |
||
663 | * @since 2.0 |
||
664 | */ |
||
665 | public function post_save( $value, $id = null, $name = null, $options = null, $fields = null, $pod = null, $params = null ) { |
||
666 | |||
667 | // Subclasses utilize this method if needed. |
||
668 | } |
||
669 | |||
670 | /** |
||
671 | * Perform actions before deleting from the DB |
||
672 | * |
||
673 | * @param int|string|null $id Current Item ID. |
||
674 | * @param string|null $name Field name. |
||
675 | * @param array|null $options Field options. |
||
676 | * @param array|null $pod Pod information. |
||
677 | * |
||
678 | * @since 2.0 |
||
679 | */ |
||
680 | public function pre_delete( $id = null, $name = null, $options = null, $pod = null ) { |
||
681 | |||
682 | // Subclasses utilize this method if needed. |
||
683 | } |
||
684 | |||
685 | /** |
||
686 | * Delete the value from the DB |
||
687 | * |
||
688 | * @param int|string|null $id Current Item ID. |
||
689 | * @param string|null $name Field name. |
||
690 | * @param array|null $options Field options. |
||
691 | * @param array|null $pod Pod information. |
||
692 | * |
||
693 | * @since 2.3 |
||
694 | */ |
||
695 | public function delete( $id = null, $name = null, $options = null, $pod = null ) { |
||
696 | |||
697 | // Subclasses utilize this method if needed. |
||
698 | } |
||
699 | |||
700 | /** |
||
701 | * Perform actions after deleting from the DB |
||
702 | * |
||
703 | * @param int|string|null $id Current Item ID. |
||
704 | * @param string|null $name Field name. |
||
705 | * @param array|null $options Field options. |
||
706 | * @param array|null $pod Pod information. |
||
707 | * |
||
708 | * @since 2.0 |
||
709 | */ |
||
710 | public function post_delete( $id = null, $name = null, $options = null, $pod = null ) { |
||
711 | |||
712 | // Subclasses utilize this method if needed. |
||
713 | } |
||
714 | |||
715 | /** |
||
716 | * Customize the Pods UI manage table column output |
||
717 | * |
||
718 | * @param int|string|null $id Current Item ID. |
||
719 | * @param mixed|null $value Current value. |
||
720 | * @param string|null $name Field name. |
||
721 | * @param array|null $options Field options. |
||
722 | * @param array|null $fields Pod fields. |
||
723 | * @param array|null $pod Pod information. |
||
724 | * |
||
725 | * @return string Value to be shown in the UI |
||
726 | * |
||
727 | * @since 2.0 |
||
728 | */ |
||
729 | public function ui( $id, $value, $name = null, $options = null, $fields = null, $pod = null ) { |
||
0 ignored issues
–
show
|
|||
730 | |||
731 | return $this->display( $value, $name, $options, $pod, $id ); |
||
732 | |||
733 | } |
||
734 | |||
735 | /** |
||
736 | * Strip HTML based on options. |
||
737 | * |
||
738 | * @param string|array $value Field value. |
||
739 | * @param array|null $options Field options. |
||
740 | * |
||
741 | * @return string |
||
742 | */ |
||
743 | public function strip_html( $value, $options = null ) { |
||
744 | |||
745 | if ( is_array( $value ) ) { |
||
746 | // @codingStandardsIgnoreLine |
||
747 | $value = @implode( ' ', $value ); |
||
748 | } |
||
749 | |||
750 | $value = trim( $value ); |
||
751 | |||
752 | if ( empty( $value ) ) { |
||
753 | return $value; |
||
754 | } |
||
755 | |||
756 | $options = (array) $options; |
||
757 | |||
758 | // Strip HTML |
||
759 | if ( 1 === (int) pods_v( static::$type . '_allow_html', $options, 0 ) ) { |
||
760 | $allowed_html_tags = ''; |
||
761 | |||
762 | if ( 0 < strlen( pods_v( static::$type . '_allowed_html_tags', $options ) ) ) { |
||
763 | $allowed_tags = pods_v( static::$type . '_allowed_html_tags', $options ); |
||
764 | $allowed_tags = trim( str_replace( array( '<', '>', ',' ), ' ', $allowed_tags ) ); |
||
765 | $allowed_tags = explode( ' ', $allowed_tags ); |
||
766 | $allowed_tags = array_unique( array_filter( $allowed_tags ) ); |
||
767 | |||
768 | if ( ! empty( $allowed_tags ) ) { |
||
769 | $allowed_html_tags = '<' . implode( '><', $allowed_tags ) . '>'; |
||
770 | } |
||
771 | } |
||
772 | |||
773 | if ( ! empty( $allowed_html_tags ) ) { |
||
774 | $value = strip_tags( $value, $allowed_html_tags ); |
||
775 | } |
||
776 | } else { |
||
777 | $value = strip_tags( $value ); |
||
778 | } |
||
779 | |||
780 | // Strip shortcodes |
||
781 | if ( 0 === (int) pods_v( static::$type . '_allow_shortcode', $options ) ) { |
||
782 | $value = strip_shortcodes( $value ); |
||
783 | } |
||
784 | |||
785 | return $value; |
||
786 | } |
||
787 | |||
788 | /** |
||
789 | * Placeholder function to allow var_export() use with classes. |
||
790 | * |
||
791 | * @param array $properties Properties to export. |
||
792 | * |
||
793 | * @return void |
||
794 | */ |
||
795 | public static function __set_state( $properties ) { |
||
796 | |||
797 | } |
||
798 | |||
799 | } |
||
800 |
This check marks private properties in classes that are never used. Those properties can be removed.