WordPress.org

Make WordPress Core

#27619 closed defect (bug) (fixed)

Widget Customizer: Scripts from plugins can be missing.

Reported by: ocean90 Owned by: ocean90
Milestone: 3.9 Priority: normal
Severity: major Version: 3.9
Component: Customize Keywords: has-patch
Focuses: Cc:

Description

If a plugin enqueue scripts via admin_enqueue_scripts and styles via admin_print_styles the scripts aren't available in the Customizer, because the named hooks aren't used there. The Customizer has it's own actions like customize_controls_print_styles or customize_controls_print_scripts.

The attached patch calls the admin hooks in Customizer's hooks. Currently I have ignored the general admin_head and admin_footer actions.

Original report: https://wordpress.org/support/topic/widgets-customizer-not-loading-widget-styles-and-scripts

Attachments (2)

27619.patch (3.0 KB) - added by ocean90 12 months ago.
27619.2.patch (4.9 KB) - added by westonruter 12 months ago.
Add a div#widgets-right container element to customizer for compat with widget scripts that do event delegation from that element; less hacky hack. Do admin_enqueue_scripts after enqueueing customize-widgets. https://github.com/x-team/wordpress-develop/compare/trac-27619

Download all attachments as: .zip

Change History (4)

@ocean9012 months ago

comment:1 @ircbot12 months ago

This ticket was mentioned in IRC in #wordpress-dev by ocean90. View the logs.

@westonruter12 months ago

Add a div#widgets-right container element to customizer for compat with widget scripts that do event delegation from that element; less hacky hack. Do admin_enqueue_scripts after enqueueing customize-widgets. https://github.com/x-team/wordpress-develop/compare/trac-27619

comment:2 @ocean9012 months ago

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

In 27907:

Widget Customizer: Improve plugin compatibility.

Some plugins are using custom scripts and styles for there widgets. These are available on the Widgets screens, but not in the Customizer yet.
Scripts and styles can be enqueued via:

  • admin_enqueue_scripts
  • admin_print_scripts and admin_print_scripts-widgets.php
  • admin_print_styles and admin_print_styles-widgets.php
  • admin_print_footer_scripts and admin_footer-widgets.php

All this hooks are now called in the Customizer too.

Previously we have add the #widgets-right ID to a container div via jQuery. Remember: #widgets-right exists on the Widgets screen and is used by many plugins to do event delegation from that element.
But since our script files are loaded in the footer, the JavaScript way is a bit late for some plugins.
We have decided to add a div#widgets-right container element to customizer. "Less hacky hack."

props westonruter, ocean90. Thanks dpe415 for testing.
fixes #27619.

Note: See TracTickets for help on using tickets.