From 73c595f3e4a3ba2c2c8bf913ae9c5978ab14234e Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 2 Nov 2016 23:59:28 +0000 Subject: [PATCH] Customize: Prevent PHP warning in applying widget starter content on fresh installs. Fixes PHP warning triggered by calling `max()` on `$widget_numbers` when there are no widget instances of the type yet. Also makes sure that widget instances start at 2 instead of 1. See #38114. git-svn-id: https://develop.svn.wordpress.org/trunk@39100 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-customize-manager.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index f96a220349..c701364149 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -928,8 +928,12 @@ final class WP_Customize_Manager { // Find the max widget number for this type. $widget_numbers = array_keys( $settings ); - $widget_numbers[] = 1; - $max_widget_numbers[ $id_base ] = call_user_func_array( 'max', $widget_numbers ); + if ( count( $widget_numbers ) > 0 ) { + $widget_numbers[] = 1; + $max_widget_numbers[ $id_base ] = call_user_func_array( 'max', $widget_numbers ); + } else { + $max_widget_numbers[ $id_base ] = 1; + } } $max_widget_numbers[ $id_base ] += 1;