PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 2.9.19.5
Pods – Custom Content Types and Fields v2.9.19.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
1647 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_back_to_items' => [
479 'label' => __( 'Back to %s', '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_name_field_description' => [
488 'label' => __( 'The name is how it appears on your site.', 'pods' ),
489 'help' => __( 'help', 'pods' ),
490 'type' => 'text',
491 'default' => '',
492 'description' => __( 'Description for the Name field on Edit Tags screen.', 'pods' ),
493 'object_type' => [ 'taxonomy' ],
494 ],
495 'label_parent_field_description' => [
496 'label' => __( 'Assign a parent term to create a hierarchy.', 'pods' ),
497 'help' => __( 'help', 'pods' ),
498 'type' => 'text',
499 'default' => '',
500 'description' => __( 'Description for the Parent field on Edit Tags screen.', 'pods' ),
501 'object_type' => [ 'taxonomy' ],
502 ],
503 'label_slug_field_description' => [
504 'label' => __( 'The "slug" is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'pods' ),
505 'help' => __( 'help', 'pods' ),
506 'type' => 'text',
507 'default' => '',
508 'description' => __( 'Description for the Slug field on Edit Tags screen.', 'pods' ),
509 'object_type' => [ 'taxonomy' ],
510 ],
511 'label_desc_field_description' => [
512 'label' => __( 'The description is not prominent by default; however, some themes may show it.', 'pods' ),
513 'help' => __( 'help', 'pods' ),
514 'type' => 'text',
515 'default' => '',
516 'description' => __( 'Description for the Description field on Edit Tags screen.', 'pods' ),
517 'object_type' => [ 'taxonomy' ],
518 ],
519 'label_separate_items_with_commas' => [
520 'label' => __( 'Separate %s with commas', 'pods' ),
521 'label_param' => 'label',
522 'label_param_default' => __( 'items', 'pods' ),
523 'help' => __( 'help', 'pods' ),
524 'type' => 'text',
525 'default' => '',
526 'object_type' => [ 'taxonomy' ],
527 ],
528 'label_add_or_remove_items' => [
529 'label' => __( 'Add or remove %s', 'pods' ),
530 'label_param' => 'label',
531 'label_param_default' => __( 'items', 'pods' ),
532 'help' => __( 'help', 'pods' ),
533 'type' => 'text',
534 'default' => '',
535 'object_type' => [ 'taxonomy' ],
536 ],
537 'label_choose_from_the_most_used' => [
538 'label' => __( 'Choose from the most used %s', 'pods' ),
539 'label_param' => 'label',
540 'label_param_default' => __( 'items', 'pods' ),
541 'help' => __( 'help', 'pods' ),
542 'type' => 'text',
543 'default' => '',
544 'object_type' => [ 'taxonomy' ],
545 ],
546 'label_no_terms' => [
547 'label' => __( 'No %s', 'pods' ),
548 'label_param' => 'label',
549 'label_param_default' => __( 'items', 'pods' ),
550 'help' => __( 'help', 'pods' ),
551 'type' => 'text',
552 'default' => '',
553 'object_type' => [ 'taxonomy' ],
554 ],
555 'label_item_published' => [
556 'label' => __( '%s Published.', 'pods' ),
557 'label_param' => 'label_singular',
558 'label_param_default' => __( 'Item', 'pods' ),
559 'help' => __( 'help', 'pods' ),
560 'type' => 'text',
561 'default' => '',
562 'object_type' => [ 'post_type' ],
563 ],
564 'label_item_published_privately' => [
565 'label' => __( '%s published privately.', 'pods' ),
566 'label_param' => 'label_singular',
567 'label_param_default' => __( 'Item', 'pods' ),
568 'help' => __( 'help', 'pods' ),
569 'type' => 'text',
570 'default' => '',
571 'object_type' => [ 'post_type' ],
572 ],
573 'label_item_reverted_to_draft' => [
574 'label' => __( '%s reverted to draft.', 'pods' ),
575 'label_param' => 'label_singular',
576 'label_param_default' => __( 'Item', 'pods' ),
577 'help' => __( 'help', 'pods' ),
578 'type' => 'text',
579 'default' => '',
580 'object_type' => [ 'post_type' ],
581 ],
582 'label_item_scheduled' => [
583 'label' => __( '%s scheduled.', 'pods' ),
584 'label_param' => 'label_singular',
585 'label_param_default' => __( 'Item', 'pods' ),
586 'help' => __( 'help', 'pods' ),
587 'type' => 'text',
588 'default' => '',
589 'object_type' => [ 'post_type' ],
590 ],
591 'label_item_updated' => [
592 'label' => __( '%s updated.', 'pods' ),
593 'label_param' => 'label_singular',
594 'label_param_default' => __( 'Item', 'pods' ),
595 'help' => __( 'help', 'pods' ),
596 'type' => 'text',
597 'default' => '',
598 'object_type' => [ 'post_type' ],
599 ],
600 'filter_by_date' => [
601 'label' => __( 'Filter by date', 'pods' ),
602 'help' => __( 'help', 'pods' ),
603 'type' => 'text',
604 'default' => '',
605 'object_type' => [ 'post_type' ],
606 ],
607 'filter_by_item' => [
608 'label' => __( 'Filter by %s', 'pods' ),
609 'label_param' => 'label_singular',
610 'label_param_default' => __( 'Item', 'pods' ),
611 'help' => __( 'help', 'pods' ),
612 'type' => 'text',
613 'default' => '',
614 'object_type' => [ 'taxonomy' ],
615 ],
616 ];
617
618 $options['labels'] = [];
619
620 /**
621 * Filter through all labels if they have an object_type set and match it against the current object type
622 */
623 foreach ( $labels as $label => $label_data ) {
624 if ( array_key_exists( 'object_type', $label_data ) ) {
625 if ( in_array( $pod_type, $label_data['object_type'], true ) ) {
626 // Do not add the object_type to the actual label data
627 unset( $label_data['object_type'] );
628
629 $options['labels'][ $label ] = $label_data;
630 }
631 } else {
632 $options['labels'][ $label ] = $label_data;
633 }
634 }
635 } elseif ( 'settings' === $pod_type ) {
636 $options['labels'] = [
637 'label' => [
638 'label' => __( 'Page Title', 'pods' ),
639 'help' => __( 'help', 'pods' ),
640 'type' => 'text',
641 'default' => str_replace( '_', ' ', pods_v( 'name', $pod ) ),
642 'text_max_length' => 30,
643 ],
644 'menu_name' => [
645 'label' => __( 'Menu Name', 'pods' ),
646 'help' => __( 'help', 'pods' ),
647 'type' => 'text',
648 'default' => pods_v( 'label', $pod, ucwords( str_replace( '_', ' ', pods_v( 'name', $pod ) ) ) ),
649 'text_max_length' => 30,
650 ],
651 ];
652 }//end if
653
654 if ( 'post_type' === $pod_type ) {
655 $options['admin-ui'] = [
656 'description' => [
657 'label' => __( 'Post Type Description', 'pods' ),
658 'help' => __( 'A short descriptive summary of what the post type is.', 'pods' ),
659 'type' => 'text',
660 'default' => '',
661 ],
662 'show_ui' => [
663 'label' => __( 'Show Admin UI', 'pods' ),
664 'help' => __( 'Whether to generate a default UI for managing this post type in the admin.', 'pods' ),
665 'type' => 'boolean',
666 'default' => pods_v( 'public', $pod, true ),
667 'boolean_yes_label' => '',
668 ],
669 'show_in_menu' => [
670 'label' => __( 'Show Admin Menu in Dashboard', 'pods' ),
671 'help' => __( 'Whether to show the post type in the admin menu.', 'pods' ),
672 'type' => 'boolean',
673 'default' => pods_v( 'public', $pod, true ),
674 'dependency' => true,
675 'boolean_yes_label' => '',
676 ],
677 'menu_location_custom' => [
678 'label' => __( 'Parent Menu ID (optional)', 'pods' ),
679 'help' => __( 'help', 'pods' ),
680 'type' => 'text',
681 'depends-on' => [ 'show_in_menu' => true ],
682 ],
683 'menu_name' => [
684 'label' => __( 'Menu Name', 'pods' ),
685 'help' => __( 'help', 'pods' ),
686 'type' => 'text',
687 'default' => '',
688 'depends-on' => [ 'show_in_menu' => true ],
689 ],
690 'menu_position' => [
691 'label' => __( 'Menu Position', 'pods' ),
692 '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' ),
693 'type' => 'number',
694 'number_decimals' => 2,
695 'number_format' => '9999.99',
696 'number_format_soft' => 1,
697 'default' => 0,
698 'depends-on' => [ 'show_in_menu' => true ],
699 ],
700 'menu_icon' => [
701 'label' => __( 'Menu Icon', 'pods' ),
702 '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' ),
703 'type' => 'text',
704 'default' => '',
705 'depends-on' => [ 'show_in_menu' => true ],
706 ],
707 'show_in_nav_menus' => [
708 'label' => __( 'Show in Navigation Menus', 'pods' ),
709 'help' => __( 'help', 'pods' ),
710 'type' => 'boolean',
711 'default' => true,
712 'boolean_yes_label' => '',
713 ],
714 'show_in_admin_bar' => [
715 'label' => __( 'Show in Admin Bar "New" Menu', 'pods' ),
716 'help' => __( 'help', 'pods' ),
717 'type' => 'boolean',
718 'default' => true,
719 'dependency' => true,
720 'boolean_yes_label' => '',
721 ],
722 'name_admin_bar' => [
723 'label' => __( 'Admin bar name', 'pods' ),
724 'help' => __( 'Defaults to singular name', 'pods' ),
725 'type' => 'text',
726 'default' => '',
727 'depends-on' => [ 'show_in_admin_bar' => true ],
728 ],
729 ];
730
731 $post_type_name = pods_v( 'name', $pod, 'post_type', true );
732
733 /**
734 * Allow filtering the default post status.
735 *
736 * @param string $default_post_status The default post status.
737 * @param \Pods\Whatsit\Pod $pod Current Pods object.
738 */
739 $default_post_status = apply_filters( "pods_api_default_status_{$post_type_name}", 'draft', $pod );
740
741 $options['connections'] = [
742 'post_type_built_in_taxonomies' => [
743 'name' => 'post_type_built_in_taxonomies',
744 'label' => __( 'Enable Connections to Taxonomy', 'pods' ),
745 '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' ),
746 'type' => 'boolean_group',
747 'boolean_group' => [],
748 'dependency' => true,
749 ],
750 ];
751
752 // Only show this if it is a Custom Post Type.
753 if ( ! $is_extended ) {
754 $options['connections']['archive_show_in_taxonomies'] = [
755 'name' => 'archive_show_in_taxonomies',
756 'label' => __( 'Show in Taxonomy Archives', 'pods' ),
757 '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' ),
758 'type' => 'boolean_group',
759 'boolean_group' => [],
760 'depends-on-any' => [
761 'built_in_taxonomies_category' => true,
762 'built_in_taxonomies_post_tag' => true,
763 ],
764 ];
765 }
766
767 $options['connections']['register_custom_taxonomy'] = [
768 'name' => 'register_custom_taxonomy',
769 'label' => __( 'Add new connection', 'pods' ),
770 'type' => 'html',
771 'html_content' => sprintf(
772 '<a href="%1$s">%2$s</a>',
773 esc_url( admin_url( 'admin.php?page=pods-add-new&create_extend=create&type=taxonomy' ) ),
774 esc_html__( 'Create a new Custom Taxonomy', 'pods' )
775 ),
776 ];
777
778 $options['advanced'] = [
779 'public' => [
780 'label' => __( 'Public', 'pods' ),
781 'help' => __( 'help', 'pods' ),
782 'type' => 'boolean',
783 'default' => true,
784 'boolean_yes_label' => '',
785 ],
786 'publicly_queryable' => [
787 'label' => __( 'Publicly Queryable', 'pods' ),
788 'help' => __( 'help', 'pods' ),
789 'type' => 'boolean',
790 'default' => pods_v( 'public', $pod, true ),
791 'boolean_yes_label' => '',
792 ],
793 'exclude_from_search' => [
794 'label' => __( 'Exclude from Search', 'pods' ),
795 'help' => __( 'help', 'pods' ),
796 'type' => 'boolean',
797 'default' => ! pods_v( 'public', $pod, true ),
798 'boolean_yes_label' => '',
799 ],
800 'capability_type' => [
801 'label' => __( 'User Capability', 'pods' ),
802 'help' => __( 'Uses these capabilities for access to this post type: edit_{capability}, read_{capability}, and delete_{capability}', 'pods' ),
803 'type' => 'pick',
804 'default' => 'post',
805 'data' => [
806 'post' => 'post',
807 'page' => 'page',
808 'custom' => __( 'Custom Capability', 'pods' ),
809 ],
810 'pick_format_single' => 'dropdown',
811 'pick_show_select_text' => 0,
812 'dependency' => true,
813 ],
814 'capability_type_custom' => [
815 'label' => __( 'Custom User Capability', 'pods' ),
816 'help' => __( 'help', 'pods' ),
817 'type' => 'text',
818 'default' => $pod_name,
819 'text_placeholder' => $pod_name,
820 'depends-on' => [ 'capability_type' => 'custom' ],
821 ],
822 'capability_type_extra' => [
823 'label' => __( 'Additional User Capabilities', 'pods' ),
824 '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' ),
825 'type' => 'boolean',
826 'default' => true,
827 'boolean_yes_label' => '',
828 ],
829 'has_archive' => [
830 'label' => __( 'Enable Archive Page', 'pods' ),
831 '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' ),
832 'type' => 'boolean',
833 'default' => false,
834 'dependency' => true,
835 'boolean_yes_label' => '',
836 ],
837 'has_archive_slug' => [
838 'label' => __( 'Archive Page Slug Override', 'pods' ),
839 'help' => __( 'If archive page is enabled, you can override the slug used by WordPress, which defaults to the name of the post type.', 'pods' ),
840 'type' => 'text',
841 'slug_fallback' => '-',
842 'default' => '',
843 'depends-on' => [ 'has_archive' => true ],
844 ],
845 'hierarchical' => [
846 'label' => __( 'Hierarchical', 'pods' ),
847 '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' ),
848 'type' => 'boolean',
849 'default' => false,
850 'dependency' => true,
851 'boolean_yes_label' => '',
852 ],
853 'can_export' => [
854 'label' => __( 'Allow Export', 'pods' ),
855 'help' => __( 'Allows you to export content for this post type in Tools > Export.', 'pods' ),
856 'type' => 'boolean',
857 'default' => true,
858 'dependency' => true,
859 'boolean_yes_label' => '',
860 ],
861 'rewrite' => [
862 'label' => __( 'Rewrite', 'pods' ),
863 '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' ),
864 'type' => 'boolean',
865 'default' => true,
866 'dependency' => true,
867 'boolean_yes_label' => '',
868 ],
869 'rewrite_custom_slug' => [
870 'label' => __( 'Custom Rewrite Slug', 'pods' ),
871 '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' ),
872 'type' => 'text',
873 'slug_fallback' => '-',
874 'default' => '',
875 'depends-on' => [ 'rewrite' => true ],
876 ],
877 'rewrite_with_front' => [
878 'label' => __( 'Rewrite with Front', 'pods' ),
879 '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' ),
880 'type' => 'boolean',
881 'default' => true,
882 'depends-on' => [ 'rewrite' => true ],
883 'boolean_yes_label' => '',
884 ],
885 'rewrite_feeds' => [
886 'label' => __( 'Rewrite Feeds', 'pods' ),
887 'help' => __( 'help', 'pods' ),
888 'type' => 'boolean',
889 'default' => false,
890 'depends-on' => [ 'rewrite' => true ],
891 'boolean_yes_label' => '',
892 ],
893 'rewrite_pages' => [
894 'label' => __( 'Rewrite Pages', 'pods' ),
895 'help' => __( 'help', 'pods' ),
896 'type' => 'boolean',
897 'default' => true,
898 'depends-on' => [ 'rewrite' => true ],
899 'boolean_yes_label' => '',
900 ],
901 'query_var' => [
902 'label' => __( 'Query Var', 'pods' ),
903 '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' ),
904 'type' => 'boolean',
905 'default' => true,
906 'boolean_yes_label' => '',
907 ],
908 'can_export' => [
909 'label' => __( 'Exportable', 'pods' ),
910 'help' => __( 'help', 'pods' ),
911 'type' => 'boolean',
912 'default' => true,
913 'boolean_yes_label' => '',
914 ],
915 'default_status' => [
916 'label' => __( 'Default Status', 'pods' ),
917 'help' => __( 'help', 'pods' ),
918 'type' => 'pick',
919 'pick_object' => 'post-status',
920 'default' => $default_post_status,
921 'pick_format_single' => 'dropdown',
922 'pick_show_select_text' => 0,
923 ],
924 'post_type_supports' => [
925 'name' => 'post_type_supports',
926 'type' => 'boolean_group',
927 'label' => __( 'Supports', 'pods' ),
928 'boolean_group' => [
929 'supports_title' => [
930 'name' => 'supports_title',
931 'label' => __( 'Title', 'pods' ),
932 'type' => 'boolean',
933 ],
934 'supports_editor' => [
935 'name' => 'supports_editor',
936 'label' => __( 'Editor', 'pods' ),
937 'type' => 'boolean',
938 ],
939 'supports_author' => [
940 'name' => 'supports_author',
941 'label' => __( 'Author', 'pods' ),
942 'type' => 'boolean',
943 ],
944 'supports_thumbnail' => [
945 'name' => 'supports_thumbnail',
946 'label' => __( 'Featured Image', 'pods' ),
947 'type' => 'boolean',
948 'dependency' => true,
949 ],
950 'supports_excerpt' => [
951 'name' => 'supports_excerpt',
952 'label' => __( 'Excerpt', 'pods' ),
953 'type' => 'boolean',
954 ],
955 'supports_trackbacks' => [
956 'name' => 'supports_trackbacks',
957 'label' => __( 'Trackbacks', 'pods' ),
958 'type' => 'boolean',
959 ],
960 'supports_custom_fields' => [
961 'name' => 'supports_custom_fields',
962 'label' => __( 'Manually Edit Custom Fields (can cause slow performance)', 'pods' ),
963 'type' => 'boolean',
964 ],
965 'supports_comments' => [
966 'name' => 'supports_comments',
967 'label' => __( 'Comments', 'pods' ),
968 'type' => 'boolean',
969 ],
970 'supports_revisions' => [
971 'name' => 'supports_revisions',
972 'label' => __( 'Revisions', 'pods' ),
973 'type' => 'boolean',
974 ],
975 'supports_page_attributes' => [
976 'name' => 'supports_page_attributes',
977 'label' => __( 'Page Attributes', 'pods' ),
978 'type' => 'boolean',
979 ],
980 'supports_post_formats' => [
981 'name' => 'supports_post_formats',
982 'label' => __( 'Post Formats', 'pods' ),
983 'type' => 'boolean',
984 ],
985 ],
986 ],
987 'supports_custom' => [
988 'name' => 'supports_custom',
989 'type' => 'text',
990 'label' => __( 'Advanced Supports', 'pods' ),
991 'help' => __( 'Comma-separated list of custom "supports" values to pass to register_post_type.', 'pods' ),
992 ],
993 'revisions_to_keep_limit' => [
994 'name' => 'revisions_to_keep_limit',
995 'type' => 'number',
996 'default' => '0',
997 'label' => __( 'Maximum revisions to keep per post', 'pods' ),
998 'description' => __( 'The default "0" will fallback to the normal WordPress default.', 'pods' ),
999 'help' => __( 'Enter -1 to keep ALL revisions. Enter any positive number to limit the number of revisions kept to that amount.', 'pods' ),
1000 'depends-on' => [ 'supports_revisions' => true ],
1001 ],
1002 'delete_with_user' => [
1003 'label' => __( 'Allow posts to be deleted when author is deleted', 'pods' ),
1004 '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' ),
1005 'type' => 'boolean',
1006 'default' => true,
1007 'boolean_yes_label' => __( 'Include posts from this post type when deleting authors and choosing not to reassign posts to a new author.', 'pods' ),
1008 ],
1009 ];
1010
1011 /**
1012 * Allow filtering the list of supported features for the post type
1013 *
1014 * @since 2.8.0
1015 *
1016 * @param array $supports The list of supported features for the post type.
1017 * @param array $options The Options fields.
1018 * @param \Pods\Whatsit\Pod $pod Current Pods object.
1019 * @param array $tabs List of registered tabs.
1020 */
1021 $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 );
1022
1023 $related_objects = PodsForm::field_method( 'pick', 'related_objects', true );
1024
1025 $available_taxonomies = [];
1026
1027 if ( ! empty( $related_objects[ __( 'Taxonomies', 'pods' ) ] ) ) {
1028 $available_taxonomies = (array) $related_objects[ __( 'Taxonomies', 'pods' ) ];
1029 }
1030
1031 foreach ( $available_taxonomies as $taxonomy => $label ) {
1032 $taxonomy = pods_str_replace( 'taxonomy-', '', $taxonomy, 1 );
1033
1034 $field_name = 'built_in_taxonomies_' . $taxonomy;
1035
1036 $options['connections']['post_type_built_in_taxonomies']['boolean_group'][ $field_name ] = [
1037 'name' => $field_name,
1038 'label' => $label,
1039 'type' => 'boolean',
1040 ];
1041
1042 if ( 'category' === $taxonomy || 'post_tag' === $taxonomy ) {
1043 $field_name = 'archive_show_in_taxonomies_' . $taxonomy;
1044
1045 $options['connections']['archive_show_in_taxonomies']['boolean_group'][ $field_name ] = [
1046 'name' => $field_name,
1047 'label' => $label,
1048 'type' => 'boolean',
1049 ];
1050 }
1051 }
1052 } elseif ( 'taxonomy' === $pod_type ) {
1053 $options['admin-ui'] = [
1054 'description' => [
1055 'label' => __( 'Taxonomy Description', 'pods' ),
1056 'help' => __( 'A short descriptive summary of what the taxonomy is.', 'pods' ),
1057 'type' => 'text',
1058 'default' => '',
1059 ],
1060 'show_ui' => [
1061 'label' => __( 'Show Admin UI', 'pods' ),
1062 'help' => __( 'Whether to generate a default UI for managing this taxonomy.', 'pods' ),
1063 'type' => 'boolean',
1064 'default' => pods_v( 'public', $pod, true ),
1065 'dependency' => true,
1066 'boolean_yes_label' => '',
1067 ],
1068 'show_in_menu' => [
1069 'label' => __( 'Show Admin Menu in Dashboard', 'pods' ),
1070 'help' => __( 'Whether to show the taxonomy in the admin menu.', 'pods' ),
1071 'type' => 'boolean',
1072 'default' => pods_v( 'public', $pod, true ),
1073 'dependency' => true,
1074 'depends-on' => [ 'show_ui' => true ],
1075 'boolean_yes_label' => '',
1076 ],
1077 'menu_name' => [
1078 'label' => __( 'Menu Name', 'pods' ),
1079 'help' => __( 'help', 'pods' ),
1080 'type' => 'text',
1081 'default' => '',
1082 'depends-on' => [ 'show_ui' => true ],
1083 ],
1084 'menu_location' => [
1085 'label' => __( 'Menu Location', 'pods' ),
1086 'help' => __( 'help', 'pods' ),
1087 'type' => 'pick',
1088 'default' => 'default',
1089 'depends-on' => [ 'show_ui' => true ],
1090 'data' => [
1091 'default' => __( 'Default - Add to associated Post Type(s) menus', 'pods' ),
1092 'settings' => __( 'Add a submenu item to Settings menu', 'pods' ),
1093 'appearances' => __( 'Add a submenu item to Appearances menu', 'pods' ),
1094 'submenu' => __( 'Add a submenu item to another menu', 'pods' ),
1095 'objects' => __( 'Make a new menu item', 'pods' ),
1096 'top' => __( 'Make a new menu item below Settings', 'pods' ),
1097 ],
1098 'pick_format_single' => 'dropdown',
1099 'pick_show_select_text' => 0,
1100 'dependency' => true,
1101 ],
1102 'menu_location_custom' => [
1103 'label' => __( 'Custom Menu Location', 'pods' ),
1104 'help' => __( 'help', 'pods' ),
1105 'type' => 'text',
1106 'depends-on' => [ 'menu_location' => 'submenu' ],
1107 ],
1108 'menu_position' => [
1109 'label' => __( 'Menu Position', 'pods' ),
1110 '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' ),
1111 'type' => 'number',
1112 'number_decimals' => 2,
1113 'number_format' => '9999.99',
1114 'number_format_soft' => 1,
1115 'default' => 0,
1116 'depends-on' => [ 'menu_location' => [ 'objects', 'top' ] ],
1117 ],
1118 'menu_icon' => [
1119 'label' => __( 'Menu Icon URL', 'pods' ),
1120 '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' ),
1121 'type' => 'text',
1122 'default' => '',
1123 'depends-on' => [ 'menu_location' => [ 'objects', 'top' ] ],
1124 ],
1125 'show_in_nav_menus' => [
1126 'label' => __( 'Show in Navigation Menus', 'pods' ),
1127 'help' => __( 'help', 'pods' ),
1128 'type' => 'boolean',
1129 'default' => pods_v( 'public', $pod, true ),
1130 'boolean_yes_label' => '',
1131 ],
1132 'show_tagcloud' => [
1133 'label' => __( 'Allow in Tag Cloud Widget', 'pods' ),
1134 'help' => __( 'help', 'pods' ),
1135 'type' => 'boolean',
1136 'default' => pods_v( 'show_ui', $pod, pods_v( 'public', $pod, true ) ),
1137 'boolean_yes_label' => '',
1138 ],
1139 'show_in_quick_edit' => [
1140 'label' => __( 'Allow in quick/bulk edit panel', 'pods' ),
1141 'help' => __( 'help', 'pods' ),
1142 'type' => 'boolean',
1143 'default' => pods_v( 'show_ui', $pod, pods_v( 'public', $pod, true ) ),
1144 'boolean_yes_label' => '',
1145 ],
1146 ];
1147
1148 $options['admin-ui']['show_admin_column'] = [
1149 'label' => __( 'Show Taxonomy column on Post Types', 'pods' ),
1150 'help' => __( 'Whether to add a column for this taxonomy on the associated post types manage screens', 'pods' ),
1151 'type' => 'boolean',
1152 'default' => false,
1153 'boolean_yes_label' => '',
1154 ];
1155
1156 // Integration for Single Value Taxonomy UI
1157 if ( function_exists( 'tax_single_value_meta_box' ) ) {
1158 $options['admin-ui']['single_value'] = [
1159 'label' => __( 'Single Value Taxonomy', 'pods' ),
1160 'help' => __( 'Use a drop-down for the input instead of the WordPress default', 'pods' ),
1161 'type' => 'boolean',
1162 'default' => false,
1163 'boolean_yes_label' => '',
1164 ];
1165
1166 $options['admin-ui']['single_value_required'] = [
1167 'label' => __( 'Single Value Taxonomy - Required', 'pods' ),
1168 'help' => __( 'A term will be selected by default in the Post Editor, not optional', 'pods' ),
1169 'type' => 'boolean',
1170 'default' => false,
1171 'boolean_yes_label' => '',
1172 ];
1173 }
1174
1175 $options['connections'] = [
1176 'taxonomy_associated_post_types' => [
1177 'name' => 'taxonomy_associated_post_types',
1178 'label' => __( 'Enable Connections to Post Types', 'pods' ),
1179 'help' => __( 'You can enable the ability to select posts from these post types on any term for this taxonomy.', 'pods' ),
1180 'type' => 'boolean_group',
1181 'boolean_group' => [],
1182 ],
1183 'register_custom_post_type' => [
1184 'name' => 'register_custom_post_type',
1185 'label' => __( 'Add new connection', 'pods' ),
1186 'type' => 'html',
1187 'html_content' => sprintf(
1188 '<a href="%1$s">%2$s</a>',
1189 esc_url( admin_url( 'admin.php?page=pods-add-new&create_extend=create&type=post_type' ) ),
1190 esc_html__( 'Create a new Custom Post Type', 'pods' )
1191 ),
1192 ],
1193 ];
1194
1195 $options['advanced'] = [
1196 'public' => [
1197 'label' => __( 'Public', 'pods' ),
1198 'help' => __( 'help', 'pods' ),
1199 'type' => 'boolean',
1200 'default' => true,
1201 'boolean_yes_label' => '',
1202 ],
1203 'hierarchical' => [
1204 'label' => __( 'Hierarchical', 'pods' ),
1205 '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' ),
1206 'type' => 'boolean',
1207 'default' => true,
1208 'dependency' => true,
1209 'boolean_yes_label' => '',
1210 ],
1211 'rewrite' => [
1212 'label' => __( 'Rewrite', 'pods' ),
1213 'help' => __( 'help', 'pods' ),
1214 'type' => 'boolean',
1215 'default' => true,
1216 'dependency' => true,
1217 'boolean_yes_label' => '',
1218 ],
1219 'rewrite_custom_slug' => [
1220 'label' => __( 'Custom Rewrite Slug', 'pods' ),
1221 'help' => __( 'help', 'pods' ),
1222 'type' => 'text',
1223 'slug_fallback' => '-',
1224 'default' => '',
1225 'depends-on' => [ 'rewrite' => true ],
1226 ],
1227 'rewrite_with_front' => [
1228 'label' => __( 'Rewrite with Front', 'pods' ),
1229 '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' ),
1230 'type' => 'boolean',
1231 'default' => true,
1232 'boolean_yes_label' => '',
1233 'depends-on' => [ 'rewrite' => true ],
1234 ],
1235 'rewrite_hierarchical' => [
1236 'label' => __( 'Hierarchical Permalinks', 'pods' ),
1237 'help' => __( 'help', 'pods' ),
1238 'type' => 'boolean',
1239 'default' => true,
1240 'boolean_yes_label' => '',
1241 'depends-on' => [ 'rewrite' => true ],
1242 ],
1243 'capability_type' => [
1244 'label' => __( 'User Capability', 'pods' ),
1245 'help' => __( 'Uses WordPress term capabilities by default', 'pods' ),
1246 'type' => 'pick',
1247 'default' => 'default',
1248 'data' => [
1249 'default' => 'Default',
1250 'custom' => __( 'Custom Capability', 'pods' ),
1251 ],
1252 'pick_format_single' => 'dropdown',
1253 'pick_show_select_text' => 0,
1254 'dependency' => true,
1255 ],
1256 'capability_type_custom' => [
1257 'label' => __( 'Custom User Capability', 'pods' ),
1258 'help' => __( 'Enables additional capabilities for this Taxonomy including: manage_{capability}_terms, edit_{capability}_terms, assign_{capability}_terms, and delete_{capability}_terms', 'pods' ),
1259 'type' => 'text',
1260 'default' => pods_v( 'name', $pod ),
1261 'depends-on' => [ 'capability_type' => 'custom' ],
1262 ],
1263 'query_var' => [
1264 'label' => __( 'Query Var', 'pods' ),
1265 'help' => __( 'help', 'pods' ),
1266 'type' => 'boolean',
1267 'default' => false,
1268 'boolean_yes_label' => '',
1269 ],
1270 'query_var' => [
1271 'label' => __( 'Query Var', 'pods' ),
1272 'help' => __( 'help', 'pods' ),
1273 'type' => 'boolean',
1274 'default' => false,
1275 'dependency' => true,
1276 'boolean_yes_label' => '',
1277 ],
1278 'query_var_string' => [
1279 'label' => __( 'Custom Query Var Name', 'pods' ),
1280 'help' => __( 'help', 'pods' ),
1281 'type' => 'text',
1282 'default' => '',
1283 'depends-on' => [ 'query_var' => true ],
1284 ],
1285 'sort' => [
1286 'label' => __( 'Remember order saved on Post Types', 'pods' ),
1287 'help' => __( 'help', 'pods' ),
1288 'type' => 'boolean',
1289 'default' => false,
1290 'boolean_yes_label' => '',
1291 ],
1292 'update_count_callback' => [
1293 'label' => __( 'Function to call when updating counts', 'pods' ),
1294 'help' => __( 'help', 'pods' ),
1295 'type' => 'text',
1296 'default' => '',
1297 ],
1298 'default_term_name' => [
1299 'label' => __( 'Default term name', 'pods' ),
1300 'type' => 'text',
1301 'default' => '',
1302 'dependency' => true,
1303 ],
1304 'default_term_slug' => [
1305 'label' => __( 'Default term slug', 'pods' ),
1306 'type' => 'text',
1307 'default' => '',
1308 'excludes-on' => [ 'default_term_name' => '' ],
1309 ],
1310 'default_term_description' => [
1311 'label' => __( 'Default term description', 'pods' ),
1312 'type' => 'wysiwyg',
1313 'default' => '',
1314 'excludes-on' => [ 'default_term_name' => '' ],
1315 ],
1316 ];
1317
1318 $related_objects = PodsForm::field_method( 'pick', 'related_objects', true );
1319
1320 $available_post_types = [];
1321
1322 if ( ! empty( $related_objects[ __( 'Post Types', 'pods' ) ] ) ) {
1323 $available_post_types = (array) $related_objects[ __( 'Post Types', 'pods' ) ];
1324 }
1325
1326 foreach ( $available_post_types as $post_type => $label ) {
1327 $post_type = pods_str_replace( 'post_type-', '', $post_type, 1 );
1328
1329 $field_name = 'built_in_post_types_' . $post_type;
1330
1331 $options['connections']['taxonomy_associated_post_types']['boolean_group'][ $field_name ] = [
1332 'name' => $field_name,
1333 'label' => $label,
1334 'type' => 'boolean',
1335 ];
1336 }
1337
1338 $options['connections']['taxonomy_associated_post_types']['boolean_group']['built_in_post_types_attachment'] = [
1339 'name' => 'built_in_post_types_attachment',
1340 'label' => __( 'Media', 'pods' ) . ' (attachment)',
1341 'type' => 'boolean',
1342 ];
1343 } elseif ( 'settings' === $pod_type ) {
1344 $options['admin-ui'] = [
1345 'ui_style' => [
1346 'label' => __( 'Admin UI Style', 'pods' ),
1347 'help' => __( 'help', 'pods' ),
1348 'type' => 'pick',
1349 'default' => 'settings',
1350 'data' => [
1351 'settings' => __( 'Normal Settings Form', 'pods' ),
1352 'post_type' => __( 'Classic Editor (Looks like the Classic Editor for Posts UI)', 'pods' ),
1353 'custom' => __( 'Custom (hook into pods_admin_ui_custom or pods_admin_ui_custom_{podname} action)', 'pods' ),
1354 ],
1355 'pick_format_single' => 'dropdown',
1356 'dependency' => true,
1357 ],
1358 'menu_location' => [
1359 'label' => __( 'Menu Location', 'pods' ),
1360 'help' => __( 'help', 'pods' ),
1361 'type' => 'pick',
1362 'default' => 'settings',
1363 'data' => [
1364 'settings' => __( 'Add a submenu item to Settings menu', 'pods' ),
1365 'appearances' => __( 'Add a submenu item to Appearances menu', 'pods' ),
1366 'submenu' => __( 'Add a submenu item to another menu', 'pods' ),
1367 'top' => __( 'Make a new menu item below Settings', 'pods' ),
1368 ],
1369 'pick_format_single' => 'dropdown',
1370 'dependency' => true,
1371 ],
1372 'menu_location_custom' => [
1373 'label' => __( 'Custom Menu Location', 'pods' ),
1374 'help' => __( 'help', 'pods' ),
1375 'type' => 'text',
1376 'depends-on' => [ 'menu_location' => 'submenu' ],
1377 ],
1378 'menu_position' => [
1379 'label' => __( 'Menu Position', 'pods' ),
1380 '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' ),
1381 'type' => 'number',
1382 'number_decimals' => 2,
1383 'number_format' => '9999.99',
1384 'number_format_soft' => 1,
1385 'default' => 0,
1386 'depends-on' => [ 'menu_location' => 'top' ],
1387 ],
1388 'menu_icon' => [
1389 'label' => __( 'Menu Icon URL', 'pods' ),
1390 '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' ),
1391 'type' => 'text',
1392 'default' => '',
1393 'depends-on' => [ 'menu_location' => 'top' ],
1394 ],
1395 ];
1396
1397 // @todo fill this in
1398 $options['advanced'] = [
1399 'temporary' => 'This type has the fields hardcoded',
1400 // :(
1401 ];
1402 } elseif ( 'pod' === $pod_type ) {
1403 $actions_enabled = [
1404 'add',
1405 'edit',
1406 'duplicate',
1407 'delete',
1408 ];
1409
1410 if ( 1 === (int) pods_v( 'ui_export', $pod ) ) {
1411 $actions_enabled = [
1412 'add',
1413 'edit',
1414 'duplicate',
1415 'delete',
1416 'export',
1417 ];
1418 }
1419
1420 $options['admin-ui'] = [
1421 'ui_style' => [
1422 'label' => __( 'Admin UI Style', 'pods' ),
1423 'help' => __( 'help', 'pods' ),
1424 'type' => 'pick',
1425 'default' => 'post_type',
1426 'data' => [
1427 'post_type' => __( 'Classic Editor (Looks like the Classic Editor for Posts UI)', 'pods' ),
1428 'custom' => __( 'Custom (hook into pods_admin_ui_custom or pods_admin_ui_custom_{podname} action)', 'pods' ),
1429 ],
1430 'pick_format_single' => 'dropdown',
1431 'dependency' => true,
1432 ],
1433 'show_in_menu' => [
1434 'label' => __( 'Show Admin Menu in Dashboard', 'pods' ),
1435 'help' => __( 'help', 'pods' ),
1436 'type' => 'boolean',
1437 'default' => false,
1438 'boolean_yes_label' => '',
1439 'dependency' => true,
1440 ],
1441 'use_submenu_fallback' => [
1442 'label' => __( 'Fallback Edit in Dashboard', 'pods' ),
1443 'help' => __( 'help', 'pods' ),
1444 'type' => 'boolean',
1445 'default' => false,
1446 'boolean_yes_label' => __( 'Use the fallback generic "Pods" content menu so content can be managed', 'pods' ),
1447 'depends-on' => [
1448 'show_in_menu' => false,
1449 ],
1450 ],
1451 'menu_location_custom' => [
1452 'label' => __( 'Parent Menu ID (optional)', 'pods' ),
1453 'help' => __( 'help', 'pods' ),
1454 'type' => 'text',
1455 'depends-on' => [ 'show_in_menu' => true ],
1456 ],
1457 'menu_position' => [
1458 'label' => __( 'Menu Position', 'pods' ),
1459 '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' ),
1460 'type' => 'number',
1461 'number_decimals' => 2,
1462 'number_format' => '9999.99',
1463 'number_format_soft' => 1,
1464 'default' => 0,
1465 'depends-on' => [ 'show_in_menu' => true ],
1466 ],
1467 'menu_icon' => [
1468 'label' => __( 'Menu Icon URL', 'pods' ),
1469 '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' ),
1470 'type' => 'text',
1471 'default' => '',
1472 'depends-on' => [ 'show_in_menu' => true ],
1473 ],
1474 'ui_icon' => [
1475 'label' => __( 'Header Icon', 'pods' ),
1476 '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' ),
1477 'type' => 'file',
1478 'default' => '',
1479 'file_edit_title' => 0,
1480 'depends-on' => [ 'show_in_menu' => true ],
1481 ],
1482 'ui_actions_enabled' => [
1483 'label' => __( 'Actions Available', 'pods' ),
1484 'help' => __( 'help', 'pods' ),
1485 'type' => 'pick',
1486 'default' => $actions_enabled,
1487 'data' => [
1488 'add' => __( 'Add New', 'pods' ),
1489 'edit' => __( 'Edit', 'pods' ),
1490 'duplicate' => __( 'Duplicate', 'pods' ),
1491 'delete' => __( 'Delete', 'pods' ),
1492 'reorder' => __( 'Reorder', 'pods' ),
1493 'export' => __( 'Export', 'pods' ),
1494 ],
1495 'pick_format_type' => 'multi',
1496 'dependency' => true,
1497 ],
1498 'ui_reorder_field' => [
1499 'label' => __( 'Reorder Field', 'pods' ),
1500 'help' => __( 'This is the field that will be reordered on, it should be numeric.', 'pods' ),
1501 'type' => 'text',
1502 'default' => 'menu_order',
1503 'depends-on' => [ 'ui_actions_enabled' => 'reorder' ],
1504 ],
1505 'ui_fields_manage' => [
1506 'label' => __( 'Admin Table Columns', 'pods' ),
1507 'help' => __( 'help', 'pods' ),
1508 'type' => 'pick',
1509 'default' => [],
1510 'data' => [],
1511 'pick_format_type' => 'multi',
1512 ],
1513 'ui_filters' => [
1514 'label' => __( 'Search Filters', 'pods' ),
1515 'help' => __( 'help', 'pods' ),
1516 'type' => 'pick',
1517 'default' => [],
1518 'data' => [],
1519 'pick_format_type' => 'multi',
1520 ],
1521 ];
1522
1523 if ( ! empty( $pod['fields'] ) ) {
1524 if ( isset( $pod['fields'][ pods_v( 'pod_index', $pod, 'name' ) ] ) ) {
1525 $options['admin-ui']['ui_fields_manage']['default'][] = pods_v( 'pod_index', $pod, 'name' );
1526 }
1527
1528 if ( isset( $pod['fields']['modified'] ) ) {
1529 $options['admin-ui']['ui_fields_manage']['default'][] = 'modified';
1530 }
1531
1532 foreach ( $pod['fields'] as $field ) {
1533 $type = '';
1534
1535 if ( isset( $field_types[ $field['type'] ] ) ) {
1536 $type = ' <small>(' . $field_types[ $field['type'] ]['label'] . ')</small>';
1537 }
1538
1539 $options['admin-ui']['ui_fields_manage']['data'][ $field['name'] ] = $field['label'] . $type;
1540 $options['admin-ui']['ui_filters']['data'][ $field['name'] ] = $field['label'] . $type;
1541 }
1542
1543 $options['admin-ui']['ui_fields_manage']['data']['id'] = 'ID';
1544 } else {
1545 unset( $options['admin-ui']['ui_fields_manage'] );
1546 unset( $options['admin-ui']['ui_filters'] );
1547 }//end if
1548
1549 $index_fields = [
1550 'id' => 'ID',
1551 ];
1552
1553 $hierarchical_fields = [];
1554
1555 foreach ( $pod['fields'] as $field ) {
1556 if ( ! in_array( $field['type'], $tableless_field_types, true ) ) {
1557 $index_fields[ $field['name'] ] = $field['label'];
1558 }
1559
1560 if ( 'pick' == $field['type'] && 'pod' === pods_v( 'pick_object', $field ) && $pod['name'] === pods_v( 'pick_val', $field ) && 'single' === pods_v( 'pick_format_type', $field ) ) {
1561 $hierarchical_fields[ $field['name'] ] = $field['label'];
1562 }
1563 }
1564
1565 // Set empty message if none found.
1566 if ( empty( $hierarchical_fields ) ) {
1567 $hierarchical_fields = [
1568 '' => __( 'No Hierarchical Fields found', 'pods' ),
1569 ];
1570 }
1571
1572 $options['advanced'] = [
1573 'detail_url' => [
1574 'label' => __( 'Detail Page URL', 'pods' ),
1575 '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' ),
1576 'type' => 'text',
1577 'text_placeholder' => 'my-pod-page/{@permalink}/',
1578 ],
1579 'pod_index' => [
1580 'label' => __( 'Title Field', 'pods' ),
1581 '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' ),
1582 'default' => 'name',
1583 'type' => 'pick',
1584 'data' => $index_fields,
1585 'pick_format_single' => 'autocomplete',
1586 ],
1587 'hierarchical' => [
1588 'label' => __( 'Hierarchical', 'pods' ),
1589 'help' => __( 'You can enable automatic hierarchical parent / child handling which shows a special built-in interface for data entry.', 'pods' ),
1590 'default' => 0,
1591 'type' => 'boolean',
1592 'dependency' => true,
1593 'boolean_yes_label' => '',
1594 ],
1595 'pod_parent' => [
1596 'label' => __( 'Hierarchical Parent Field', 'pods' ),
1597 'help' => __( 'You can enable automatic hierarchical parent / child handling which shows a special built-in interface for data entry.', 'pods' ),
1598 'default' => 'parent',
1599 'type' => 'pick',
1600 'data' => $hierarchical_fields,
1601 'depends-on' => [
1602 'hierarchical' => true,
1603 ],
1604 'pick_format_single' => 'autocomplete',
1605 ],
1606 ];
1607 }//end if
1608
1609 // Only include kitchen sink if dev mode on and not running Codecept tests.
1610 if ( pods_developer() && ! function_exists( 'codecept_debug' ) ) {
1611 $options['kitchen-sink'] = json_decode( file_get_contents( PODS_DIR . 'tests/codeception/_data/kitchen-sink-config.json' ), true );
1612 }
1613
1614 $pod_type = $pod['type'];
1615 $pod_name = $pod['name'];
1616
1617 /**
1618 * Add admin fields to the Pods editor for a specific Pod.
1619 *
1620 * @param array $options The Options fields.
1621 * @param \Pods\Whatsit\Pod $pod Current Pods object.
1622 * @param array $tabs List of registered tabs.
1623 */
1624 $options = apply_filters( "pods_admin_setup_edit_options_{$pod_type}_{$pod_name}", $options, $pod, $tabs );
1625
1626 /**
1627 * Add admin fields to the Pods editor for any Pod of a specific content type.
1628 *
1629 * @param array $options The Options fields.
1630 * @param \Pods\Whatsit\Pod $pod Current Pods object.
1631 * @param array $tabs List of registered tabs.
1632 */
1633 $options = apply_filters( "pods_admin_setup_edit_options_{$pod_type}", $options, $pod, $tabs );
1634
1635 /**
1636 * Add admin fields to the Pods editor for all Pods.
1637 *
1638 * @param array $options The Options fields.
1639 * @param \Pods\Whatsit\Pod $pod Current Pods object.
1640 * @param array $tabs List of registered tabs.
1641 */
1642 $options = apply_filters( 'pods_admin_setup_edit_options', $options, $pod, $tabs );
1643
1644 return $options;
1645 }
1646 }
1647