~canonical-sysadmins/wordpress/5.1

« back to all changes in this revision

Viewing changes to wp-includes/load.php

  • Committer: Haw Loeung
  • Date: 2016-12-13 06:54:17 UTC
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: haw.loeung@canonical.com-20161213065417-pemlo49o7in8nmkn
New upstream version 4.7.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/**
3
3
 * These functions are needed to load WordPress.
4
4
 *
5
 
 * @internal This file must be parsable by PHP4.
6
 
 *
7
5
 * @package WordPress
8
6
 */
9
7
 
130
128
                $protocol = wp_get_server_protocol();
131
129
                header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 );
132
130
                header( 'Content-Type: text/html; charset=utf-8' );
 
131
                /* translators: 1: Current PHP version number, 2: WordPress version number, 3: Minimum required PHP version number */
133
132
                die( sprintf( __( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.' ), $php_version, $wp_version, $required_php_version ) );
134
133
        }
135
134
 
334
333
                error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
335
334
        }
336
335
 
337
 
        if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
 
336
        if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() ) {
338
337
                @ini_set( 'display_errors', 0 );
339
338
        }
340
339
}
398
397
        if ( file_exists( WP_CONTENT_DIR . '/db.php' ) )
399
398
                require_once( WP_CONTENT_DIR . '/db.php' );
400
399
 
401
 
        if ( isset( $wpdb ) )
 
400
        if ( isset( $wpdb ) ) {
402
401
                return;
 
402
        }
403
403
 
404
404
        $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
405
405
}
470
470
 *
471
471
 * @since 3.0.0
472
472
 * @access private
473
 
 *
474
 
 * @global int $blog_id Blog ID.
475
473
 */
476
474
function wp_start_object_cache() {
477
 
        global $blog_id;
478
 
 
479
475
        $first_init = false;
480
476
        if ( ! function_exists( 'wp_cache_init' ) ) {
481
477
                if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
482
478
                        require_once ( WP_CONTENT_DIR . '/object-cache.php' );
483
 
                        if ( function_exists( 'wp_cache_init' ) )
 
479
                        if ( function_exists( 'wp_cache_init' ) ) {
484
480
                                wp_using_ext_object_cache( true );
 
481
                        }
485
482
                }
486
483
 
487
484
                $first_init = true;
495
492
                wp_using_ext_object_cache( true );
496
493
        }
497
494
 
498
 
        if ( ! wp_using_ext_object_cache() )
 
495
        if ( ! wp_using_ext_object_cache() ) {
499
496
                require_once ( ABSPATH . WPINC . '/cache.php' );
 
497
        }
500
498
 
501
499
        /*
502
500
         * If cache supports reset, reset instead of init if already
503
501
         * initialized. Reset signals to the cache that global IDs
504
502
         * have changed and it may need to update keys and cleanup caches.
505
503
         */
506
 
        if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) )
507
 
                wp_cache_switch_to_blog( $blog_id );
508
 
        elseif ( function_exists( 'wp_cache_init' ) )
 
504
        if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) {
 
505
                wp_cache_switch_to_blog( get_current_blog_id() );
 
506
        } elseif ( function_exists( 'wp_cache_init' ) ) {
509
507
                wp_cache_init();
 
508
        }
510
509
 
511
510
        if ( function_exists( 'wp_cache_add_global_groups' ) ) {
512
511
                wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'site-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) );
814
813
 *
815
814
 * @since 4.6.0
816
815
 *
817
 
 * @global WP_Network $current_site The current network.
818
 
 *
819
816
 * @return int The ID of the current network.
820
817
 */
821
818
function get_current_network_id() {
823
820
                return 1;
824
821
        }
825
822
 
826
 
        $current_site = get_current_site();
 
823
        $current_network = get_network();
827
824
 
828
 
        if ( ! isset( $current_site->id ) ) {
 
825
        if ( ! isset( $current_network->id ) ) {
829
826
                return get_main_network_id();
830
827
        }
831
828
 
832
 
        return absint( $current_site->id );
 
829
        return absint( $current_network->id );
833
830
}
834
831
 
835
832
/**
845
842
 * @since 3.4.0
846
843
 * @access private
847
844
 *
848
 
 * @global string    $text_direction
849
 
 * @global WP_Locale $wp_locale      The WordPress date and time locale object.
 
845
 * @global WP_Locale $wp_locale The WordPress date and time locale object.
850
846
 *
851
847
 * @staticvar bool $loaded
852
848
 */
853
849
function wp_load_translations_early() {
854
 
        global $text_direction, $wp_locale;
 
850
        global $wp_locale;
855
851
 
856
852
        static $loaded = false;
857
853
        if ( $loaded )
867
863
        // Translation and localization
868
864
        require_once ABSPATH . WPINC . '/pomo/mo.php';
869
865
        require_once ABSPATH . WPINC . '/l10n.php';
870
 
        require_once ABSPATH . WPINC . '/locale.php';
 
866
        require_once ABSPATH . WPINC . '/class-wp-locale.php';
 
867
        require_once ABSPATH . WPINC . '/class-wp-locale-switcher.php';
871
868
 
872
869
        // General libraries
873
870
        require_once ABSPATH . WPINC . '/plugin.php';
981
978
 * @since 2.3.0
982
979
 * @since 4.6.0 Moved from media.php to load.php.
983
980
 *
984
 
 * @link http://php.net/manual/en/function.ini-get.php
985
 
 * @link http://php.net/manual/en/faq.using.php#faq.using.shorthandbytes
 
981
 * @link https://secure.php.net/manual/en/function.ini-get.php
 
982
 * @link https://secure.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
986
983
 *
987
984
 * @param string $value A (PHP ini) byte value, either shorthand or ordinary.
988
985
 * @return int An integer byte value.
1008
1005
 *
1009
1006
 * @since 4.6.0
1010
1007
 *
1011
 
 * @link http://php.net/manual/en/function.ini-get-all.php
 
1008
 * @link https://secure.php.net/manual/en/function.ini-get-all.php
1012
1009
 *
1013
1010
 * @param string $setting The name of the ini setting to check.
1014
1011
 * @return bool True if the value is changeable at runtime. False otherwise.
1036
1033
 
1037
1034
        return false;
1038
1035
}
 
1036
 
 
1037
/**
 
1038
 * Determines whether the current request is a WordPress Ajax request.
 
1039
 *
 
1040
 * @since 4.7.0
 
1041
 *
 
1042
 * @return bool True if it's a WordPress Ajax request, false otherwise.
 
1043
 */
 
1044
function wp_doing_ajax() {
 
1045
        /**
 
1046
         * Filters whether the current request is a WordPress Ajax request.
 
1047
         *
 
1048
         * @since 4.7.0
 
1049
         *
 
1050
         * @param bool $wp_doing_ajax Whether the current request is a WordPress Ajax request.
 
1051
         */
 
1052
        return apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX );
 
1053
}
 
1054
 
 
1055
/**
 
1056
 * Check whether variable is a WordPress Error.
 
1057
 *
 
1058
 * Returns true if $thing is an object of the WP_Error class.
 
1059
 *
 
1060
 * @since 2.1.0
 
1061
 *
 
1062
 * @param mixed $thing Check if unknown variable is a WP_Error object.
 
1063
 * @return bool True, if WP_Error. False, if not WP_Error.
 
1064
 */
 
1065
function is_wp_error( $thing ) {
 
1066
        return ( $thing instanceof WP_Error );
 
1067
}