Skip to content

Classic theme preview: Potential issues with JavaScript loaded by themes #68952

Open
@carolinan

Description

@carolinan

Description

When a classic theme adds the theme support for editor-styles, a menu item called "Design" replaces the Pattern menu, and following this link shows the dark sidebar and an iframe with the site embedded.
The preview of the front of the site replaces the preview of the editor that is shown for block themes.

Many themes may load custom JavaScript, potentially causing errors on this screen.
For example, the theme Hello Elementor adds JavaScript for their admin notice, and there is a console error.

How can themes detect that the user is viewing this screen, and prevent loading JavaScript that is meant for other admin pages?
It does not seem possible with https://developer.wordpress.org/reference/functions/get_current_screen/

Step-by-step reproduction instructions

Activate a classic theme with support for editor-styles.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Site EditorRelated to the overarching Site Editor (formerly "full site editing")[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions