Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 4 years ago

#46686 closed defect (bug) (fixed)

Customize Close Button Not Updating URL

Reported by: jarretc's profile JarretC Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.4 Priority: normal
Severity: normal Version:
Component: Customize Keywords: has-patch
Focuses: Cc:

Description

Currently the close button at the top left of the Customize menu uses whatever URL you visited the Customizer from. If you activate a theme that has documentation, view that page, then go to Appearance->Customize and change to a new theme the exit button still points to the old theme documentation.

Upon trying to exit out, you're redirected to a 'Sorry, you are not allowed to access this page.' message.

To replicate...

  1. Download Tonic theme ( https://wordpress.org/themes/tonic/ ) or any other that has custom documentation
  2. Visit the theme documentation ( /wp-admin/themes.php?page=bavotasan_documentation )
  3. Open up Appearance->Customize from the documentation page
  4. Activate any other theme
  5. Attempt to close out of the Customizer using the X at the top left, it will still point to /wp-admin/themes.php?page=bavotasan_documentation even though the theme is no longer active

Attachments (1)

46686.diff (703 bytes) - added by Jean-David 6 years ago.

Download all attachments as: .zip

Change History (12)

#1 @dlh
6 years ago

Seems like this would be an issue with any theme-generated admin screen (or plugin-generated — see #40451), not just documentation screens.

@JarretC Any thoughts about where the "close" link should go after activating the other theme?

#2 @JarretC
6 years ago

Correct, any screen specific to the previously activated theme, I had just run across the issue messing around with that theme so used it as my example.

In regards to the redirect, I would think that /wp-admin/themes.php would be suitable.

#3 @SergeyBiryukov
6 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

#4 @Jean-David
6 years ago

Is this even possible to know what is an accepted URL in this case ?
A theme can add query parameters from anywhere, so what allows us to distinguish between core query parameters and custom made ones ?
wp-admin/themes.php?page=bavotasan_documentation is custom but wp-admin/edit.php?post_type=page is not. In my example each URL has query parameters in it.

@SergeyBiryukov do you think it's possible ? Could you share your experience on this ?

#5 @JarretC
6 years ago

@Jean-David not sure I follow about the query parameters.... once the Close button is clicked on, it should just redirect back to /wp-admin/themes.php or something theme related whether the current URL has a query parameter or not

@Jean-David
6 years ago

#6 @Jean-David
6 years ago

  • Keywords has-patch added; needs-patch removed

I'm not sure if it's a real problem, it's been this behaviour since 3.0. Anyway I tried to make a patch, we'll see.

Last edited 6 years ago by Jean-David (previous) (diff)

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


6 years ago

#8 @SergeyBiryukov
6 years ago

Looking at 46686.diff, we cannot just remove $wp_customize->get_return_url() there, as the Close button would then always lead to the Themes screen instead of the previous page.

Seems like some logic should be added to WP_Customize_Manager::get_return_url() to check if the return link still exists, by checking the $_registered_pages global, something similar to user_can_access_admin_page().

A unit test would also be great, Tests_WP_Customize_Manager::test_return_url() could be used as an example.

#9 @SergeyBiryukov
6 years ago

  • Milestone changed from Future Release to 5.4

#10 @SergeyBiryukov
6 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 46754:

Customize: If the return URL for Close button is a page added to the Appearance menu by a deactivated theme, fall back to the Themes screen.

Props JarretC, Jean-David, SergeyBiryukov.
Fixes #46686.

This ticket was mentioned in Slack in #core-php by hellofromtonya. View the logs.


4 years ago

Note: See TracTickets for help on using tickets.