Make WordPress Core


Ignore:
Timestamp:
07/28/2020 04:05:39 PM (4 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-theme-upgrader.php

    r48493 r48666  
    589589        }
    590590
     591        $requires_php = isset( $info['RequiresPHP'] ) ? $info['RequiresPHP'] : null;
     592        $requires_wp  = isset( $info['RequiresWP'] ) ? $info['RequiresWP'] : null;
     593
     594        if ( ! is_php_version_compatible( $requires_php ) ) {
     595            $error = sprintf(
     596                /* translators: 1: Current PHP version, 2: Version required by the uploaded theme. */
     597                __( 'The PHP version on your server is %1$s, however the uploaded theme requires %2$s.' ),
     598                phpversion(),
     599                $requires_php
     600            );
     601
     602            return new WP_Error( 'incompatible_php_required_version', $this->strings['incompatible_archive'], $error );
     603        }
     604        if ( ! is_wp_version_compatible( $requires_wp ) ) {
     605            $error = sprintf(
     606                /* translators: 1: Current WordPress version, 2: Version required by the uploaded theme. */
     607                __( 'Your WordPress version is %1$s, however the uploaded theme requires %2$s.' ),
     608                $GLOBALS['wp_version'],
     609                $requires_wp
     610            );
     611
     612            return new WP_Error( 'incompatible_wp_required_version', $this->strings['incompatible_archive'], $error );
     613        }
     614
    591615        $this->new_theme_data = $info;
     616
    592617        return $source;
    593618    }
Note: See TracChangeset for help on using the changeset viewer.