WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/02/2016 11:59:28 PM (3 years ago)
Author:
westonruter
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r39038 r39100  
    929929                    // Find the max widget number for this type.
    930930                    $widget_numbers = array_keys( $settings );
    931                     $widget_numbers[] = 1;
    932                     $max_widget_numbers[ $id_base ] = call_user_func_array( 'max', $widget_numbers );
     931                    if ( count( $widget_numbers ) > 0 ) {
     932                        $widget_numbers[] = 1;
     933                        $max_widget_numbers[ $id_base ] = call_user_func_array( 'max', $widget_numbers );
     934                    } else {
     935                        $max_widget_numbers[ $id_base ] = 1;
     936                    }
    933937                }
    934938                $max_widget_numbers[ $id_base ] += 1;
Note: See TracChangeset for help on using the changeset viewer.