Make WordPress Core

Ticket #32845: 32845.01.patch

File 32845.01.patch, 10.5 KB (added by johnjamesjacoby, 9 years ago)
  • src/wp-includes/plugin.php

     
    3535        $wp_current_filter = array();
    3636
    3737/**
     38 * Helper function for including files in a filterable manner
     39 *
     40 * @since 4.4.0
     41 *
     42 * @param  string  $file      Full path to the file to include
     43 * @param  bool    $required  True to require|False to include
     44 * @param  bool    $once      True to use _once|False not to
     45 *
     46 * @return void
     47 */
     48function wp_include( $file = '', $required = true, $once = false ) {
     49
     50        // Combine parameters into an array of arguments
     51        $args = array(
     52                'file'     => $file,
     53                'required' => $required,
     54                'once'     => $once
     55        );
     56
     57        /**
     58         * Filter the file to include, and how to include it
     59         *
     60         * @since 4.4.0
     61         *
     62         * @param array $args An array built from the function parameters
     63         */
     64        $r = apply_filters( 'wp_include', $args );
     65
     66        // Overwrite local variables with filtered ones
     67        extract( $r );
     68
     69        // `require()` or `include()`
     70        $func = ( true === $required )
     71                ? 'require'
     72                : 'include';
     73
     74        // `require_once()` or `include_once()`
     75        $func .= ( true === $once )
     76                ? '_once'
     77                : '';
     78
     79        // Include/require the file, maybe one time only
     80        call_user_func( $func, $file );
     81}
     82
     83/**
    3884 * Hook a function or method to a specific filter action.
    3985 *
    4086 * WordPress offers filter hooks to allow plugins to modify
  • src/wp-settings.php

     
    1818define( 'WPINC', 'wp-includes' );
    1919
    2020// Include files required for initialization.
    21 require( ABSPATH . WPINC . '/load.php' );
    22 require( ABSPATH . WPINC . '/default-constants.php' );
     21wp_include( ABSPATH . WPINC . '/load.php' );
     22wp_include( ABSPATH . WPINC . '/default-constants.php' );
    2323
    2424/*
    2525 * These can't be directly globalized in version.php. When updating,
     
    2727 * these values to be overridden if already set.
    2828 */
    2929global $wp_version, $wp_db_version, $tinymce_version, $required_php_version, $required_mysql_version;
    30 require( ABSPATH . WPINC . '/version.php' );
     30wp_include( ABSPATH . WPINC . '/version.php' );
    3131
    3232// Set initial default constants including WP_MEMORY_LIMIT, WP_MAX_MEMORY_LIMIT, WP_DEBUG, SCRIPT_DEBUG, WP_CONTENT_DIR and WP_CACHE.
    3333wp_initial_constants();
     
    6868wp_set_lang_dir();
    6969
    7070// Load early WordPress files.
    71 require( ABSPATH . WPINC . '/compat.php' );
    72 require( ABSPATH . WPINC . '/functions.php' );
    73 require( ABSPATH . WPINC . '/class-wp.php' );
    74 require( ABSPATH . WPINC . '/class-wp-error.php' );
    75 require( ABSPATH . WPINC . '/plugin.php' );
    76 require( ABSPATH . WPINC . '/pomo/mo.php' );
     71wp_include( ABSPATH . WPINC . '/compat.php' );
     72wp_include( ABSPATH . WPINC . '/functions.php' );
     73wp_include( ABSPATH . WPINC . '/class-wp.php' );
     74wp_include( ABSPATH . WPINC . '/class-wp-error.php' );
     75wp_include( ABSPATH . WPINC . '/plugin.php' );
     76wp_include( ABSPATH . WPINC . '/pomo/mo.php' );
    7777
    7878// Include the wpdb class and, if present, a db.php database drop-in.
    7979require_wp_db();
     
    8686wp_start_object_cache();
    8787
    8888// Attach the default filters.
    89 require( ABSPATH . WPINC . '/default-filters.php' );
     89wp_include( ABSPATH . WPINC . '/default-filters.php' );
    9090
    9191// Initialize multisite if enabled.
    9292if ( is_multisite() ) {
    93         require( ABSPATH . WPINC . '/ms-blogs.php' );
    94         require( ABSPATH . WPINC . '/ms-settings.php' );
     93        wp_include( ABSPATH . WPINC . '/ms-blogs.php' );
     94        wp_include( ABSPATH . WPINC . '/ms-settings.php' );
    9595} elseif ( ! defined( 'MULTISITE' ) ) {
    9696        define( 'MULTISITE', false );
    9797}
     
    103103        return false;
    104104
    105105// Load the L10n library.
    106 require_once( ABSPATH . WPINC . '/l10n.php' );
     106wp_include( ABSPATH . WPINC . '/l10n.php', true, true );
    107107
    108108// Run the installer if WordPress is not installed.
    109109wp_not_installed();
    110110
    111111// Load most of WordPress.
    112 require( ABSPATH . WPINC . '/class-wp-walker.php' );
    113 require( ABSPATH . WPINC . '/class-wp-ajax-response.php' );
    114 require( ABSPATH . WPINC . '/formatting.php' );
    115 require( ABSPATH . WPINC . '/capabilities.php' );
    116 require( ABSPATH . WPINC . '/query.php' );
    117 require( ABSPATH . WPINC . '/date.php' );
    118 require( ABSPATH . WPINC . '/theme.php' );
    119 require( ABSPATH . WPINC . '/class-wp-theme.php' );
    120 require( ABSPATH . WPINC . '/template.php' );
    121 require( ABSPATH . WPINC . '/user.php' );
    122 require( ABSPATH . WPINC . '/session.php' );
    123 require( ABSPATH . WPINC . '/meta.php' );
    124 require( ABSPATH . WPINC . '/general-template.php' );
    125 require( ABSPATH . WPINC . '/link-template.php' );
    126 require( ABSPATH . WPINC . '/author-template.php' );
    127 require( ABSPATH . WPINC . '/post.php' );
    128 require( ABSPATH . WPINC . '/post-template.php' );
    129 require( ABSPATH . WPINC . '/revision.php' );
    130 require( ABSPATH . WPINC . '/post-formats.php' );
    131 require( ABSPATH . WPINC . '/post-thumbnail-template.php' );
    132 require( ABSPATH . WPINC . '/category.php' );
    133 require( ABSPATH . WPINC . '/category-template.php' );
    134 require( ABSPATH . WPINC . '/comment.php' );
    135 require( ABSPATH . WPINC . '/comment-template.php' );
    136 require( ABSPATH . WPINC . '/rewrite.php' );
    137 require( ABSPATH . WPINC . '/feed.php' );
    138 require( ABSPATH . WPINC . '/bookmark.php' );
    139 require( ABSPATH . WPINC . '/bookmark-template.php' );
    140 require( ABSPATH . WPINC . '/kses.php' );
    141 require( ABSPATH . WPINC . '/cron.php' );
    142 require( ABSPATH . WPINC . '/deprecated.php' );
    143 require( ABSPATH . WPINC . '/script-loader.php' );
    144 require( ABSPATH . WPINC . '/taxonomy.php' );
    145 require( ABSPATH . WPINC . '/update.php' );
    146 require( ABSPATH . WPINC . '/canonical.php' );
    147 require( ABSPATH . WPINC . '/shortcodes.php' );
    148 require( ABSPATH . WPINC . '/class-wp-embed.php' );
    149 require( ABSPATH . WPINC . '/media.php' );
    150 require( ABSPATH . WPINC . '/http.php' );
    151 require( ABSPATH . WPINC . '/class-http.php' );
    152 require( ABSPATH . WPINC . '/widgets.php' );
    153 require( ABSPATH . WPINC . '/nav-menu.php' );
    154 require( ABSPATH . WPINC . '/nav-menu-template.php' );
    155 require( ABSPATH . WPINC . '/admin-bar.php' );
     112wp_include( ABSPATH . WPINC . '/class-wp-walker.php' );
     113wp_include( ABSPATH . WPINC . '/class-wp-ajax-response.php' );
     114wp_include( ABSPATH . WPINC . '/formatting.php' );
     115wp_include( ABSPATH . WPINC . '/capabilities.php' );
     116wp_include( ABSPATH . WPINC . '/query.php' );
     117wp_include( ABSPATH . WPINC . '/date.php' );
     118wp_include( ABSPATH . WPINC . '/theme.php' );
     119wp_include( ABSPATH . WPINC . '/class-wp-theme.php' );
     120wp_include( ABSPATH . WPINC . '/template.php' );
     121wp_include( ABSPATH . WPINC . '/user.php' );
     122wp_include( ABSPATH . WPINC . '/session.php' );
     123wp_include( ABSPATH . WPINC . '/meta.php' );
     124wp_include( ABSPATH . WPINC . '/general-template.php' );
     125wp_include( ABSPATH . WPINC . '/link-template.php' );
     126wp_include( ABSPATH . WPINC . '/author-template.php' );
     127wp_include( ABSPATH . WPINC . '/post.php' );
     128wp_include( ABSPATH . WPINC . '/post-template.php' );
     129wp_include( ABSPATH . WPINC . '/revision.php' );
     130wp_include( ABSPATH . WPINC . '/post-formats.php' );
     131wp_include( ABSPATH . WPINC . '/post-thumbnail-template.php' );
     132wp_include( ABSPATH . WPINC . '/category.php' );
     133wp_include( ABSPATH . WPINC . '/category-template.php' );
     134wp_include( ABSPATH . WPINC . '/comment.php' );
     135wp_include( ABSPATH . WPINC . '/comment-template.php' );
     136wp_include( ABSPATH . WPINC . '/rewrite.php' );
     137wp_include( ABSPATH . WPINC . '/feed.php' );
     138wp_include( ABSPATH . WPINC . '/bookmark.php' );
     139wp_include( ABSPATH . WPINC . '/bookmark-template.php' );
     140wp_include( ABSPATH . WPINC . '/kses.php' );
     141wp_include( ABSPATH . WPINC . '/cron.php' );
     142wp_include( ABSPATH . WPINC . '/deprecated.php' );
     143wp_include( ABSPATH . WPINC . '/script-loader.php' );
     144wp_include( ABSPATH . WPINC . '/taxonomy.php' );
     145wp_include( ABSPATH . WPINC . '/update.php' );
     146wp_include( ABSPATH . WPINC . '/canonical.php' );
     147wp_include( ABSPATH . WPINC . '/shortcodes.php' );
     148wp_include( ABSPATH . WPINC . '/class-wp-embed.php' );
     149wp_include( ABSPATH . WPINC . '/media.php' );
     150wp_include( ABSPATH . WPINC . '/http.php' );
     151wp_include( ABSPATH . WPINC . '/class-http.php' );
     152wp_include( ABSPATH . WPINC . '/widgets.php' );
     153wp_include( ABSPATH . WPINC . '/nav-menu.php' );
     154wp_include( ABSPATH . WPINC . '/nav-menu-template.php' );
     155wp_include( ABSPATH . WPINC . '/admin-bar.php' );
    156156
    157157// Load multisite-specific files.
    158158if ( is_multisite() ) {
    159         require( ABSPATH . WPINC . '/ms-functions.php' );
    160         require( ABSPATH . WPINC . '/ms-default-filters.php' );
    161         require( ABSPATH . WPINC . '/ms-deprecated.php' );
     159        wp_include( ABSPATH . WPINC . '/ms-functions.php' );
     160        wp_include( ABSPATH . WPINC . '/ms-default-filters.php' );
     161        wp_include( ABSPATH . WPINC . '/ms-deprecated.php' );
    162162}
    163163
    164164// Define constants that rely on the API to obtain the default value.
     
    169169
    170170// Load must-use plugins.
    171171foreach ( wp_get_mu_plugins() as $mu_plugin ) {
    172         include_once( $mu_plugin );
     172        wp_include( $mu_plugin, false, true );
    173173}
    174174unset( $mu_plugin );
    175175
     
    177177if ( is_multisite() ) {
    178178        foreach( wp_get_active_network_plugins() as $network_plugin ) {
    179179                wp_register_plugin_realpath( $network_plugin );
    180                 include_once( $network_plugin );
     180                wp_include( $network_plugin, false, true );
    181181        }
    182182        unset( $network_plugin );
    183183}
     
    199199wp_ssl_constants();
    200200
    201201// Create common globals.
    202 require( ABSPATH . WPINC . '/vars.php' );
     202wp_include( ABSPATH . WPINC . '/vars.php' );
    203203
    204204// Make taxonomies and posts available to plugins and themes.
    205205// @plugin authors: warning: these get registered again on the init hook.
     
    212212// Load active plugins.
    213213foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
    214214        wp_register_plugin_realpath( $plugin );
    215         include_once( $plugin );
     215        wp_include( $plugin, false, true );
    216216}
    217217unset( $plugin );
    218218
    219219// Load pluggable functions.
    220 require( ABSPATH . WPINC . '/pluggable.php' );
    221 require( ABSPATH . WPINC . '/pluggable-deprecated.php' );
     220wp_include( ABSPATH . WPINC . '/pluggable.php' );
     221wp_include( ABSPATH . WPINC . '/pluggable-deprecated.php' );
    222222
    223223// Set internal encoding.
    224224wp_set_internal_encoding();
     
    308308$locale = get_locale();
    309309$locale_file = WP_LANG_DIR . "/$locale.php";
    310310if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) )
    311         require( $locale_file );
     311        wp_include( $locale_file );
    312312unset( $locale_file );
    313313
    314314// Pull in locale data after loading text domain.
    315 require_once( ABSPATH . WPINC . '/locale.php' );
     315wp_include( ABSPATH . WPINC . '/locale.php', true, true );
    316316
    317317/**
    318318 * WordPress Locale object for loading locale domain date and various strings.
     
    355355// Check site status
    356356if ( is_multisite() ) {
    357357        if ( true !== ( $file = ms_site_check() ) ) {
    358                 require( $file );
     358                wp_include( $file );
    359359                die();
    360360        }
    361361        unset($file);