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