<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[57628] trunk: REST API: Revert the refactor of global styles endpoints in REST API in [57624].</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/57628">57628</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/57628","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>davidbaumwald</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-02-13 15:10:37 +0000 (Tue, 13 Feb 2024)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>REST API: Revert the refactor of global styles endpoints in REST API in <a href="https://core.trac.wordpress.org/changeset/57624">[57624]</a>.
<a href="https://core.trac.wordpress.org/changeset/57624">[57624]</a> introduced some E2E test failures which are the result of an incompatibility with the Gutenberg plugin.
Props jorbin, spacedmonkey, swissspidy, hellofromTonya, youknowriad, costdev.
See <a href="https://core.trac.wordpress.org/ticket/60131">#60131</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpposttypephp">trunk/src/wp-includes/class-wp-post-type.php</a></li>
<li><a href="#trunksrcwpincludespostphp">trunk/src/wp-includes/post.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestglobalstylescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestglobalstylesrevisionscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiphp">trunk/src/wp-includes/rest-api.php</a></li>
<li><a href="#trunksrcwpsettingsphp">trunk/src/wp-settings.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestglobalstylesrevisionscontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php</a></li>
<li><a href="#trunktestsqunitfixtureswpapigeneratedjs">trunk/tests/qunit/fixtures/wp-api-generated.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpposttypephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-post-type.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-post-type.php 2024-02-13 15:10:21 UTC (rev 57627)
+++ trunk/src/wp-includes/class-wp-post-type.php 2024-02-13 15:10:37 UTC (rev 57628)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -913,7 +913,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Will only instantiate the controller class once per request.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.4.0
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 6.5.0 Prevents autosave class instantiation for wp_global_styles post types.
</del><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Controller|null The controller instance, or null if the post type
</span><span class="cx" style="display: block; padding: 0 10px"> * is set not to show in rest.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -923,7 +922,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return null;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( in_array( $this->name, array( 'attachment', 'wp_global_styles' ), true ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( 'attachment' === $this->name ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return null;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludespostphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/post.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/post.php 2024-02-13 15:10:21 UTC (rev 57627)
+++ trunk/src/wp-includes/post.php 2024-02-13 15:10:37 UTC (rev 57628)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -473,19 +473,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> register_post_type(
</span><span class="cx" style="display: block; padding: 0 10px"> 'wp_global_styles',
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'label' => _x( 'Global Styles', 'post type general name' ),
- 'description' => __( 'Global styles to include in themes.' ),
- 'public' => false,
- '_builtin' => true, /* internal use only. don't use this when registering your own post type. */
- '_edit_link' => '/site-editor.php?canvas=edit', /* internal use only. don't use this when registering your own post type. */
- 'show_ui' => false,
- 'show_in_rest' => true,
- 'rewrite' => false,
- 'rest_base' => 'global-styles',
- 'rest_controller_class' => 'WP_REST_Global_Styles_Controller',
- 'revisions_rest_controller_class' => 'WP_REST_Global_Styles_Revisions_Controller',
- 'late_route_registration' => true,
- 'capabilities' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'label' => _x( 'Global Styles', 'post type general name' ),
+ 'description' => __( 'Global styles to include in themes.' ),
+ 'public' => false,
+ '_builtin' => true, /* internal use only. don't use this when registering your own post type. */
+ '_edit_link' => '/site-editor.php?canvas=edit', /* internal use only. don't use this when registering your own post type. */
+ 'show_ui' => false,
+ 'show_in_rest' => false,
+ 'rewrite' => false,
+ 'capabilities' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'read' => 'edit_theme_options',
</span><span class="cx" style="display: block; padding: 0 10px"> 'create_posts' => 'edit_theme_options',
</span><span class="cx" style="display: block; padding: 0 10px"> 'edit_posts' => 'edit_theme_options',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -494,8 +490,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'edit_others_posts' => 'edit_theme_options',
</span><span class="cx" style="display: block; padding: 0 10px"> 'delete_others_posts' => 'edit_theme_options',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'map_meta_cap' => true,
- 'supports' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'map_meta_cap' => true,
+ 'supports' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'title',
</span><span class="cx" style="display: block; padding: 0 10px"> 'editor',
</span><span class="cx" style="display: block; padding: 0 10px"> 'revisions',
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestglobalstylescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php 2024-02-13 15:10:21 UTC (rev 57627)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php 2024-02-13 15:10:37 UTC (rev 57628)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10,16 +10,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Base Global Styles REST API Controller.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-class WP_REST_Global_Styles_Controller extends WP_REST_Posts_Controller {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+class WP_REST_Global_Styles_Controller extends WP_REST_Controller {
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Whether the controller supports batching.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Post type.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 6.5.0
- * @var array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.9.0
+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected $allow_batch = array( 'v1' => false );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected $post_type;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Constructor.
+ * @since 5.9.0
+ */
+ public function __construct() {
+ $this->namespace = 'wp/v2';
+ $this->rest_base = 'global-styles';
+ $this->post_type = 'wp_global_styles';
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Registers the controllers routes.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.9.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -183,11 +194,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param WP_Post $post Post object.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return bool Whether the post can be read.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function check_read_permission( $post ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected function check_read_permission( $post ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return current_user_can( 'read_post', $post->ID );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns the given global styles config.
+ *
+ * @since 5.9.0
+ *
+ * @param WP_REST_Request $request The request instance.
+ *
+ * @return WP_REST_Response|WP_Error
+ */
+ public function get_item( $request ) {
+ $post = $this->get_post( $request['id'] );
+ if ( is_wp_error( $post ) ) {
+ return $post;
+ }
+
+ return $this->prepare_item_for_response( $post, $request );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Checks if a given request has access to write a single global styles config.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.9.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -213,6 +242,55 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a global style can be edited.
+ *
+ * @since 5.9.0
+ *
+ * @param WP_Post $post Post object.
+ * @return bool Whether the post can be edited.
+ */
+ protected function check_update_permission( $post ) {
+ return current_user_can( 'edit_post', $post->ID );
+ }
+
+ /**
+ * Updates a single global style config.
+ *
+ * @since 5.9.0
+ *
+ * @param WP_REST_Request $request Full details about the request.
+ * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
+ */
+ public function update_item( $request ) {
+ $post_before = $this->get_post( $request['id'] );
+ if ( is_wp_error( $post_before ) ) {
+ return $post_before;
+ }
+
+ $changes = $this->prepare_item_for_database( $request );
+ if ( is_wp_error( $changes ) ) {
+ return $changes;
+ }
+
+ $result = wp_update_post( wp_slash( (array) $changes ), true, false );
+ if ( is_wp_error( $result ) ) {
+ return $result;
+ }
+
+ $post = get_post( $request['id'] );
+ $fields_update = $this->update_additional_fields_for_object( $post, $request );
+ if ( is_wp_error( $fields_update ) ) {
+ return $fields_update;
+ }
+
+ wp_after_insert_post( $post, true, $post_before );
+
+ $response = $this->prepare_item_for_response( $post, $request );
+
+ return rest_ensure_response( $response );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Prepares a single global styles config for update.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.9.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -329,7 +407,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $links = $this->prepare_links( $post->ID );
</span><span class="cx" style="display: block; padding: 0 10px"> $response->add_links( $links );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $links['self']['href'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $actions = $this->get_available_actions( $post, $request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $actions = $this->get_available_actions();
</ins><span class="cx" style="display: block; padding: 0 10px"> $self = $links['self']['href'];
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $actions as $rel ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $response->add_link( $rel, $self );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -353,12 +431,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $base = sprintf( '%s/%s', $this->namespace, $this->rest_base );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $links = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'self' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'self' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'href' => rest_url( trailingslashit( $base ) . $id ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'about' => array(
- 'href' => rest_url( 'wp/v2/types/' . $this->post_type ),
- ),
</del><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( post_type_supports( $this->post_type, 'revisions' ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -379,16 +454,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.9.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.2.0 Added 'edit-css' action.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 6.5.0 Added $post and $request parameters.
</del><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param WP_Post $post Post object.
- * @param WP_REST_Request $request Request object.
</del><span class="cx" style="display: block; padding: 0 10px"> * @return array List of link relations.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected function get_available_actions( $post, $request ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected function get_available_actions() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $rels = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_type = get_post_type_object( $post->post_type );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_type = get_post_type_object( $this->post_type );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( current_user_can( $post_type->cap->publish_posts ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $rels[] = 'https://api.w.org/action-publish';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -401,6 +473,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Overwrites the default protected title format.
+ *
+ * By default, WordPress will show password protected posts with a title of
+ * "Protected: %s", as the REST API communicates the protected status of a post
+ * in a machine readable format, we remove the "Protected: " prefix.
+ *
+ * @since 5.9.0
+ *
+ * @return string Protected title format.
+ */
+ public function protected_title_format() {
+ return '%s';
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Retrieves the query params for the global styles collection.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.9.0
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestglobalstylesrevisionscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php 2024-02-13 15:10:21 UTC (rev 57627)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php 2024-02-13 15:10:37 UTC (rev 57628)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -14,14 +14,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see WP_REST_Controller
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-class WP_REST_Global_Styles_Revisions_Controller extends WP_REST_Revisions_Controller {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+class WP_REST_Global_Styles_Revisions_Controller extends WP_REST_Controller {
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Parent controller.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Parent post type.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 6.5.0
- * @var WP_REST_Controller
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.3.0
+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- private $parent_controller;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected $parent_post_type;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The base of the parent controller's route.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -35,23 +35,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Constructor.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.3.0
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 6.5.0 Extends class from WP_REST_Revisions_Controller.
- *
- * @param string $parent_post_type Post type of the parent.
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function __construct( $parent_post_type ) {
- parent::__construct( $parent_post_type );
- $post_type_object = get_post_type_object( $parent_post_type );
- $parent_controller = $post_type_object->get_rest_controller();
-
- if ( ! $parent_controller ) {
- $parent_controller = new WP_REST_Global_Styles_Controller( $parent_post_type );
- }
-
- $this->parent_controller = $parent_controller;
- $this->rest_base = 'revisions';
- $this->parent_base = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name;
- $this->namespace = ! empty( $post_type_object->rest_namespace ) ? $post_type_object->rest_namespace : 'wp/v2';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function __construct() {
+ $this->parent_post_type = 'wp_global_styles';
+ $this->rest_base = 'revisions';
+ $this->parent_base = 'global-styles';
+ $this->namespace = 'wp/v2';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -74,7 +63,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'methods' => WP_REST_Server::READABLE,
</span><span class="cx" style="display: block; padding: 0 10px"> 'callback' => array( $this, 'get_items' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'permission_callback' => array( $this, 'get_items_permissions_check' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'permission_callback' => array( $this, 'get_item_permissions_check' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'args' => $this->get_collection_params(),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'schema' => array( $this, 'get_public_item_schema' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -109,6 +98,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Retrieves the query params for collections.
+ *
+ * Inherits from WP_REST_Controller::get_collection_params(),
+ * also reflects changes to return value WP_REST_Revisions_Controller::get_collection_params().
+ *
+ * @since 6.3.0
+ *
+ * @return array Collection parameters.
+ */
+ public function get_collection_params() {
+ $collection_params = parent::get_collection_params();
+ $collection_params['context']['default'] = 'view';
+ $collection_params['offset'] = array(
+ 'description' => __( 'Offset the result set by a specific number of items.' ),
+ 'type' => 'integer',
+ );
+ unset( $collection_params['search'] );
+ unset( $collection_params['per_page']['default'] );
+
+ return $collection_params;
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Returns decoded JSON from post content string,
</span><span class="cx" style="display: block; padding: 0 10px"> * or a 404 if not found.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -257,6 +269,80 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Retrieves one global styles revision from the collection.
+ *
+ * @since 6.5.0
+ *
+ * @param WP_REST_Request $request Full details about the request.
+ * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
+ */
+ public function get_item( $request ) {
+ $parent = $this->get_parent( $request['parent'] );
+ if ( is_wp_error( $parent ) ) {
+ return $parent;
+ }
+
+ $revision = $this->get_revision( $request['id'] );
+ if ( is_wp_error( $revision ) ) {
+ return $revision;
+ }
+
+ $response = $this->prepare_item_for_response( $revision, $request );
+ return rest_ensure_response( $response );
+ }
+
+ /**
+ * Gets the global styles revision, if the ID is valid.
+ *
+ * @since 6.5.0
+ *
+ * @param int $id Supplied ID.
+ * @return WP_Post|WP_Error Revision post object if ID is valid, WP_Error otherwise.
+ */
+ protected function get_revision( $id ) {
+ $error = new WP_Error(
+ 'rest_post_invalid_id',
+ __( 'Invalid global styles revision ID.' ),
+ array( 'status' => 404 )
+ );
+
+ if ( (int) $id <= 0 ) {
+ return $error;
+ }
+
+ $revision = get_post( (int) $id );
+ if ( empty( $revision ) || empty( $revision->ID ) || 'revision' !== $revision->post_type ) {
+ return $error;
+ }
+
+ return $revision;
+ }
+
+ /**
+ * Checks the post_date_gmt or modified_gmt and prepare any post or
+ * modified date for single post output.
+ *
+ * Duplicate of WP_REST_Revisions_Controller::prepare_date_response.
+ *
+ * @since 6.3.0
+ *
+ * @param string $date_gmt GMT publication time.
+ * @param string|null $date Optional. Local publication time. Default null.
+ * @return string|null ISO8601/RFC3339 formatted datetime, otherwise null.
+ */
+ protected function prepare_date_response( $date_gmt, $date = null ) {
+ if ( '0000-00-00 00:00:00' === $date_gmt ) {
+ return null;
+ }
+
+ if ( isset( $date ) ) {
+ return mysql_to_rfc3339( $date );
+ }
+
+ return mysql_to_rfc3339( $date_gmt );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Prepares the revision for the REST response.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.3.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -325,7 +411,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Retrieves the revision's schema, conforming to JSON Schema.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.3.0
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 6.5.0 Merged parent and parent controller schema data.
</del><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Item schema data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -334,16 +419,71 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->add_additional_fields_schema( $this->schema );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $schema = parent::get_item_schema();
- $parent_schema = $this->parent_controller->get_item_schema();
- $schema['properties'] = array_merge( $schema['properties'], $parent_schema['properties'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $schema = array(
+ '$schema' => 'http://json-schema.org/draft-04/schema#',
+ 'title' => "{$this->parent_post_type}-revision",
+ 'type' => 'object',
+ // Base properties for every revision.
+ 'properties' => array(
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- unset( $schema['properties']['guid'] );
- unset( $schema['properties']['slug'] );
- unset( $schema['properties']['meta'] );
- unset( $schema['properties']['content'] );
- unset( $schema['properties']['title'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Adds settings and styles from the WP_REST_Revisions_Controller item fields.
+ * Leaves out GUID as global styles shouldn't be accessible via URL.
+ */
+ 'author' => array(
+ 'description' => __( 'The ID for the author of the revision.' ),
+ 'type' => 'integer',
+ 'context' => array( 'view', 'edit', 'embed' ),
+ ),
+ 'date' => array(
+ 'description' => __( "The date the revision was published, in the site's timezone." ),
+ 'type' => 'string',
+ 'format' => 'date-time',
+ 'context' => array( 'view', 'edit', 'embed' ),
+ ),
+ 'date_gmt' => array(
+ 'description' => __( 'The date the revision was published, as GMT.' ),
+ 'type' => 'string',
+ 'format' => 'date-time',
+ 'context' => array( 'view', 'edit' ),
+ ),
+ 'id' => array(
+ 'description' => __( 'Unique identifier for the revision.' ),
+ 'type' => 'integer',
+ 'context' => array( 'view', 'edit', 'embed' ),
+ ),
+ 'modified' => array(
+ 'description' => __( "The date the revision was last modified, in the site's timezone." ),
+ 'type' => 'string',
+ 'format' => 'date-time',
+ 'context' => array( 'view', 'edit' ),
+ ),
+ 'modified_gmt' => array(
+ 'description' => __( 'The date the revision was last modified, as GMT.' ),
+ 'type' => 'string',
+ 'format' => 'date-time',
+ 'context' => array( 'view', 'edit' ),
+ ),
+ 'parent' => array(
+ 'description' => __( 'The ID for the parent of the revision.' ),
+ 'type' => 'integer',
+ 'context' => array( 'view', 'edit', 'embed' ),
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Adds settings and styles from the WP_REST_Global_Styles_Controller parent schema.
+ 'styles' => array(
+ 'description' => __( 'Global styles.' ),
+ 'type' => array( 'object' ),
+ 'context' => array( 'view', 'edit' ),
+ ),
+ 'settings' => array(
+ 'description' => __( 'Global settings.' ),
+ 'type' => array( 'object' ),
+ 'context' => array( 'view', 'edit' ),
+ ),
+ ),
+ );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->schema = $schema;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->add_additional_fields_schema( $this->schema );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -350,20 +490,62 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Retrieves the query params for collections.
- * Removes params that are not supported by global styles revisions.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a given request has access to read a single global style.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 6.5.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.3.0
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return array Collection parameters.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param WP_REST_Request $request Full details about the request.
+ * @return true|WP_Error True if the request has read access, WP_Error object otherwise.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function get_collection_params() {
- $query_params = parent::get_collection_params();
- unset( $query_params['exclude'] );
- unset( $query_params['include'] );
- unset( $query_params['search'] );
- unset( $query_params['order'] );
- unset( $query_params['orderby'] );
- return $query_params;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function get_item_permissions_check( $request ) {
+ $post = $this->get_parent( $request['parent'] );
+ if ( is_wp_error( $post ) ) {
+ return $post;
+ }
+
+ /*
+ * The same check as WP_REST_Global_Styles_Controller::get_item_permissions_check.
+ */
+ if ( ! current_user_can( 'read_post', $post->ID ) ) {
+ return new WP_Error(
+ 'rest_cannot_view',
+ __( 'Sorry, you are not allowed to view revisions for this global style.' ),
+ array( 'status' => rest_authorization_required_code() )
+ );
+ }
+
+ return true;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * Gets the parent post, if the ID is valid.
+ *
+ * Duplicate of WP_REST_Revisions_Controller::get_parent.
+ *
+ * @since 6.3.0
+ *
+ * @param int $parent_post_id Supplied ID.
+ * @return WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise.
+ */
+ protected function get_parent( $parent_post_id ) {
+ $error = new WP_Error(
+ 'rest_post_invalid_parent',
+ __( 'Invalid post parent ID.' ),
+ array( 'status' => 404 )
+ );
+
+ if ( (int) $parent_post_id <= 0 ) {
+ return $error;
+ }
+
+ $parent_post = get_post( (int) $parent_post_id );
+
+ if ( empty( $parent_post ) || empty( $parent_post->ID )
+ || $this->parent_post_type !== $parent_post->post_type
+ ) {
+ return $error;
+ }
+
+ return $parent_post;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api.php 2024-02-13 15:10:21 UTC (rev 57627)
+++ trunk/src/wp-includes/rest-api.php 2024-02-13 15:10:37 UTC (rev 57628)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -323,6 +323,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $controller = new WP_REST_Block_Types_Controller();
</span><span class="cx" style="display: block; padding: 0 10px"> $controller->register_routes();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Global Styles revisions.
+ $controller = new WP_REST_Global_Styles_Revisions_Controller();
+ $controller->register_routes();
+
+ // Global Styles.
+ $controller = new WP_REST_Global_Styles_Controller();
+ $controller->register_routes();
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Settings.
</span><span class="cx" style="display: block; padding: 0 10px"> $controller = new WP_REST_Settings_Controller();
</span><span class="cx" style="display: block; padding: 0 10px"> $controller->register_routes();
</span></span></pre></div>
<a id="trunksrcwpsettingsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-settings.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-settings.php 2024-02-13 15:10:21 UTC (rev 57627)
+++ trunk/src/wp-settings.php 2024-02-13 15:10:37 UTC (rev 57628)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -276,10 +276,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-posts-controller.php';
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-attachments-controller.php';
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-global-styles-controller.php';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php';
</ins><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-types-controller.php';
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-statuses-controller.php';
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-revisions-controller.php';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php';
</del><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-template-revisions-controller.php';
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-autosaves-controller.php';
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-template-autosaves-controller.php';
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestglobalstylesrevisionscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php 2024-02-13 15:10:21 UTC (rev 57627)
+++ trunk/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php 2024-02-13 15:10:37 UTC (rev 57628)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -420,7 +420,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 58524
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @ticket 60131
</del><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_REST_Global_Styles_Controller::get_item_permissions_check
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -429,7 +428,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'GET', '/wp/v2/global-styles/' . self::$global_styles_id . '/revisions' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertErrorResponse( 'rest_cannot_read', $response, 403 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertErrorResponse( 'rest_cannot_view', $response, 403 );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -830,7 +829,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @doesNotPerformAssertions
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_context_param() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Controller does not implement get_context_param().
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Controller does not implement test_context_param().
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsqunitfixtureswpapigeneratedjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/qunit/fixtures/wp-api-generated.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/qunit/fixtures/wp-api-generated.js 2024-02-13 15:10:21 UTC (rev 57627)
+++ trunk/tests/qunit/fixtures/wp-api-generated.js 2024-02-13 15:10:37 UTC (rev 57628)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5811,207 +5811,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> ]
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "/wp/v2/global-styles/(?P<parent>[\\d]+)/revisions": {
- "namespace": "wp/v2",
- "methods": [
- "GET"
- ],
- "endpoints": [
- {
- "methods": [
- "GET"
- ],
- "args": {
- "parent": {
- "description": "The ID for the parent of the revision.",
- "type": "integer",
- "required": false
- },
- "context": {
- "description": "Scope under which the request is made; determines fields present in response.",
- "type": "string",
- "enum": [
- "view",
- "embed",
- "edit"
- ],
- "default": "view",
- "required": false
- },
- "page": {
- "description": "Current page of the collection.",
- "type": "integer",
- "default": 1,
- "minimum": 1,
- "required": false
- },
- "per_page": {
- "description": "Maximum number of items to be returned in result set.",
- "type": "integer",
- "minimum": 1,
- "maximum": 100,
- "required": false
- },
- "offset": {
- "description": "Offset the result set by a specific number of items.",
- "type": "integer",
- "required": false
- }
- }
- }
- ]
- },
- "/wp/v2/global-styles/(?P<parent>[\\d]+)/revisions/(?P<id>[\\d]+)": {
- "namespace": "wp/v2",
- "methods": [
- "GET"
- ],
- "endpoints": [
- {
- "methods": [
- "GET"
- ],
- "args": {
- "parent": {
- "description": "The ID for the parent of the global styles revision.",
- "type": "integer",
- "required": false
- },
- "id": {
- "description": "Unique identifier for the global styles revision.",
- "type": "integer",
- "required": false
- },
- "context": {
- "description": "Scope under which the request is made; determines fields present in response.",
- "type": "string",
- "enum": [
- "view",
- "embed",
- "edit"
- ],
- "default": "view",
- "required": false
- }
- }
- }
- ]
- },
- "/wp/v2/global-styles/themes/(?P<stylesheet>[\\/\\s%\\w\\.\\(\\)\\[\\]\\@_\\-]+)/variations": {
- "namespace": "wp/v2",
- "methods": [
- "GET"
- ],
- "endpoints": [
- {
- "methods": [
- "GET"
- ],
- "args": {
- "stylesheet": {
- "description": "The theme identifier",
- "type": "string",
- "required": false
- }
- }
- }
- ]
- },
- "/wp/v2/global-styles/themes/(?P<stylesheet>[^\\/:<>\\*\\?\"\\|]+(?:\\/[^\\/:<>\\*\\?\"\\|]+)?)": {
- "namespace": "wp/v2",
- "methods": [
- "GET"
- ],
- "endpoints": [
- {
- "methods": [
- "GET"
- ],
- "args": {
- "stylesheet": {
- "description": "The theme identifier",
- "type": "string",
- "required": false
- }
- }
- }
- ]
- },
- "/wp/v2/global-styles/(?P<id>[\\/\\w-]+)": {
- "namespace": "wp/v2",
- "methods": [
- "GET",
- "POST",
- "PUT",
- "PATCH"
- ],
- "endpoints": [
- {
- "methods": [
- "GET"
- ],
- "args": {
- "id": {
- "description": "The id of a template",
- "type": "string",
- "required": false
- }
- }
- },
- {
- "methods": [
- "POST",
- "PUT",
- "PATCH"
- ],
- "args": {
- "styles": {
- "description": "Global styles.",
- "type": [
- "object"
- ],
- "required": false
- },
- "settings": {
- "description": "Global settings.",
- "type": [
- "object"
- ],
- "required": false
- },
- "title": {
- "description": "Title of the global styles variation.",
- "type": [
- "object",
- "string"
- ],
- "properties": {
- "raw": {
- "description": "Title for the global styles variation, as it exists in the database.",
- "type": "string",
- "context": [
- "view",
- "edit",
- "embed"
- ]
- },
- "rendered": {
- "description": "HTML title for the post, transformed for display.",
- "type": "string",
- "context": [
- "view",
- "edit",
- "embed"
- ],
- "readonly": true
- }
- },
- "required": false
- }
- }
- }
- ]
- },
</del><span class="cx" style="display: block; padding: 0 10px"> "/wp/v2/navigation": {
</span><span class="cx" style="display: block; padding: 0 10px"> "namespace": "wp/v2",
</span><span class="cx" style="display: block; padding: 0 10px"> "methods": [
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -9370,7 +9169,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> "wp_block": "wp_block",
</span><span class="cx" style="display: block; padding: 0 10px"> "wp_template": "wp_template",
</span><span class="cx" style="display: block; padding: 0 10px"> "wp_template_part": "wp_template_part",
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "wp_global_styles": "wp_global_styles",
</del><span class="cx" style="display: block; padding: 0 10px"> "wp_navigation": "wp_navigation",
</span><span class="cx" style="display: block; padding: 0 10px"> "wp_font_family": "wp_font_family",
</span><span class="cx" style="display: block; padding: 0 10px"> "wp_font_face": "wp_font_face",
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10583,6 +10381,207 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> ]
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "/wp/v2/global-styles/(?P<parent>[\\d]+)/revisions": {
+ "namespace": "wp/v2",
+ "methods": [
+ "GET"
+ ],
+ "endpoints": [
+ {
+ "methods": [
+ "GET"
+ ],
+ "args": {
+ "parent": {
+ "description": "The ID for the parent of the revision.",
+ "type": "integer",
+ "required": false
+ },
+ "context": {
+ "description": "Scope under which the request is made; determines fields present in response.",
+ "type": "string",
+ "enum": [
+ "view",
+ "embed",
+ "edit"
+ ],
+ "default": "view",
+ "required": false
+ },
+ "page": {
+ "description": "Current page of the collection.",
+ "type": "integer",
+ "default": 1,
+ "minimum": 1,
+ "required": false
+ },
+ "per_page": {
+ "description": "Maximum number of items to be returned in result set.",
+ "type": "integer",
+ "minimum": 1,
+ "maximum": 100,
+ "required": false
+ },
+ "offset": {
+ "description": "Offset the result set by a specific number of items.",
+ "type": "integer",
+ "required": false
+ }
+ }
+ }
+ ]
+ },
+ "/wp/v2/global-styles/(?P<parent>[\\d]+)/revisions/(?P<id>[\\d]+)": {
+ "namespace": "wp/v2",
+ "methods": [
+ "GET"
+ ],
+ "endpoints": [
+ {
+ "methods": [
+ "GET"
+ ],
+ "args": {
+ "parent": {
+ "description": "The ID for the parent of the global styles revision.",
+ "type": "integer",
+ "required": false
+ },
+ "id": {
+ "description": "Unique identifier for the global styles revision.",
+ "type": "integer",
+ "required": false
+ },
+ "context": {
+ "description": "Scope under which the request is made; determines fields present in response.",
+ "type": "string",
+ "enum": [
+ "view",
+ "embed",
+ "edit"
+ ],
+ "default": "view",
+ "required": false
+ }
+ }
+ }
+ ]
+ },
+ "/wp/v2/global-styles/themes/(?P<stylesheet>[\\/\\s%\\w\\.\\(\\)\\[\\]\\@_\\-]+)/variations": {
+ "namespace": "wp/v2",
+ "methods": [
+ "GET"
+ ],
+ "endpoints": [
+ {
+ "methods": [
+ "GET"
+ ],
+ "args": {
+ "stylesheet": {
+ "description": "The theme identifier",
+ "type": "string",
+ "required": false
+ }
+ }
+ }
+ ]
+ },
+ "/wp/v2/global-styles/themes/(?P<stylesheet>[^\\/:<>\\*\\?\"\\|]+(?:\\/[^\\/:<>\\*\\?\"\\|]+)?)": {
+ "namespace": "wp/v2",
+ "methods": [
+ "GET"
+ ],
+ "endpoints": [
+ {
+ "methods": [
+ "GET"
+ ],
+ "args": {
+ "stylesheet": {
+ "description": "The theme identifier",
+ "type": "string",
+ "required": false
+ }
+ }
+ }
+ ]
+ },
+ "/wp/v2/global-styles/(?P<id>[\\/\\w-]+)": {
+ "namespace": "wp/v2",
+ "methods": [
+ "GET",
+ "POST",
+ "PUT",
+ "PATCH"
+ ],
+ "endpoints": [
+ {
+ "methods": [
+ "GET"
+ ],
+ "args": {
+ "id": {
+ "description": "The id of a template",
+ "type": "string",
+ "required": false
+ }
+ }
+ },
+ {
+ "methods": [
+ "POST",
+ "PUT",
+ "PATCH"
+ ],
+ "args": {
+ "styles": {
+ "description": "Global styles.",
+ "type": [
+ "object"
+ ],
+ "required": false
+ },
+ "settings": {
+ "description": "Global settings.",
+ "type": [
+ "object"
+ ],
+ "required": false
+ },
+ "title": {
+ "description": "Title of the global styles variation.",
+ "type": [
+ "object",
+ "string"
+ ],
+ "properties": {
+ "raw": {
+ "description": "Title for the global styles variation, as it exists in the database.",
+ "type": "string",
+ "context": [
+ "view",
+ "edit",
+ "embed"
+ ]
+ },
+ "rendered": {
+ "description": "HTML title for the post, transformed for display.",
+ "type": "string",
+ "context": [
+ "view",
+ "edit",
+ "embed"
+ ],
+ "readonly": true
+ }
+ },
+ "required": false
+ }
+ }
+ }
+ ]
+ },
</ins><span class="cx" style="display: block; padding: 0 10px"> "/wp/v2/settings": {
</span><span class="cx" style="display: block; padding: 0 10px"> "namespace": "wp/v2",
</span><span class="cx" style="display: block; padding: 0 10px"> "methods": [
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12975,36 +12974,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ]
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "wp_global_styles": {
- "description": "Global styles to include in themes.",
- "hierarchical": false,
- "has_archive": false,
- "name": "Global Styles",
- "slug": "wp_global_styles",
- "icon": null,
- "taxonomies": [],
- "rest_base": "global-styles",
- "rest_namespace": "wp/v2",
- "_links": {
- "collection": [
- {
- "href": "http://example.org/index.php?rest_route=/wp/v2/types"
- }
- ],
- "wp:items": [
- {
- "href": "http://example.org/index.php?rest_route=/wp/v2/global-styles"
- }
- ],
- "curies": [
- {
- "name": "wp",
- "href": "https://api.w.org/{rel}",
- "templated": true
- }
- ]
- }
- },
</del><span class="cx" style="display: block; padding: 0 10px"> "wp_navigation": {
</span><span class="cx" style="display: block; padding: 0 10px"> "description": "Navigation menus that can be inserted into your site.",
</span><span class="cx" style="display: block; padding: 0 10px"> "hierarchical": false,
</span></span></pre>
</div>
</div>
</body>
</html>