WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#35895 closed defect (bug) (fixed)

Widgets and Nav Menus components produce errors if user only has customize capability

Reported by: westonruter Owned by: westonruter
Milestone: 4.5 Priority: normal
Severity: normal Version: 4.0
Component: Customize Keywords: has-patch commit
Focuses: Cc:

Description

In #28605, a customize capability was introduced to allow a plugin to grant users (e.g. subscribers) access to the Customizer without having to grant all edit_theme_options. However, the Widgets and Nav Menus components currently are not fully taking this into account, resulting in errors when objects are not present as expected

There is a PHP notice:

Notice: Trying to get property of non-object in .../wp-includes/class-wp-customize-nav-menus.php on line 368

And a JS error:

Uncaught TypeError: Cannot read property 'bind' of undefined in customize-preview-widgets.js

Relates to having discrete capabilities for editing nav menus (#29213) and widgets (#31020).

Attachments (1)

35895.0.diff (2.7 KB) - added by westonruter 4 years ago.

Download all attachments as: .zip

Change History (3)

@westonruter
4 years ago

#1 @westonruter
4 years ago

  • Keywords has-patch commit added
  • Owner set to westonruter
  • Status changed from new to accepted

#2 @westonruter
4 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 36611:

Customize: Prevent PHP notice and JS error caused by widgets and nav menus components if user only has customize capability.

Short-circuits components from initializing their hooks needlessly if current user lacks required capability.

Fixes #35895.

Note: See TracTickets for help on using tickets.