simpletoc icon indicating copy to clipboard operation
simpletoc copied to clipboard

Incompatibility with the widget editor from a classic theme

Open elcapo opened this issue 5 months ago • 2 comments

The issue

To reproduce this issue:

  1. install the plugin in a WordPress v6.8.2
  2. use a theme with the 3 files below
  3. then navigate to the appearance > widgets page

at that point, this warning will be rendered:

Notice: Function wp_enqueue_script() was called incorrectly. "wp-editor" script should not be enqueued together with the new widgets editor (wp-edit-widgets or wp-customize-widgets). Please see Debugging in WordPress for more information. (This message was added in version 5.8.0.) in /var/www/html/wp-includes/functions.php on line 6121

There is information about this in https://github.com/WordPress/gutenberg/issues/67333.

Minimal theme to reproduce the issue

style.css

/*
Theme Name: Editor Conflict
Theme URI: https://example.com
Author: You
Version: 1.0
Description: Minimal theme to reproduce wp-editor enqueue conflict in Widgets screen.
*/

functions.php

<?php

add_action('widgets_init', function () {
	register_sidebar(
		array(
			'id'            => 'primary',
			'name'          => __( 'Primary Sidebar' ),
			'description'   => __( 'A short description of the sidebar.' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget'  => '</div>',
			'before_title'  => '<h3 class="widget-title">',
			'after_title'   => '</h3>',
		)
	);
});

index.php

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Editor Conflict</title>
    <?php wp_head(); ?>
</head>
<body>
    <?php wp_footer(); ?>
</body>
</html>

Solution

The quickest solution I've found is to remove wp-editor from the list of dependencies of the plugin. I'll be sending a PR for consideration a few minutes after publishing this issue.

elcapo avatar Jul 22 '25 20:07 elcapo

It is not obvious why we need such a hack. The widgets menu is deprecated, isn't it? See here: #71

mtoensing avatar Aug 17 '25 11:08 mtoensing

Ho @mtoensing,

The issue and the pull request #71 are meant to be related. This is the issue and the pull request attempts to solve it.

I'm not actually interested in making this work with widgets but to remove a notice message that's shown when used along with a classical theme. In particular, when the plugin is enabled and the widgets area is visited, this notice is shown (see the top left corner of the screenshot):

Image

I'll take a look at your suggestions in the PR and try to find a more elegant feature detection solution.

Thanks for the patience.

elcapo avatar Aug 18 '25 13:08 elcapo