PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.2.2
Pods – Custom Content Types and Fields v3.2.2
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 / src / Pods / Admin / Config / Field.php
pods / src / Pods / Admin / Config Last commit date
Base.php 4 years ago Field.php 2 years ago Group.php 3 years ago Pod.php 2 years ago
Field.php
762 lines
1 <?php
2
3 namespace Pods\Admin\Config;
4
5 use Pods\WP\Meta;
6 use PodsForm;
7
8 /**
9 * Field configuration class.
10 *
11 * @since 2.8.0
12 */
13 class Field extends Base {
14
15 /**
16 * Get list of tabs for the Field object.
17 *
18 * @since 2.8.0
19 *
20 * @param \Pods\Whatsit\Pod $pod The pod object.
21 *
22 * @return array List of tabs for the Field object.
23 */
24 public function get_tabs( \Pods\Whatsit\Pod $pod ) {
25 $repeatable_field_types = PodsForm::repeatable_field_types();
26
27 $core_tabs = [
28 'basic' => __( 'Field Details', 'pods' ),
29 ];
30
31 $field_types = PodsForm::field_types();
32
33 foreach ( $field_types as $type => $field_type_data ) {
34 $core_tabs[ 'additional-field-' . $type ] = [
35 'name' => 'additional-field-' . $type,
36 /* translators: %s: Field type label. */
37 'label' => sprintf( _x( '%s Options', 'Field type options', 'pods' ), $field_type_data['label'] ),
38 'depends-on' => [
39 'type' => $type,
40 ],
41 ];
42 }
43
44 $core_tabs['repeatable'] = [
45 'name' => 'repeatable',
46 'label' => __( 'Repeatable', 'pods' ),
47 'depends-on' => [
48 'type' => $repeatable_field_types,
49 ],
50 ];
51
52 $core_tabs['advanced'] = __( 'Advanced', 'pods' );
53 $core_tabs['conditional-logic'] = __( 'Conditional Logic', 'pods' );
54
55 // Only include kitchen sink if dev mode on and not running Codecept tests.
56 if ( pods_developer() && ! function_exists( 'codecept_debug' ) ) {
57 $core_tabs['kitchen-sink'] = __( 'Kitchen Sink (temp)', 'pods' );
58 }
59
60 $pod_type = $pod['type'];
61 $pod_name = $pod['name'];
62
63 $tabs = $core_tabs;
64
65 /**
66 * Filter the Pod Field option tabs for a specific pod type and name.
67 *
68 * @since 2.8.0
69 *
70 * @param array $core_tabs Tabs to set.
71 * @param \Pods\Whatsit\Pod $pod Current Pods object.
72 */
73 $tabs = (array) apply_filters( "pods_admin_setup_edit_field_tabs_{$pod_type}_{$pod_name}", $tabs, $pod );
74
75 /**
76 * Filter the Pod Field option tabs for a specific pod type.
77 *
78 * @since 2.8.0
79 *
80 * @param array $tabs Tabs to set.
81 * @param \Pods\Whatsit\Pod $pod Current Pods object.
82 */
83 $tabs = (array) apply_filters( "pods_admin_setup_edit_field_tabs_{$pod_type}", $tabs, $pod );
84
85 /**
86 * Filter the Pod Field option tabs.
87 *
88 * @since 2.8.0
89 *
90 * @param array $tabs Tabs to set.
91 * @param \Pods\Whatsit\Pod $pod Current Pods object.
92 */
93 $tabs = (array) apply_filters( 'pods_admin_setup_edit_field_tabs', $tabs, $pod );
94
95 // Sort and then enforce the core tabs to be in front.
96 uksort( $tabs, 'strnatcmp' );
97
98 $tabs = array_merge( $core_tabs, $tabs );
99
100 return $tabs;
101 }
102
103 /**
104 * Get list of fields for the Field object.
105 *
106 * @since 2.8.0
107 *
108 * @param \Pods\Whatsit\Pod $pod The pod object.
109 * @param array $tabs The list of tabs for the pod object.
110 *
111 * @return array List of fields for the Field object.
112 */
113 public function get_fields( \Pods\Whatsit\Pod $pod, array $tabs ) {
114 $field_types = PodsForm::field_types();
115 $tableless_field_types = PodsForm::tableless_field_types();
116 $repeatable_field_types = PodsForm::repeatable_field_types();
117 $separator_excluded_field_types = PodsForm::separator_excluded_field_types();
118 $layout_non_input_field_types = PodsForm::layout_field_types() + PodsForm::non_input_field_types();
119
120 // Remove repeatable fields custom separator options.
121 $serial_repeatable_field_types = array_values( array_diff( $repeatable_field_types, $separator_excluded_field_types ) );
122
123 $options = [];
124
125 $options['basic'] = [
126 'label' => [
127 'name' => 'label',
128 'label' => __( 'Label', 'pods' ),
129 'type' => 'text',
130 'default' => '',
131 'help' => 'help',
132 'required' => true,
133 ],
134 'name' => [
135 'name' => 'name',
136 'label' => __( 'Name', 'pods' ),
137 'type' => 'slug',
138 'default' => '',
139 'attributes' => [
140 'maxlength' => 50,
141 ],
142 'help' => 'help',
143 'required' => true,
144 ],
145 'description' => [
146 'name' => 'description',
147 'label' => __( 'Description', 'pods' ),
148 'type' => 'text',
149 'default' => '',
150 'help' => 'help',
151 ],
152 'type' => [
153 'name' => 'type',
154 'label' => __( 'Field Type', 'pods' ),
155 'type' => 'pick',
156 'default' => 'text',
157 'required' => true,
158 'data' => [],
159 'pick_format_single' => 'dropdown',
160 'dependency' => true,
161 'help' => 'help',
162 ],
163 'pick_object' => [
164 'name' => 'pick_object',
165 'label' => __( 'Related Type', 'pods' ),
166 'type' => 'pick',
167 'default' => 'custom-simple',
168 'required' => true,
169 'data' => [],
170 'pick_format_single' => 'dropdown',
171 'pick_show_select_text' => 0,
172 'dependency' => true,
173 'depends-on' => [
174 'type' => 'pick',
175 ],
176 'help' => 'help',
177 ],
178 'pick_custom' => [
179 'name' => 'pick_custom',
180 'label' => __( 'Custom Defined Options', 'pods' ),
181 'type' => 'paragraph',
182 'default' => '',
183 'required' => true,
184 'depends-on' => [
185 'type' => 'pick',
186 'pick_object' => 'custom-simple',
187 ],
188 'help' => __( 'One option per line, use <em>value|Label</em> for separate values and labels', 'pods' ),
189 ],
190 'pick_table' => [
191 'name' => 'pick_table',
192 'label' => __( 'Related Table', 'pods' ),
193 'type' => 'pick',
194 'default' => '',
195 'data' => [],
196 'pick_format_single' => 'dropdown',
197 'pick_show_select_text' => 0,
198 'depends-on' => [
199 'type' => 'pick',
200 'pick_object' => 'table',
201 ],
202 'help' => 'help',
203 ],
204 'sister_id' => [
205 'name' => 'sister_id',
206 'label' => __( 'Bi-directional Field', 'pods' ),
207 'type' => 'pick',
208 'default' => '',
209 'data' => [],
210 'pick_format_single' => 'dropdown',
211 'depends-on' => [
212 'type' => 'pick',
213 'pick_object' => PodsForm::field_method( 'pick', 'bidirectional_objects' ),
214 ],
215 'help' => __( 'Bi-directional fields will update their related field for any item you select. This feature is only available for two relationships between two Pods.<br /><br />For example, when you update a Parent pod item to relate to a Child item, when you go to edit that Child item you will see the Parent pod item selected.', 'pods' ),
216 ],
217 'required' => [
218 'name' => 'required',
219 'label' => __( 'Required', 'pods' ),
220 'type' => 'boolean',
221 'default' => 0,
222 'boolean_yes_label' => '',
223 'excludes-on' => [
224 'type' => $layout_non_input_field_types,
225 ],
226 'help' => __( 'This will require a non-empty value to be entered.', 'pods' ),
227 ],
228 'required_help_boolean' => [
229 'name' => 'required_help_boolean',
230 'label' => '',
231 'type' => 'html',
232 'default' => 0,
233 'html_content' => '<p><em>' . esc_html__( 'Please note: When Yes/No fields are required, the field must be set to Yes (checked) to be able to submit the form.', 'pods' ) . '</em></p>',
234 'dependency' => true,
235 'depends-on' => [
236 'required' => true,
237 'type' => 'boolean',
238 ],
239 ],
240 ];
241
242 $options['repeatable'] = [
243 'repeatable' => [
244 'name' => 'repeatable',
245 'label' => __( 'Repeatable', 'pods' ),
246 'default' => 0,
247 'type' => 'boolean',
248 'help' => __( 'Making a field repeatable will add controls next to the field which allows users to Add / Remove / Reorder additional values.', 'pods' ),
249 'boolean_yes_label' => __( 'Allow multiple values', 'pods' ),
250 'dependency' => true,
251 'depends-on' => [
252 'type' => $repeatable_field_types,
253 ],
254 ],
255 'repeatable_add_new_label' => [
256 'name' => 'repeatable_add_new_label',
257 'label' => __( 'Repeatable - Add New Label', 'pods' ),
258 'placeholder' => __( 'Add New', 'pods' ),
259 'default' => '',
260 'type' => 'text',
261 'depends-on' => [
262 'type' => $repeatable_field_types,
263 'repeatable' => true,
264 ],
265 ],
266 'repeatable_format' => [
267 'label' => __( 'Repeatable - Display Format', 'pods' ),
268 'help' => __( 'Used as format for front-end display', 'pods' ),
269 'depends-on' => [
270 'type' => $serial_repeatable_field_types,
271 'repeatable' => true,
272 ],
273 'default' => 'default',
274 'required' => true,
275 'type' => 'pick',
276 'data' => [
277 'default' => __( 'Item 1, Item 2, and Item 3', 'pods' ),
278 'non_serial' => __( 'Item 1, Item 2 and Item 3', 'pods' ),
279 'br' => __( 'Line breaks', 'pods' ),
280 'ul' => __( 'Unordered list', 'pods' ),
281 'ol' => __( 'Ordered list', 'pods' ),
282 'custom' => __( 'Custom separator (without "and")', 'pods' ),
283 ],
284 'pick_format_single' => 'dropdown',
285 'pick_show_select_text' => 0,
286 'dependency' => true,
287 ],
288 'repeatable_format_separator' => [
289 'label' => __( 'Repeatable - Display Format Separator', 'pods' ),
290 'help' => __( 'Used as separator for front-end display. Be sure to include exactly the spaces that you need since the separator is used literally between values. For example, you would use ", " to have values like "One, Two, Three". You would also use " | " to have values like "One | Two | Three".', 'pods' ),
291 'description' => __( 'This option will default to ", "', 'pods' ),
292 'depends-on' => [
293 'type' => $serial_repeatable_field_types,
294 'repeatable' => true,
295 'repeatable_format' => 'custom',
296 ],
297 'placeholder' => '',
298 'type' => 'text',
299 ],
300 ];
301
302 $options['advanced'] = [
303 'visual' => [
304 'name' => 'visual',
305 'label' => __( 'Visual', 'pods' ),
306 'type' => 'heading',
307 ],
308 'class' => [
309 'name' => 'class',
310 'label' => __( 'Additional CSS Classes', 'pods' ),
311 'help' => __( 'You can provide additional CSS classes separated by spaces to be output for the field markup.', 'pods' ),
312 'type' => 'text',
313 'default' => '',
314 ],
315 'values' => [
316 'name' => 'values',
317 'label' => __( 'Values', 'pods' ),
318 'type' => 'heading',
319 'excludes-on' => [
320 'type' => $layout_non_input_field_types,
321 ],
322 ],
323 'default_value' => [
324 'name' => 'default_value',
325 'label' => __( 'Default Value', 'pods' ),
326 'help' => __( 'This is the default value used when the Add New form is used. For multiple-value fields, you can separate multiple default values with commas.', 'pods' ),
327 'description' => __( 'This value is only used on Add New forms', 'pods' ),
328 'type' => 'text',
329 'default' => '',
330 'text_max_length' => - 1,
331 'excludes-on' => [
332 'type' => $layout_non_input_field_types,
333 ],
334 ],
335 'default_value_parameter' => [
336 'name' => 'default_value_parameter',
337 'label' => __( 'Set Default Value via Parameter', 'pods' ),
338 'help' => __( 'You can automatically populate the value of this field from the URL parameter "your_field" such as ?your_field=1234', 'pods' ),
339 'type' => 'text',
340 'default' => '',
341 'excludes-on' => [
342 'type' => $layout_non_input_field_types,
343 ],
344 ],
345 'default_evaluate_tags' => [
346 'name' => 'default_evaluate_tags',
347 'label' => __( 'Evaluate tags in default values', 'pods' ),
348 'help' => __( 'Whether to evaluate tags like {@user.ID} in your default value. This does NOT evaluate tags passed dynamically via Parameter.', 'pods' ),
349 'type' => 'boolean',
350 'default' => false,
351 'boolean_yes_label' => __( 'Evaluate tags like {@user.ID} in the default value', 'pods' ),
352 'excludes-on' => [
353 'type' => $layout_non_input_field_types,
354 ],
355 ],
356 'default_empty_fields' => [
357 'name' => 'default_empty_fields',
358 'label' => __( 'Default Empty Fields in Forms', 'pods' ),
359 'help' => __( 'On forms where the field value is empty you can enable Default Empty Fields to override the value with your chosen default value.', 'pods' ),
360 'type' => 'boolean',
361 'default' => false,
362 'boolean_yes_label' => __( 'Use the default value when this field is empty', 'pods' ),
363 'excludes-on' => [
364 'type' => $layout_non_input_field_types,
365 ],
366 ],
367 'visibility' => [
368 'name' => 'visibility',
369 'label' => __( 'Visibility', 'pods' ),
370 'type' => 'heading',
371 ],
372 'restrict_access' => [
373 'type' => 'boolean_group',
374 'name' => 'restrict_access',
375 'label' => __( 'Restrict Access', 'pods' ),
376 'boolean_group' => [
377 'logged_in_only' => [
378 'name' => 'logged_in_only',
379 'label' => __( 'Restrict access to Logged In Users', 'pods' ),
380 'default' => 0,
381 'type' => 'boolean',
382 'dependency' => true,
383 'help' => __( 'This field will only be able to be edited by logged in users. This is not required to be on for the other Restrict Access options to work.', 'pods' ),
384 ],
385 'admin_only' => [
386 'name' => 'admin_only',
387 'label' => __( 'Restrict access to Admins', 'pods' ),
388 'default' => 0,
389 'type' => 'boolean',
390 'dependency' => true,
391 'help' => __( 'This field will only be able to be edited by users with the ability to manage_options or delete_users, or super admins of a WordPress Multisite network', 'pods' ),
392 ],
393 'restrict_role' => [
394 'name' => 'restrict_role',
395 'label' => __( 'Restrict access by Role', 'pods' ),
396 'default' => 0,
397 'type' => 'boolean',
398 'dependency' => true,
399 ],
400 'restrict_capability' => [
401 'name' => 'restrict_capability',
402 'label' => __( 'Restrict access by Capability', 'pods' ),
403 'default' => 0,
404 'type' => 'boolean',
405 'dependency' => true,
406 ],
407 'hidden' => [
408 'name' => 'hidden',
409 'label' => __( 'Hide field from UI', 'pods' ),
410 'default' => 0,
411 'type' => 'boolean',
412 'help' => __( 'This option is overridden by access restrictions. If the user does not have access to edit this field, it will be hidden. If no access restrictions are set, this field will always be hidden.', 'pods' ),
413 ],
414 'read_only' => [
415 'name' => 'read_only',
416 'label' => __( 'Make field "Read Only" in UI', 'pods' ),
417 'default' => 0,
418 'type' => 'boolean',
419 'help' => __( 'This option is overridden by access restrictions. If the user does not have access to edit this field, it will be read only. If no access restrictions are set, this field will always be read only. This does not prevent the field from being changed manually through HTML DOM manipulation, this just shows the field as a read-only text field that cannot be normally changed without developer intervention.', 'pods' ),
420 'depends-on' => [
421 'type' => [
422 'boolean',
423 'color',
424 'currency',
425 'date',
426 'datetime',
427 'email',
428 'number',
429 'paragraph',
430 'password',
431 'phone',
432 'slug',
433 'text',
434 'time',
435 'website',
436 ],
437 ],
438 ],
439 ],
440 ],
441 'roles_allowed' => [
442 'name' => 'roles_allowed',
443 'label' => __( 'Role(s) Allowed', 'pods' ),
444 'help' => __( 'If none are selected, this option will be ignored.', 'pods' ),
445 'type' => 'pick',
446 'pick_object' => 'role',
447 'pick_format_type' => 'multi',
448 'default' => 'administrator',
449 'depends-on' => [
450 'restrict_role' => true,
451 ],
452 ],
453 'capability_allowed' => [
454 'name' => 'capability_allowed',
455 'label' => __( 'Capability Allowed', 'pods' ),
456 'help' => __( 'Comma-separated list of capabilities, for example add_podname_item, please see the Roles and Capabilities component for the complete list and a way to add your own.', 'pods' ),
457 'type' => 'text',
458 'default' => '',
459 'depends-on' => [
460 'restrict_capability' => true,
461 ],
462 ],
463 ];
464
465 if ( 'post_type' === $pod->get_type() && 'meta' === $pod->get_storage() ) {
466 $options['advanced']['other_options'] = [
467 'name' => 'other_options',
468 'label' => __( 'Other Options', 'pods' ),
469 'type' => 'heading',
470 'depends-on' => [
471 'type' => PodsForm::revisionable_field_types(),
472 ],
473 ];
474
475 $options['advanced']['revisions_revision_field'] = [
476 'name' => 'revisions_revision_field',
477 'label' => __( 'Track field value changes in revisions', 'pods' ),
478 'help' => __( 'Revisions allow comparing and restoring previous saved changes. This setting requires revisions to be enabled on the pod. Revisions for meta as of WordPress 6.5 does not have additional UI to show the custom field value differences in the Revisions UI but upon restoring a revision those covered meta field values will be restored too while leaving non-covered meta field values in place.', 'pods' ),
479 'type' => 'boolean',
480 'default' => false,
481 'boolean_yes_label' => __( 'Track field value changes for this field.', 'pods' ),
482 'depends-on' => [
483 'type' => PodsForm::revisionable_field_types(),
484 ],
485 ];
486 }
487
488 $options['conditional-logic'] = [
489 'enable_conditional_logic' => [
490 'name' => 'enable_conditional_logic',
491 'label' => __( 'Enable Conditional Logic', 'pods' ),
492 'help' => __( 'Conditional logic can automatically show or hide this field depending on the value of other fields.', 'pods' ),
493 'type' => 'boolean',
494 'default' => 0,
495 ],
496 'conditional_logic' => [
497 'name' => 'conditional_logic',
498 'label' => __( 'Conditions', 'pods' ),
499 'help' => __( 'help', 'pods' ),
500 'type' => 'conditional-logic',
501 'depends-on' => [
502 'enable_conditional_logic' => true,
503 ],
504 ],
505 'conditional_logic_help' => [
506 'name' => 'conditional_logic_help',
507 'label' => '',
508 'help' => __( 'help', 'pods' ),
509 'type' => 'html',
510 'html_content' => wpautop(
511 sprintf(
512 '
513 %1$s
514
515 <ul>
516 <li>%2$s</li>
517 <li>%3$s</li>
518 </ul>
519
520 <a href="https://docs.pods.io/fields/conditional-logic-for-fields/">%4$s &raquo;</a>
521 ',
522 __( 'Each field type has their own conditional options available to them.', 'pods' ),
523 __( 'For pattern matching on text-based fields: Use Regular Expressions and do not use the wrapping character "/" like "/[a-z]/", you will need to use "[a-z]"', 'pods' ),
524 __( 'For relationships: Use the ID for any relationship object or the text value for any custom defined / simple relationship', 'pods' ),
525 __( 'Learn more about conditional logic for fields', 'pods' )
526 )
527 ),
528 'depends-on' => [
529 'enable_conditional_logic' => true,
530 ],
531 ],
532 ];
533
534 $pick_tables = pods_transient_get( 'pods_tables' );
535
536 if ( empty( $pick_tables ) ) {
537 $pick_tables = [
538 '' => __( '-- Select Table --', 'pods' ),
539 ];
540
541 global $wpdb;
542
543 $tables = $wpdb->get_results( 'SHOW TABLES', ARRAY_N );
544
545 if ( ! empty( $tables ) ) {
546 foreach ( $tables as $table ) {
547 $pick_tables[ $table[0] ] = $table[0];
548 }
549 }
550
551 pods_transient_set( 'pods_tables', $pick_tables, WEEK_IN_SECONDS );
552 }
553
554 $field_settings = [
555 'field_types_select' => [],
556 'pick_object' => PodsForm::field_method( 'pick', 'related_objects', true ),
557 'pick_table' => $pick_tables,
558 'sister_id' => [
559 '' => __( 'No Related Fields Found', 'pods' ),
560 ],
561 ];
562
563 $pod_name = $pod['name'];
564 $pod_type = $pod['type'];
565
566 foreach ( $field_types as $type => $field_type_data ) {
567 /**
568 * @var $field_type PodsField
569 */
570 $field_type_object = PodsForm::field_loader( $type, $field_type_data['file'] );
571
572 $field_type_vars = get_class_vars( get_class( $field_type_object ) );
573
574 if ( ! isset( $field_type_vars['pod_types'] ) ) {
575 $field_type_vars['pod_types'] = true;
576 }
577
578 $options[ 'additional-field-' . $type ] = [];
579
580 // Only show supported field types
581 if ( true !== $field_type_vars['pod_types'] ) {
582 if ( empty( $field_type_vars['pod_types'] ) ) {
583 continue;
584 } elseif ( is_array( $field_type_vars['pod_types'] ) && ! in_array( $pod_type, $field_type_vars['pod_types'], true ) ) {
585 continue;
586 } elseif ( ! is_array( $field_type_vars['pod_types'] ) && $pod_type !== $field_type_vars['pod_types'] ) {
587 continue;
588 }
589 }
590
591 if ( ! empty( PodsForm::$field_group ) ) {
592 if ( ! isset( $field_settings['field_types_select'][ PodsForm::$field_group ] ) ) {
593 $field_settings['field_types_select'][ PodsForm::$field_group ] = [];
594 }
595
596 $field_settings['field_types_select'][ PodsForm::$field_group ][ $type ] = $field_type_data['label'];
597 } else {
598 if ( ! isset( $field_settings['field_types_select'][ __( 'Other', 'pods' ) ] ) ) {
599 $field_settings['field_types_select'][ __( 'Other', 'pods' ) ] = [];
600 }
601
602 $field_settings['field_types_select'][ __( 'Other', 'pods' ) ][ $type ] = $field_type_data['label'];
603 }
604
605 $type_options = PodsForm::ui_options( $type );
606
607 $dev_mode = pods_developer();
608
609 if ( ! $dev_mode ) {
610 foreach ( $type_options as $type_option => $option_data ) {
611 if ( ! empty( $option_data['developer_mode'] ) ) {
612 unset( $type_options[ $type_option ] );
613 }
614 }
615 }
616
617 /**
618 * Modify Additional Field Options tab for a specific field type.
619 *
620 * @since 2.7.0
621 *
622 * @param array $type_options Additional field type options.
623 * @param string $type Field type.
624 * @param array $options Tabs, indexed by label.
625 * @param null|\Pods\Whatsit\Pod $pod Pods object for the Pod this UI is for.
626 */
627 $type_options = apply_filters( "pods_admin_setup_edit_{$type}_additional_field_options", $type_options, $type, $options, $pod );
628
629 /**
630 * Modify Additional Field Options tab.
631 *
632 * @since 2.7.0
633 *
634 * @param array $type_options Additional field type options.
635 * @param string $type Field type.
636 * @param array $options Tabs, indexed by label.
637 * @param null|\Pods\Whatsit\Pod $pod Pods object for the Pod this UI is for.
638 */
639 $type_options = apply_filters( 'pods_admin_setup_edit_additional_field_options', $type_options, $type, $options, $pod );
640
641 $options[ 'additional-field-' . $type ] = $type_options;
642 }//end foreach
643
644 /**
645 * Allow filtering the field settings by pod name.
646 *
647 * @param array $field_settings List of field settings to use.
648 * @param null|\Pods\Whatsit\Pod $pod Pods object for the Pod this UI is for.
649 * @param array $tabs List of registered tabs
650 */
651 $field_settings = apply_filters( "pods_field_settings_{$pod_name}", $field_settings, $pod );
652
653 /**
654 * Allow filtering the field settings by pod name.
655 *
656 * @param array $field_settings List of field settings to use.
657 * @param null|\Pods\Whatsit\Pod $pod Pods object for the Pod this UI is for.
658 * @param array $tabs List of registered tabs
659 */
660 $field_settings = apply_filters( 'pods_field_settings', $field_settings, $pod, $tabs );
661
662 $options['basic']['type']['data'] = $field_settings['field_types_select'];
663 $options['basic']['pick_object']['data'] = $field_settings['pick_object'];
664 $options['basic']['pick_table']['data'] = $field_settings['pick_table'];
665
666 // @todo Look into supporting these in the future.
667 /*
668 'search' => [
669 'label' => __( 'Include in searches', 'pods' ),
670 'help' => __( 'help', 'pods' ),
671 'default' => 1,
672 'type' => 'boolean',
673 ],
674 'regex_validation' => [
675 'label' => __( 'RegEx Validation', 'pods' ),
676 'help' => __( 'help', 'pods' ),
677 'type' => 'text',
678 'default' => '',
679 ],
680 'message_regex' => [
681 'label' => __( 'Message if field does not pass RegEx', 'pods' ),
682 'help' => __( 'help', 'pods' ),
683 'type' => 'text',
684 'default' => '',
685 ],
686 'message_required' => [
687 'label' => __( 'Message if field is blank', 'pods' ),
688 'help' => __( 'help', 'pods' ),
689 'type' => 'text',
690 'default' => '',
691 'depends-on' => [ 'required' => true ],
692 ],
693 'message_unique' => [
694 'label' => __( 'Message if field is not unique', 'pods' ),
695 'help' => __( 'help', 'pods' ),
696 'type' => 'text',
697 'default' => '',
698 'depends-on' => [ 'unique' => true ],
699 ],
700 */
701
702 if ( 'table' === $pod['storage'] || 'pod' === $pod['type'] ) {
703 unset( $options['basic']['repeatable'] );
704
705 $options['basic']['unique'] = [
706 'name' => 'unique',
707 'label' => __( 'Unique', 'pods' ),
708 'type' => 'boolean',
709 'default' => 0,
710 'boolean_yes_label' => '',
711 'help' => __( 'This will require that the field value entered is unique and has not been saved before.', 'pods' ),
712 'excludes-on' => [
713 'type' => $tableless_field_types,
714 ],
715 ];
716 }
717
718 // Only include kitchen sink if dev mode on and not running Codecept tests.
719 if ( pods_developer() && ! function_exists( 'codecept_debug' ) ) {
720 $options['kitchen-sink'] = json_decode( file_get_contents( PODS_DIR . 'tests/codeception/_data/kitchen-sink-config.json' ), true );
721 }
722
723 $pod_type = $pod['type'];
724 $pod_name = $pod['name'];
725
726 /**
727 * Add admin fields to the Pod Fields editor for a specific Pod.
728 *
729 * @since 2.8.0
730 *
731 * @param array $options The Options fields.
732 * @param \Pods\Whatsit\Pod $pod Current Pods object.
733 * @param array $tabs List of registered tabs.
734 */
735 $options = apply_filters( "pods_admin_setup_edit_field_options_{$pod_type}_{$pod_name}", $options, $pod, $tabs );
736
737 /**
738 * Add admin fields to the Pod Fields editor for any Pod of a specific content type.
739 *
740 * @since 2.8.0
741 *
742 * @param array $options The Options fields.
743 * @param \Pods\Whatsit\Pod $pod Current Pods object.
744 * @param array $tabs List of registered tabs.
745 */
746 $options = apply_filters( "pods_admin_setup_edit_field_options_{$pod_type}", $options, $pod, $tabs );
747
748 /**
749 * Add admin fields to the Pod Fields editor for all Pods.
750 *
751 * @since 2.8.0
752 *
753 * @param array $options The Options fields.
754 * @param \Pods\Whatsit\Pod $pod Current Pods object.
755 * @param array $tabs List of registered tabs.
756 */
757 $options = apply_filters( 'pods_admin_setup_edit_field_options', $options, $pod, $tabs );
758
759 return $options;
760 }
761 }
762