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.

Built from https://develop.svn.wordpress.org/trunk@39100


git-svn-id: http://core.svn.wordpress.org/trunk@39042 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2016-11-03 00:00:32 +00:00
parent ceeb8ddb46
commit c0b41d8fee
2 changed files with 7 additions and 3 deletions

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;

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-beta1-39099';
$wp_version = '4.7-beta1-39100';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.