Bootstrap: Autoload classes using a Composer-generated PHP 5.2-compatible Autoloader.

* `wp-admin` and `wp-includes` are scanned for classes to autoload
* Several 3rd-party and Ryan McCue-shaped libraries are excluded when the classmap is generated, see `composer.json`: `autoload.exclude-from-classmap`
* `wp-vendor/autoload_52.php` is included at the top of `wp-settings.php` - no changes need to be made to unit tests to include the autoloader
* An avalanche of `require()` and `require_once()` calls that loaded class files have been removed from the codebase.

The following files have been added to `svn:ignore` - they are not 5.2-compatible and fail during pre-commit:
* src/wp-vendor/autoload.php
* src/wp-vendor/composer/autoload_real.php
* src/wp-vendor/composer/autoload_static.php
* src/wp-vendor/composer/ClassLoader.php

We favor these files instead:
* src/wp-vendor/autoload_52.php
* src/wp-vendor/composer/autoload_real_52.php
* src/wp-vendor/composer/ClassLoader52.php

When new PHP classes are added to the codebase, simply run `composer install` or `composer update` from the project root to update the autoloader.

The future is now.

See #36335.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38340 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor
2016-08-27 09:15:29 +00:00
parent cb74a4401b
commit 6a529648cf
46 changed files with 39 additions and 381 deletions

View File

@@ -1507,7 +1507,6 @@ function wp_ajax_wp_link_ajax() {
$args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
require(ABSPATH . WPINC . '/class-wp-editor.php');
$results = _WP_Editors::wp_link_query( $args );
if ( ! isset( $results ) )
@@ -3137,7 +3136,6 @@ function wp_ajax_destroy_sessions() {
*/
function wp_ajax_press_this_save_post() {
if ( empty( $GLOBALS['wp_press_this'] ) ) {
include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
$GLOBALS['wp_press_this'] = new WP_Press_This();
}
@@ -3153,7 +3151,6 @@ function wp_ajax_press_this_save_post() {
*/
function wp_ajax_press_this_add_category() {
if ( empty( $GLOBALS['wp_press_this'] ) ) {
include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
$GLOBALS['wp_press_this'] = new WP_Press_This();
}
@@ -3183,7 +3180,6 @@ function wp_ajax_crop_image() {
switch ( $context ) {
case 'site-icon':
require_once ABSPATH . '/wp-admin/includes/class-wp-site-icon.php';
$wp_site_icon = new WP_Site_Icon();
// Skip creating a new attachment if the attachment is a Site Icon.
@@ -3332,7 +3328,6 @@ function wp_ajax_install_theme() {
wp_send_json_error( $status );
}
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
include_once( ABSPATH . 'wp-admin/includes/theme.php' );
$api = themes_api( 'theme_information', array(
@@ -3439,8 +3434,6 @@ function wp_ajax_update_theme() {
wp_send_json_error( $status );
}
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
$current = get_site_transient( 'update_themes' );
if ( empty( $current ) ) {
wp_update_themes();
@@ -3590,7 +3583,6 @@ function wp_ajax_install_plugin() {
wp_send_json_error( $status );
}
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
$api = plugins_api( 'plugin_information', array(
@@ -3698,8 +3690,6 @@ function wp_ajax_update_plugin() {
$status['oldVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
}
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
wp_update_plugins();
$skin = new WP_Ajax_Upgrader_Skin();