Make WordPress Core


Ignore:
Timestamp:
10/31/2021 05:17:53 AM (5 years ago)
Author:
TimothyBlynJacobs
Message:

REST API: Add visibility information to the Post Types controller.

Props spacedmonkey, peterwilsoncc.
Fixes #54055.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php

    r51786 r51959  
    196196                if ( in_array( 'hierarchical', $fields, true ) ) {
    197197                        $data['hierarchical'] = $post_type->hierarchical;
     198                }
     199
     200                if ( in_array( 'visibility', $fields, true ) ) {
     201                        $data['visibility'] = array(
     202                                'show_in_nav_menus' => (bool) $post_type->show_in_nav_menus,
     203                                'show_ui'           => (bool) $post_type->show_ui,
     204                        );
    198205                }
    199206
     
    338345                                        'readonly'    => true,
    339346                                ),
     347                                'visibility'   => array(
     348                                        'description' => __( 'The visibility settings for the post type.' ),
     349                                        'type'        => 'object',
     350                                        'context'     => array( 'edit' ),
     351                                        'readonly'    => true,
     352                                        'properties'  => array(
     353                                                'show_ui'           => array(
     354                                                        'description' => __( 'Whether to generate a default UI for managing this post type.' ),
     355                                                        'type'        => 'boolean',
     356                                                ),
     357                                                'show_in_nav_menus' => array(
     358                                                        'description' => __( 'Whether to make the post type is available for selection in navigation menus.' ),
     359                                                        'type'        => 'boolean',
     360                                                ),
     361                                        ),
     362                                ),
    340363                        ),
    341364                );
Note: See TracChangeset for help on using the changeset viewer.