Make WordPress Core


Ignore:
Timestamp:
07/28/2020 04:05:39 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Upgrade/Install: Check WordPress and PHP version requirements when uploading a plugin or theme from ZIP file.

Props mariovalney, desrosj.
See #50593.

File:
1 edited

Legend:

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

    r48446 r48666  
    442442                }
    443443
     444                $requires_php = isset( $info['RequiresPHP'] ) ? $info['RequiresPHP'] : null;
     445                $requires_wp  = isset( $info['RequiresWP'] ) ? $info['RequiresWP'] : null;
     446
     447                if ( ! is_php_version_compatible( $requires_php ) ) {
     448                        $error = sprintf(
     449                                /* translators: 1: Current PHP version, 2: Version required by the uploaded plugin. */
     450                                __( 'The PHP version on your server is %1$s, however the uploaded plugin requires %2$s.' ),
     451                                phpversion(),
     452                                $requires_php
     453                        );
     454
     455                        return new WP_Error( 'incompatible_php_required_version', $this->strings['incompatible_archive'], $error );
     456                }
     457
     458                if ( ! is_wp_version_compatible( $requires_wp ) ) {
     459                        $error = sprintf(
     460                                /* translators: 1: Current WordPress version, 2: Version required by the uploaded plugin. */
     461                                __( 'Your WordPress version is %1$s, however the uploaded plugin requires %2$s.' ),
     462                                $GLOBALS['wp_version'],
     463                                $requires_wp
     464                        );
     465
     466                        return new WP_Error( 'incompatible_wp_required_version', $this->strings['incompatible_archive'], $error );
     467                }
     468
    444469                return $source;
    445470        }
Note: See TracChangeset for help on using the changeset viewer.