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
This commit is contained in:
Weston Ruter 2016-11-02 23:59:28 +00:00
parent 21dc2530eb
commit 73c595f3e4

View File

@ -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;