Make WordPress Core


Ignore:
Timestamp:
09/21/2022 12:27:33 PM (20 months ago)
Author:
jorgefilipecosta
Message:

Editor: Add has_archive property to the post types REST endpoint.

Backports PHP changes in WordPress/gutenberg#42746 to the core. Adds a has_archive field to the post types endpoint.

Props mcsf, ntsekouras, oandregal.
See #56467.

File:
1 edited

Legend:

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

    r54269 r54273  
    197197        if ( rest_is_field_included( 'hierarchical', $fields ) ) {
    198198            $data['hierarchical'] = $post_type->hierarchical;
     199        }
     200
     201        if ( rest_is_field_included( 'hierarchical', $fields ) ) {
     202            $data['has_archive'] = $post_type->has_archive;
    199203        }
    200204
     
    354358                    'readonly'    => true,
    355359                ),
     360                'has_archive'    => array(
     361                    'description' => __( 'If the value is a string, the value will be used as the archive slug. If the value is false the post type has no archive.' ),
     362                    'type'        => array( 'string', 'boolean' ),
     363                    'context'     => array( 'view', 'edit' ),
     364                    'readonly'    => true,
     365                ),
    356366                'taxonomies'     => array(
    357367                    'description' => __( 'Taxonomies associated with post type.' ),
Note: See TracChangeset for help on using the changeset viewer.