Skip to content

Commit

Permalink
prep build 11/28
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Nov 28, 2024
2 parents 9c6154a + 45d9528 commit 22f987e
Show file tree
Hide file tree
Showing 162 changed files with 4,239 additions and 2,188 deletions.
3 changes: 3 additions & 0 deletions backport-changelog/6.8/7903.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/7903

* https://github.com/WordPress/gutenberg/pull/67199
3 changes: 3 additions & 0 deletions backport-changelog/6.8/7909.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/7909

* https://github.com/WordPress/gutenberg/pull/67330
291 changes: 291 additions & 0 deletions changelog.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/reference-guides/data/data-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ _Parameters_
- _state_ `State`: State tree
- _kind_ `string`: Entity kind.
- _name_ `string`: Entity name.
- _key_ `EntityRecordKey`: Record's key
- _key_ `EntityRecordKey`: Optional record's key. If requesting a global record (e.g. site settings), the key can be omitted. If requesting a specific item, the key must always be included.
- _query_ `GetRecordsHttpQuery`: Optional query. If requesting specific fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available "Retrieve a [Entity kind]".

_Returns_
Expand Down
62 changes: 62 additions & 0 deletions lib/compat/wordpress-6.8/class-gutenberg-rest-user-controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

/**
* Add search_columns parameter to users endpoint parameters
*
* @param array $query_params JSON Schema-formatted collection parameters.
* @return array Updated collection parameters
*/
function gutenberg_add_search_columns_param( $query_params ) {
$query_params['search_columns'] = array(
'default' => array(),
'description' => __( 'Array of column names to be searched.' ),
'type' => 'array',
'items' => array(
'enum' => array( 'email', 'name', 'id', 'username', 'slug' ),
'type' => 'string',
),
);

return $query_params;
}

add_filter( 'rest_user_collection_params', 'gutenberg_add_search_columns_param', 10, 1 );

/**
* Modify user query based on search_columns parameter
*
* @param array $prepared_args Array of arguments for WP_User_Query.
* @param WP_REST_Request $request The REST API request.
* @return array Modified arguments
*/
function gutenberg_modify_user_query_args( $prepared_args, $request ) {
if ( $request->get_param( 'search' ) && $request->get_param( 'search_columns' ) ) {
$search_columns = $request->get_param( 'search_columns' );

// Validate search columns
$valid_columns = isset( $prepared_args['search_columns'] )
? $prepared_args['search_columns']
: array( 'ID', 'user_login', 'user_nicename', 'user_email', 'user_url', 'display_name' );
$search_columns_mapping = array(
'id' => 'ID',
'username' => 'user_login',
'slug' => 'user_nicename',
'email' => 'user_email',
'name' => 'display_name',
);
$search_columns = array_map(
static function ( $column ) use ( $search_columns_mapping ) {
return $search_columns_mapping[ $column ];
},
$search_columns
);
$search_columns = array_intersect( $search_columns, $valid_columns );

if ( ! empty( $search_columns ) ) {
$prepared_args['search_columns'] = $search_columns;
}
}

return $prepared_args;
}
add_filter( 'rest_user_query', 'gutenberg_modify_user_query_args', 10, 2 );
124 changes: 124 additions & 0 deletions lib/compat/wordpress-6.8/site-editor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?php
/**
* Updates to the site editor in 6.8.
*
* Adds a mandatory dashboard link and redirects old urls.
*
* @package gutenberg
*/

add_filter(
'block_editor_settings_all',
function ( $settings ) {
$settings['__experimentalDashboardLink'] = admin_url( '/' );
return $settings;
}
);

function gutenberg_get_site_editor_redirection() {
global $pagenow;
if ( 'site-editor.php' !== $pagenow || isset( $_REQUEST['p'] ) || ! $_SERVER['QUERY_STRING'] ) {
return false;
}

// The following redirects are for the new permalinks in the site editor.
if ( isset( $_REQUEST['postType'] ) && 'wp_navigation' === $_REQUEST['postType'] && ! empty( $_REQUEST['postId'] ) ) {
return add_query_arg( array( 'p' => '/wp_navigation/' . $_REQUEST['postId'] ), remove_query_arg( array( 'postType', 'postId' ) ) );
}

if ( isset( $_REQUEST['postType'] ) && 'wp_navigation' === $_REQUEST['postType'] && empty( $_REQUEST['postId'] ) ) {
return add_query_arg( array( 'p' => '/navigation' ), remove_query_arg( 'postType' ) );
}

if ( isset( $_REQUEST['path'] ) && '/wp_global_styles' === $_REQUEST['path'] ) {
return add_query_arg( array( 'p' => '/styles' ), remove_query_arg( 'path' ) );
}

if ( isset( $_REQUEST['postType'] ) && 'page' === $_REQUEST['postType'] && ( empty( $_REQUEST['canvas'] ) || empty( $_REQUEST['postId'] ) ) ) {
return add_query_arg( array( 'p' => '/page' ), remove_query_arg( 'postType' ) );
}

if ( isset( $_REQUEST['postType'] ) && 'page' === $_REQUEST['postType'] && ! empty( $_REQUEST['postId'] ) ) {
return add_query_arg( array( 'p' => '/page/' . $_REQUEST['postId'] ), remove_query_arg( array( 'postType', 'postId' ) ) );
}

if ( isset( $_REQUEST['postType'] ) && 'wp_template' === $_REQUEST['postType'] && ( empty( $_REQUEST['canvas'] ) || empty( $_REQUEST['postId'] ) ) ) {
return add_query_arg( array( 'p' => '/template' ), remove_query_arg( 'postType' ) );
}

if ( isset( $_REQUEST['postType'] ) && 'wp_template' === $_REQUEST['postType'] && ! empty( $_REQUEST['postId'] ) ) {
return add_query_arg( array( 'p' => '/wp_template/' . $_REQUEST['postId'] ), remove_query_arg( array( 'postType', 'postId' ) ) );
}

if ( isset( $_REQUEST['postType'] ) && 'wp_block' === $_REQUEST['postType'] && ( empty( $_REQUEST['canvas'] ) || empty( $_REQUEST['postId'] ) ) ) {
return add_query_arg( array( 'p' => '/pattern' ), remove_query_arg( 'postType' ) );
}

if ( isset( $_REQUEST['postType'] ) && 'wp_block' === $_REQUEST['postType'] && ! empty( $_REQUEST['postId'] ) ) {
return add_query_arg( array( 'p' => '/wp_block/' . $_REQUEST['postId'] ), remove_query_arg( array( 'postType', 'postId' ) ) );
}

if ( isset( $_REQUEST['postType'] ) && 'wp_template_part' === $_REQUEST['postType'] && ( empty( $_REQUEST['canvas'] ) || empty( $_REQUEST['postId'] ) ) ) {
return add_query_arg( array( 'p' => '/pattern' ) );
}

if ( isset( $_REQUEST['postType'] ) && 'wp_template_part' === $_REQUEST['postType'] && ! empty( $_REQUEST['postId'] ) ) {
return add_query_arg( array( 'p' => '/wp_template_part/' . $_REQUEST['postId'] ), remove_query_arg( array( 'postType', 'postId' ) ) );
}

// The following redirects are for backward compatibility with the old site editor URLs.
if ( isset( $_REQUEST['path'] ) && '/wp_template_part/all' === $_REQUEST['path'] ) {
return add_query_arg(
array(
'p' => '/pattern',
'postType' => 'wp_template_part',
),
remove_query_arg( 'path' )
);
}

if ( isset( $_REQUEST['path'] ) && '/page' === $_REQUEST['path'] ) {
return add_query_arg( array( 'p' => '/page' ), remove_query_arg( 'path' ) );
}

if ( isset( $_REQUEST['path'] ) && '/wp_template' === $_REQUEST['path'] ) {
return add_query_arg( array( 'p' => '/template' ), remove_query_arg( 'path' ) );
}

if ( isset( $_REQUEST['path'] ) && '/patterns' === $_REQUEST['path'] ) {
return add_query_arg( array( 'p' => '/pattern' ), remove_query_arg( 'path' ) );
}

if ( isset( $_REQUEST['path'] ) && '/navigation' === $_REQUEST['path'] ) {
return add_query_arg( array( 'p' => '/navigation' ), remove_query_arg( 'path' ) );
}

return add_query_arg( array( 'p' => '/' ) );
}

function gutenberg_redirect_site_editor_deprecated_urls() {
$redirection = gutenberg_get_site_editor_redirection();
if ( false !== $redirection ) {
wp_redirect( $redirection, 301 );
exit;
}
}
add_action( 'admin_init', 'gutenberg_redirect_site_editor_deprecated_urls' );

/**
* Filter the `wp_die_handler` to allow access to the Site Editor's new pages page
* for Classic themes.
*
* site-editor.php's access is forbidden for hybrid/classic themes and only allowed with some very special query args (some very special pages like template parts...).
* The only way to disable this protection since we're changing the urls in Gutenberg is to override the wp_die_handler.
*
* @param callable $default_handler The default handler.
* @return callable The default handler or a custom handler.
*/
function gutenberg_styles_wp_die_handler( $default_handler ) {
if ( ! wp_is_block_theme() && str_contains( $_SERVER['REQUEST_URI'], 'site-editor.php' ) && isset( $_GET['p'] ) ) {
return '__return_false';
}
return $default_handler;
}
add_filter( 'wp_die_handler', 'gutenberg_styles_wp_die_handler' );
12 changes: 0 additions & 12 deletions lib/experimental/posts/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,6 @@ function gutenberg_posts_dashboard() {
echo '<div id="gutenberg-posts-dashboard"></div>';
}

/**
* Redirects to the new posts dashboard page and adds the postType query arg.
*/
function gutenberg_add_post_type_arg() {
global $pagenow;
if ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'gutenberg-posts-dashboard' === $_GET['page'] && empty( $_GET['postType'] ) ) {
wp_redirect( admin_url( '/admin.php?page=gutenberg-posts-dashboard&postType=post' ) );
exit;
}
}
add_action( 'admin_init', 'gutenberg_add_post_type_arg' );

/**
* Replaces the default posts menu item with the new posts dashboard.
*/
Expand Down
2 changes: 2 additions & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/compat/wordpress-6.8/blocks.php';
require __DIR__ . '/compat/wordpress-6.8/functions.php';
require __DIR__ . '/compat/wordpress-6.8/post.php';
require __DIR__ . '/compat/wordpress-6.8/site-editor.php';
require __DIR__ . '/compat/wordpress-6.8/class-gutenberg-rest-user-controller.php';

// Experimental features.
require __DIR__ . '/experimental/block-editor-settings-mobile.php';
Expand Down
12 changes: 9 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';

/**
* Internal dependencies
*/
import { AlignmentToolbar } from '..';

/**
* The `AlignmentToolbar` component renders a dropdown menu that displays alignment options for the selected block in `Toolbar`.
*/
const meta = {
title: 'BlockEditor/AlignmentToolbar',
component: AlignmentToolbar,
argTypes: {
value: {
control: { type: null },
defaultValue: 'undefined',
description: 'The current value of the alignment setting.',
},
onChange: {
action: 'onChange',
control: { type: null },
description:
"A callback function invoked when the toolbar's alignment value is changed via an interaction with any of the toolbar's buttons. Called with the new alignment value (ie: `left`, `center`, `right`, `undefined`) as the only argument.",
},
},
};
export default meta;

export const Default = {
render: function Template( { onChange, ...args } ) {
const [ value, setValue ] = useState();
return (
<AlignmentToolbar
{ ...args }
onChange={ ( ...changeArgs ) => {
onChange( ...changeArgs );
setValue( ...changeArgs );
} }
value={ value }
/>
);
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';

/**
* Internal dependencies
*/
import { AlignmentControl } from '../';

/**
* The `AlignmentControl` component renders a dropdown menu that displays alignment options for the selected block.
*
* This component is mostly used for blocks that display text, such as Heading, Paragraph, Post Author, Post Comments, Verse, Quote, Post Title, etc... And the available alignment options are `left`, `center` or `right` alignment.
*
* If you want to use the alignment control in a toolbar, you should use the `AlignmentToolbar` component instead.
*/
const meta = {
title: 'BlockEditor/AlignmentControl',
component: AlignmentControl,
argTypes: {
value: {
control: { type: null },
defaultValue: 'undefined',
description: 'The current value of the alignment setting.',
},
onChange: {
action: 'onChange',
control: { type: null },
description:
"A callback function invoked when the toolbar's alignment value is changed via an interaction with any of the toolbar's buttons. Called with the new alignment value (ie: `left`, `center`, `right`, `undefined`) as the only argument.",
},
},
};
export default meta;

export const Default = {
render: function Template( { onChange, ...args } ) {
const [ value, setValue ] = useState();
return (
<AlignmentControl
{ ...args }
onChange={ ( ...changeArgs ) => {
onChange( ...changeArgs );
setValue( ...changeArgs );
} }
value={ value }
/>
);
},
};
Loading

0 comments on commit 22f987e

Please sign in to comment.