diff --git a/src/wp-admin/admin-footer.php b/src/wp-admin/admin-footer.php index abb020e046459..5719880201f4e 100644 --- a/src/wp-admin/admin-footer.php +++ b/src/wp-admin/admin-footer.php @@ -104,13 +104,6 @@ */ do_action( "admin_footer-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores -// get_site_option() won't exist when auto upgrading from <= 2.7. -if ( function_exists( 'get_site_option' ) - && false === get_site_option( 'can_compress_scripts' ) -) { - compression_test(); -} - ?>
diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 2af08fba70af9..43b53135978f1 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -181,69 +181,11 @@ function wp_ajax_ajax_tag_search() { * Handles compression testing via AJAX. * * @since 3.1.0 + * @deprecated 7.1.0 Script concatenation and compression via load-scripts.php are deprecated. + * The compression test is no longer needed. */ function wp_ajax_wp_compression_test() { - if ( ! current_user_can( 'manage_options' ) ) { - wp_die( -1 ); - } - - if ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) ) { - // Use `update_option()` on single site to mark the option for autoloading. - if ( is_multisite() ) { - update_site_option( 'can_compress_scripts', 0 ); - } else { - update_option( 'can_compress_scripts', 0, true ); - } - wp_die( 0 ); - } - - if ( isset( $_GET['test'] ) ) { - header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' ); - header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); - header( 'Cache-Control: no-cache, must-revalidate, max-age=0' ); - header( 'Content-Type: application/javascript; charset=UTF-8' ); - $force_gzip = ( defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ); - $test_str = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."'; - - if ( '1' === $_GET['test'] ) { - echo $test_str; - wp_die(); - } elseif ( '2' === $_GET['test'] ) { - if ( ! isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) { - wp_die( -1 ); - } - - if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate' ) && function_exists( 'gzdeflate' ) && ! $force_gzip ) { - header( 'Content-Encoding: deflate' ); - $output = gzdeflate( $test_str, 1 ); - } elseif ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && function_exists( 'gzencode' ) ) { - header( 'Content-Encoding: gzip' ); - $output = gzencode( $test_str, 1 ); - } else { - wp_die( -1 ); - } - - echo $output; - wp_die(); - } elseif ( 'no' === $_GET['test'] ) { - check_ajax_referer( 'update_can_compress_scripts' ); - // Use `update_option()` on single site to mark the option for autoloading. - if ( is_multisite() ) { - update_site_option( 'can_compress_scripts', 0 ); - } else { - update_option( 'can_compress_scripts', 0, true ); - } - } elseif ( 'yes' === $_GET['test'] ) { - check_ajax_referer( 'update_can_compress_scripts' ); - // Use `update_option()` on single site to mark the option for autoloading. - if ( is_multisite() ) { - update_site_option( 'can_compress_scripts', 1 ); - } else { - update_option( 'can_compress_scripts', 1, true ); - } - } - } - + _deprecated_function( __FUNCTION__, '7.1.0' ); wp_die( 0 ); } diff --git a/src/wp-admin/includes/noop.php b/src/wp-admin/includes/noop.php index 39dc9702c1eb6..741cedaea6bf1 100644 --- a/src/wp-admin/includes/noop.php +++ b/src/wp-admin/includes/noop.php @@ -2,28 +2,42 @@ /** * Noop functions for load-scripts.php and load-styles.php. * + * These stubs allow the script/style loader classes to be bootstrapped + * without loading the full WordPress stack. Each stub returns a type-safe + * empty value that matches what the real function would return, preventing + * PHP 8 type errors when the return value is used downstream. + * * @package WordPress * @subpackage Administration * @since 4.4.0 + * @deprecated 7.1.0 Script/style concatenation via load-scripts.php and load-styles.php is deprecated. */ /** * @ignore + * @return string */ -function __() {} +function __() { + return ''; +} /** * @ignore + * @return string */ -function _x() {} +function _x() { + return ''; +} /** * @ignore + * @return void */ function add_filter() {} /** * @ignore + * @return false */ function has_filter() { return false; @@ -31,46 +45,70 @@ function has_filter() { /** * @ignore + * @param string $text + * @return string */ -function esc_attr() {} +function esc_attr( $text = '' ) { + return (string) $text; +} /** * @ignore + * @return mixed Returns the first argument passed, matching the real apply_filters() contract. */ -function apply_filters() {} +function apply_filters() { + $args = func_get_args(); + // Return the second argument (the value), mirroring the real apply_filters() behaviour. + return isset( $args[1] ) ? $args[1] : null; +} /** * @ignore + * @return false */ -function get_option() {} +function get_option() { + return false; +} /** * @ignore + * @return false */ -function is_lighttpd_before_150() {} +function is_lighttpd_before_150() { + return false; +} /** * @ignore + * @return void */ function add_action() {} /** * @ignore + * @return false */ -function did_action() {} +function did_action() { + return false; +} /** * @ignore + * @return void */ function do_action_ref_array() {} /** * @ignore + * @return string */ -function get_bloginfo() {} +function get_bloginfo() { + return ''; +} /** * @ignore + * @return true */ function is_admin() { return true; @@ -78,36 +116,60 @@ function is_admin() { /** * @ignore + * @return string */ -function site_url() {} +function site_url() { + return ''; +} /** * @ignore + * @return string */ -function admin_url() {} +function admin_url() { + return ''; +} /** * @ignore + * @return string */ -function home_url() {} +function home_url() { + return ''; +} /** * @ignore + * @return string */ -function includes_url() {} +function includes_url() { + return ''; +} /** * @ignore + * @return string */ -function wp_guess_url() {} +function wp_guess_url() { + return ''; +} +/** + * Returns the contents of the given file path, or an empty string if the file + * does not exist or cannot be read. + * + * @param string $path Absolute filesystem path to the file. + * @return string File contents, or empty string on failure. + */ function get_file( $path ) { $path = realpath( $path ); - if ( ! $path || ! @is_file( $path ) ) { + if ( ! $path || ! is_file( $path ) ) { return ''; } - return @file_get_contents( $path ); + $contents = file_get_contents( $path ); + + return false !== $contents ? $contents : ''; } diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index 6680bca89691a..99b138313ec75 100644 --- a/src/wp-admin/includes/template.php +++ b/src/wp-admin/includes/template.php @@ -2497,8 +2497,11 @@ function get_media_states( $post ) { * has to be deleted. * * @since 2.8.0 + * @deprecated 7.1.0 Script concatenation and compression via load-scripts.php are deprecated. + * The compression test is no longer needed. */ function compression_test() { + _deprecated_function( __FUNCTION__, '7.1.0' ); ?>