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
This commit is contained in:
Sergey Biryukov 2021-06-08 10:13:00 +00:00
parent 55f3de101b
commit 08f5a1b098
3 changed files with 3 additions and 37 deletions

View File

@ -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'] );

View File

@ -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'] );

View File

@ -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.