Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#35242 closed defect (bug) (fixed)

PHP Noticed caused by Customizer if widgets panel removed

Reported by: djpaul's profile DJPaul Owned by: westonruter's profile westonruter
Milestone: 4.5 Priority: normal
Severity: normal Version: 4.4
Component: Customize Keywords: has-patch
Focuses: Cc:

Description

If $wp_customize->remove_panel( 'widgets' ); is done, the Customizer throws a PHP Notice:

PHP Notice: Trying to get property of non-object in /srv/www/buddypress.dev/src/wp-includes/class-wp-customize-widgets.php on line 716

Tested on 4.4 SVN branch.

Attachments (3)

35242.diff (846 bytes) - added by voldemortensen 9 years ago.
35242(1).diff (846 bytes) - added by voldemortensen 9 years ago.
35242.2.diff (1.1 KB) - added by DrewAPicture 9 years ago.

Download all attachments as: .zip

Change History (14)

#1 @johnbillion
9 years ago

  • Keywords needs-patch added

#2 @ericlewis
9 years ago

  • Keywords needs-patch removed

Hi @DJPaul — there's a special way to remove a Customizer component.

Perhaps we need to review documentation here, to point developers in the right direction?

#3 @DJPaul
9 years ago

Thanks. I discovered the remove_panel method from a blog post on make/core. Maybe the docblock for remove_panel could say don't use this to remove the core widgets or nav menus panels, maybe.

@voldemortensen
9 years ago

#4 follow-up: @voldemortensen
9 years ago

  • Keywords has-patch added

35242.diff adds a _doing_it_wrong warning. Thoughts?

#5 in reply to: ↑ 4 @westonruter
9 years ago

Replying to voldemortensen:

35242.diff adds a _doing_it_wrong warning. Thoughts?

Good idea.

Feedback:

#6 @voldemortensen
9 years ago

Thanks for the feedback, updated the patch.

#7 @westonruter
9 years ago

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

In 36216:

Customizer: Call _doing_it_wrong() if widgets or nav_menus are manually removed via WP_Customize_Manager::remove_panel().

Advise that the customize_loaded_components filter should be used instead.

Props voldemortensen.
See #33552.
Fixes #35242.

@DrewAPicture
9 years ago

#8 @DrewAPicture
9 years ago

  • Milestone changed from Awaiting Review to 4.5
  • Resolution fixed deleted
  • Status changed from closed to reopened

Following [36216]:

  • Instead of arbitrarily linking a Trac comment, let's link to the code reference page for the hook where I have conveniently added simplified versions of the examples from comment:12:ticket:33552 :-)
  • <code>customize_loaded_components</code> shouldn't be translatable
  • The string is missing a translator comment for the specifiers

All of the above are done in 35242.2.diff.

#9 @westonruter
9 years ago

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

In 36219:

Customizer: Improve _doing_it_wrong() message when widgets or nav_menus are manually removed via WP_Customize_Manager::remove_panel().

  • Link to code reference page for customize_loaded_components instead of linking to a Trac comment.
  • Remove HTML code from being included in translated string.
  • Add missing translator comment for the specifiers in the translated string.

Amends [36216].
Props DrewAPicture.
Fixes #35242.

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


9 years ago

#11 @westonruter
9 years ago

In 36262:

Customizer: Re-use list of components to eliminate code duplication.

Introduces protected WP_Customize_Manager::$components to store list of loaded core components filtered by customize_loaded_components.

Props DrewAPicture.
See #35242
See #33552.
Fixes #35354.

Note: See TracTickets for help on using tickets.