WordPress.org

Make WordPress Core

#45314 closed defect (bug) (duplicate)

Links widget breaks live preview in customizer

Reported by: angelocarosio Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Customize Keywords:
Focuses: Cc:

Description

I saw a few other tickets on this from a while ago but it doesn't seem like an actual fix has ever made it into core. I did some digging on this to maybe point in the right direction, there are basically 2 issues:

  1. The regex on line 51 of class-wp-widget-links.php is replacing the live preview IDs that are injected into the widget containers inside the customizer. As it currently is, adding any links widget breaks the edit shortcuts and live preview ability for all other widgets in the widget area.
  1. While I was able to basically fix #1 by filtering some widget args, there is still another issue. When the widget is set to show multiple categories, each category gets its own widget container markup (line 56 and 57). This breaks the 1:1 relationship between the widget and its container that the customizer is expecting, so even if #1 is fixed, changing options around causes multiple copies of the widget to be inserted inside the customizer. Wrapping everything in an additional div and giving that the widget markup seems to fix this problem, but that's obviously not a fix I can make.

Turning off 'customize_selective_refresh' => true, in the widget options obviously also fixes this, and I think most people would be happier with a working links widget even if selective refresh isn't supported, considering this is technically a depreciated feature.

Attachments (3)

markup causing error.png (102.9 KB) - added by angelocarosio 21 months ago.
js error.png (39.3 KB) - added by angelocarosio 21 months ago.
post regex fix -- multiple widget copies.png (109.9 KB) - added by angelocarosio 21 months ago.

Download all attachments as: .zip

Change History (4)

#1 @dlh
21 months ago

  • Component changed from Widgets to Customize
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi @angelocarosio, and welcome to WordPress Trac!

As you noted, this issue has been previously reported. I would recommend posting your findings and any suggested changes to #39451.

Note: See TracTickets for help on using tickets.