PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 2.8.23.5
Pods – Custom Content Types and Fields v2.8.23.5
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 days ago Field.php 2 days ago Group.php 2 days ago Pod.php 2 days ago
Pod.php
1589 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' => $pod_name,
777 'text_placeholder' => $pod_name,
778 'depends-on' => [ 'capability_type' => 'custom' ],
779 ],
780 'capability_type_extra' => [
781 'label' => __( 'Additional User Capabilities', 'pods' ),
782 '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' ),
783 'type' => 'boolean',
784 'default' => true,
785 'boolean_yes_label' => '',
786 ],
787 'has_archive' => [
788 'label' => __( 'Enable Archive Page', 'pods' ),
789 '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' ),
790 'type' => 'boolean',
791 'default' => false,
792 'dependency' => true,
793 'boolean_yes_label' => '',
794 ],
795 'has_archive_slug' => [
796 'label' => __( 'Archive Page Slug Override', 'pods' ),
797 'help' => __( 'If archive page is enabled, you can override the slug used by WordPress, which defaults to the name of the post type.', 'pods' ),
798 'type' => 'text',
799 'slug_fallback' => '-',
800 'default' => '',
801 'depends-on' => [ 'has_archive' => true ],
802 ],
803 'hierarchical' => [
804 'label' => __( 'Hierarchical', 'pods' ),
805 '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' ),
806 'type' => 'boolean',
807 'default' => false,
808 'dependency' => true,
809 'boolean_yes_label' => '',
810 ],
811 'rewrite' => [
812 'label' => __( 'Rewrite', 'pods' ),
813 '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' ),
814 'type' => 'boolean',
815 'default' => true,
816 'dependency' => true,
817 'boolean_yes_label' => '',
818 ],
819 'rewrite_custom_slug' => [
820 'label' => __( 'Custom Rewrite Slug', 'pods' ),
821 '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' ),
822 'type' => 'text',
823 'slug_fallback' => '-',
824 'default' => '',
825 'depends-on' => [ 'rewrite' => true ],
826 ],
827 'rewrite_with_front' => [
828 'label' => __( 'Rewrite with Front', 'pods' ),
829 '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' ),
830 'type' => 'boolean',
831 'default' => true,
832 'depends-on' => [ 'rewrite' => true ],
833 'boolean_yes_label' => '',
834 ],
835 'rewrite_feeds' => [
836 'label' => __( 'Rewrite Feeds', 'pods' ),
837 'help' => __( 'help', 'pods' ),
838 'type' => 'boolean',
839 'default' => false,
840 'depends-on' => [ 'rewrite' => true ],
841 'boolean_yes_label' => '',
842 ],
843 'rewrite_pages' => [
844 'label' => __( 'Rewrite Pages', 'pods' ),
845 'help' => __( 'help', 'pods' ),
846 'type' => 'boolean',
847 'default' => true,
848 'depends-on' => [ 'rewrite' => true ],
849 'boolean_yes_label' => '',
850 ],
851 'query_var' => [
852 'label' => __( 'Query Var', 'pods' ),
853 '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' ),
854 'type' => 'boolean',
855 'default' => true,
856 'boolean_yes_label' => '',
857 ],
858 'can_export' => [
859 'label' => __( 'Exportable', 'pods' ),
860 'help' => __( 'help', 'pods' ),
861 'type' => 'boolean',
862 'default' => true,
863 'boolean_yes_label' => '',
864 ],
865 'default_status' => [
866 'label' => __( 'Default Status', 'pods' ),
867 'help' => __( 'help', 'pods' ),
868 'type' => 'pick',
869 'pick_object' => 'post-status',
870 'default' => $default_post_status,
871 'pick_show_select_text' => 0,
872 ],
873 'post_type_supports' => [
874 'name' => 'post_type_supports',
875 'type' => 'boolean_group',
876 'label' => __( 'Supports', 'pods' ),
877 'boolean_group' => [
878 'supports_title' => [
879 'name' => 'supports_title',
880 'label' => __( 'Title', 'pods' ),
881 'type' => 'boolean',
882 ],
883 'supports_editor' => [
884 'name' => 'supports_editor',
885 'label' => __( 'Editor', 'pods' ),
886 'type' => 'boolean',
887 ],
888 'supports_author' => [
889 'name' => 'supports_author',
890 'label' => __( 'Author', 'pods' ),
891 'type' => 'boolean',
892 ],
893 'supports_thumbnail' => [
894 'name' => 'supports_thumbnail',
895 'label' => __( 'Featured Image', 'pods' ),
896 'type' => 'boolean',
897 'dependency' => true,
898 ],
899 'supports_excerpt' => [
900 'name' => 'supports_excerpt',
901 'label' => __( 'Excerpt', 'pods' ),
902 'type' => 'boolean',
903 ],
904 'supports_trackbacks' => [
905 'name' => 'supports_trackbacks',
906 'label' => __( 'Trackbacks', 'pods' ),
907 'type' => 'boolean',
908 ],
909 'supports_custom_fields' => [
910 'name' => 'supports_custom_fields',
911 'label' => __( 'Manually Edit Custom Fields (can cause slow performance)', 'pods' ),
912 'type' => 'boolean',
913 ],
914 'supports_comments' => [
915 'name' => 'supports_comments',
916 'label' => __( 'Comments', 'pods' ),
917 'type' => 'boolean',
918 ],
919 'supports_revisions' => [
920 'name' => 'supports_revisions',
921 'label' => __( 'Revisions', 'pods' ),
922 'type' => 'boolean',
923 ],
924 'supports_page_attributes' => [
925 'name' => 'supports_page_attributes',
926 'label' => __( 'Page Attributes', 'pods' ),
927 'type' => 'boolean',
928 ],
929 'supports_post_formats' => [
930 'name' => 'supports_post_formats',
931 'label' => __( 'Post Formats', 'pods' ),
932 'type' => 'boolean',
933 ],
934 ],
935 ],
936 'supports_custom' => [
937 'name' => 'supports_custom',
938 'type' => 'text',
939 'label' => __( 'Advanced Supports', 'pods' ),
940 'help' => __( 'Comma-separated list of custom "supports" values to pass to register_post_type.', 'pods' ),
941 ],
942 'revisions_to_keep_limit' => [
943 'name' => 'revisions_to_keep_limit',
944 'type' => 'number',
945 'default' => '0',
946 'label' => __( 'Maximum revisions to keep per post', 'pods' ),
947 'description' => __( 'The default "0" will fallback to the normal WordPress default.', 'pods' ),
948 'help' => __( 'Enter -1 to keep ALL revisions. Enter any positive number to limit the number of revisions kept to that amount.', 'pods' ),
949 'depends-on' => [ 'supports_revisions' => true ],
950 ],
951 'delete_with_user' => [
952 'label' => __( 'Allow posts to be deleted when author is deleted', 'pods' ),
953 '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' ),
954 'type' => 'boolean',
955 'default' => true,
956 'boolean_yes_label' => __( 'Include posts from this post type when deleting authors and choosing not to reassign posts to a new author.', 'pods' ),
957 ],
958 ];
959
960 /**
961 * Allow filtering the list of supported features for the post type
962 *
963 * @since 2.8.0
964 *
965 * @param array $supports The list of supported features for the post type.
966 * @param array $options The Options fields.
967 * @param \Pods\Whatsit\Pod $pod Current Pods object.
968 * @param array $tabs List of registered tabs.
969 */
970 $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 );
971
972 $related_objects = PodsForm::field_method( 'pick', 'related_objects', true );
973
974 $available_taxonomies = [];
975
976 if ( ! empty( $related_objects[ __( 'Taxonomies', 'pods' ) ] ) ) {
977 $available_taxonomies = (array) $related_objects[ __( 'Taxonomies', 'pods' ) ];
978 }
979
980 foreach ( $available_taxonomies as $taxonomy => $label ) {
981 $taxonomy = pods_str_replace( 'taxonomy-', '', $taxonomy, 1 );
982
983 $field_name = 'built_in_taxonomies_' . $taxonomy;
984
985 $options['connections']['post_type_built_in_taxonomies']['boolean_group'][ $field_name ] = [
986 'name' => $field_name,
987 'label' => $label,
988 'type' => 'boolean',
989 ];
990
991 if ( 'category' === $taxonomy || 'post_tag' === $taxonomy ) {
992 $field_name = 'archive_show_in_taxonomies_' . $taxonomy;
993
994 $options['connections']['archive_show_in_taxonomies']['boolean_group'][ $field_name ] = [
995 'name' => $field_name,
996 'label' => $label,
997 'type' => 'boolean',
998 ];
999 }
1000 }
1001 } elseif ( 'taxonomy' === $pod_type ) {
1002 $options['admin-ui'] = [
1003 'description' => [
1004 'label' => __( 'Taxonomy Description', 'pods' ),
1005 'help' => __( 'A short descriptive summary of what the taxonomy is.', 'pods' ),
1006 'type' => 'text',
1007 'default' => '',
1008 ],
1009 'show_ui' => [
1010 'label' => __( 'Show Admin UI', 'pods' ),
1011 'help' => __( 'Whether to generate a default UI for managing this taxonomy.', 'pods' ),
1012 'type' => 'boolean',
1013 'default' => pods_v( 'public', $pod, true ),
1014 'dependency' => true,
1015 'boolean_yes_label' => '',
1016 ],
1017 'show_in_menu' => [
1018 'label' => __( 'Show Admin Menu in Dashboard', 'pods' ),
1019 'help' => __( 'Whether to show the taxonomy in the admin menu.', 'pods' ),
1020 'type' => 'boolean',
1021 'default' => pods_v( 'public', $pod, true ),
1022 'dependency' => true,
1023 'depends-on' => [ 'show_ui' => true ],
1024 'boolean_yes_label' => '',
1025 ],
1026 'menu_name' => [
1027 'label' => __( 'Menu Name', 'pods' ),
1028 'help' => __( 'help', 'pods' ),
1029 'type' => 'text',
1030 'default' => '',
1031 'depends-on' => [ 'show_ui' => true ],
1032 ],
1033 'menu_location' => [
1034 'label' => __( 'Menu Location', 'pods' ),
1035 'help' => __( 'help', 'pods' ),
1036 'type' => 'pick',
1037 'default' => 'default',
1038 'depends-on' => [ 'show_ui' => true ],
1039 'data' => [
1040 'default' => __( 'Default - Add to associated Post Type(s) menus', 'pods' ),
1041 'settings' => __( 'Add a submenu item to Settings menu', 'pods' ),
1042 'appearances' => __( 'Add a submenu item to Appearances menu', 'pods' ),
1043 'submenu' => __( 'Add a submenu item to another menu', 'pods' ),
1044 'objects' => __( 'Make a new menu item', 'pods' ),
1045 'top' => __( 'Make a new menu item below Settings', 'pods' ),
1046 ],
1047 'pick_show_select_text' => 0,
1048 'dependency' => true,
1049 ],
1050 'menu_location_custom' => [
1051 'label' => __( 'Custom Menu Location', 'pods' ),
1052 'help' => __( 'help', 'pods' ),
1053 'type' => 'text',
1054 'depends-on' => [ 'menu_location' => 'submenu' ],
1055 ],
1056 'menu_position' => [
1057 'label' => __( 'Menu Position', 'pods' ),
1058 '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' ),
1059 'type' => 'number',
1060 'number_decimals' => 2,
1061 'number_format' => '9999.99',
1062 'number_format_soft' => 1,
1063 'default' => 0,
1064 'depends-on' => [ 'menu_location' => [ 'objects', 'top' ] ],
1065 ],
1066 'menu_icon' => [
1067 'label' => __( 'Menu Icon URL', 'pods' ),
1068 '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' ),
1069 'type' => 'text',
1070 'default' => '',
1071 'depends-on' => [ 'menu_location' => [ 'objects', 'top' ] ],
1072 ],
1073 'show_in_nav_menus' => [
1074 'label' => __( 'Show in Navigation Menus', 'pods' ),
1075 'help' => __( 'help', 'pods' ),
1076 'type' => 'boolean',
1077 'default' => pods_v( 'public', $pod, true ),
1078 'boolean_yes_label' => '',
1079 ],
1080 'show_tagcloud' => [
1081 'label' => __( 'Allow in Tag Cloud Widget', 'pods' ),
1082 'help' => __( 'help', 'pods' ),
1083 'type' => 'boolean',
1084 'default' => pods_v( 'show_ui', $pod, pods_v( 'public', $pod, true ) ),
1085 'boolean_yes_label' => '',
1086 ],
1087 // @todo check https://core.trac.wordpress.org/ticket/36964
1088 'show_tagcloud_in_edit' => [
1089 'label' => __( 'Allow Tag Cloud on term edit pages', 'pods' ),
1090 'help' => __( 'help', 'pods' ),
1091 'type' => 'boolean',
1092 'default' => pods_v( 'show_ui', $pod, pods_v( 'show_tagcloud', $pod, true ) ),
1093 'boolean_yes_label' => '',
1094 ],
1095 'show_in_quick_edit' => [
1096 'label' => __( 'Allow in quick/bulk edit panel', 'pods' ),
1097 'help' => __( 'help', 'pods' ),
1098 'type' => 'boolean',
1099 'default' => pods_v( 'show_ui', $pod, pods_v( 'public', $pod, true ) ),
1100 'boolean_yes_label' => '',
1101 ],
1102 ];
1103
1104 $options['admin-ui']['show_admin_column'] = [
1105 'label' => __( 'Show Taxonomy column on Post Types', 'pods' ),
1106 'help' => __( 'Whether to add a column for this taxonomy on the associated post types manage screens', 'pods' ),
1107 'type' => 'boolean',
1108 'default' => false,
1109 'boolean_yes_label' => '',
1110 ];
1111
1112 // Integration for Single Value Taxonomy UI
1113 if ( function_exists( 'tax_single_value_meta_box' ) ) {
1114 $options['admin-ui']['single_value'] = [
1115 'label' => __( 'Single Value Taxonomy', 'pods' ),
1116 'help' => __( 'Use a drop-down for the input instead of the WordPress default', 'pods' ),
1117 'type' => 'boolean',
1118 'default' => false,
1119 'boolean_yes_label' => '',
1120 ];
1121
1122 $options['admin-ui']['single_value_required'] = [
1123 'label' => __( 'Single Value Taxonomy - Required', 'pods' ),
1124 'help' => __( 'A term will be selected by default in the Post Editor, not optional', 'pods' ),
1125 'type' => 'boolean',
1126 'default' => false,
1127 'boolean_yes_label' => '',
1128 ];
1129 }
1130
1131 $options['connections'] = [
1132 'taxonomy_associated_post_types' => [
1133 'name' => 'taxonomy_associated_post_types',
1134 'label' => __( 'Enable Connections to Post Types', 'pods' ),
1135 'help' => __( 'You can enable the ability to select posts from these post types on any term for this taxonomy.', 'pods' ),
1136 'type' => 'boolean_group',
1137 'boolean_group' => [],
1138 ],
1139 'register_custom_post_type' => [
1140 'name' => 'register_custom_post_type',
1141 'label' => __( 'Add new connection', 'pods' ),
1142 'type' => 'html',
1143 'html_content' => sprintf(
1144 '<a href="%1$s">%2$s</a>',
1145 esc_url( admin_url( 'admin.php?page=pods-add-new&create_extend=create&type=post_type' ) ),
1146 esc_html__( 'Create a new Custom Post Type', 'pods' )
1147 ),
1148 ],
1149 ];
1150
1151 $options['advanced'] = [
1152 'public' => [
1153 'label' => __( 'Public', 'pods' ),
1154 'help' => __( 'help', 'pods' ),
1155 'type' => 'boolean',
1156 'default' => true,
1157 'boolean_yes_label' => '',
1158 ],
1159 'hierarchical' => [
1160 'label' => __( 'Hierarchical', 'pods' ),
1161 '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' ),
1162 'type' => 'boolean',
1163 'default' => true,
1164 'dependency' => true,
1165 'boolean_yes_label' => '',
1166 ],
1167 'rewrite' => [
1168 'label' => __( 'Rewrite', 'pods' ),
1169 'help' => __( 'help', 'pods' ),
1170 'type' => 'boolean',
1171 'default' => true,
1172 'dependency' => true,
1173 'boolean_yes_label' => '',
1174 ],
1175 'rewrite_custom_slug' => [
1176 'label' => __( 'Custom Rewrite Slug', 'pods' ),
1177 'help' => __( 'help', 'pods' ),
1178 'type' => 'text',
1179 'slug_fallback' => '-',
1180 'default' => '',
1181 'depends-on' => [ 'rewrite' => true ],
1182 ],
1183 'rewrite_with_front' => [
1184 'label' => __( 'Rewrite with Front', 'pods' ),
1185 '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' ),
1186 'type' => 'boolean',
1187 'default' => true,
1188 'boolean_yes_label' => '',
1189 'depends-on' => [ 'rewrite' => true ],
1190 ],
1191 'rewrite_hierarchical' => [
1192 'label' => __( 'Hierarchical Permalinks', 'pods' ),
1193 'help' => __( 'help', 'pods' ),
1194 'type' => 'boolean',
1195 'default' => true,
1196 'boolean_yes_label' => '',
1197 'depends-on' => [ 'rewrite' => true ],
1198 ],
1199 'capability_type' => [
1200 'label' => __( 'User Capability', 'pods' ),
1201 'help' => __( 'Uses WordPress term capabilities by default', 'pods' ),
1202 'type' => 'pick',
1203 'default' => 'default',
1204 'data' => [
1205 'default' => 'Default',
1206 'custom' => __( 'Custom Capability', 'pods' ),
1207 ],
1208 'pick_show_select_text' => 0,
1209 'dependency' => true,
1210 ],
1211 'capability_type_custom' => [
1212 'label' => __( 'Custom User Capability', 'pods' ),
1213 'help' => __( 'Enables additional capabilities for this Taxonomy including: manage_{capability}_terms, edit_{capability}_terms, assign_{capability}_terms, and delete_{capability}_terms', 'pods' ),
1214 'type' => 'text',
1215 'default' => pods_v( 'name', $pod ),
1216 'depends-on' => [ 'capability_type' => 'custom' ],
1217 ],
1218 'query_var' => [
1219 'label' => __( 'Query Var', 'pods' ),
1220 'help' => __( 'help', 'pods' ),
1221 'type' => 'boolean',
1222 'default' => false,
1223 'boolean_yes_label' => '',
1224 ],
1225 'query_var' => [
1226 'label' => __( 'Query Var', 'pods' ),
1227 'help' => __( 'help', 'pods' ),
1228 'type' => 'boolean',
1229 'default' => false,
1230 'dependency' => true,
1231 'boolean_yes_label' => '',
1232 ],
1233 'query_var_string' => [
1234 'label' => __( 'Custom Query Var Name', 'pods' ),
1235 'help' => __( 'help', 'pods' ),
1236 'type' => 'text',
1237 'default' => '',
1238 'depends-on' => [ 'query_var' => true ],
1239 ],
1240 'sort' => [
1241 'label' => __( 'Remember order saved on Post Types', 'pods' ),
1242 'help' => __( 'help', 'pods' ),
1243 'type' => 'boolean',
1244 'default' => false,
1245 'boolean_yes_label' => '',
1246 ],
1247 'update_count_callback' => [
1248 'label' => __( 'Function to call when updating counts', 'pods' ),
1249 'help' => __( 'help', 'pods' ),
1250 'type' => 'text',
1251 'default' => '',
1252 ],
1253 'default_term_name' => [
1254 'label' => __( 'Default term name', 'pods' ),
1255 'type' => 'text',
1256 'default' => '',
1257 'dependency' => true,
1258 ],
1259 'default_term_slug' => [
1260 'label' => __( 'Default term slug', 'pods' ),
1261 'type' => 'text',
1262 'default' => '',
1263 'excludes-on' => [ 'default_term_name' => '' ],
1264 ],
1265 'default_term_description' => [
1266 'label' => __( 'Default term description', 'pods' ),
1267 'type' => 'wysiwyg',
1268 'default' => '',
1269 'excludes-on' => [ 'default_term_name' => '' ],
1270 ],
1271 ];
1272
1273 $related_objects = PodsForm::field_method( 'pick', 'related_objects', true );
1274
1275 $available_post_types = [];
1276
1277 if ( ! empty( $related_objects[ __( 'Post Types', 'pods' ) ] ) ) {
1278 $available_post_types = (array) $related_objects[ __( 'Post Types', 'pods' ) ];
1279 }
1280
1281 foreach ( $available_post_types as $post_type => $label ) {
1282 $post_type = pods_str_replace( 'post_type-', '', $post_type, 1 );
1283
1284 $field_name = 'built_in_post_types_' . $post_type;
1285
1286 $options['connections']['taxonomy_associated_post_types']['boolean_group'][ $field_name ] = [
1287 'name' => $field_name,
1288 'label' => $label,
1289 'type' => 'boolean',
1290 ];
1291 }
1292
1293 $options['connections']['taxonomy_associated_post_types']['boolean_group']['built_in_post_types_attachment'] = [
1294 'name' => 'built_in_post_types_attachment',
1295 'label' => __( 'Media', 'pods' ) . ' (attachment)',
1296 'type' => 'boolean',
1297 ];
1298 } elseif ( 'settings' === $pod_type ) {
1299 $options['admin-ui'] = [
1300 'ui_style' => [
1301 'label' => __( 'Admin UI Style', 'pods' ),
1302 'help' => __( 'help', 'pods' ),
1303 'type' => 'pick',
1304 'default' => 'settings',
1305 'data' => [
1306 'settings' => __( 'Normal Settings Form', 'pods' ),
1307 'post_type' => __( 'Post Type UI', 'pods' ),
1308 'custom' => __( 'Custom (hook into pods_admin_ui_custom or pods_admin_ui_custom_{podname} action)', 'pods' ),
1309 ],
1310 'dependency' => true,
1311 ],
1312 'menu_location' => [
1313 'label' => __( 'Menu Location', 'pods' ),
1314 'help' => __( 'help', 'pods' ),
1315 'type' => 'pick',
1316 'default' => 'settings',
1317 'data' => [
1318 'settings' => __( 'Add a submenu item to Settings menu', 'pods' ),
1319 'appearances' => __( 'Add a submenu item to Appearances menu', 'pods' ),
1320 'submenu' => __( 'Add a submenu item to another menu', 'pods' ),
1321 'top' => __( 'Make a new menu item below Settings', 'pods' ),
1322 ],
1323 'dependency' => true,
1324 ],
1325 'menu_location_custom' => [
1326 'label' => __( 'Custom Menu Location', 'pods' ),
1327 'help' => __( 'help', 'pods' ),
1328 'type' => 'text',
1329 'depends-on' => [ 'menu_location' => 'submenu' ],
1330 ],
1331 'menu_position' => [
1332 'label' => __( 'Menu Position', 'pods' ),
1333 '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' ),
1334 'type' => 'number',
1335 'number_decimals' => 2,
1336 'number_format' => '9999.99',
1337 'number_format_soft' => 1,
1338 'default' => 0,
1339 'depends-on' => [ 'menu_location' => 'top' ],
1340 ],
1341 'menu_icon' => [
1342 'label' => __( 'Menu Icon URL', 'pods' ),
1343 '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' ),
1344 'type' => 'text',
1345 'default' => '',
1346 'depends-on' => [ 'menu_location' => 'top' ],
1347 ],
1348 ];
1349
1350 // @todo fill this in
1351 $options['advanced'] = [
1352 'temporary' => 'This type has the fields hardcoded',
1353 // :(
1354 ];
1355 } elseif ( 'pod' === $pod_type ) {
1356 $actions_enabled = [
1357 'add',
1358 'edit',
1359 'duplicate',
1360 'delete',
1361 ];
1362
1363 if ( 1 === (int) pods_v( 'ui_export', $pod ) ) {
1364 $actions_enabled = [
1365 'add',
1366 'edit',
1367 'duplicate',
1368 'delete',
1369 'export',
1370 ];
1371 }
1372
1373 $options['admin-ui'] = [
1374 'ui_style' => [
1375 'label' => __( 'Admin UI Style', 'pods' ),
1376 'help' => __( 'help', 'pods' ),
1377 'type' => 'pick',
1378 'default' => 'settings',
1379 'data' => [
1380 'post_type' => __( 'Normal (Looks like the Post Type UI)', 'pods' ),
1381 'custom' => __( 'Custom (hook into pods_admin_ui_custom or pods_admin_ui_custom_{podname} action)', 'pods' ),
1382 ],
1383 'dependency' => true,
1384 ],
1385 'show_in_menu' => [
1386 'label' => __( 'Show Admin Menu in Dashboard', 'pods' ),
1387 'help' => __( 'help', 'pods' ),
1388 'type' => 'boolean',
1389 'default' => false,
1390 'boolean_yes_label' => '',
1391 'dependency' => true,
1392 ],
1393 'menu_location_custom' => [
1394 'label' => __( 'Parent Menu ID (optional)', 'pods' ),
1395 'help' => __( 'help', 'pods' ),
1396 'type' => 'text',
1397 'depends-on' => [ 'show_in_menu' => true ],
1398 ],
1399 'menu_position' => [
1400 'label' => __( 'Menu Position', 'pods' ),
1401 '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' ),
1402 'type' => 'number',
1403 'number_decimals' => 2,
1404 'number_format' => '9999.99',
1405 'number_format_soft' => 1,
1406 'default' => 0,
1407 'depends-on' => [ 'show_in_menu' => true ],
1408 ],
1409 'menu_icon' => [
1410 'label' => __( 'Menu Icon URL', 'pods' ),
1411 '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' ),
1412 'type' => 'text',
1413 'default' => '',
1414 'depends-on' => [ 'show_in_menu' => true ],
1415 ],
1416 'ui_icon' => [
1417 'label' => __( 'Header Icon', 'pods' ),
1418 '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' ),
1419 'type' => 'file',
1420 'default' => '',
1421 'file_edit_title' => 0,
1422 'depends-on' => [ 'show_in_menu' => true ],
1423 ],
1424 'ui_actions_enabled' => [
1425 'label' => __( 'Actions Available', 'pods' ),
1426 'help' => __( 'help', 'pods' ),
1427 'type' => 'pick',
1428 'default' => $actions_enabled,
1429 'data' => [
1430 'add' => __( 'Add New', 'pods' ),
1431 'edit' => __( 'Edit', 'pods' ),
1432 'duplicate' => __( 'Duplicate', 'pods' ),
1433 'delete' => __( 'Delete', 'pods' ),
1434 'reorder' => __( 'Reorder', 'pods' ),
1435 'export' => __( 'Export', 'pods' ),
1436 ],
1437 'pick_format_type' => 'multi',
1438 'dependency' => true,
1439 ],
1440 'ui_reorder_field' => [
1441 'label' => __( 'Reorder Field', 'pods' ),
1442 'help' => __( 'This is the field that will be reordered on, it should be numeric.', 'pods' ),
1443 'type' => 'text',
1444 'default' => 'menu_order',
1445 'depends-on' => [ 'ui_actions_enabled' => 'reorder' ],
1446 ],
1447 'ui_fields_manage' => [
1448 'label' => __( 'Admin Table Columns', 'pods' ),
1449 'help' => __( 'help', 'pods' ),
1450 'type' => 'pick',
1451 'default' => [],
1452 'data' => [],
1453 'pick_format_type' => 'multi',
1454 ],
1455 'ui_filters' => [
1456 'label' => __( 'Search Filters', 'pods' ),
1457 'help' => __( 'help', 'pods' ),
1458 'type' => 'pick',
1459 'default' => [],
1460 'data' => [],
1461 'pick_format_type' => 'multi',
1462 ],
1463 ];
1464
1465 if ( ! empty( $pod['fields'] ) ) {
1466 if ( isset( $pod['fields'][ pods_v( 'pod_index', $pod, 'name' ) ] ) ) {
1467 $options['admin-ui']['ui_fields_manage']['default'][] = pods_v( 'pod_index', $pod, 'name' );
1468 }
1469
1470 if ( isset( $pod['fields']['modified'] ) ) {
1471 $options['admin-ui']['ui_fields_manage']['default'][] = 'modified';
1472 }
1473
1474 foreach ( $pod['fields'] as $field ) {
1475 $type = '';
1476
1477 if ( isset( $field_types[ $field['type'] ] ) ) {
1478 $type = ' <small>(' . $field_types[ $field['type'] ]['label'] . ')</small>';
1479 }
1480
1481 $options['admin-ui']['ui_fields_manage']['data'][ $field['name'] ] = $field['label'] . $type;
1482 $options['admin-ui']['ui_filters']['data'][ $field['name'] ] = $field['label'] . $type;
1483 }
1484
1485 $options['admin-ui']['ui_fields_manage']['data']['id'] = 'ID';
1486 } else {
1487 unset( $options['admin-ui']['ui_fields_manage'] );
1488 unset( $options['admin-ui']['ui_filters'] );
1489 }//end if
1490
1491 $index_fields = [
1492 'id' => 'ID',
1493 ];
1494
1495 $hierarchical_fields = [];
1496
1497 foreach ( $pod['fields'] as $field ) {
1498 if ( ! in_array( $field['type'], $tableless_field_types, true ) ) {
1499 $index_fields[ $field['name'] ] = $field['label'];
1500 }
1501
1502 if ( 'pick' == $field['type'] && 'pod' === pods_v( 'pick_object', $field ) && $pod['name'] === pods_v( 'pick_val', $field ) && 'single' === pods_v( 'pick_format_type', $field ) ) {
1503 $hierarchical_fields[ $field['name'] ] = $field['label'];
1504 }
1505 }
1506
1507 // Set empty message if none found.
1508 if ( empty( $hierarchical_fields ) ) {
1509 $hierarchical_fields = [
1510 '' => __( 'No Hierarchical Fields found', 'pods' ),
1511 ];
1512 }
1513
1514 $options['advanced'] = [
1515 'detail_url' => [
1516 'label' => __( 'Detail Page URL', 'pods' ),
1517 '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' ),
1518 'type' => 'text',
1519 'text_placeholder' => 'my-pod-page/{@permalink}/',
1520 ],
1521 'pod_index' => [
1522 'label' => __( 'Title Field', 'pods' ),
1523 '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' ),
1524 'default' => 'name',
1525 'type' => 'pick',
1526 'data' => $index_fields,
1527 'pick_format_single' => 'autocomplete',
1528 ],
1529 'hierarchical' => [
1530 'label' => __( 'Hierarchical', 'pods' ),
1531 'help' => __( 'You can enable automatic hierarchical parent / child handling which shows a special built-in interface for data entry.', 'pods' ),
1532 'default' => 0,
1533 'type' => 'boolean',
1534 'dependency' => true,
1535 'boolean_yes_label' => '',
1536 ],
1537 'pod_parent' => [
1538 'label' => __( 'Hierarchical Parent Field', 'pods' ),
1539 'help' => __( 'You can enable automatic hierarchical parent / child handling which shows a special built-in interface for data entry.', 'pods' ),
1540 'default' => 'parent',
1541 'type' => 'pick',
1542 'data' => $hierarchical_fields,
1543 'depends-on' => [
1544 'hierarchical' => true,
1545 ],
1546 'pick_format_single' => 'autocomplete',
1547 ],
1548 ];
1549 }//end if
1550
1551 // Only include kitchen sink if dev mode on and not running Codecept tests.
1552 if ( pods_developer() && ! function_exists( 'codecept_debug' ) ) {
1553 $options['kitchen-sink'] = json_decode( file_get_contents( PODS_DIR . 'tests/codeception/_data/kitchen-sink-config.json' ), true );
1554 }
1555
1556 $pod_type = $pod['type'];
1557 $pod_name = $pod['name'];
1558
1559 /**
1560 * Add admin fields to the Pods editor for a specific Pod.
1561 *
1562 * @param array $options The Options fields.
1563 * @param \Pods\Whatsit\Pod $pod Current Pods object.
1564 * @param array $tabs List of registered tabs.
1565 */
1566 $options = apply_filters( "pods_admin_setup_edit_options_{$pod_type}_{$pod_name}", $options, $pod, $tabs );
1567
1568 /**
1569 * Add admin fields to the Pods editor for any Pod of a specific content type.
1570 *
1571 * @param array $options The Options fields.
1572 * @param \Pods\Whatsit\Pod $pod Current Pods object.
1573 * @param array $tabs List of registered tabs.
1574 */
1575 $options = apply_filters( "pods_admin_setup_edit_options_{$pod_type}", $options, $pod, $tabs );
1576
1577 /**
1578 * Add admin fields to the Pods editor for all Pods.
1579 *
1580 * @param array $options The Options fields.
1581 * @param \Pods\Whatsit\Pod $pod Current Pods object.
1582 * @param array $tabs List of registered tabs.
1583 */
1584 $options = apply_filters( 'pods_admin_setup_edit_options', $options, $pod, $tabs );
1585
1586 return $options;
1587 }
1588 }
1589