WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 11 months ago

#39451 new defect (bug)

Javascript error when link_manager_enabled ( WP_Widget_Links) and theme supports customize-selective-refresh-widgets

Reported by: nikeo Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.5
Component: Customize Keywords: has-patch
Focuses: javascript Cc:
PR Number:

Description

The error occurs in the customizer when a user uses the WP_Widget_Links widget has enabled support for customize-selective-refresh-widgets.

The WP_Widget_Links is now deprecated, but it is retro-compatible if user had it already installed.

The error message in the browser js console looks like this :

customize-preview-widgets.js?ver=4.7:63 Uncaught Error: Illegal id for widget partial.
    at child.initialize (customize-preview-widgets.js?ver=4.7:63)
    at child.api.Class (customize-base.js?ver=4.7:93)
    at child [as constructor] (customize-base.js?ver=4.7:34)
    at new child (customize-base.js?ver=4.7:34)
    at HTMLDivElement.<anonymous> (customize-selective-refresh.js?ver=4.7:863)
    at Function.each (jquery.js?ver=1.12.4:2)
    at jQuery.fn.init.each (jquery.js?ver=1.12.4:2)
    at Object.wp.customize.selectiveRefresh.self.addPartials (customize-selective-refresh.js?ver=4.7:850)
    at Function.<anonymous> (customize-selective-refresh.js?ver=4.7:961)
    at i (jquery.js?ver=1.12.4:2)

Theme or plugin developers can fix the problem by removing the support for customize-selective-refresh-widgets if link_manager_enabled is set to true. But a core fix would be better of course.

Temporary solution :

if ( ! get_option( 'link_manager_enabled' ) ) {
   add_theme_support( 'customize-selective-refresh-widgets' );
}

Attachments (1)

39451.diff (685 bytes) - added by dlh 23 months ago.

Download all attachments as: .zip

Change History (10)

#1 @nikeo
3 years ago

There's a typo in my description. I meant : The error occurs in the customizer when a user uses the WP_Widget_Links widget and has enabled support for customize-selective-refresh-widgets.

Last edited 3 years ago by nikeo (previous) (diff)

#2 @westonruter
3 years ago

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

Coincidentally I also ran across this issue myself in working on the JS Widgets plugin for #33507 and #35574.

#3 @westonruter
3 years ago

  • Version changed from 4.7 to 4.5

#4 @nikeo
3 years ago

OK.
The bug was reported by two different users for my theme Hueman.
The latest topic is this one : https://wordpress.org/support/topic/customizer-never-loads-in-chrome-with-hueman-addon-plugin-enables/
cheers

#5 @greenshady
2 years ago

I've run into this problem too with users. I've also seen it within a plugin of mine that creates a more robust links widget.

I think this is because the links widget creates "fake" widgets on output. Each category of links is wrapped into its own widget markup. And, the customizer JS is looking to match actual widgets.

Even disabling the customize_selective_refresh for the Links widget doesn't address the issue.

This ticket was mentioned in Slack in #core-customize by presskopp. View the logs.


23 months ago

@dlh
23 months ago

#7 @dlh
23 months ago

  • Keywords has-patch added; needs-patch removed

WP_Widget_Links::widget() contains a preg_replace() for the id attribute that also seems to be affecting the data-customize-partial-id attribute, creating the "illegal id." The fix might be as straightforward as adjusting the regex pattern, which I've tried in 39451.diff.

#8 @rayfusci
12 months ago

This 39451.diff patch is not present in v4.9.8. Any plans to include it? It does resolve this problem, at least in some cases; it resolved this problem in my case.

Last edited 12 months ago by rayfusci (previous) (diff)

#9 @dlh
11 months ago

#45314 was marked as a duplicate.

Note: See TracTickets for help on using tickets.