WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/27/2016 09:15:01 AM (4 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/admin-bar.php

    r38340 r38399  
    2424    global $wp_admin_bar;
    2525
    26     if ( ! is_admin_bar_showing() )
     26    if ( ! is_admin_bar_showing() ) {
    2727        return false;
    28 
    29     /* Load the admin bar class code ready for instantiation */
    30     require_once( ABSPATH . WPINC . '/class-wp-admin-bar.php' );
     28    }
    3129
    3230    /* Instantiate the admin bar */
     
    4038     */
    4139    $admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' );
    42     if ( class_exists( $admin_bar_class ) )
     40    if ( class_exists( $admin_bar_class ) ) {
    4341        $wp_admin_bar = new $admin_bar_class;
    44     else
     42    } else {
    4543        return false;
    46 
     44    }
    4745    $wp_admin_bar->initialize();
    4846    $wp_admin_bar->add_menus();
     
    295293
    296294    if ( is_network_admin() ) {
    297         /* translators: %s: site name */ 
     295        /* translators: %s: site name */
    298296        $blogname = sprintf( __( 'Network Admin: %s' ), esc_html( get_current_site()->site_name ) );
    299297    } elseif ( is_user_admin() ) {
    300         /* translators: %s: site name */ 
     298        /* translators: %s: site name */
    301299        $blogname = sprintf( __( 'User Dashboard: %s' ), esc_html( get_current_site()->site_name ) );
    302300    }
Note: See TracChangeset for help on using the changeset viewer.