Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#35242 closed defect (bug) (fixed)

PHP Noticed caused by Customizer if widgets panel removed

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

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 11 years ago.
35242(1).diff​ (846 bytes ) - added by voldemortensen 11 years ago.
35242.2.diff​ (1.1 KB ) - added by DrewAPicture 11 years ago.

Download all attachments as: .zip

Change History (14)

#1 @johnbillion
11 years ago

  • Keywords needs-patch added

#2 @ericlewis
11 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
11 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.

#4 follow-up: @voldemortensen
11 years ago

  • Keywords has-patch added

35242.diff adds a _doing_it_wrong warning. Thoughts?

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

Replying to voldemortensen:

35242.diff adds a _doing_it_wrong warning. Thoughts?

Good idea.

Feedback:

#6 @voldemortensen
11 years ago

Thanks for the feedback, updated the patch.

#7 @westonruter
11 years ago

  • Owner set to westonruter
  • Resolution → fixed
  • Status new → 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.

#8 @DrewAPicture
11 years ago

  • Milestone Awaiting Review → 4.5
  • Resolution fixed
  • Status closed → 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
11 years ago

  • Resolution → fixed
  • Status reopened → 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.


11 years ago

#11 @westonruter
11 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.