Make WordPress Core


Ignore:
Timestamp:
10/28/2025 01:34:00 PM (6 months ago)
Author:
ellatrix
Message:

Template activation: merge changes for Beta 2.

Developed in https://github.com/WordPress/wordpress-develop/pull/10425.
See https://core.trac.wordpress.org/ticket/62755.

Fixes #62755.
Props ellatrix, priethor.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api.php

    r61045 r61078  
    264264 */
    265265function create_initial_rest_routes() {
    266     global $wp_post_types;
    267 
    268     // Register the registered templates endpoint. For that we need to copy the
    269     // wp_template post type so that it's available as an entity in core-data.
    270     $wp_post_types['wp_registered_template']                        = clone $wp_post_types['wp_template'];
    271     $wp_post_types['wp_registered_template']->name                  = 'wp_registered_template';
    272     $wp_post_types['wp_registered_template']->rest_base             = 'wp_registered_template';
    273     $wp_post_types['wp_registered_template']->rest_controller_class = 'WP_REST_Registered_Templates_Controller';
    274 
    275266    foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) {
    276267        $controller = $post_type->get_rest_controller();
     
    298289        }
    299290    }
     291
     292    global $wp_post_types;
    300293
    301294    // Register the old templates endpoints. The WP_REST_Templates_Controller
     
    304297    // To maintain backward and changes to these controller classes, we make use
    305298    // that the wp_template post type has the right information it needs.
     299    $current_wp_template_rest_base           = $wp_post_types['wp_template']->rest_base;
    306300    $wp_post_types['wp_template']->rest_base = 'templates';
    307301    // Store the classes so they can be restored.
     
    329323    $wp_post_types['wp_template']->revisions_rest_controller_class = $original_revisions_rest_controller_class;
    330324    // Restore the original base.
    331     $wp_post_types['wp_template']->rest_base = 'wp_template';
     325    $wp_post_types['wp_template']->rest_base = $current_wp_template_rest_base;
    332326
    333327    // Register the old routes.
     
    356350        )
    357351    );
     352
     353    // Registered templates.
     354    $controller = new WP_REST_Registered_Templates_Controller();
     355    $controller->register_routes();
    358356
    359357    // Post types.
Note: See TracChangeset for help on using the changeset viewer.