Make WordPress Core


Ignore:
Timestamp:
06/04/2014 04:11:21 AM (12 years ago)
Author:
DrewAPicture
Message:

Improve inline documentation for wp-includes/load.php.

Props ericlewis, DrewAPicture.
Fixes #24886.

File:
1 edited

Legend:

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

    r27836 r28656  
    1111 * Turn register globals off.
    1212 *
    13  * @access private
    1413 * @since 2.1.0
    15  * @return null Will return null if register_globals PHP directive was disabled
     14 * @access private
     15 *
     16 * @return null Will return null if register_globals PHP directive was disabled.
    1617 */
    1718function wp_unregister_GLOBALS() {
     
    3334
    3435/**
    35  * Fix $_SERVER variables for various setups.
    36  *
    37  * @access private
    38  * @since 3.0.0
     36 * Fix `$_SERVER` variables for various setups.
     37 *
     38 * @since 3.0.0
     39 * @access private
     40 *
     41 * @global string $PHP_SELF The filename of the currently executing script,
     42 *                          relative to the document root.
    3943 */
    4044function wp_fix_server_vars() {
     
    9397
    9498/**
    95  * Check for the required PHP version, and the MySQL extension or a database drop-in.
     99 * Check for the required PHP version, and the MySQL extension or
     100 * a database drop-in.
    96101 *
    97102 * Dies if requirements are not met.
    98103 *
    99  * @access private
    100  * @since 3.0.0
     104 * @since 3.0.0
     105 * @access private
     106 *
     107 * @global string $required_php_version The required PHP version string.
     108 * @global string $wp_version           The WordPress version string.
    101109 */
    102110function wp_check_php_mysql_versions() {
    103111    global $required_php_version, $wp_version;
    104112    $php_version = phpversion();
     113
    105114    if ( version_compare( $required_php_version, $php_version, '>' ) ) {
    106115        wp_load_translations_early();
     
    118127/**
    119128 * Don't load all of WordPress when handling a favicon.ico request.
     129 *
    120130 * Instead, send the headers for a zero-length favicon and bail.
    121131 *
     
    131141
    132142/**
    133  * Dies with a maintenance message when conditions are met.
     143 * Die with a maintenance message when conditions are met.
    134144 *
    135145 * Checks for a file in the WordPress root directory named ".maintenance".
     
    141151 * the wp-content directory).
    142152 *
    143  * @access private
    144  * @since 3.0.0
     153 * @since 3.0.0
     154 * @access private
     155 *
     156 * @global int $upgrading the unix timestamp marking when upgrading WordPress began.
    145157 */
    146158function wp_maintenance() {
     
    185197
    186198/**
    187  * PHP 5 standard microtime start capture.
    188  *
    189  * @access private
     199 * Start the WordPress micro-timer.
     200 *
    190201 * @since 0.71
    191  * @global float $timestart Seconds from when function is called.
     202 * @access private
     203 *
     204 * @global float $timestart Unix timestamp set at the beginning of the page load.
     205 * @see timer_stop()
     206 *
    192207 * @return bool Always returns true.
    193208 */
     
    224239
    225240/**
    226  * Sets PHP error handling and handles WordPress debug mode.
    227  *
    228  * Uses three constants: WP_DEBUG, WP_DEBUG_DISPLAY, and WP_DEBUG_LOG. All three can be
    229  * defined in wp-config.php. Example: <code> define( 'WP_DEBUG', true ); </code>
    230  *
    231  * WP_DEBUG_DISPLAY and WP_DEBUG_LOG perform no function unless WP_DEBUG is true.
    232  * WP_DEBUG defaults to false.
    233  *
    234  * When WP_DEBUG is true, all PHP notices are reported. WordPress will also display
    235  * notices, including one when a deprecated WordPress function, function argument,
    236  * or file is used. Deprecated code may be removed from a later version.
    237  *
    238  * It is strongly recommended that plugin and theme developers use WP_DEBUG in their
    239  * development environments.
    240  *
    241  * When WP_DEBUG_DISPLAY is true, WordPress will force errors to be displayed.
    242  * WP_DEBUG_DISPLAY defaults to true. Defining it as null prevents WordPress from
    243  * changing the global configuration setting. Defining WP_DEBUG_DISPLAY as false
    244  * will force errors to be hidden.
    245  *
    246  * When WP_DEBUG_LOG is true, errors will be logged to wp-content/debug.log.
    247  * WP_DEBUG_LOG defaults to false.
     241 * Set PHP error reporting based on WordPress debug settings.
     242 *
     243 * Uses three constants: `WP_DEBUG`, `WP_DEBUG_DISPLAY`, and `WP_DEBUG_LOG`.
     244 * All three can be defined in wp-config.php, and by default are set to false.
     245 *
     246 * When `WP_DEBUG` is true, all PHP notices are reported. WordPress will also
     247 * display internal notices: when a deprecated WordPress function, function
     248 * argument, or file is used. Deprecated code may be removed from a later
     249 * version.
     250 *
     251 * It is strongly recommended that plugin and theme developers use `WP_DEBUG`
     252 * in their development environments.
     253 *
     254 * `WP_DEBUG_DISPLAY` and `WP_DEBUG_LOG` perform no function unless `WP_DEBUG`
     255 * is true.
     256 *
     257 * When `WP_DEBUG_DISPLAY` is true, WordPress will force errors to be displayed.
     258 * `WP_DEBUG_DISPLAY` defaults to true. Defining it as null prevents WordPress
     259 * from changing the global configuration setting. Defining `WP_DEBUG_DISPLAY`
     260 * as false will force errors to be hidden.
     261 *
     262 * When `WP_DEBUG_LOG` is true, errors will be logged to debug.log in the content
     263 * directory.
    248264 *
    249265 * Errors are never displayed for XML-RPC requests.
    250266 *
    251  * @access private
    252  * @since 3.0.0
     267 * @since 3.0.0
     268 * @access private
    253269 */
    254270function wp_debug_mode() {
     
    273289
    274290/**
    275  * Sets the location of the language directory.
    276  *
    277  * To set directory manually, define <code>WP_LANG_DIR</code> in wp-config.php.
    278  *
    279  * If the language directory exists within WP_CONTENT_DIR, that is used.
    280  * Otherwise if the language directory exists within WPINC, that's used.
    281  * Finally, if neither of the preceding directories are found,
    282  * WP_CONTENT_DIR/languages is used.
    283  *
    284  * The WP_LANG_DIR constant was introduced in 2.1.0.
    285  *
    286  * @access private
    287  * @since 3.0.0
     291 * Set the location of the language directory.
     292 *
     293 * To set directory manually, define the `WP_LANG_DIR` constant
     294 * in wp-config.php.
     295 *
     296 * If the language directory exists within `WP_CONTENT_DIR`, it
     297 * is used. Otherwise the language directory is assumed to live
     298 * in `WPINC`.
     299 *
     300 * @since 3.0.0
     301 * @access private
    288302 */
    289303function wp_set_lang_dir() {
    290304    if ( !defined( 'WP_LANG_DIR' ) ) {
    291305        if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || !@is_dir(ABSPATH . WPINC . '/languages') ) {
    292             define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' ); // no leading slash, no trailing slash, full path, not relative to ABSPATH
     306            /**
     307             * Server path of the language directory.
     308             *
     309             * No leading slash, no trailing slash, full path, not relative to ABSPATH
     310             *
     311             * @since 2.1.0
     312             */
     313            define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' );
    293314            if ( !defined( 'LANGDIR' ) ) {
    294315                // Old static relative path maintained for limited backwards compatibility - won't work in some cases
     
    296317            }
    297318        } else {
    298             define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' ); // no leading slash, no trailing slash, full path, not relative to ABSPATH
     319            /**
     320             * Server path of the language directory.
     321             *
     322             * No leading slash, no trailing slash, full path, not relative to `ABSPATH`.
     323             *
     324             * @since 2.1.0
     325             */
     326            define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' );
    299327            if ( !defined( 'LANGDIR' ) ) {
    300328                // Old relative path maintained for backwards compatibility
     
    306334
    307335/**
    308  * Load the correct database class file.
    309  *
    310  * This function is used to load the database class file either at runtime or by
    311  * wp-admin/setup-config.php. We must globalize $wpdb to ensure that it is
    312  * defined globally by the inline code in wp-db.php.
     336 * Load the database class file and instantiate the `$wpdb` global.
    313337 *
    314338 * @since 2.5.0
    315  * @global $wpdb WordPress Database Object
     339 *
     340 * @global wpdb $wpdb The WordPress database class.
    316341 */
    317342function require_wp_db() {
     
    329354
    330355/**
    331  * Sets the database table prefix and the format specifiers for database table columns.
    332  *
    333  * Columns not listed here default to %s.
    334  *
    335  * @see wpdb::$field_types Since 2.8.0
    336  * @see wpdb::prepare()
    337  * @see wpdb::insert()
    338  * @see wpdb::update()
    339  * @see wpdb::set_prefix()
    340  *
    341  * @access private
    342  * @since 3.0.0
     356 * Set the database table prefix and the format specifiers for database
     357 * table columns.
     358 *
     359 * Columns not listed here default to `%s`.
     360 *
     361 * @since 3.0.0
     362 * @access private
     363 *
     364 * @global wpdb   $wpdb         The WordPress database class.
     365 * @global string $table_prefix The database table prefix.
    343366 */
    344367function wp_set_wpdb_vars() {
     
    364387
    365388/**
    366  * Access/Modify private global variable $_wp_using_ext_object_cache
    367  *
    368  * Toggle $_wp_using_ext_object_cache on and off without directly touching global
     389 * Access/Modify private global variable `$_wp_using_ext_object_cache`.
     390 *
     391 * Toggle `$_wp_using_ext_object_cache` on and off without directly
     392 * touching global.
    369393 *
    370394 * @since 3.7.0
    371395 *
    372  * @param bool $using Whether external object cache is being used
    373  * @return bool The current 'using' setting
     396 * @param bool $using Whether external object cache is being used.
     397 * @return bool The current 'using' setting.
    374398 */
    375399function wp_using_ext_object_cache( $using = null ) {
     
    382406
    383407/**
    384  * Starts the WordPress object cache.
     408 * Start the WordPress object cache.
    385409 *
    386410 * If an object-cache.php file exists in the wp-content directory,
    387411 * it uses that drop-in as an external object cache.
    388412 *
    389  * @access private
    390  * @since 3.0.0
     413 * @since 3.0.0
     414 * @access private
     415 *
     416 * @global int $blog_id Blog ID.
    391417 */
    392418function wp_start_object_cache() {
     
    403429        $first_init = true;
    404430    } else if ( ! wp_using_ext_object_cache() && file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
    405         // Sometimes advanced-cache.php can load object-cache.php before it is loaded here.
    406         // This breaks the function_exists check above and can result in $_wp_using_ext_object_cache
    407         // being set incorrectly. Double check if an external cache exists.
     431        /*
     432         * Sometimes advanced-cache.php can load object-cache.php before
     433         * it is loaded here. This breaks the function_exists check above
     434         * and can result in `$_wp_using_ext_object_cache` being set
     435         * incorrectly. Double check if an external cache exists.
     436         */
    408437        wp_using_ext_object_cache( true );
    409438    }
     
    412441        require_once ( ABSPATH . WPINC . '/cache.php' );
    413442
    414     // If cache supports reset, reset instead of init if already initialized.
    415     // Reset signals to the cache that global IDs have changed and it may need to update keys
    416     // and cleanup caches.
     443    /*
     444     * If cache supports reset, reset instead of init if already
     445     * initialized. Reset signals to the cache that global IDs
     446     * have changed and it may need to update keys and cleanup caches.
     447     */
    417448    if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) )
    418449        wp_cache_switch_to_blog( $blog_id );
     
    427458
    428459/**
    429  * Redirects to the installer if WordPress is not installed.
    430  *
    431  * Dies with an error message when multisite is enabled.
    432  *
    433  * @access private
    434  * @since 3.0.0
     460 * Redirect to the installer if WordPress is not installed.
     461 *
     462 * Dies with an error message when Multisite is enabled.
     463 *
     464 * @since 3.0.0
     465 * @access private
    435466 */
    436467function wp_not_installed() {
     
    451482
    452483/**
    453  * Returns array of must-use plugin files to be included in global scope.
    454  *
    455  * The default directory is wp-content/mu-plugins. To change the default directory
    456  * manually, define <code>WPMU_PLUGIN_DIR</code> and <code>WPMU_PLUGIN_URL</code>
     484 * Retrieve an array of must-use plugin files.
     485 *
     486 * The default directory is wp-content/mu-plugins. To change the default
     487 * directory manually, define `WPMU_PLUGIN_DIR` and `WPMU_PLUGIN_URL`
    457488 * in wp-config.php.
    458489 *
    459  * @access private
    460  * @since 3.0.0
    461  * @return array Files to include
     490 * @since 3.0.0
     491 * @access private
     492 *
     493 * @return array Files to include.
    462494 */
    463495function wp_get_mu_plugins() {
     
    478510
    479511/**
    480  * Returns array of plugin files to be included in global scope.
    481  *
    482  * The default directory is wp-content/plugins. To change the default directory
    483  * manually, define <code>WP_PLUGIN_DIR</code> and <code>WP_PLUGIN_URL</code>
     512 * Retrieve an array of active and valid plugin files.
     513 *
     514 * While upgrading or installing WordPress, no plugins are returned.
     515 *
     516 * The default directory is wp-content/plugins. To change the default
     517 * directory manually, define `WP_PLUGIN_DIR` and `WP_PLUGIN_URL`
    484518 * in wp-config.php.
    485519 *
    486  * @access private
    487  * @since 3.0.0
    488  * @return array Files to include
     520 * @since 3.0.0
     521 * @access private
     522 *
     523 * @return array Files.
    489524 */
    490525function wp_get_active_and_valid_plugins() {
     
    516551
    517552/**
    518  * Sets internal encoding using mb_internal_encoding().
    519  *
    520  * In most cases the default internal encoding is latin1, which is of no use,
    521  * since we want to use the mb_ functions for utf-8 strings.
    522  *
    523  * @access private
    524  * @since 3.0.0
     553 * Set internal encoding.
     554 *
     555 * In most cases the default internal encoding is latin1, which is
     556 * of no use, since we want to use the `mb_` functions for `utf-8` strings.
     557 *
     558 * @since 3.0.0
     559 * @access private
    525560 */
    526561function wp_set_internal_encoding() {
     
    533568
    534569/**
    535  * Add magic quotes to $_GET, $_POST, $_COOKIE, and $_SERVER.
    536  *
    537  * Also forces $_REQUEST to be $_GET + $_POST. If $_SERVER, $_COOKIE,
    538  * or $_ENV are needed, use those superglobals directly.
    539  *
    540  * @access private
    541  * @since 3.0.0
     570 * Add magic quotes to `$_GET`, `$_POST`, `$_COOKIE`, and `$_SERVER`.
     571 *
     572 * Also forces `$_REQUEST` to be `$_GET + $_POST`. If `$_SERVER`,
     573 * `$_COOKIE`, or `$_ENV` are needed, use those superglobals directly.
     574 *
     575 * @since 3.0.0
     576 * @access private
    542577 */
    543578function wp_magic_quotes() {
     
    562597 * Runs just before PHP shuts down execution.
    563598 *
    564  * @access private
    565599 * @since 1.2.0
     600 * @access private
    566601 */
    567602function shutdown_action_hook() {
     
    572607     */
    573608    do_action( 'shutdown' );
     609
    574610    wp_cache_close();
    575611}
     
    579615 *
    580616 * @since 2.7.0
    581  * @deprecated 3.2
    582  *
    583  * @param object $object The object to clone
    584  * @return object The cloned object
    585  */
    586 
     617 * @deprecated 3.2.0
     618 *
     619 * @param object $object The object to clone.
     620 * @return object The cloned object.
     621 */
    587622function wp_clone( $object ) {
    588623    // Use parens for clone to accommodate PHP 4. See #17880
     
    591626
    592627/**
    593  * Whether the current request is for a network or blog admin page
    594  *
    595  * Does not inform on whether the user is an admin! Use capability checks to
    596  * tell if the user should be accessing a section or not.
     628 * Whether the current request is for an administrative interface page.
     629 *
     630 * Does not check if the user is an administrator; {@see current_user_can()}
     631 * for checking roles and capabilities.
    597632 *
    598633 * @since 1.5.1
    599634 *
    600  * @return bool True if inside WordPress administration pages.
     635 * @return bool True if inside WordPress administration interface, false otherwise.
    601636 */
    602637function is_admin() {
     
    610645
    611646/**
    612  * Whether the current request is for a blog admin screen /wp-admin/
    613  *
    614  * Does not inform on whether the user is a blog admin! Use capability checks to
    615  * tell if the user should be accessing a section or not.
     647 * Whether the current request is for a site's admininstrative interface.
     648 *
     649 * e.g. `/wp-admin/`
     650 *
     651 * Does not check if the user is an administrator; {@see current_user_can()}
     652 * for checking roles and capabilities.
    616653 *
    617654 * @since 3.1.0
    618655 *
    619  * @return bool True if inside WordPress network administration pages.
     656 * @return bool True if inside WordPress blog administration pages.
    620657 */
    621658function is_blog_admin() {
     
    629666
    630667/**
    631  * Whether the current request is for a network admin screen /wp-admin/network/
    632  *
    633  * Does not inform on whether the user is a network admin! Use capability checks to
    634  * tell if the user should be accessing a section or not.
     668 * Whether the current request is for the network administrative interface.
     669 *
     670 * e.g. `/wp-admin/network/`
     671 *
     672 * Does not check if the user is an administrator; {@see current_user_can()}
     673 * for checking roles and capabilities.
    635674 *
    636675 * @since 3.1.0
     
    648687
    649688/**
    650  * Whether the current request is for a user admin screen /wp-admin/user/
    651  *
    652  * Does not inform on whether the user is an admin! Use capability checks to
    653  * tell if the user should be accessing a section or not.
     689 * Whether the current request is for a user admin screen.
     690 *
     691 * e.g. `/wp-admin/user/`
     692 *
     693 * Does not inform on whether the user is an admin! Use capability
     694 * checks to tell if the user should be accessing a section or not
     695 * {@see current_user_can()}.
    654696 *
    655697 * @since 3.1.0
     
    667709
    668710/**
    669  * Whether Multisite support is enabled
    670  *
    671  * @since 3.0.0
    672  *
    673  * @return bool True if multisite is enabled, false otherwise.
     711 * If Multisite is enabled.
     712 *
     713 * @since 3.0.0
     714 *
     715 * @return bool True if Multisite is enabled, false otherwise.
    674716 */
    675717function is_multisite() {
     
    684726
    685727/**
    686  * Retrieve the current blog id
     728 * Retrieve the current blog ID.
    687729 *
    688730 * @since 3.1.0
     
    696738
    697739/**
    698  * Attempts an early load of translations.
    699  *
    700  * Used for errors encountered during the initial loading process, before the locale has been
    701  * properly detected and loaded.
    702  *
    703  * Designed for unusual load sequences (like setup-config.php) or for when the script will then
    704  * terminate with an error, otherwise there is a risk that a file can be double-included.
     740 * Attempt an early load of translations.
     741 *
     742 * Used for errors encountered during the initial loading process, before
     743 * the locale has been properly detected and loaded.
     744 *
     745 * Designed for unusual load sequences (like setup-config.php) or for when
     746 * the script will then terminate with an error, otherwise there is a risk
     747 * that a file can be double-included.
    705748 *
    706749 * @since 3.4.0
    707750 * @access private
     751 *
     752 * @global $wp_locale The WordPress date and time locale object.
    708753 */
    709754function wp_load_translations_early() {
Note: See TracChangeset for help on using the changeset viewer.