WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/17/16 08:17:57 (6 months ago)
Author:
westonruter
Message:

Customize: Add unit tests for importing theme starter content.

Props welcher, westonruter.
See #38114, #38533, #38615.
Fixes #38540.

File:
1 edited

Legend:

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

    r39272 r39276  
    896896     * @var array 
    897897     */ 
    898     protected $starter_content_settings_ids = array(); 
     898    protected $pending_starter_content_settings_ids = array(); 
    899899 
    900900    /** 
     
    954954                if ( empty( $changeset_data[ $setting_id ] ) || ! empty( $changeset_data[ $setting_id ]['starter_content'] ) ) { 
    955955                    $this->set_post_value( $setting_id, $setting_value ); 
    956                     $this->starter_content_settings_ids[] = $setting_id; 
     956                    $this->pending_starter_content_settings_ids[] = $setting_id; 
    957957                } 
    958958                $sidebar_widget_ids[] = $widget_id; 
     
    962962            if ( empty( $changeset_data[ $setting_id ] ) || ! empty( $changeset_data[ $setting_id ]['starter_content'] ) ) { 
    963963                $this->set_post_value( $setting_id, $sidebar_widget_ids ); 
    964                 $this->starter_content_settings_ids[] = $setting_id; 
     964                $this->pending_starter_content_settings_ids[] = $setting_id; 
    965965            } 
    966966        } 
     
    10161016                $nav_menus_created_posts = array_unique( array_merge( $nav_menus_created_posts, wp_list_pluck( $posts, 'ID' ) ) ); 
    10171017                $this->set_post_value( $setting_id, array_values( $nav_menus_created_posts ) ); 
    1018                 $this->starter_content_settings_ids[] = $setting_id; 
     1018                $this->pending_starter_content_settings_ids[] = $setting_id; 
    10191019            } 
    10201020        } 
     
    10571057                'name' => isset( $nav_menu['name'] ) ? $nav_menu['name'] : $nav_menu_location, 
    10581058            ) ); 
    1059             $this->starter_content_settings_ids[] = $nav_menu_setting_id; 
     1059            $this->pending_starter_content_settings_ids[] = $nav_menu_setting_id; 
    10601060 
    10611061            // @todo Add support for menu_item_parent. 
     
    10841084                if ( empty( $changeset_data[ $nav_menu_item_setting_id ] ) || ! empty( $changeset_data[ $nav_menu_item_setting_id ]['starter_content'] ) ) { 
    10851085                    $this->set_post_value( $nav_menu_item_setting_id, $nav_menu_item ); 
    1086                     $this->starter_content_settings_ids[] = $nav_menu_item_setting_id; 
     1086                    $this->pending_starter_content_settings_ids[] = $nav_menu_item_setting_id; 
    10871087                } 
    10881088            } 
     
    10911091            if ( empty( $changeset_data[ $setting_id ] ) || ! empty( $changeset_data[ $setting_id ]['starter_content'] ) ) { 
    10921092                $this->set_post_value( $setting_id, $nav_menu_term_id ); 
    1093                 $this->starter_content_settings_ids[] = $setting_id; 
     1093                $this->pending_starter_content_settings_ids[] = $setting_id; 
    10941094            } 
    10951095        } 
     
    11031103            if ( empty( $changeset_data[ $name ] ) || ! empty( $changeset_data[ $name ]['starter_content'] ) ) { 
    11041104                $this->set_post_value( $name, $value ); 
    1105                 $this->starter_content_settings_ids[] = $name; 
     1105                $this->pending_starter_content_settings_ids[] = $name; 
    11061106            } 
    11071107        } 
     
    11151115            if ( empty( $changeset_data[ $name ] ) || ! empty( $changeset_data[ $name ]['starter_content'] ) ) { 
    11161116                $this->set_post_value( $name, $value ); 
    1117                 $this->starter_content_settings_ids[] = $name; 
    1118             } 
    1119         } 
    1120  
    1121         if ( ! empty( $this->starter_content_settings_ids ) ) { 
     1117                $this->pending_starter_content_settings_ids[] = $name; 
     1118            } 
     1119        } 
     1120 
     1121        if ( ! empty( $this->pending_starter_content_settings_ids ) ) { 
    11221122            if ( did_action( 'customize_register' ) ) { 
    11231123                $this->_save_starter_content_changeset(); 
     
    11361136    public function _save_starter_content_changeset() { 
    11371137 
    1138         if ( empty( $this->starter_content_settings_ids ) ) { 
     1138        if ( empty( $this->pending_starter_content_settings_ids ) ) { 
    11391139            return; 
    11401140        } 
    11411141 
    11421142        $this->save_changeset_post( array( 
    1143             'data' => array_fill_keys( $this->starter_content_settings_ids, array( 'starter_content' => true ) ), 
     1143            'data' => array_fill_keys( $this->pending_starter_content_settings_ids, array( 'starter_content' => true ) ), 
    11441144            'starter_content' => true, 
    11451145        ) ); 
     1146 
     1147        $this->pending_starter_content_settings_ids = array(); 
    11461148    } 
    11471149 
Note: See TracChangeset for help on using the changeset viewer.