I have the following code on line 315 and 316 of my theme file customizer.php For some reason I get error in my error_log file in the root of the installation. Everything seems to work fine though.

 $wp_customize->get_panel('widgets')->title = __( 'Widgets' );
 $wp_customize->get_panel('widgets')->priority = 4;

This is the error:

PHP Warning: Creating default object from empty value in /wp-content/themes/theme/inc/customizer.php on line 315 PHP Warning: Creating default object from empty value in /wp-content/themes/theme/inc/customizer.php on line 316

What is wrong with the above code?

  • This is a debug message caused by PHP 5.4 on your server and does not indicate a functionality problem with the customizer in most cases. By default, PHP has this set to 0 for production servers on most hosts (your host should have PHP debugging turned OFF) – vikrant zilpe Jan 3 at 14:18
  • So there is no error here? I can turn off debugging to not fill up the error_log file? – joq3 Jan 3 at 14:19
  • @vikrantzilpe according to this: codex.wordpress.org/Debugging_in_WordPress WP_DEBUG_LOG does nothing if WP_DEBUG is set to false? – joq3 Jan 3 at 14:24
  • So why do I need to set WP_DEBUG_LOG to true? I already have WP_DEBUG set to false. – joq3 Jan 3 at 14:27
  • Let us continue this discussion in chat. – vikrant zilpe Jan 3 at 14:30

This is the solution, it seems like it returned an array before:

$widgets_section = (object) $wp_customize->get_panel( 'widgets' );
$widgets_section->title = __( 'Widgets' );
$widgets_section->priority = 4;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.