WordPress.org

Make WordPress Core

Changeset 51092


Ignore:
Timestamp:
06/08/2021 10:11:49 AM (12 days ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/plugin.php

    r51064 r51092  
    11201120 * defined in the plugin's main PHP file.
    11211121 *
    1122  * If the headers are not present in the plugin's main PHP file,
    1123  * `readme.txt` is also checked as a fallback.
    1124  *
    11251122 * @since 5.2.0
    11261123 * @since 5.3.0 Added support for reading the headers from the plugin's
    11271124 *              main PHP file, with `readme.txt` as a fallback.
     1125 * @since 5.8.0 Removed support for using `readme.txt` as a fallback.
    11281126 *
    11291127 * @param string $plugin Path to the plugin file relative to the plugins directory.
     
    11371135        'requires_php' => ! empty( $plugin_headers['RequiresPHP'] ) ? $plugin_headers['RequiresPHP'] : '',
    11381136    );
    1139 
    1140     $readme_file = WP_PLUGIN_DIR . '/' . dirname( $plugin ) . '/readme.txt';
    1141 
    1142     if ( file_exists( $readme_file ) ) {
    1143         $readme_headers = get_file_data(
    1144             $readme_file,
    1145             array(
    1146                 'requires'     => 'Requires at least',
    1147                 'requires_php' => 'Requires PHP',
    1148             ),
    1149             'plugin'
    1150         );
    1151 
    1152         $requirements = array_merge( $readme_headers, $requirements );
    1153     }
    11541137
    11551138    $compatible_wp  = is_wp_version_compatible( $requirements['requires'] );
  • trunk/src/wp-includes/theme.php

    r50395 r51092  
    900900 * defined in the theme's `style.css` file.
    901901 *
    902  * If the headers are not present in the theme's stylesheet file,
    903  * `readme.txt` is also checked as a fallback.
    904  *
    905902 * @since 5.5.0
     903 * @since 5.8.0 Removed support for using `readme.txt` as a fallback.
    906904 *
    907905 * @param string $stylesheet Directory name for the theme.
     
    915913        'requires_php' => ! empty( $theme->get( 'RequiresPHP' ) ) ? $theme->get( 'RequiresPHP' ) : '',
    916914    );
    917 
    918     $readme_file = $theme->theme_root . '/' . $stylesheet . '/readme.txt';
    919 
    920     if ( file_exists( $readme_file ) ) {
    921         $readme_headers = get_file_data(
    922             $readme_file,
    923             array(
    924                 'requires'     => 'Requires at least',
    925                 'requires_php' => 'Requires PHP',
    926             ),
    927             'theme'
    928         );
    929 
    930         $requirements = array_merge( $readme_headers, $requirements );
    931     }
    932915
    933916    $compatible_wp  = is_wp_version_compatible( $requirements['requires'] );
Note: See TracChangeset for help on using the changeset viewer.