Make WordPress Core

Opened 4 months ago

Closed 7 weeks ago

#62585 closed enhancement (fixed)

Site Editor: Update the editor to use path based routing.

Reported by: youknowriad's profile youknowriad Owned by: peterwilsoncc's profile peterwilsoncc
Milestone: 6.8 Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch gutenberg-merge commit
Focuses: Cc:

Description

This ticket tracks the backports of the changes introduced in the following Gutenberg PR

https://github.com/WordPress/gutenberg/pull/67199

  • Redirect to the new site editor urls.
  • Remove limitation preventing overriding these urls in Gutenberg.

Change History (23)

This ticket was mentioned in PR #7903 on WordPress/wordpress-develop by @youknowriad.


4 months ago
#1

  • Keywords has-patch added

This backports the change introduced in Gutenberg in this PR https://github.com/WordPress/gutenberg/pull/67199
It includes:

  • Redirection of old site editor urls to the new correct ones.
  • Removing of condition to prevent loading the site editor.
  • Always pass the dashboard link option to the site editor.

@youknowriad commented on PR #7903:


4 months ago
#2

This patch will have to wait for the next package update to be able to get committed. As the new urls won't work until the package update.

#3 @joemcgill
2 months ago

  • Owner set to joemcgill
  • Status changed from new to reviewing

@Mamaduka and @youknowriad based on this comment:

This patch will have to wait for the next package update to be able to get committed. As the new urls won't work until the package update.

Does this mean that this should not be committed until after the first package sync during this release cycle? Just double checking whether this might be a blocker for the next sync of not.

#4 follow-up: @youknowriad
2 months ago

Correct, these redirects (in the patch) won't work unless the new site editor JS script is shipped.
The site editor JS script doesn't fully need this PHP code so it's fine to ship it before but the redirects are necessary for backwards compatibility of old urls.

So the order of shipping should be:

1- package update.
2- this ticket.

#5 in reply to: ↑ 4 @joemcgill
2 months ago

Replying to youknowriad:

Thanks for confirming!

@youknowriad commented on PR #7903:


2 months ago
#6

Is this the intended behavior? If so, it would be good to add a set of unit tests for _get_site_editor_redirection_url() that cover this intended behavior.

Yes, this is the intended behavior. Unfortunately, I don't have time to add unit tests or work on PRs at the moment.

#7 follow-up: @poena
2 months ago

I am seeing some conflict with this change and the introduction of the stylebook in classic themes:
https://github.com/WordPress/gutenberg/pull/66851
https://github.com/WordPress/wordpress-develop/pull/7865/

(the style book PR is the one that will require updating but I am unsure of how).

Last edited 2 months ago by poena (previous) (diff)

@peterwilsoncc commented on PR #7903:


8 weeks ago
#8

Unfortunately, I don't have time to add unit tests or work on PRs at the moment.

@youknowriad I've taken the liberty of pushing to your branch and will continue to do so ;)

  • documented global
  • fixed access annotation
  • switched to use wp_safe_redirect() in 6e2a8d8794c093d64f9c1874766d3c65d5f51f60

I'll add some unit tests once I've caught up on the ticket and am clear what they out to be.

@youknowriad commented on PR #7903:


8 weeks ago
#9

Thanks @peterwilsoncc

Just want to add that any change you make to these "backport PRs" should ideally also be made in the Gutenberg repository.

@joemcgill commented on PR #7903:


8 weeks ago
#10

Noticed that there was one existing test that was failing due to the new block editor setting being added. Addressed in 8da7a26.

@peterwilsoncc commented on PR #7903:


8 weeks ago
#11

@joemcgill Another thing I'd like is to use a wp prefix on the function (because of course I would), are you happy if I rename it _wp_get_site_editor_redirection_url() prior to commit. Otherwise, I'm happy to commit and add tests later.

@joemcgill commented on PR #7903:


8 weeks ago
#12

@peterwilsoncc I'm not opposed, but it's worth noting that there already :alot: of private functions in the global space not using this prefix (examples below).

Can you also take a look at updating the relevant code in the GB repo based on your previous changes?

===

Some examples:

26 results - 4 files

WP Dev • src/wp-includes/block-patterns.php:
   17   */
   18: function _register_core_block_patterns_and_categories() {
   19  	$should_register_core_patterns = get_theme_support( 'core-block-patterns' );

  215   */
  216: function _load_remote_block_patterns( $deprecated = null ) {
  217  	if ( ! empty( $deprecated ) ) {

  262   */
  263: function _load_remote_featured_patterns() {
  264  	$supports_core_patterns = get_theme_support( 'core-block-patterns' );

  303   */
  304: function _register_remote_theme_patterns() {
  305  	/** This filter is documented in wp-includes/block-patterns.php */

  348   */
  349: function _register_theme_block_patterns() {
  350  

WP Dev • src/wp-includes/block-template-utils.php:
  237   */
  238: function _filter_block_template_part_area( $type ) {
  239  	$allowed_areas = array_map(

  267   */
  268: function _get_block_templates_paths( $base_directory ) {
  269  	static $template_path_list = array();

  305   */
  306: function _get_block_template_file( $template_type, $slug ) {
  307  	if ( 'wp_template' !== $template_type && 'wp_template_part' !== $template_type ) {

  359   */
  360: function _get_block_templates_files( $template_type, $query = array() ) {
  361  	if ( 'wp_template' !== $template_type && 'wp_template_part' !== $template_type ) {

  461   */
  462: function _add_block_template_info( $template_item ) {
  463  	if ( ! wp_theme_has_theme_json() ) {

  484   */
  485: function _add_block_template_part_area_info( $template_info ) {
  486  	if ( wp_theme_has_theme_json() ) {

  509   */
  510: function _flatten_blocks( &$blocks ) {
  511  	$all_blocks = array();

  540   */
  541: function _inject_theme_attribute_in_template_part_block( &$block ) {
  542  	if (

  557   */
  558: function _remove_theme_attribute_from_template_part_block( &$block ) {
  559  	if (

  577   */
  578: function _build_block_template_result_from_file( $template_file, $template_type ) {
  579  	$default_template_types = get_default_block_template_types();

  816   */
  817: function _build_block_template_object_from_post_object( $post, $terms = array(), $meta = array() ) {
  818  	if ( empty( $terms['wp_theme'] ) ) {

  870   */
  871: function _build_block_template_result_from_post( $post ) {
  872  	$post_id = wp_is_post_revision( $post );

WP Dev • src/wp-includes/block-template.php:
   13   */
   14: function _add_template_loader_filters() {
   15  	if ( isset( $_GET['_wp-find-template'] ) && current_theme_supports( 'block-templates' ) ) {

  231   */
  232: function _block_template_render_title_tag() {
  233  	echo '<title>' . wp_get_document_title() . '</title>' . "\n";

  314   */
  315: function _block_template_viewport_meta_tag() {
  316  	echo '<meta name="viewport" content="width=device-width, initial-scale=1" />' . "\n";

  327   */
  328: function _strip_template_file_suffix( $template_file ) {
  329  	return preg_replace( '/\.(php|html)$/', '', $template_file );

  341   */
  342: function _block_template_render_without_post_block_context( $context ) {
  343  	/*

  367   */
  368: function _resolve_template_for_new_post( $wp_query ) {
  369  	if ( ! $wp_query->is_main_query() ) {

WP Dev • src/wp-includes/blocks.php:
  1885   */
  1886: function _filter_block_content_callback( $matches ) {
  1887  	return '';

  2097   */
  2098: function _excerpt_render_inner_blocks( $parsed_block, $allowed_blocks ) {
  2099  	$output = '';

  2312   */
  2313: function _restore_wpautop_hook( $content ) {
  2314  	$current_priority = has_filter( 'the_content', '_restore_wpautop_hook' );

@peterwilsoncc commented on PR #7903:


8 weeks ago
#13

but it's worth noting that there already :alot: of private functions in the global space not using this prefix (examples below).

Yeah, I know. It's not something we committers have been consistent catching in the past but it's only possible to fix code going forward.

@peterwilsoncc commented on PR #7903:


8 weeks ago
#14

Sorry, I just noticed it's using a 301 redirect rather than a 302. I think wp tends to use 302's within the admin as 301s are cached by the browser so it may produce unexpected results once the user is logged out.

@peterwilsoncc commented on PR #7903:


7 weeks ago
#15

I think this is good to go in to Core but it will need to be committed shortly after the first package update so the redirected URLs work.

#16 @joemcgill
7 weeks ago

  • Keywords gutenberg-merge added

#17 @joemcgill
7 weeks ago

  • Keywords changed from has-patch, gutenberg-merge to has-patch gutenberg-merge
  • Status changed from reviewing to accepted

#18 @joemcgill
7 weeks ago

  • Keywords commit added
  • Owner changed from joemcgill to peterwilsoncc
  • Status changed from accepted to assigned

Reassigning to @peterwilsoncc who volunteered to wrap this one off :hero:

This ticket was mentioned in Slack in #core by peterwilsoncc. View the logs.


7 weeks ago

#20 in reply to: ↑ 7 @peterwilsoncc
7 weeks ago

Replying to poena:

I am seeing some conflict with this change and the introduction of the stylebook in classic themes:
https://github.com/WordPress/gutenberg/pull/66851
https://github.com/WordPress/wordpress-develop/pull/7865/

(the style book PR is the one that will require updating but I am unsure of how).

@poena Just so I am clear, is the PR linked to this issue good to merge prior to resolving the stylebook issue?

This ticket was mentioned in Slack in #core-editor by poena. View the logs.


7 weeks ago

#22 @poena
7 weeks ago

Yes, any changes needed related to Site Editor access in classic themes can be a follow up.
It is not 100% set yet if the stylebook in classic themes will be opt-in or opt out or neither.

#23 @peterwilsoncc
7 weeks ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 59794:

Site Editor: Redirect deprecated URLs to path based routing.

The site editor now uses path based routing rather than query string arguments. This redirects the legacy query string URLs to the new routing.

Props youknowriad, peterwilsoncc, joemcgill, mukesh27, poena.
Fixes #62585.

Note: See TracTickets for help on using tickets.