Make WordPress Core


Ignore:
Timestamp:
11/30/2021 03:52:49 PM (3 years ago)
Author:
hellofromTonya
Message:

REST API: Replace hardcoded wp/v2/ preloaded paths with rest_get_route_for_taxonomy_items() and rest_get_route_for_post_type_items() in wp-admin/site-editor.php.

[51962] and [51964] introduced two new functions: rest_get_route_for_post_type_items() and rest_get_route_for_taxonomy_items(). These functions replaced hardcoded references in all parts of core that reference taxonomy and post type rest controller endpoints. However, several instances were missed in the wp-admin/site-editor.php file.

This commit replaces those remaining hardcoded instances.

Follow-up to [51962], [51964], [52232].

Props spacedmonkey.
Fixes #54536.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/site-editor.php

    r52275 r52281  
    6565        '/wp/v2/types/' . $post_type->name . '?context=edit',
    6666        '/wp/v2/types?context=edit',
    67         '/wp/v2/' . $post_type->rest_base . '?context=edit',
     67        add_query_arg( 'context', 'edit', rest_get_route_for_post_type_items( $post_type ) ),
    6868    );
    6969
     
    8989    $active_theme            = wp_get_theme()->get_stylesheet();
    9090    $preload_paths           = array(
    91         array( '/wp/v2/media', 'OPTIONS' ),
     91        array( rest_get_route_for_post_type_items( 'attachment' ), 'OPTIONS' ),
    9292        '/',
    9393        '/wp/v2/types?context=edit',
    9494        '/wp/v2/taxonomies?context=edit',
    95         '/wp/v2/pages?context=edit',
    96         '/wp/v2/categories?context=edit',
    97         '/wp/v2/posts?context=edit',
    98         '/wp/v2/tags?context=edit',
    99         '/wp/v2/templates?context=edit',
    100         '/wp/v2/template-parts?context=edit',
     95        add_query_arg( 'context', 'edit', rest_get_route_for_post_type_items( 'page' ) ),
     96        add_query_arg( 'context', 'edit', rest_get_route_for_post_type_items( 'post' ) ),
     97        add_query_arg( 'context', 'edit', rest_get_route_for_taxonomy_items( 'category' ) ),
     98        add_query_arg( 'context', 'edit', rest_get_route_for_taxonomy_items( 'post_tag' ) ),
     99        add_query_arg( 'context', 'edit', rest_get_route_for_post_type_items( 'wp_template' ) ),
     100        add_query_arg( 'context', 'edit', rest_get_route_for_post_type_items( 'wp_template_part' ) ),
    101101        '/wp/v2/settings',
    102102        '/wp/v2/themes?context=edit&status=active',
Note: See TracChangeset for help on using the changeset viewer.