wp/wp-admin/load-scripts.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
     1 <?php
     1 <?php
     2 
     2 
     3 /*
     3 /*
     4  * Disable error reporting.
     4  * The error_reporting() function can be disabled in php.ini. On systems where that is the case,
     5  *
     5  * it's best to add a dummy function to the wp-config.php file, but as this call to the function
     6  * Set this to error_reporting( -1 ) for debugging.
     6  * is run prior to wp-config.php loading, it is wrapped in a function_exists() check.
     7  */
     7  */
     8 error_reporting( 0 );
     8 if ( function_exists( 'error_reporting' ) ) {
       
     9 	/*
       
    10 	 * Disable error reporting.
       
    11 	 *
       
    12 	 * Set this to error_reporting( -1 ) for debugging.
       
    13 	 */
       
    14 	error_reporting( 0 );
       
    15 }
     9 
    16 
    10 // Set ABSPATH for execution.
    17 // Set ABSPATH for execution.
    11 if ( ! defined( 'ABSPATH' ) ) {
    18 if ( ! defined( 'ABSPATH' ) ) {
    12 	define( 'ABSPATH', dirname( __DIR__ ) . '/' );
    19 	define( 'ABSPATH', dirname( __DIR__ ) . '/' );
    13 }
    20 }
    43 $wp_scripts = new WP_Scripts();
    50 $wp_scripts = new WP_Scripts();
    44 wp_default_scripts( $wp_scripts );
    51 wp_default_scripts( $wp_scripts );
    45 wp_default_packages_vendor( $wp_scripts );
    52 wp_default_packages_vendor( $wp_scripts );
    46 wp_default_packages_scripts( $wp_scripts );
    53 wp_default_packages_scripts( $wp_scripts );
    47 
    54 
    48 $etag = "WP:{$wp_version};";
    55 $etag = $wp_scripts->get_etag( $load );
    49 
       
    50 foreach ( $load as $handle ) {
       
    51 	if ( ! array_key_exists( $handle, $wp_scripts->registered ) ) {
       
    52 		continue;
       
    53 	}
       
    54 
       
    55 	$ver   = $wp_scripts->registered[ $handle ]->ver ? $wp_scripts->registered[ $handle ]->ver : $wp_version;
       
    56 	$etag .= "{$handle}:{$ver};";
       
    57 }
       
    58 
       
    59 /*
       
    60  * This is not intended to be cryptographically secure, just a fast way to get
       
    61  * a fixed length string based on the script versions. As this file does not
       
    62  * load the full WordPress environment, it is not possible to use the salted
       
    63  * wp_hash() function.
       
    64  */
       
    65 $etag = 'W/"' . md5( $etag ) . '"';
       
    66 
    56 
    67 if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $etag ) {
    57 if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $etag ) {
    68 	header( "$protocol 304 Not Modified" );
    58 	header( "$protocol 304 Not Modified" );
    69 	exit;
    59 	exit;
    70 }
    60 }