WordPress.org

Make WordPress Core

Ticket #46938: 46938.diff

File 46938.diff, 3.1 KB (added by afragen, 3 months ago)

test for new plugin compatibility headers

  • wp-admin/includes/plugin.php

    diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php
    index 7a1b038518..76a590333f 100644
    a b  
    3131 *     Network: Optional. Specify "Network: true" to require that a plugin is activated
    3232 *          across all sites in an installation. This will prevent a plugin from being
    3333 *          activated on a single site when Multisite is enabled.
     34 *     Requires WP: Optional. Specify the minimum required WordPress version.
     35 *     Requires PHP: Optional. Specify the minimum required PHP version.
    3436 *      * / # Remove the space to close comment
    3537 *
    3638 * Some users have issues with opening large files and manipulating the contents
     
    4648 * reading.
    4749 *
    4850 * @since 1.5.0
     51 * @since 5.3.0 Added `RequiresWP` and `RequiresPHP`.
    4952 *
    5053 * @param string $plugin_file Absolute path to the main plugin file.
    5154 * @param bool   $markup      Optional. If the returned data should have HTML markup applied.
     
    6366 *     @type string $TextDomain  Plugin textdomain.
    6467 *     @type string $DomainPath  Plugins relative directory path to .mo files.
    6568 *     @type bool   $Network     Whether the plugin can only be activated network-wide.
     69 *     @type string $RequiresWP  Minimum required version of WordPress.
     70 *     @type string $RequiresPHP Minimum required version of PHP.
    6671 * }
    6772 */
    6873function get_plugin_data( $plugin_file, $markup = true, $translate = true ) {
    function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { 
    7782                'TextDomain'  => 'Text Domain',
    7883                'DomainPath'  => 'Domain Path',
    7984                'Network'     => 'Network',
     85                'RequiresWP'  => 'Requires WP',
     86                'RequiresPHP' => 'Requires PHP',
    8087                // Site Wide Only is deprecated in favor of Network.
    8188                '_sitewide'   => 'Site Wide Only',
    8289        );
    function validate_plugin( $plugin ) { 
    10851092 */
    10861093function validate_plugin_requirements( $plugin ) {
    10871094        $readme_file = WP_PLUGIN_DIR . '/' . dirname( $plugin ) . '/readme.txt';
     1095        $plugin_data = array();
    10881096
    10891097        if ( file_exists( $readme_file ) ) {
    10901098                $plugin_data = get_file_data(
    function validate_plugin_requirements( $plugin ) { 
    10951103                        ),
    10961104                        'plugin'
    10971105                );
    1098         } else {
    1099                 return true;
    11001106        }
    11011107
     1108        $plugin_data = array_merge( $plugin_data, get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ) );
     1109
     1110        // Check for headers in plugin file, precedence to headers in readme.txt file.
     1111        $plugin_data['requires']     = isset( $plugin_data['requires'] ) ? $plugin_data['requires'] : $plugin_data['RequiresWP'];
     1112        $plugin_data['requires_php'] = isset( $plugin_data['requires_php'] ) ? $plugin_data['requires_php'] : $plugin_data['RequiresPHP'];
     1113
    11021114        $plugin_data['wp_compatible']  = is_wp_version_compatible( $plugin_data['requires'] );
    11031115        $plugin_data['php_compatible'] = is_php_version_compatible( $plugin_data['requires_php'] );
    11041116
    1105         $plugin_data = array_merge( $plugin_data, get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ) );
    1106 
    11071117        if ( ! $plugin_data['wp_compatible'] && ! $plugin_data['php_compatible'] ) {
    11081118                return new WP_Error(
    11091119                        'plugin_wp_php_incompatible',