Make WordPress Core

Ticket #20507: 20507.2.diff

File 20507.2.diff, 5.7 KB (added by ryan, 13 years ago)

Handle $wp_scripts not being set

  • wp-includes/class-wp-customize.php

     
    2727         * @since 3.4.0
    2828         */
    2929        public function __construct() {
     30                require( ABSPATH . 'wp-admin/includes/admin.php' );
    3031                require( ABSPATH . WPINC . '/class-wp-customize-setting.php' );
    3132                require( ABSPATH . WPINC . '/class-wp-customize-section.php' );
    3233                require( ABSPATH . WPINC . '/class-wp-customize-control.php' );
    3334
    3435                add_action( 'setup_theme',  array( $this, 'setup_theme' ) );
    35                 add_action( 'admin_init',   array( $this, 'admin_init' ) );
    3636                add_action( 'wp_loaded',    array( $this, 'wp_loaded' ) );
    3737
    3838                add_action( 'wp_ajax_customize_save', array( $this, 'save' ) );
     
    150150        public function wp_loaded() {
    151151                do_action( 'customize_register', $this );
    152152
     153                $this->maybe_load_controls();
     154
    153155                if ( $this->is_preview() && ! is_admin() )
    154156                        $this->customize_preview_init();
    155157        }
     
    286288        }
    287289
    288290        /**
    289          * Trigger save action and load customize controls.
     291         * Potentially load customize controls.
    290292         *
    291293         * @since 3.4.0
    292294         */
    293         public function admin_init() {
     295        public function maybe_load_controls() {
    294296                if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) )
    295297                        return;
    296298
  • wp-includes/theme.php

     
    13401340 * @access private
    13411341 */
    13421342function _custom_header_background_just_in_time() {
    1343         global $custom_image_header, $custom_background;
    1344 
    13451343        if ( current_theme_supports( 'custom-header' ) ) {
    13461344                // In case any constants were defined after an add_custom_image_header() call, re-run.
    13471345                add_theme_support( 'custom-header', array( '__jit' => true ) );
     
    13491347                $args = get_theme_support( 'custom-header' );
    13501348                if ( $args[0]['wp-head-callback'] && $args[0]['admin-head-callback'] ) {
    13511349                        add_action( 'wp_head', $args[0]['wp-head-callback'] );
    1352 
    1353                         if ( is_admin() ) {
    1354                                 require_once( ABSPATH . 'wp-admin/custom-header.php' );
    1355                                 $custom_image_header = new Custom_Image_Header( $args[0]['admin-head-callback'], $args[0]['admin-preview-callback'] );
    1356                         }
     1350                        add_action( 'admin_init', '_custom_header_background_load_admin' );
    13571351                }
    13581352        }
    13591353
     
    13631357
    13641358                $args = get_theme_support( 'custom-background' );
    13651359                add_action( 'wp_head', $args[0]['wp-head-callback'] );
    1366 
    1367                 if ( is_admin() ) {
    1368                         require_once( ABSPATH . 'wp-admin/custom-background.php' );
    1369                         $custom_background = new Custom_Background( $args[0]['admin-head-callback'], $args[0]['admin-preview-callback'] );
    1370                 }
     1360                add_action( 'admin_init', '_custom_header_background_load_admin' );
    13711361        }
    13721362}
    13731363add_action( 'wp_loaded', '_custom_header_background_just_in_time' );
    13741364
    13751365/**
     1366 * Loads the internal custom header and background routines.
     1367 *
     1368 * @since 3.4.0
     1369 * @access private
     1370 */
     1371function _custom_header_background_load_admin() {
     1372        global $custom_image_header, $custom_background;
     1373        if ( current_theme_supports( 'custom-header' ) ) {
     1374                $args = get_theme_support( 'custom-header' );
     1375                require_once( ABSPATH . 'wp-admin/custom-header.php' );
     1376                $custom_image_header = new Custom_Image_Header( $args[0]['admin-head-callback'], $args[0]['admin-preview-callback'] );
     1377        }
     1378        if ( current_theme_supports( 'custom-background' ) ) {
     1379                $args = get_theme_support( 'custom-background' );
     1380                require_once( ABSPATH . 'wp-admin/custom-background.php' );
     1381                $custom_background = new Custom_Background( $args[0]['admin-head-callback'], $args[0]['admin-preview-callback'] );
     1382        }
     1383}
     1384
     1385/**
    13761386 * Gets the theme support arguments passed when registering that support
    13771387 *
    13781388 * @since 3.1
     
    16041614 * @since 3.4.0
    16051615 */
    16061616function wp_customize_url( $stylesheet ) {
    1607         return esc_url( admin_url( 'admin.php' ) . '?customize=on&theme=' . $stylesheet );
     1617        return esc_url( home_url( '?customize=on&theme=' . $stylesheet ) );
    16081618}
     1619 No newline at end of file
  • wp-includes/customize-controls.php

     
    1010if ( ! defined( 'ABSPATH' ) )
    1111        die;
    1212
    13 global $wp_scripts;
     13do_action( 'admin_init' ); // To register the color schemes and possibly other things, who knows.
    1414
     15if ( empty ( $wp_scripts ) ) {
     16        $wp_scripts = new WP_Scripts;
     17} else {
     18        $registered = $wp_scripts->registered;
     19        $wp_scripts = new WP_Scripts;
     20        $wp_scripts->registered = $registered;
     21}
     22
    1523$registered = $wp_scripts->registered;
    1624$wp_scripts = new WP_Scripts;
    1725$wp_scripts->registered = $registered;
  • wp-includes/script-loader.php

     
    302302        $scripts->add( 'customize-controls', "/wp-includes/js/customize-controls$suffix.js", array( 'customize-base' ), false, 1 );
    303303        $scripts->add( 'customize-preview',  "/wp-includes/js/customize-preview$suffix.js",  array( 'customize-base' ), false, 1 );
    304304
     305        $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' );
     306
    305307        if ( is_admin() ) {
    306308                $scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ) );
    307309                $scripts->add_data( 'ajaxcat', 'group', 1 );
     
    391393                        'ays' => __('Are you sure you want to install this plugin?')
    392394                ) );
    393395
    394                 $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' );
    395 
    396396                $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), false, 1 );
    397397
    398398                $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" );