2009-01-14 09:18:51 -05:00
|
|
|
<?php
|
|
|
|
|
2021-12-10 15:30:05 -05:00
|
|
|
/*
|
2024-08-16 10:29:15 -04:00
|
|
|
* The error_reporting() function can be disabled in php.ini. On systems where that is the case,
|
|
|
|
* it's best to add a dummy function to the wp-config.php file, but as this call to the function
|
|
|
|
* is run prior to wp-config.php loading, it is wrapped in a function_exists() check.
|
2009-04-15 15:55:41 -04:00
|
|
|
*/
|
2024-08-16 10:29:15 -04:00
|
|
|
if ( function_exists( 'error_reporting' ) ) {
|
|
|
|
/*
|
|
|
|
* Disable error reporting.
|
|
|
|
*
|
|
|
|
* Set this to error_reporting( -1 ) for debugging.
|
|
|
|
*/
|
|
|
|
error_reporting( 0 );
|
|
|
|
}
|
2009-04-15 15:55:41 -04:00
|
|
|
|
2021-12-10 15:30:05 -05:00
|
|
|
// Set ABSPATH for execution.
|
2016-04-14 13:53:28 -04:00
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
2020-02-06 01:33:11 -05:00
|
|
|
define( 'ABSPATH', dirname( __DIR__ ) . '/' );
|
2016-04-14 13:53:28 -04:00
|
|
|
}
|
|
|
|
|
2009-04-04 23:32:49 -04:00
|
|
|
define( 'WPINC', 'wp-includes' );
|
2021-06-01 19:09:58 -04:00
|
|
|
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
|
2009-01-14 09:18:51 -05:00
|
|
|
|
2020-02-06 01:33:11 -05:00
|
|
|
require ABSPATH . 'wp-admin/includes/noop.php';
|
2021-06-01 19:09:58 -04:00
|
|
|
require ABSPATH . WPINC . '/theme.php';
|
|
|
|
require ABSPATH . WPINC . '/class-wp-theme-json-resolver.php';
|
2021-11-08 16:45:58 -05:00
|
|
|
require ABSPATH . WPINC . '/global-styles-and-settings.php';
|
2020-02-06 01:33:11 -05:00
|
|
|
require ABSPATH . WPINC . '/script-loader.php';
|
|
|
|
require ABSPATH . WPINC . '/version.php';
|
2009-01-14 09:18:51 -05:00
|
|
|
|
2019-08-03 18:17:57 -04:00
|
|
|
$protocol = $_SERVER['SERVER_PROTOCOL'];
|
2021-11-09 18:07:01 -05:00
|
|
|
if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0', 'HTTP/3' ), true ) ) {
|
2019-08-03 18:17:57 -04:00
|
|
|
$protocol = 'HTTP/1.0';
|
|
|
|
}
|
|
|
|
|
2016-01-18 04:57:29 -05:00
|
|
|
$load = $_GET['load'];
|
|
|
|
if ( is_array( $load ) ) {
|
2019-05-27 22:43:55 -04:00
|
|
|
ksort( $load );
|
2016-01-18 04:57:29 -05:00
|
|
|
$load = implode( '', $load );
|
|
|
|
}
|
2019-05-27 22:43:55 -04:00
|
|
|
|
2016-01-18 04:57:29 -05:00
|
|
|
$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load );
|
2013-07-29 13:57:04 -04:00
|
|
|
$load = array_unique( explode( ',', $load ) );
|
2009-01-14 09:18:51 -05:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( empty( $load ) ) {
|
2019-08-03 18:17:57 -04:00
|
|
|
header( "$protocol 400 Bad Request" );
|
2009-01-14 09:18:51 -05:00
|
|
|
exit;
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2009-01-14 09:18:51 -05:00
|
|
|
|
2020-05-12 14:32:08 -04:00
|
|
|
$rtl = ( isset( $_GET['dir'] ) && 'rtl' === $_GET['dir'] );
|
2020-01-28 19:45:18 -05:00
|
|
|
$expires_offset = 31536000; // 1 year.
|
2017-11-30 18:11:00 -05:00
|
|
|
$out = '';
|
2009-01-14 09:18:51 -05:00
|
|
|
|
|
|
|
$wp_styles = new WP_Styles();
|
2017-11-30 18:11:00 -05:00
|
|
|
wp_default_styles( $wp_styles );
|
2009-01-14 09:18:51 -05:00
|
|
|
|
2024-08-25 19:48:13 -04:00
|
|
|
$etag = $wp_styles->get_etag( $wp_version, $load );
|
2024-04-07 19:53:19 -04:00
|
|
|
|
|
|
|
if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $etag ) {
|
2016-01-15 05:23:25 -05:00
|
|
|
header( "$protocol 304 Not Modified" );
|
2020-05-26 05:37:10 -04:00
|
|
|
exit;
|
2016-01-15 05:23:25 -05:00
|
|
|
}
|
|
|
|
|
2015-08-25 16:28:22 -04:00
|
|
|
foreach ( $load as $handle ) {
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( ! array_key_exists( $handle, $wp_styles->registered ) ) {
|
2009-01-14 09:18:51 -05:00
|
|
|
continue;
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2009-01-14 09:18:51 -05:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
$style = $wp_styles->registered[ $handle ];
|
2016-01-18 04:57:29 -05:00
|
|
|
|
|
|
|
if ( empty( $style->src ) ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-01-14 09:18:51 -05:00
|
|
|
$path = ABSPATH . $style->src;
|
|
|
|
|
2013-11-13 00:10:10 -05:00
|
|
|
if ( $rtl && ! empty( $style->extra['rtl'] ) ) {
|
|
|
|
// All default styles have fully independent RTL files.
|
|
|
|
$path = str_replace( '.min.css', '-rtl.min.css', $path );
|
2009-01-14 09:18:51 -05:00
|
|
|
}
|
|
|
|
|
2013-11-13 00:10:10 -05:00
|
|
|
$content = get_file( $path ) . "\n";
|
|
|
|
|
2023-06-23 08:17:24 -04:00
|
|
|
// Note: str_starts_with() is not used here, as wp-includes/compat.php is not loaded in this file.
|
2023-05-03 11:46:22 -04:00
|
|
|
if ( 0 === strpos( $style->src, '/' . WPINC . '/css/' ) ) {
|
2014-06-29 18:21:15 -04:00
|
|
|
$content = str_replace( '../images/', '../' . WPINC . '/images/', $content );
|
|
|
|
$content = str_replace( '../js/tinymce/', '../' . WPINC . '/js/tinymce/', $content );
|
|
|
|
$content = str_replace( '../fonts/', '../' . WPINC . '/fonts/', $content );
|
2017-11-30 18:11:00 -05:00
|
|
|
$out .= $content;
|
2011-08-03 19:56:21 -04:00
|
|
|
} else {
|
2011-07-24 20:36:06 -04:00
|
|
|
$out .= str_replace( '../images/', 'images/', $content );
|
2011-08-03 19:56:21 -04:00
|
|
|
}
|
2009-01-14 09:18:51 -05:00
|
|
|
}
|
|
|
|
|
2024-04-07 19:53:19 -04:00
|
|
|
header( "Etag: $etag" );
|
2017-11-30 18:11:00 -05:00
|
|
|
header( 'Content-Type: text/css; charset=UTF-8' );
|
|
|
|
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' );
|
|
|
|
header( "Cache-Control: public, max-age=$expires_offset" );
|
2009-02-01 04:45:24 -05:00
|
|
|
|
2009-01-14 09:18:51 -05:00
|
|
|
echo $out;
|
|
|
|
exit;
|