PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 2.8.23.4
Pods – Custom Content Types and Fields v2.8.23.4
2.7.31.4 2.8.23.5 2.9.19.5 3.0.10.5 3.1.4.3 3.2.8.4 3.3.9.2 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 / src / Pods / Admin / Config / Pod.php
pods / src / Pods / Admin / Config Last commit date
Base.php 2 weeks ago Field.php 2 weeks ago Group.php 2 weeks ago Pod.php 2 weeks ago
Pod.php
1588 lines
1 <?php
2
3 namespace Pods\Admin\Config;
4
5 use PodsForm;
6
7 /**
8 * Pod configuration class.
9 *
10 * @since 2.8.0
11 */
12 class Pod extends Base {
13
14 /**
15 * Get list of tabs for the Pod object.
16 *
17 * @since 2.8.0
18 *
19 * @param \Pods\Whatsit\Pod $pod The pod object.
20 *
21 * @return array List of tabs for the Pod object.
22 */
23 public function get_tabs( \Pods\Whatsit\Pod $pod ) {
24 $labels = false;
25 $admin_ui = false;
26 $connections = false;
27 $advanced = false;
28
29 $pod_type = pods_v( 'type', $pod );
30 $is_extended = $pod->is_extended();
31
32 if ( 'post_type' === $pod_type && ! $is_extended ) {
33 $labels = true;
34 $admin_ui = true;
35 $connections = true;
36 $advanced = true;
37 } elseif ( 'taxonomy' === $pod_type && ! $is_extended ) {
38 $labels = true;
39 $admin_ui = true;
40 $connections = true;
41 $advanced = true;
42 } elseif ( 'pod' === $pod_type ) {
43 $labels = true;
44 $admin_ui = true;
45 $advanced = true;
46 } elseif ( 'settings' === $pod_type ) {
47 $labels = true;
48 $admin_ui = true;
49 }
50
51 $core_tabs = [];
52
53 if ( $labels ) {
54 $core_tabs['labels'] = __( 'Labels', 'pods' );
55 }
56
57 if ( $admin_ui ) {
58 $core_tabs['admin-ui'] = __( 'Admin UI', 'pods' );
59 }
60
61 if ( $connections ) {
62 $core_tabs['connections'] = __( 'Connections', 'pods' );
63 }
64
65 if ( $advanced ) {
66 $core_tabs['advanced'] = __( 'Advanced Options', 'pods' );
67 }
68
69 // Only include kitchen sink if dev mode on and not running Codecept tests.
70 if ( pods_developer() && ! function_exists( 'codecept_debug' ) ) {
71 $core_tabs['kitchen-sink'] = __( 'Kitchen Sink (temp)', 'pods' );
72 }
73
74 $args = compact( [ 'labels', 'admin_ui', 'connections', 'advanced' ] );
75
76 $pod_name = $pod['name'];
77
78 $tabs = $core_tabs;
79
80 /**
81 * Filter the Pod option tabs for a specific pod type and name.
82 *
83 * @param array $core_tabs Tabs to set.
84 * @param \Pods\Whatsit\Pod $pod Current Pods object.
85 * @param array $args Additional args.
86 */
87 $tabs = (array) apply_filters( "pods_admin_setup_edit_tabs_{$pod_type}_{$pod_name}", $tabs, $pod, $args );
88
89 /**
90 * Filter the Pod option tabs for a specific pod type.
91 *
92 * @param array $tabs Tabs to set.
93 * @param \Pods\Whatsit\Pod $pod Current Pods object.
94 * @param array $args Additional args.
95 */
96 $tabs = (array) apply_filters( "pods_admin_setup_edit_tabs_{$pod_type}", $tabs, $pod, $args );
97
98 /**
99 * Filter the Pod option tabs.
100 *
101 * @param array $tabs Tabs to set.
102 * @param \Pods\Whatsit\Pod $pod Current Pods object.
103 * @param array $args Additional args.
104 */
105 $tabs = (array) apply_filters( 'pods_admin_setup_edit_tabs', $tabs, $pod, $args );
106
107 // Sort and then enforce the core tabs to be in front.
108 uksort( $tabs, 'strnatcmp' );
109
110 $tabs = array_merge( $core_tabs, $tabs );
111
112 return $tabs;
113 }
114
115 /**
116 * Get list of fields for the Pod object.
117 *
118 * @since 2.8.0
119 *
120 * @param \Pods\Whatsit\Pod $pod The pod object.
121 * @param array $tabs The list of tabs for the Pod object.
122 *
123 * @return array List of fields for the Pod object.
124 */
125 public function get_fields( \Pods\Whatsit\Pod $pod, array $tabs ) {
126 $pod_type = pods_v( 'type', $pod );
127 $pod_name = pods_v( 'name', $pod );
128 $is_extended = $pod->is_extended();
129
130 $options = [];
131
132 $tableless_field_types = PodsForm::tableless_field_types();
133
134 if ( 'settings' !== $pod_type && ! $is_extended ) {
135 $labels = [
136 'label' => [
137 'label' => __( 'Label', 'pods' ),
138 'help' => __( 'help', 'pods' ),
139 'type' => 'text',
140 'default' => pods_v( 'label', $pod, ucwords( str_replace( '_', ' ', pods_v( 'name', $pod ) ) ) ),
141 'text_max_length' => 30,
142 ],
143 'label_singular' => [
144 'label' => __( 'Singular Label', 'pods' ),
145 'help' => __( 'help', 'pods' ),
146 'type' => 'text',
147 'default' => pods_v( 'label_singular', $pod, pods_v( 'label', $pod, ucwords( str_replace( '_', ' ', pods_v( 'name', $pod ) ) ) ) ),
148 'text_max_length' => 30,
149 ],
150 'placeholder_enter_title_here' => [
151 'label' => __( 'New post title placeholder text', 'pods' ),
152 'help' => __( 'help', 'pods' ),
153 'type' => 'text',
154 'default' => '',
155 'placeholder' => __( 'Add title' ),
156 'object_type' => [ 'post_type' ],
157 ],
158 'label_add_new' => [
159 'label' => __( 'Add New', 'pods' ),
160 'help' => __( 'help', 'pods' ),
161 'type' => 'text',
162 'default' => '',
163 'object_type' => [ 'post_type', 'pod' ],
164 ],
165 'label_add_new_item' => [
166 'label' => __( 'Add new %s', 'pods' ),
167 'label_param' => 'label_singular',
168 'label_param_default' => __( 'Item', 'pods' ),
169 'help' => __( 'help', 'pods' ),
170 'type' => 'text',
171 'default' => '',
172 ],
173 'label_new_item' => [
174 'label' => __( 'New %s', 'pods' ),
175 'label_param' => 'label_singular',
176 'label_param_default' => __( 'Item', 'pods' ),
177 'help' => __( 'help', 'pods' ),
178 'type' => 'text',
179 'default' => '',
180 'object_type' => [ 'post_type', 'pod' ],
181 ],
182 'label_new_item_name' => [
183 'label' => __( 'New %s Name', 'pods' ),
184 'label_param' => 'label_singular',
185 'label_param_default' => __( 'Item', 'pods' ),
186 'help' => __( 'help', 'pods' ),
187 'type' => 'text',
188 'default' => '',
189 'object_type' => [ 'taxonomy' ],
190 ],
191 'label_edit' => [
192 'label' => __( 'Edit', 'pods' ),
193 'help' => __( 'help', 'pods' ),
194 'type' => 'text',
195 'default' => '',
196 'object_type' => [ 'pod' ],
197 ],
198 'label_edit_item' => [
199 'label' => __( 'Edit %s', 'pods' ),
200 'label_param' => 'label_singular',
201 'label_param_default' => __( 'Item', 'pods' ),
202 'help' => __( 'help', 'pods' ),
203 'type' => 'text',
204 'default' => '',
205 ],
206 'label_update_item' => [
207 'label' => __( 'Update %s', 'pods' ),
208 'label_param' => 'label_singular',
209 'label_param_default' => __( 'Item', 'pods' ),
210 'help' => __( 'help', 'pods' ),
211 'type' => 'text',
212 'default' => '',
213 'object_type' => [ 'taxonomy', 'pod' ],
214 ],
215 'label_duplicate' => [
216 'label' => __( 'Duplicate', 'pods' ),
217 'help' => __( 'help', 'pods' ),
218 'type' => 'text',
219 'default' => '',
220 'object_type' => [ 'pod' ],
221 ],
222 'label_duplicate_item' => [
223 'label' => __( 'Duplicate %s', 'pods' ),
224 'label_param' => 'label_singular',
225 'label_param_default' => __( 'Item', 'pods' ),
226 'help' => __( 'help', 'pods' ),
227 'type' => 'text',
228 'default' => '',
229 'object_type' => [ 'pod' ],
230 ],
231 'label_delete_item' => [
232 'label' => __( 'Delete %s', 'pods' ),
233 'label_param' => 'label_singular',
234 'label_param_default' => __( 'Item', 'pods' ),
235 'help' => __( 'help', 'pods' ),
236 'type' => 'text',
237 'default' => '',
238 'object_type' => [ 'pod' ],
239 ],
240 'label_view' => [
241 'label' => __( 'View', 'pods' ),
242 'help' => __( 'help', 'pods' ),
243 'type' => 'text',
244 'default' => '',
245 'object_type' => [ 'pod' ],
246 ],
247 'label_view_item' => [
248 'label' => __( 'View %s', 'pods' ),
249 'label_param' => 'label_singular',
250 'label_param_default' => __( 'Item', 'pods' ),
251 'help' => __( 'help', 'pods' ),
252 'type' => 'text',
253 'default' => '',
254 ],
255 'label_view_items' => [
256 'label' => __( 'View %s', 'pods' ),
257 'label_param' => 'label',
258 'label_param_default' => __( 'Items', 'pods' ),
259 'help' => __( 'help', 'pods' ),
260 'type' => 'text',
261 'default' => '',
262 'object_type' => [ 'post_type' ],
263 ],
264 'label_back_to_manage' => [
265 'label' => __( 'Back to Manage', 'pods' ),
266 'help' => __( 'help', 'pods' ),
267 'type' => 'text',
268 'default' => '',
269 'object_type' => [ 'pod' ],
270 ],
271 'label_manage' => [
272 'label' => __( 'Manage', 'pods' ),
273 'help' => __( 'help', 'pods' ),
274 'type' => 'text',
275 'default' => '',
276 'object_type' => [ 'pod' ],
277 ],
278 'label_manage_items' => [
279 'label' => __( 'Manage %s', 'pods' ),
280 'label_param' => 'label',
281 'label_param_default' => __( 'Items', 'pods' ),
282 'help' => __( 'help', 'pods' ),
283 'type' => 'text',
284 'default' => '',
285 'object_type' => [ 'pod' ],
286 ],
287 'label_reorder' => [
288 'label' => __( 'Reorder', 'pods' ),
289 'help' => __( 'help', 'pods' ),
290 'type' => 'text',
291 'default' => '',
292 'object_type' => [ 'pod' ],
293 ],
294 'label_reorder_items' => [
295 'label' => __( 'Reorder %s', 'pods' ),
296 'label_param' => 'label',
297 'label_param_default' => __( 'Items', 'pods' ),
298 'help' => __( 'help', 'pods' ),
299 'type' => 'text',
300 'default' => '',
301 'object_type' => [ 'pod' ],
302 ],
303 'label_all_items' => [
304 'label' => __( 'All %s', 'pods' ),
305 'label_param' => 'label',
306 'label_param_default' => __( 'Items', 'pods' ),
307 'help' => __( 'help', 'pods' ),
308 'type' => 'text',
309 'default' => '',
310 ],
311 'label_search' => [
312 'label' => __( 'Search', 'pods' ),
313 'help' => __( 'help', 'pods' ),
314 'type' => 'text',
315 'default' => '',
316 'object_type' => [ 'pod' ],
317 ],
318 'label_search_items' => [
319 'label' => __( 'Search %s', 'pods' ),
320 'label_param' => 'label',
321 'label_param_default' => __( 'items', 'pods' ),
322 'help' => __( 'help', 'pods' ),
323 'type' => 'text',
324 'default' => '',
325 ],
326 'label_popular_items' => [
327 'label' => __( 'Popular %s', 'pods' ),
328 'label_param' => 'label',
329 'label_param_default' => __( 'Items', 'pods' ),
330 'help' => __( 'help', 'pods' ),
331 'type' => 'text',
332 'default' => '',
333 'object_type' => [ 'taxonomy' ],
334 ],
335 'label_parent' => [
336 'label' => __( 'Parent %s', 'pods' ),
337 'label_param' => 'label_singular',
338 'label_param_default' => __( 'Item', 'pods' ),
339 'help' => __( 'help', 'pods' ),
340 'type' => 'text',
341 'default' => '',
342 'object_type' => [ 'post_type', 'pod' ],
343 ],
344 'label_parent_item' => [
345 'label' => __( 'Parent %s', 'pods' ),
346 'label_param' => 'label_singular',
347 'label_param_default' => __( 'Item', 'pods' ),
348 'help' => __( 'help', 'pods' ),
349 'type' => 'text',
350 'default' => '',
351 'object_type' => [ 'taxonomy' ],
352 ],
353 'label_parent_item_colon' => [
354 'label' => __( 'Parent %s:', 'pods' ),
355 'label_param' => 'label_singular',
356 'label_param_default' => __( 'Item', 'pods' ),
357 'help' => __( 'help', 'pods' ),
358 'type' => 'text',
359 'default' => '',
360 ],
361 'label_not_found' => [
362 'label' => __( 'Not Found', 'pods' ),
363 'help' => __( 'help', 'pods' ),
364 'type' => 'text',
365 'default' => '',
366 ],
367 'label_no_items_found' => [
368 'label' => __( 'No %s Found', 'pods' ),
369 'label_param' => 'label_singular',
370 'label_param_default' => __( 'Item', 'pods' ),
371 'help' => __( 'help', 'pods' ),
372 'type' => 'text',
373 'default' => '',
374 'object_type' => [ 'pod' ],
375 ],
376 'label_not_found_in_trash' => [
377 'label' => __( 'Not Found in Trash', 'pods' ),
378 'help' => __( 'help', 'pods' ),
379 'type' => 'text',
380 'default' => '',
381 'object_type' => [ 'post_type', 'pod' ],
382 ],
383 'label_archives' => [
384 'label' => __( '%s Archives', 'pods' ),
385 'label_param' => 'label_singular',
386 'label_param_default' => __( 'Item', 'pods' ),
387 'help' => __( 'help', 'pods' ),
388 'type' => 'text',
389 'default' => '',
390 'object_type' => [ 'post_type' ],
391 ],
392 'label_attributes' => [
393 'label' => __( '%s Attributes', 'pods' ),
394 'label_param' => 'label_singular',
395 'label_param_default' => __( 'Item', 'pods' ),
396 'help' => __( 'help', 'pods' ),
397 'type' => 'text',
398 'default' => '',
399 'object_type' => [ 'post_type' ],
400 ],
401 'label_insert_into_item' => [
402 'label' => __( 'Insert into %s', 'pods' ),
403 'label_param' => 'label_singular',
404 'label_param_default' => __( 'Item', 'pods' ),
405 'help' => __( 'help', 'pods' ),
406 'type' => 'text',
407 'default' => '',
408 'object_type' => [ 'post_type' ],
409 ],
410 'label_uploaded_to_this_item' => [
411 'label' => __( 'Uploaded to this %s', 'pods' ),
412 'label_param' => 'label_singular',
413 'label_param_default' => __( 'Item', 'pods' ),
414 'help' => __( 'help', 'pods' ),
415 'type' => 'text',
416 'default' => '',
417 'object_type' => [ 'post_type' ],
418 ],
419 'label_featured_image' => [
420 'label' => __( 'Featured Image', 'pods' ),
421 'help' => __( 'help', 'pods' ),
422 'type' => 'text',
423 'default' => '',
424 // 'depends-on' => array( 'supports_thumbnail' => true ), // @todo Dependency from other tabs not working
425 'object_type' => [ 'post_type' ],
426 ],
427 'label_set_featured_image' => [
428 'label' => __( 'Set featured Image', 'pods' ),
429 'help' => __( 'help', 'pods' ),
430 'type' => 'text',
431 'default' => '',
432 // 'depends-on' => array( 'supports_thumbnail' => true ), // @todo Dependency from other tabs not working
433 'object_type' => [ 'post_type' ],
434 ],
435 'label_remove_featured_image' => [
436 'label' => __( 'Remove featured Image', 'pods' ),
437 'help' => __( 'help', 'pods' ),
438 'type' => 'text',
439 'default' => '',
440 // 'depends-on' => array( 'supports_thumbnail' => true ), // @todo Dependency from other tabs not working
441 'object_type' => [ 'post_type' ],
442 ],
443 'label_use_featured_image' => [
444 'label' => __( 'Use as featured Image', 'pods' ),
445 'help' => __( 'help', 'pods' ),
446 'type' => 'text',
447 'default' => '',
448 // 'depends-on' => array( 'supports_thumbnail' => true ), // @todo Dependency from other tabs not working
449 'object_type' => [ 'post_type' ],
450 ],
451 'label_filter_items_list' => [
452 'label' => __( 'Filter %s', 'pods' ),
453 'label_param' => 'label',
454 'label_param_default' => __( 'Items', 'pods' ),
455 'help' => __( 'help', 'pods' ),
456 'type' => 'text',
457 'default' => '',
458 'object_type' => [ 'post_type' ],
459 ],
460 'label_items_list_navigation' => [
461 'label' => __( '%s list navigation', 'pods' ),
462 'label_param' => 'label',
463 'label_param_default' => __( 'Items', 'pods' ),
464 'help' => __( 'help', 'pods' ),
465 'type' => 'text',
466 'default' => '',
467 'object_type' => [ 'post_type', 'taxonomy' ],
468 ],
469 'label_items_list' => [
470 'label' => __( '%s list', 'pods' ),
471 'label_param' => 'label',
472 'label_param_default' => __( 'Items', 'pods' ),
473 'help' => __( 'help', 'pods' ),
474 'type' => 'text',
475 'default' => '',
476 'object_type' => [ 'post_type', 'taxonomy' ],
477 ],
478 'label_separate_items_with_commas' => [
479 'label' => __( 'Separate %s with commas', 'pods' ),
480 'label_param' => 'label',
481 'label_param_default' => __( 'items', 'pods' ),
482 'help' => __( 'help', 'pods' ),
483 'type' => 'text',
484 'default' => '',
485 'object_type' => [ 'taxonomy' ],
486 ],
487 'label_add_or_remove_items' => [
488 'label' => __( 'Add or remove %s', 'pods' ),
489 'label_param' => 'label',
490 'label_param_default' => __( 'items', 'pods' ),
491 'help' => __( 'help', 'pods' ),
492 'type' => 'text',
493 'default' => '',
494 'object_type' => [ 'taxonomy' ],
495 ],
496 'label_choose_from_the_most_used' => [
497 'label' => __( 'Choose from the most used %s', 'pods' ),
498 'label_param' => 'label',
499 'label_param_default' => __( 'items', 'pods' ),
500 'help' => __( 'help', 'pods' ),
501 'type' => 'text',
502 'default' => '',
503 'object_type' => [ 'taxonomy' ],
504 ],
505 'label_no_terms' => [
506 'label' => __( 'No %s', 'pods' ),
507 'label_param' => 'label',
508 'label_param_default' => __( 'items', 'pods' ),
509 'help' => __( 'help', 'pods' ),
510 'type' => 'text',
511 'default' => '',
512 'object_type' => [ 'taxonomy' ],
513 ],
514 'label_item_published' => [
515 'label' => __( '%s Published.', 'pods' ),
516 'label_param' => 'label_singular',
517 'label_param_default' => __( 'Item', 'pods' ),
518 'help' => __( 'help', 'pods' ),
519 'type' => 'text',
520 'default' => '',
521 'object_type' => [ 'post_type' ],
522 ],
523 'label_item_published_privately' => [
524 'label' => __( '%s published privately.', 'pods' ),
525 'label_param' => 'label_singular',
526 'label_param_default' => __( 'Item', 'pods' ),
527 'help' => __( 'help', 'pods' ),
528 'type' => 'text',
529 'default' => '',
530 'object_type' => [ 'post_type' ],
531 ],
532 'label_item_reverted_to_draft' => [
533 'label' => __( '%s reverted to draft.', 'pods' ),
534 'label_param' => 'label_singular',
535 'label_param_default' => __( 'Item', 'pods' ),
536 'help' => __( 'help', 'pods' ),
537 'type' => 'text',
538 'default' => '',
539 'object_type' => [ 'post_type' ],
540 ],
541 'label_item_scheduled' => [
542 'label' => __( '%s scheduled.', 'pods' ),
543 'label_param' => 'label_singular',
544 'label_param_default' => __( 'Item', 'pods' ),
545 'help' => __( 'help', 'pods' ),
546 'type' => 'text',
547 'default' => '',
548 'object_type' => [ 'post_type' ],
549 ],
550 'label_item_updated' => [
551 'label' => __( '%s updated.', 'pods' ),
552 'label_param' => 'label_singular',
553 'label_param_default' => __( 'Item', 'pods' ),
554 'help' => __( 'help', 'pods' ),
555 'type' => 'text',
556 'default' => '',
557 'object_type' => [ 'post_type' ],
558 ],
559 'filter_by_date' => [
560 'label' => __( 'Filter by date', 'pods' ),
561 'help' => __( 'help', 'pods' ),
562 'type' => 'text',
563 'default' => '',
564 'object_type' => [ 'post_type' ],
565 ],
566 'filter_by_item' => [
567 'label' => __( 'Filter by %s', 'pods' ),
568 'label_param' => 'label_singular',
569 'label_param_default' => __( 'Item', 'pods' ),
570 'help' => __( 'help', 'pods' ),
571 'type' => 'text',
572 'default' => '',
573 'object_type' => [ 'taxonomy' ],
574 ],
575 ];
576
577 $options['labels'] = [];
578
579 /**
580 * Filter through all labels if they have an object_type set and match it against the current object type
581 */
582 foreach ( $labels as $label => $label_data ) {
583 if ( array_key_exists( 'object_type', $label_data ) ) {
584 if ( in_array( $pod_type, $label_data['object_type'], true ) ) {
585 // Do not add the object_type to the actual label data
586 unset( $label_data['object_type'] );
587
588 $options['labels'][ $label ] = $label_data;
589 }
590 } else {
591 $options['labels'][ $label ] = $label_data;
592 }
593 }
594 } elseif ( 'settings' === $pod_type ) {
595 $options['labels'] = [
596 'label' => [
597 'label' => __( 'Page Title', 'pods' ),
598 'help' => __( 'help', 'pods' ),
599 'type' => 'text',
600 'default' => str_replace( '_', ' ', pods_v( 'name', $pod ) ),
601 'text_max_length' => 30,
602 ],
603 'menu_name' => [
604 'label' => __( 'Menu Name', 'pods' ),
605 'help' => __( 'help', 'pods' ),
606 'type' => 'text',
607 'default' => pods_v( 'label', $pod, ucwords( str_replace( '_', ' ', pods_v( 'name', $pod ) ) ) ),
608 'text_max_length' => 30,
609 ],
610 ];
611 }//end if
612
613 if ( 'post_type' === $pod_type ) {
614 $options['admin-ui'] = [
615 'description' => [
616 'label' => __( 'Post Type Description', 'pods' ),
617 'help' => __( 'A short descriptive summary of what the post type is.', 'pods' ),
618 'type' => 'text',
619 'default' => '',
620 ],
621 'show_ui' => [
622 'label' => __( 'Show Admin UI', 'pods' ),
623 'help' => __( 'Whether to generate a default UI for managing this post type in the admin.', 'pods' ),
624 'type' => 'boolean',
625 'default' => pods_v( 'public', $pod, true ),
626 'boolean_yes_label' => '',
627 ],
628 'show_in_menu' => [
629 'label' => __( 'Show Admin Menu in Dashboard', 'pods' ),
630 'help' => __( 'Whether to show the post type in the admin menu.', 'pods' ),
631 'type' => 'boolean',
632 'default' => pods_v( 'public', $pod, true ),
633 'dependency' => true,
634 'boolean_yes_label' => '',
635 ],
636 'menu_location_custom' => [
637 'label' => __( 'Parent Menu ID (optional)', 'pods' ),
638 'help' => __( 'help', 'pods' ),
639 'type' => 'text',
640 'depends-on' => [ 'show_in_menu' => true ],
641 ],
642 'menu_name' => [
643 'label' => __( 'Menu Name', 'pods' ),
644 'help' => __( 'help', 'pods' ),
645 'type' => 'text',
646 'default' => '',
647 'depends-on' => [ 'show_in_menu' => true ],
648 ],
649 'menu_position' => [
650 'label' => __( 'Menu Position', 'pods' ),
651 'help' => __( 'This will be the position of the menu item. See <a href="https://developer.wordpress.org/themes/functionality/administration-menus/#top-level-menus" target="_blank" rel="noopener noreferrer">WordPress.org Developer Docs</a> for more details about how positioning works.', 'pods' ),
652 'type' => 'number',
653 'number_decimals' => 2,
654 'number_format' => '9999.99',
655 'number_format_soft' => 1,
656 'default' => 0,
657 'depends-on' => [ 'show_in_menu' => true ],
658 ],
659 'menu_icon' => [
660 'label' => __( 'Menu Icon', 'pods' ),
661 'help' => __( 'URL or Dashicon name for the menu icon. You may specify the path to the icon using one of the <a href="https://docs.pods.io/displaying-pods/magic-tags/special-magic-tags/#Site_Tags" target="_blank" rel="noopener noreferrer">site tag</a> type <a href="https://docs.pods.io/displaying-pods/magic-tags/special-magic-tags/" target="_blank" rel="noopener noreferrer">special magic tags</a>. For example, for a file in your theme directory, use "{@template-url}/path/to/image.png". You may also use the name of a <a href="https://developer.wordpress.org/resource/dashicons/" target="_blank" rel="noopener noreferrer">Dashicon</a>. For example, to use the empty star icon, use "dashicons-star-empty".', 'pods' ),
662 'type' => 'text',
663 'default' => '',
664 'depends-on' => [ 'show_in_menu' => true ],
665 ],
666 'show_in_nav_menus' => [
667 'label' => __( 'Show in Navigation Menus', 'pods' ),
668 'help' => __( 'help', 'pods' ),
669 'type' => 'boolean',
670 'default' => true,
671 'boolean_yes_label' => '',
672 ],
673 'show_in_admin_bar' => [
674 'label' => __( 'Show in Admin Bar "New" Menu', 'pods' ),
675 'help' => __( 'help', 'pods' ),
676 'type' => 'boolean',
677 'default' => true,
678 'dependency' => true,
679 'boolean_yes_label' => '',
680 ],
681 'name_admin_bar' => [
682 'label' => __( 'Admin bar name', 'pods' ),
683 'help' => __( 'Defaults to singular name', 'pods' ),
684 'type' => 'text',
685 'default' => '',
686 'depends-on' => [ 'show_in_admin_bar' => true ],
687 ],
688 ];
689
690 $post_type_name = pods_v( 'name', $pod, 'post_type', true );
691
692 /**
693 * Allow filtering the default post status.
694 *
695 * @param string $default_post_status The default post status.
696 * @param \Pods\Whatsit\Pod $pod Current Pods object.
697 */
698 $default_post_status = apply_filters( "pods_api_default_status_{$post_type_name}", 'draft', $pod );
699
700 $options['connections'] = [
701 'post_type_built_in_taxonomies' => [
702 'name' => 'post_type_built_in_taxonomies',
703 'label' => __( 'Enable Connections to Taxonomy', 'pods' ),
704 'help' => __( 'You can enable the ability to select terms from these Taxonomies on any post for this Post Type. Once connected, posts from this Custom Post Type will appear in the Taxonomy archive page of the associated Taxonomies selected. Only Categories and Tag need to be specifically selected to be shown on Taxonomy archives on their own.', 'pods' ),
705 'type' => 'boolean_group',
706 'boolean_group' => [],
707 'dependency' => true,
708 ],
709 ];
710
711 // Only show this if it is a Custom Post Type.
712 if ( ! $is_extended ) {
713 $options['connections']['archive_show_in_taxonomies'] = [
714 'name' => 'archive_show_in_taxonomies',
715 'label' => __( 'Show in Taxonomy Archives', 'pods' ),
716 'help' => __( 'You can include posts from this Custom Post Type in the Taxonomy archive page for Categories and Tags. These Taxonomies operate differently in WordPress and require an opt-in to have Custom Post Types included.', 'pods' ),
717 'type' => 'boolean_group',
718 'boolean_group' => [],
719 'depends-on-any' => [
720 'built_in_taxonomies_category' => true,
721 'built_in_taxonomies_post_tag' => true,
722 ],
723 ];
724 }
725
726 $options['connections']['register_custom_taxonomy'] = [
727 'name' => 'register_custom_taxonomy',
728 'label' => __( 'Add new connection', 'pods' ),
729 'type' => 'html',
730 'html_content' => sprintf(
731 '<a href="%1$s">%2$s</a>',
732 esc_url( admin_url( 'admin.php?page=pods-add-new&create_extend=create&type=taxonomy' ) ),
733 esc_html__( 'Create a new Custom Taxonomy', 'pods' )
734 ),
735 ];
736
737 $options['advanced'] = [
738 'public' => [
739 'label' => __( 'Public', 'pods' ),
740 'help' => __( 'help', 'pods' ),
741 'type' => 'boolean',
742 'default' => true,
743 'boolean_yes_label' => '',
744 ],
745 'publicly_queryable' => [
746 'label' => __( 'Publicly Queryable', 'pods' ),
747 'help' => __( 'help', 'pods' ),
748 'type' => 'boolean',
749 'default' => pods_v( 'public', $pod, true ),
750 'boolean_yes_label' => '',
751 ],
752 'exclude_from_search' => [
753 'label' => __( 'Exclude from Search', 'pods' ),
754 'help' => __( 'help', 'pods' ),
755 'type' => 'boolean',
756 'default' => ! pods_v( 'public', $pod, true ),
757 'boolean_yes_label' => '',
758 ],
759 'capability_type' => [
760 'label' => __( 'User Capability', 'pods' ),
761 'help' => __( 'Uses these capabilities for access to this post type: edit_{capability}, read_{capability}, and delete_{capability}', 'pods' ),
762 'type' => 'pick',
763 'default' => 'post',
764 'data' => [
765 'post' => 'post',
766 'page' => 'page',
767 'custom' => __( 'Custom Capability', 'pods' ),
768 ],
769 'pick_show_select_text' => 0,
770 'dependency' => true,
771 ],
772 'capability_type_custom' => [
773 'label' => __( 'Custom User Capability', 'pods' ),
774 'help' => __( 'help', 'pods' ),
775 'type' => 'text',
776 'default' => pods_v( 'name', $pod ),
777 'depends-on' => [ 'capability_type' => 'custom' ],
778 ],
779 'capability_type_extra' => [
780 'label' => __( 'Additional User Capabilities', 'pods' ),
781 'help' => __( 'Enables additional capabilities for this Post Type including: delete_{capability}s, delete_private_{capability}s, delete_published_{capability}s, delete_others_{capability}s, edit_private_{capability}s, and edit_published_{capability}s', 'pods' ),
782 'type' => 'boolean',
783 'default' => true,
784 'boolean_yes_label' => '',
785 ],
786 'has_archive' => [
787 'label' => __( 'Enable Archive Page', 'pods' ),
788 'help' => __( 'If enabled, creates an archive page with list of of items in this custom post type. Functions like a category page for posts. Can be controlled with a template in your theme called "archive-{$post-type}.php".', 'pods' ),
789 'type' => 'boolean',
790 'default' => false,
791 'dependency' => true,
792 'boolean_yes_label' => '',
793 ],
794 'has_archive_slug' => [
795 'label' => __( 'Archive Page Slug Override', 'pods' ),
796 'help' => __( 'If archive page is enabled, you can override the slug used by WordPress, which defaults to the name of the post type.', 'pods' ),
797 'type' => 'text',
798 'slug_fallback' => '-',
799 'default' => '',
800 'depends-on' => [ 'has_archive' => true ],
801 ],
802 'hierarchical' => [
803 'label' => __( 'Hierarchical', 'pods' ),
804 'help' => __( 'Allows for parent/ child relationships between items, just like with Pages. Note: To edit relationships in the post editor, you must enable "Page Attributes" in the "Supports" section below.', 'pods' ),
805 'type' => 'boolean',
806 'default' => false,
807 'dependency' => true,
808 'boolean_yes_label' => '',
809 ],
810 'rewrite' => [
811 'label' => __( 'Rewrite', 'pods' ),
812 'help' => __( 'Allows you to use pretty permalinks, if set in WordPress Settings->Permalinks. If not enabled, your links will be in the form of "example.com/?pod_name=post_slug" regardless of your permalink settings.', 'pods' ),
813 'type' => 'boolean',
814 'default' => true,
815 'dependency' => true,
816 'boolean_yes_label' => '',
817 ],
818 'rewrite_custom_slug' => [
819 'label' => __( 'Custom Rewrite Slug', 'pods' ),
820 'help' => __( 'Changes the first segment of the URL, which by default is the name of the Pod. For example, if your Pod is called "foo", if this field is left blank, your link will be "example.com/foo/post_slug", but if you were to enter "bar" your link will be "example.com/bar/post_slug".', 'pods' ),
821 'type' => 'text',
822 'slug_fallback' => '-',
823 'default' => '',
824 'depends-on' => [ 'rewrite' => true ],
825 ],
826 'rewrite_with_front' => [
827 'label' => __( 'Rewrite with Front', 'pods' ),
828 'help' => __( 'Allows permalinks to be prepended with your front base (example: if your permalink structure is /blog/, then your links will be: Unchecked->/news/, Checked->/blog/news/)', 'pods' ),
829 'type' => 'boolean',
830 'default' => true,
831 'depends-on' => [ 'rewrite' => true ],
832 'boolean_yes_label' => '',
833 ],
834 'rewrite_feeds' => [
835 'label' => __( 'Rewrite Feeds', 'pods' ),
836 'help' => __( 'help', 'pods' ),
837 'type' => 'boolean',
838 'default' => false,
839 'depends-on' => [ 'rewrite' => true ],
840 'boolean_yes_label' => '',
841 ],
842 'rewrite_pages' => [
843 'label' => __( 'Rewrite Pages', 'pods' ),
844 'help' => __( 'help', 'pods' ),
845 'type' => 'boolean',
846 'default' => true,
847 'depends-on' => [ 'rewrite' => true ],
848 'boolean_yes_label' => '',
849 ],
850 'query_var' => [
851 'label' => __( 'Query Var', 'pods' ),
852 'help' => __( 'The Query Var is used in the URL and underneath the WordPress Rewrite API to tell WordPress what page or post type you are on. For a list of reserved Query Vars, read <a href="http://codex.wordpress.org/WordPress_Query_Vars">WordPress Query Vars</a> from the WordPress Codex.', 'pods' ),
853 'type' => 'boolean',
854 'default' => true,
855 'boolean_yes_label' => '',
856 ],
857 'can_export' => [
858 'label' => __( 'Exportable', 'pods' ),
859 'help' => __( 'help', 'pods' ),
860 'type' => 'boolean',
861 'default' => true,
862 'boolean_yes_label' => '',
863 ],
864 'default_status' => [
865 'label' => __( 'Default Status', 'pods' ),
866 'help' => __( 'help', 'pods' ),
867 'type' => 'pick',
868 'pick_object' => 'post-status',
869 'default' => $default_post_status,
870 'pick_show_select_text' => 0,
871 ],
872 'post_type_supports' => [
873 'name' => 'post_type_supports',
874 'type' => 'boolean_group',
875 'label' => __( 'Supports', 'pods' ),
876 'boolean_group' => [
877 'supports_title' => [
878 'name' => 'supports_title',
879 'label' => __( 'Title', 'pods' ),
880 'type' => 'boolean',
881 ],
882 'supports_editor' => [
883 'name' => 'supports_editor',
884 'label' => __( 'Editor', 'pods' ),
885 'type' => 'boolean',
886 ],
887 'supports_author' => [
888 'name' => 'supports_author',
889 'label' => __( 'Author', 'pods' ),
890 'type' => 'boolean',
891 ],
892 'supports_thumbnail' => [
893 'name' => 'supports_thumbnail',
894 'label' => __( 'Featured Image', 'pods' ),
895 'type' => 'boolean',
896 'dependency' => true,
897 ],
898 'supports_excerpt' => [
899 'name' => 'supports_excerpt',
900 'label' => __( 'Excerpt', 'pods' ),
901 'type' => 'boolean',
902 ],
903 'supports_trackbacks' => [
904 'name' => 'supports_trackbacks',
905 'label' => __( 'Trackbacks', 'pods' ),
906 'type' => 'boolean',
907 ],
908 'supports_custom_fields' => [
909 'name' => 'supports_custom_fields',
910 'label' => __( 'Manually Edit Custom Fields (can cause slow performance)', 'pods' ),
911 'type' => 'boolean',
912 ],
913 'supports_comments' => [
914 'name' => 'supports_comments',
915 'label' => __( 'Comments', 'pods' ),
916 'type' => 'boolean',
917 ],
918 'supports_revisions' => [
919 'name' => 'supports_revisions',
920 'label' => __( 'Revisions', 'pods' ),
921 'type' => 'boolean',
922 ],
923 'supports_page_attributes' => [
924 'name' => 'supports_page_attributes',
925 'label' => __( 'Page Attributes', 'pods' ),
926 'type' => 'boolean',
927 ],
928 'supports_post_formats' => [
929 'name' => 'supports_post_formats',
930 'label' => __( 'Post Formats', 'pods' ),
931 'type' => 'boolean',
932 ],
933 ],
934 ],
935 'supports_custom' => [
936 'name' => 'supports_custom',
937 'type' => 'text',
938 'label' => __( 'Advanced Supports', 'pods' ),
939 'help' => __( 'Comma-separated list of custom "supports" values to pass to register_post_type.', 'pods' ),
940 ],
941 'revisions_to_keep_limit' => [
942 'name' => 'revisions_to_keep_limit',
943 'type' => 'number',
944 'default' => '0',
945 'label' => __( 'Maximum revisions to keep per post', 'pods' ),
946 'description' => __( 'The default "0" will fallback to the normal WordPress default.', 'pods' ),
947 'help' => __( 'Enter -1 to keep ALL revisions. Enter any positive number to limit the number of revisions kept to that amount.', 'pods' ),
948 'depends-on' => [ 'supports_revisions' => true ],
949 ],
950 'delete_with_user' => [
951 'label' => __( 'Allow posts to be deleted when author is deleted', 'pods' ),
952 'help' => __( 'When you go to delete a user who is an author of any posts for this post type, you will be given an option to reassign all of their posts to a different author or to delete their posts. With this option on, it will be included in posts to delete upon choosing to delete all posts.', 'pods' ),
953 'type' => 'boolean',
954 'default' => true,
955 'boolean_yes_label' => __( 'Include posts from this post type when deleting authors and choosing not to reassign posts to a new author.', 'pods' ),
956 ],
957 ];
958
959 /**
960 * Allow filtering the list of supported features for the post type
961 *
962 * @since 2.8.0
963 *
964 * @param array $supports The list of supported features for the post type.
965 * @param array $options The Options fields.
966 * @param \Pods\Whatsit\Pod $pod Current Pods object.
967 * @param array $tabs List of registered tabs.
968 */
969 $options['advanced']['post_type_supports']['boolean_group'] = apply_filters( 'pods_admin_config_pod_fields_post_type_supported_features', $options['advanced']['post_type_supports']['boolean_group'], $options, $pod, $tabs );
970
971 $related_objects = PodsForm::field_method( 'pick', 'related_objects', true );
972
973 $available_taxonomies = [];
974
975 if ( ! empty( $related_objects[ __( 'Taxonomies', 'pods' ) ] ) ) {
976 $available_taxonomies = (array) $related_objects[ __( 'Taxonomies', 'pods' ) ];
977 }
978
979 foreach ( $available_taxonomies as $taxonomy => $label ) {
980 $taxonomy = pods_str_replace( 'taxonomy-', '', $taxonomy, 1 );
981
982 $field_name = 'built_in_taxonomies_' . $taxonomy;
983
984 $options['connections']['post_type_built_in_taxonomies']['boolean_group'][ $field_name ] = [
985 'name' => $field_name,
986 'label' => $label,
987 'type' => 'boolean',
988 ];
989
990 if ( 'category' === $taxonomy || 'post_tag' === $taxonomy ) {
991 $field_name = 'archive_show_in_taxonomies_' . $taxonomy;
992
993 $options['connections']['archive_show_in_taxonomies']['boolean_group'][ $field_name ] = [
994 'name' => $field_name,
995 'label' => $label,
996 'type' => 'boolean',
997 ];
998 }
999 }
1000 } elseif ( 'taxonomy' === $pod_type ) {
1001 $options['admin-ui'] = [
1002 'description' => [
1003 'label' => __( 'Taxonomy Description', 'pods' ),
1004 'help' => __( 'A short descriptive summary of what the taxonomy is.', 'pods' ),
1005 'type' => 'text',
1006 'default' => '',
1007 ],
1008 'show_ui' => [
1009 'label' => __( 'Show Admin UI', 'pods' ),
1010 'help' => __( 'Whether to generate a default UI for managing this taxonomy.', 'pods' ),
1011 'type' => 'boolean',
1012 'default' => pods_v( 'public', $pod, true ),
1013 'dependency' => true,
1014 'boolean_yes_label' => '',
1015 ],
1016 'show_in_menu' => [
1017 'label' => __( 'Show Admin Menu in Dashboard', 'pods' ),
1018 'help' => __( 'Whether to show the taxonomy in the admin menu.', 'pods' ),
1019 'type' => 'boolean',
1020 'default' => pods_v( 'public', $pod, true ),
1021 'dependency' => true,
1022 'depends-on' => [ 'show_ui' => true ],
1023 'boolean_yes_label' => '',
1024 ],
1025 'menu_name' => [
1026 'label' => __( 'Menu Name', 'pods' ),
1027 'help' => __( 'help', 'pods' ),
1028 'type' => 'text',
1029 'default' => '',
1030 'depends-on' => [ 'show_ui' => true ],
1031 ],
1032 'menu_location' => [
1033 'label' => __( 'Menu Location', 'pods' ),
1034 'help' => __( 'help', 'pods' ),
1035 'type' => 'pick',
1036 'default' => 'default',
1037 'depends-on' => [ 'show_ui' => true ],
1038 'data' => [
1039 'default' => __( 'Default - Add to associated Post Type(s) menus', 'pods' ),
1040 'settings' => __( 'Add a submenu item to Settings menu', 'pods' ),
1041 'appearances' => __( 'Add a submenu item to Appearances menu', 'pods' ),
1042 'submenu' => __( 'Add a submenu item to another menu', 'pods' ),
1043 'objects' => __( 'Make a new menu item', 'pods' ),
1044 'top' => __( 'Make a new menu item below Settings', 'pods' ),
1045 ],
1046 'pick_show_select_text' => 0,
1047 'dependency' => true,
1048 ],
1049 'menu_location_custom' => [
1050 'label' => __( 'Custom Menu Location', 'pods' ),
1051 'help' => __( 'help', 'pods' ),
1052 'type' => 'text',
1053 'depends-on' => [ 'menu_location' => 'submenu' ],
1054 ],
1055 'menu_position' => [
1056 'label' => __( 'Menu Position', 'pods' ),
1057 'help' => __( 'This will be the position of the menu item. See <a href="https://developer.wordpress.org/themes/functionality/administration-menus/#top-level-menus" target="_blank" rel="noopener noreferrer">WordPress.org Developer Docs</a> for more details about how positioning works.', 'pods' ),
1058 'type' => 'number',
1059 'number_decimals' => 2,
1060 'number_format' => '9999.99',
1061 'number_format_soft' => 1,
1062 'default' => 0,
1063 'depends-on' => [ 'menu_location' => [ 'objects', 'top' ] ],
1064 ],
1065 'menu_icon' => [
1066 'label' => __( 'Menu Icon URL', 'pods' ),
1067 'help' => __( 'URL or Dashicon name for the menu icon. You may specify the path to the icon using one of the <a href="https://docs.pods.io/displaying-pods/magic-tags/special-magic-tags/#Site_Tags" target="_blank" rel="noopener noreferrer">site tag</a> type <a href="https://docs.pods.io/displaying-pods/magic-tags/special-magic-tags/" target="_blank" rel="noopener noreferrer">special magic tags</a>. For example, for a file in your theme directory, use "{@template-url}/path/to/image.png". You may also use the name of a <a href="https://developer.wordpress.org/resource/dashicons/" target="_blank" rel="noopener noreferrer">Dashicon</a>. For example, to use the empty star icon, use "dashicons-star-empty".', 'pods' ),
1068 'type' => 'text',
1069 'default' => '',
1070 'depends-on' => [ 'menu_location' => [ 'objects', 'top' ] ],
1071 ],
1072 'show_in_nav_menus' => [
1073 'label' => __( 'Show in Navigation Menus', 'pods' ),
1074 'help' => __( 'help', 'pods' ),
1075 'type' => 'boolean',
1076 'default' => pods_v( 'public', $pod, true ),
1077 'boolean_yes_label' => '',
1078 ],
1079 'show_tagcloud' => [
1080 'label' => __( 'Allow in Tag Cloud Widget', 'pods' ),
1081 'help' => __( 'help', 'pods' ),
1082 'type' => 'boolean',
1083 'default' => pods_v( 'show_ui', $pod, pods_v( 'public', $pod, true ) ),
1084 'boolean_yes_label' => '',
1085 ],
1086 // @todo check https://core.trac.wordpress.org/ticket/36964
1087 'show_tagcloud_in_edit' => [
1088 'label' => __( 'Allow Tag Cloud on term edit pages', 'pods' ),
1089 'help' => __( 'help', 'pods' ),
1090 'type' => 'boolean',
1091 'default' => pods_v( 'show_ui', $pod, pods_v( 'show_tagcloud', $pod, true ) ),
1092 'boolean_yes_label' => '',
1093 ],
1094 'show_in_quick_edit' => [
1095 'label' => __( 'Allow in quick/bulk edit panel', 'pods' ),
1096 'help' => __( 'help', 'pods' ),
1097 'type' => 'boolean',
1098 'default' => pods_v( 'show_ui', $pod, pods_v( 'public', $pod, true ) ),
1099 'boolean_yes_label' => '',
1100 ],
1101 ];
1102
1103 $options['admin-ui']['show_admin_column'] = [
1104 'label' => __( 'Show Taxonomy column on Post Types', 'pods' ),
1105 'help' => __( 'Whether to add a column for this taxonomy on the associated post types manage screens', 'pods' ),
1106 'type' => 'boolean',
1107 'default' => false,
1108 'boolean_yes_label' => '',
1109 ];
1110
1111 // Integration for Single Value Taxonomy UI
1112 if ( function_exists( 'tax_single_value_meta_box' ) ) {
1113 $options['admin-ui']['single_value'] = [
1114 'label' => __( 'Single Value Taxonomy', 'pods' ),
1115 'help' => __( 'Use a drop-down for the input instead of the WordPress default', 'pods' ),
1116 'type' => 'boolean',
1117 'default' => false,
1118 'boolean_yes_label' => '',
1119 ];
1120
1121 $options['admin-ui']['single_value_required'] = [
1122 'label' => __( 'Single Value Taxonomy - Required', 'pods' ),
1123 'help' => __( 'A term will be selected by default in the Post Editor, not optional', 'pods' ),
1124 'type' => 'boolean',
1125 'default' => false,
1126 'boolean_yes_label' => '',
1127 ];
1128 }
1129
1130 $options['connections'] = [
1131 'taxonomy_associated_post_types' => [
1132 'name' => 'taxonomy_associated_post_types',
1133 'label' => __( 'Enable Connections to Post Types', 'pods' ),
1134 'help' => __( 'You can enable the ability to select posts from these post types on any term for this taxonomy.', 'pods' ),
1135 'type' => 'boolean_group',
1136 'boolean_group' => [],
1137 ],
1138 'register_custom_post_type' => [
1139 'name' => 'register_custom_post_type',
1140 'label' => __( 'Add new connection', 'pods' ),
1141 'type' => 'html',
1142 'html_content' => sprintf(
1143 '<a href="%1$s">%2$s</a>',
1144 esc_url( admin_url( 'admin.php?page=pods-add-new&create_extend=create&type=post_type' ) ),
1145 esc_html__( 'Create a new Custom Post Type', 'pods' )
1146 ),
1147 ],
1148 ];
1149
1150 $options['advanced'] = [
1151 'public' => [
1152 'label' => __( 'Public', 'pods' ),
1153 'help' => __( 'help', 'pods' ),
1154 'type' => 'boolean',
1155 'default' => true,
1156 'boolean_yes_label' => '',
1157 ],
1158 'hierarchical' => [
1159 'label' => __( 'Hierarchical', 'pods' ),
1160 'help' => __( 'Hierarchical taxonomies will have a list with checkboxes to select an existing category in the taxonomy admin box on the post edit page (like default post categories). Non-hierarchical taxonomies will just have an empty text field to type-in taxonomy terms to associate with the post (like default post tags).', 'pods' ),
1161 'type' => 'boolean',
1162 'default' => true,
1163 'dependency' => true,
1164 'boolean_yes_label' => '',
1165 ],
1166 'rewrite' => [
1167 'label' => __( 'Rewrite', 'pods' ),
1168 'help' => __( 'help', 'pods' ),
1169 'type' => 'boolean',
1170 'default' => true,
1171 'dependency' => true,
1172 'boolean_yes_label' => '',
1173 ],
1174 'rewrite_custom_slug' => [
1175 'label' => __( 'Custom Rewrite Slug', 'pods' ),
1176 'help' => __( 'help', 'pods' ),
1177 'type' => 'text',
1178 'slug_fallback' => '-',
1179 'default' => '',
1180 'depends-on' => [ 'rewrite' => true ],
1181 ],
1182 'rewrite_with_front' => [
1183 'label' => __( 'Rewrite with Front', 'pods' ),
1184 'help' => __( 'Allows permalinks to be prepended with your front base (example: if your permalink structure is /blog/, then your links will be: Unchecked->/news/, Checked->/blog/news/)', 'pods' ),
1185 'type' => 'boolean',
1186 'default' => true,
1187 'boolean_yes_label' => '',
1188 'depends-on' => [ 'rewrite' => true ],
1189 ],
1190 'rewrite_hierarchical' => [
1191 'label' => __( 'Hierarchical Permalinks', 'pods' ),
1192 'help' => __( 'help', 'pods' ),
1193 'type' => 'boolean',
1194 'default' => true,
1195 'boolean_yes_label' => '',
1196 'depends-on' => [ 'rewrite' => true ],
1197 ],
1198 'capability_type' => [
1199 'label' => __( 'User Capability', 'pods' ),
1200 'help' => __( 'Uses WordPress term capabilities by default', 'pods' ),
1201 'type' => 'pick',
1202 'default' => 'default',
1203 'data' => [
1204 'default' => 'Default',
1205 'custom' => __( 'Custom Capability', 'pods' ),
1206 ],
1207 'pick_show_select_text' => 0,
1208 'dependency' => true,
1209 ],
1210 'capability_type_custom' => [
1211 'label' => __( 'Custom User Capability', 'pods' ),
1212 'help' => __( 'Enables additional capabilities for this Taxonomy including: manage_{capability}_terms, edit_{capability}_terms, assign_{capability}_terms, and delete_{capability}_terms', 'pods' ),
1213 'type' => 'text',
1214 'default' => pods_v( 'name', $pod ),
1215 'depends-on' => [ 'capability_type' => 'custom' ],
1216 ],
1217 'query_var' => [
1218 'label' => __( 'Query Var', 'pods' ),
1219 'help' => __( 'help', 'pods' ),
1220 'type' => 'boolean',
1221 'default' => false,
1222 'boolean_yes_label' => '',
1223 ],
1224 'query_var' => [
1225 'label' => __( 'Query Var', 'pods' ),
1226 'help' => __( 'help', 'pods' ),
1227 'type' => 'boolean',
1228 'default' => false,
1229 'dependency' => true,
1230 'boolean_yes_label' => '',
1231 ],
1232 'query_var_string' => [
1233 'label' => __( 'Custom Query Var Name', 'pods' ),
1234 'help' => __( 'help', 'pods' ),
1235 'type' => 'text',
1236 'default' => '',
1237 'depends-on' => [ 'query_var' => true ],
1238 ],
1239 'sort' => [
1240 'label' => __( 'Remember order saved on Post Types', 'pods' ),
1241 'help' => __( 'help', 'pods' ),
1242 'type' => 'boolean',
1243 'default' => false,
1244 'boolean_yes_label' => '',
1245 ],
1246 'update_count_callback' => [
1247 'label' => __( 'Function to call when updating counts', 'pods' ),
1248 'help' => __( 'help', 'pods' ),
1249 'type' => 'text',
1250 'default' => '',
1251 ],
1252 'default_term_name' => [
1253 'label' => __( 'Default term name', 'pods' ),
1254 'type' => 'text',
1255 'default' => '',
1256 'dependency' => true,
1257 ],
1258 'default_term_slug' => [
1259 'label' => __( 'Default term slug', 'pods' ),
1260 'type' => 'text',
1261 'default' => '',
1262 'excludes-on' => [ 'default_term_name' => '' ],
1263 ],
1264 'default_term_description' => [
1265 'label' => __( 'Default term description', 'pods' ),
1266 'type' => 'wysiwyg',
1267 'default' => '',
1268 'excludes-on' => [ 'default_term_name' => '' ],
1269 ],
1270 ];
1271
1272 $related_objects = PodsForm::field_method( 'pick', 'related_objects', true );
1273
1274 $available_post_types = [];
1275
1276 if ( ! empty( $related_objects[ __( 'Post Types', 'pods' ) ] ) ) {
1277 $available_post_types = (array) $related_objects[ __( 'Post Types', 'pods' ) ];
1278 }
1279
1280 foreach ( $available_post_types as $post_type => $label ) {
1281 $post_type = pods_str_replace( 'post_type-', '', $post_type, 1 );
1282
1283 $field_name = 'built_in_post_types_' . $post_type;
1284
1285 $options['connections']['taxonomy_associated_post_types']['boolean_group'][ $field_name ] = [
1286 'name' => $field_name,
1287 'label' => $label,
1288 'type' => 'boolean',
1289 ];
1290 }
1291
1292 $options['connections']['taxonomy_associated_post_types']['boolean_group']['built_in_post_types_attachment'] = [
1293 'name' => 'built_in_post_types_attachment',
1294 'label' => __( 'Media', 'pods' ) . ' (attachment)',
1295 'type' => 'boolean',
1296 ];
1297 } elseif ( 'settings' === $pod_type ) {
1298 $options['admin-ui'] = [
1299 'ui_style' => [
1300 'label' => __( 'Admin UI Style', 'pods' ),
1301 'help' => __( 'help', 'pods' ),
1302 'type' => 'pick',
1303 'default' => 'settings',
1304 'data' => [
1305 'settings' => __( 'Normal Settings Form', 'pods' ),
1306 'post_type' => __( 'Post Type UI', 'pods' ),
1307 'custom' => __( 'Custom (hook into pods_admin_ui_custom or pods_admin_ui_custom_{podname} action)', 'pods' ),
1308 ],
1309 'dependency' => true,
1310 ],
1311 'menu_location' => [
1312 'label' => __( 'Menu Location', 'pods' ),
1313 'help' => __( 'help', 'pods' ),
1314 'type' => 'pick',
1315 'default' => 'settings',
1316 'data' => [
1317 'settings' => __( 'Add a submenu item to Settings menu', 'pods' ),
1318 'appearances' => __( 'Add a submenu item to Appearances menu', 'pods' ),
1319 'submenu' => __( 'Add a submenu item to another menu', 'pods' ),
1320 'top' => __( 'Make a new menu item below Settings', 'pods' ),
1321 ],
1322 'dependency' => true,
1323 ],
1324 'menu_location_custom' => [
1325 'label' => __( 'Custom Menu Location', 'pods' ),
1326 'help' => __( 'help', 'pods' ),
1327 'type' => 'text',
1328 'depends-on' => [ 'menu_location' => 'submenu' ],
1329 ],
1330 'menu_position' => [
1331 'label' => __( 'Menu Position', 'pods' ),
1332 'help' => __( 'This will be the position of the menu item. See <a href="https://developer.wordpress.org/themes/functionality/administration-menus/#top-level-menus" target="_blank" rel="noopener noreferrer">WordPress.org Developer Docs</a> for more details about how positioning works.', 'pods' ),
1333 'type' => 'number',
1334 'number_decimals' => 2,
1335 'number_format' => '9999.99',
1336 'number_format_soft' => 1,
1337 'default' => 0,
1338 'depends-on' => [ 'menu_location' => 'top' ],
1339 ],
1340 'menu_icon' => [
1341 'label' => __( 'Menu Icon URL', 'pods' ),
1342 'help' => __( 'URL or Dashicon name for the menu icon. You may specify the path to the icon using one of the <a href="https://docs.pods.io/displaying-pods/magic-tags/special-magic-tags/#Site_Tags" target="_blank" rel="noopener noreferrer">site tag</a> type <a href="https://docs.pods.io/displaying-pods/magic-tags/special-magic-tags/" target="_blank" rel="noopener noreferrer">special magic tags</a>. For example, for a file in your theme directory, use "{@template-url}/path/to/image.png". You may also use the name of a <a href="https://developer.wordpress.org/resource/dashicons/" target="_blank" rel="noopener noreferrer">Dashicon</a>. For example, to use the empty star icon, use "dashicons-star-empty".', 'pods' ),
1343 'type' => 'text',
1344 'default' => '',
1345 'depends-on' => [ 'menu_location' => 'top' ],
1346 ],
1347 ];
1348
1349 // @todo fill this in
1350 $options['advanced'] = [
1351 'temporary' => 'This type has the fields hardcoded',
1352 // :(
1353 ];
1354 } elseif ( 'pod' === $pod_type ) {
1355 $actions_enabled = [
1356 'add',
1357 'edit',
1358 'duplicate',
1359 'delete',
1360 ];
1361
1362 if ( 1 === (int) pods_v( 'ui_export', $pod ) ) {
1363 $actions_enabled = [
1364 'add',
1365 'edit',
1366 'duplicate',
1367 'delete',
1368 'export',
1369 ];
1370 }
1371
1372 $options['admin-ui'] = [
1373 'ui_style' => [
1374 'label' => __( 'Admin UI Style', 'pods' ),
1375 'help' => __( 'help', 'pods' ),
1376 'type' => 'pick',
1377 'default' => 'settings',
1378 'data' => [
1379 'post_type' => __( 'Normal (Looks like the Post Type UI)', 'pods' ),
1380 'custom' => __( 'Custom (hook into pods_admin_ui_custom or pods_admin_ui_custom_{podname} action)', 'pods' ),
1381 ],
1382 'dependency' => true,
1383 ],
1384 'show_in_menu' => [
1385 'label' => __( 'Show Admin Menu in Dashboard', 'pods' ),
1386 'help' => __( 'help', 'pods' ),
1387 'type' => 'boolean',
1388 'default' => false,
1389 'boolean_yes_label' => '',
1390 'dependency' => true,
1391 ],
1392 'menu_location_custom' => [
1393 'label' => __( 'Parent Menu ID (optional)', 'pods' ),
1394 'help' => __( 'help', 'pods' ),
1395 'type' => 'text',
1396 'depends-on' => [ 'show_in_menu' => true ],
1397 ],
1398 'menu_position' => [
1399 'label' => __( 'Menu Position', 'pods' ),
1400 'help' => __( 'This will be the position of the menu item. See <a href="https://developer.wordpress.org/themes/functionality/administration-menus/#top-level-menus" target="_blank" rel="noopener noreferrer">WordPress.org Developer Docs</a> for more details about how positioning works.', 'pods' ),
1401 'type' => 'number',
1402 'number_decimals' => 2,
1403 'number_format' => '9999.99',
1404 'number_format_soft' => 1,
1405 'default' => 0,
1406 'depends-on' => [ 'show_in_menu' => true ],
1407 ],
1408 'menu_icon' => [
1409 'label' => __( 'Menu Icon URL', 'pods' ),
1410 'help' => __( 'URL or Dashicon name for the menu icon. You may specify the path to the icon using one of the <a href="https://docs.pods.io/displaying-pods/magic-tags/special-magic-tags/#Site_Tags" target="_blank" rel="noopener noreferrer">site tag</a> type <a href="https://docs.pods.io/displaying-pods/magic-tags/special-magic-tags/" target="_blank" rel="noopener noreferrer">special magic tags</a>. For example, for a file in your theme directory, use "{@template-url}/path/to/image.png". You may also use the name of a <a href="https://developer.wordpress.org/resource/dashicons/" target="_blank" rel="noopener noreferrer">Dashicon</a>. For example, to use the empty star icon, use "dashicons-star-empty".', 'pods' ),
1411 'type' => 'text',
1412 'default' => '',
1413 'depends-on' => [ 'show_in_menu' => true ],
1414 ],
1415 'ui_icon' => [
1416 'label' => __( 'Header Icon', 'pods' ),
1417 'help' => __( 'This is the icon shown to the left of the heading text at the top of the manage pages for this content type.', 'pods' ),
1418 'type' => 'file',
1419 'default' => '',
1420 'file_edit_title' => 0,
1421 'depends-on' => [ 'show_in_menu' => true ],
1422 ],
1423 'ui_actions_enabled' => [
1424 'label' => __( 'Actions Available', 'pods' ),
1425 'help' => __( 'help', 'pods' ),
1426 'type' => 'pick',
1427 'default' => $actions_enabled,
1428 'data' => [
1429 'add' => __( 'Add New', 'pods' ),
1430 'edit' => __( 'Edit', 'pods' ),
1431 'duplicate' => __( 'Duplicate', 'pods' ),
1432 'delete' => __( 'Delete', 'pods' ),
1433 'reorder' => __( 'Reorder', 'pods' ),
1434 'export' => __( 'Export', 'pods' ),
1435 ],
1436 'pick_format_type' => 'multi',
1437 'dependency' => true,
1438 ],
1439 'ui_reorder_field' => [
1440 'label' => __( 'Reorder Field', 'pods' ),
1441 'help' => __( 'This is the field that will be reordered on, it should be numeric.', 'pods' ),
1442 'type' => 'text',
1443 'default' => 'menu_order',
1444 'depends-on' => [ 'ui_actions_enabled' => 'reorder' ],
1445 ],
1446 'ui_fields_manage' => [
1447 'label' => __( 'Admin Table Columns', 'pods' ),
1448 'help' => __( 'help', 'pods' ),
1449 'type' => 'pick',
1450 'default' => [],
1451 'data' => [],
1452 'pick_format_type' => 'multi',
1453 ],
1454 'ui_filters' => [
1455 'label' => __( 'Search Filters', 'pods' ),
1456 'help' => __( 'help', 'pods' ),
1457 'type' => 'pick',
1458 'default' => [],
1459 'data' => [],
1460 'pick_format_type' => 'multi',
1461 ],
1462 ];
1463
1464 if ( ! empty( $pod['fields'] ) ) {
1465 if ( isset( $pod['fields'][ pods_v( 'pod_index', $pod, 'name' ) ] ) ) {
1466 $options['admin-ui']['ui_fields_manage']['default'][] = pods_v( 'pod_index', $pod, 'name' );
1467 }
1468
1469 if ( isset( $pod['fields']['modified'] ) ) {
1470 $options['admin-ui']['ui_fields_manage']['default'][] = 'modified';
1471 }
1472
1473 foreach ( $pod['fields'] as $field ) {
1474 $type = '';
1475
1476 if ( isset( $field_types[ $field['type'] ] ) ) {
1477 $type = ' <small>(' . $field_types[ $field['type'] ]['label'] . ')</small>';
1478 }
1479
1480 $options['admin-ui']['ui_fields_manage']['data'][ $field['name'] ] = $field['label'] . $type;
1481 $options['admin-ui']['ui_filters']['data'][ $field['name'] ] = $field['label'] . $type;
1482 }
1483
1484 $options['admin-ui']['ui_fields_manage']['data']['id'] = 'ID';
1485 } else {
1486 unset( $options['admin-ui']['ui_fields_manage'] );
1487 unset( $options['admin-ui']['ui_filters'] );
1488 }//end if
1489
1490 $index_fields = [
1491 'id' => 'ID',
1492 ];
1493
1494 $hierarchical_fields = [];
1495
1496 foreach ( $pod['fields'] as $field ) {
1497 if ( ! in_array( $field['type'], $tableless_field_types, true ) ) {
1498 $index_fields[ $field['name'] ] = $field['label'];
1499 }
1500
1501 if ( 'pick' == $field['type'] && 'pod' === pods_v( 'pick_object', $field ) && $pod['name'] === pods_v( 'pick_val', $field ) && 'single' === pods_v( 'pick_format_type', $field ) ) {
1502 $hierarchical_fields[ $field['name'] ] = $field['label'];
1503 }
1504 }
1505
1506 // Set empty message if none found.
1507 if ( empty( $hierarchical_fields ) ) {
1508 $hierarchical_fields = [
1509 '' => __( 'No Hierarchical Fields found', 'pods' ),
1510 ];
1511 }
1512
1513 $options['advanced'] = [
1514 'detail_url' => [
1515 'label' => __( 'Detail Page URL', 'pods' ),
1516 'help' => __( 'This is the path relative to your WordPress site URL so you can call {@detail_url} to automatically link to it. Enter something like "my-pod-page/{@permalink}/" to automatically link to "https://mysite.com/my-pod-page/my-pod-item/".', 'pods' ),
1517 'type' => 'text',
1518 'text_placeholder' => 'my-pod-page/{@permalink}/',
1519 ],
1520 'pod_index' => [
1521 'label' => __( 'Title Field', 'pods' ),
1522 'help' => __( 'If you delete the "name" field, we need to specify the field to use as your primary title field. This field will serve as an index of your content. Most commonly this field represents the name of a person, place, thing, or a summary field.', 'pods' ),
1523 'default' => 'name',
1524 'type' => 'pick',
1525 'data' => $index_fields,
1526 'pick_format_single' => 'autocomplete',
1527 ],
1528 'hierarchical' => [
1529 'label' => __( 'Hierarchical', 'pods' ),
1530 'help' => __( 'You can enable automatic hierarchical parent / child handling which shows a special built-in interface for data entry.', 'pods' ),
1531 'default' => 0,
1532 'type' => 'boolean',
1533 'dependency' => true,
1534 'boolean_yes_label' => '',
1535 ],
1536 'pod_parent' => [
1537 'label' => __( 'Hierarchical Parent Field', 'pods' ),
1538 'help' => __( 'You can enable automatic hierarchical parent / child handling which shows a special built-in interface for data entry.', 'pods' ),
1539 'default' => 'parent',
1540 'type' => 'pick',
1541 'data' => $hierarchical_fields,
1542 'depends-on' => [
1543 'hierarchical' => true,
1544 ],
1545 'pick_format_single' => 'autocomplete',
1546 ],
1547 ];
1548 }//end if
1549
1550 // Only include kitchen sink if dev mode on and not running Codecept tests.
1551 if ( pods_developer() && ! function_exists( 'codecept_debug' ) ) {
1552 $options['kitchen-sink'] = json_decode( file_get_contents( PODS_DIR . 'tests/codeception/_data/kitchen-sink-config.json' ), true );
1553 }
1554
1555 $pod_type = $pod['type'];
1556 $pod_name = $pod['name'];
1557
1558 /**
1559 * Add admin fields to the Pods editor for a specific Pod.
1560 *
1561 * @param array $options The Options fields.
1562 * @param \Pods\Whatsit\Pod $pod Current Pods object.
1563 * @param array $tabs List of registered tabs.
1564 */
1565 $options = apply_filters( "pods_admin_setup_edit_options_{$pod_type}_{$pod_name}", $options, $pod, $tabs );
1566
1567 /**
1568 * Add admin fields to the Pods editor for any Pod of a specific content type.
1569 *
1570 * @param array $options The Options fields.
1571 * @param \Pods\Whatsit\Pod $pod Current Pods object.
1572 * @param array $tabs List of registered tabs.
1573 */
1574 $options = apply_filters( "pods_admin_setup_edit_options_{$pod_type}", $options, $pod, $tabs );
1575
1576 /**
1577 * Add admin fields to the Pods editor for all Pods.
1578 *
1579 * @param array $options The Options fields.
1580 * @param \Pods\Whatsit\Pod $pod Current Pods object.
1581 * @param array $tabs List of registered tabs.
1582 */
1583 $options = apply_filters( 'pods_admin_setup_edit_options', $options, $pod, $tabs );
1584
1585 return $options;
1586 }
1587 }
1588