From 08f5a1b09831603768663c1b6b6cc33fddc11d25 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 8 Jun 2021 10:13:00 +0000 Subject: [PATCH] Upgrade/Install: Remove parsing of `readme.txt` files for plugin or theme requirements. This affects: * `validate_plugin_requirements()` * `validate_theme_requirements()` Historically, the `Requires PHP` header was introduced in #meta2952 for the Plugin Directory first, so at the time it made sense to have it defined in the same place as `Requires at least`, which only existed in `readme.txt`. Since parsing of PHP and WordPress requirements was later added to WordPress core, the core should retrieve all the necessary data from the main plugin or theme file and not from `readme.txt`, which only contains the data meant for the Plugin or Theme Directory. The recommended place for `Requires PHP` and `Requires at least` headers is as follows: * The plugin's main PHP file * The theme's `style.css` file The place for the `Tested up to` header remains in `readme.txt` for the time being, as it's not used by WordPress core. Follow-up to [44978], [45546], [47573], [47574], [meta5841], [meta9050]. Props afragen, Otto42, joyously, williampatton, audrasjb. Fixes #48520. See #48515, #meta2952, #meta4514, #meta4621. Built from https://develop.svn.wordpress.org/trunk@51092 git-svn-id: http://core.svn.wordpress.org/trunk@50701 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/plugin.php | 19 +------------------ wp-includes/theme.php | 19 +------------------ wp-includes/version.php | 2 +- 3 files changed, 3 insertions(+), 37 deletions(-) diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index ce913919da..2b77846f8b 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -1119,12 +1119,10 @@ function validate_plugin( $plugin ) { * Uses the information from `Requires at least` and `Requires PHP` headers * defined in the plugin's main PHP file. * - * If the headers are not present in the plugin's main PHP file, - * `readme.txt` is also checked as a fallback. - * * @since 5.2.0 * @since 5.3.0 Added support for reading the headers from the plugin's * main PHP file, with `readme.txt` as a fallback. + * @since 5.8.0 Removed support for using `readme.txt` as a fallback. * * @param string $plugin Path to the plugin file relative to the plugins directory. * @return true|WP_Error True if requirements are met, WP_Error on failure. @@ -1137,21 +1135,6 @@ function validate_plugin_requirements( $plugin ) { 'requires_php' => ! empty( $plugin_headers['RequiresPHP'] ) ? $plugin_headers['RequiresPHP'] : '', ); - $readme_file = WP_PLUGIN_DIR . '/' . dirname( $plugin ) . '/readme.txt'; - - if ( file_exists( $readme_file ) ) { - $readme_headers = get_file_data( - $readme_file, - array( - 'requires' => 'Requires at least', - 'requires_php' => 'Requires PHP', - ), - 'plugin' - ); - - $requirements = array_merge( $readme_headers, $requirements ); - } - $compatible_wp = is_wp_version_compatible( $requirements['requires'] ); $compatible_php = is_php_version_compatible( $requirements['requires_php'] ); diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 458b8e6b3a..7d4b62684b 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -899,10 +899,8 @@ function validate_current_theme() { * Uses the information from `Requires at least` and `Requires PHP` headers * defined in the theme's `style.css` file. * - * If the headers are not present in the theme's stylesheet file, - * `readme.txt` is also checked as a fallback. - * * @since 5.5.0 + * @since 5.8.0 Removed support for using `readme.txt` as a fallback. * * @param string $stylesheet Directory name for the theme. * @return true|WP_Error True if requirements are met, WP_Error on failure. @@ -915,21 +913,6 @@ function validate_theme_requirements( $stylesheet ) { 'requires_php' => ! empty( $theme->get( 'RequiresPHP' ) ) ? $theme->get( 'RequiresPHP' ) : '', ); - $readme_file = $theme->theme_root . '/' . $stylesheet . '/readme.txt'; - - if ( file_exists( $readme_file ) ) { - $readme_headers = get_file_data( - $readme_file, - array( - 'requires' => 'Requires at least', - 'requires_php' => 'Requires PHP', - ), - 'theme' - ); - - $requirements = array_merge( $readme_headers, $requirements ); - } - $compatible_wp = is_wp_version_compatible( $requirements['requires'] ); $compatible_php = is_php_version_compatible( $requirements['requires_php'] ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 28164074aa..75d2ef6709 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.8-alpha-51091'; +$wp_version = '5.8-alpha-51092'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.