WordPress.org

Make WordPress Core

Changeset 48172


Ignore:
Timestamp:
06/26/2020 12:25:15 AM (17 months ago)
Author:
SergeyBiryukov
Message:

Site Health: Improve the error message displayed when activating a plugin that requires a higher version of PHP or WordPress.

This adds some extra details to the message:

  • The current PHP or WordPress version.
  • The plugin's minimum required PHP or WordPress version.
  • A link to the support documentation on how to update PHP.

Props stuffradio, johnbillion, garrett-eclipse, sabernhardt, williampatton, SergeyBiryukov.
Fixes #48245.

Location:
trunk/src/wp-admin
Files:
5 edited

Legend:

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

    r48142 r48172  
    11491149    $compatible_php = is_php_version_compatible( $requirements['requires_php'] );
    11501150
     1151    /* translators: %s: URL to Update PHP page. */
     1152    $php_update_message = '</p><p>' . sprintf(
     1153        __( '<a href="%s">Learn more about updating PHP</a>.' ),
     1154        esc_url( wp_get_update_php_url() )
     1155    );
     1156
     1157    $annotation = wp_get_update_php_annotation();
     1158
     1159    if ( $annotation ) {
     1160        $php_update_message .= '</p><p><em>' . $annotation . '</em>';
     1161    }
     1162
    11511163    if ( ! $compatible_wp && ! $compatible_php ) {
    11521164        return new WP_Error(
    11531165            'plugin_wp_php_incompatible',
    1154             sprintf(
    1155                 /* translators: %s: Plugin name. */
    1156                 _x( '<strong>Error:</strong> Current WordPress and PHP versions do not meet minimum requirements for %s.', 'plugin' ),
    1157                 $plugin_headers['Name']
    1158             )
     1166            '<p>' . sprintf(
     1167                /* translators: 1: Current WordPress version, 2: Current PHP version, 3: Plugin name, 4: Required WordPress version, 5: Required PHP version. */
     1168                _x( '<strong>Error:</strong> Current versions of WordPress (%1$s) and PHP (%2$s) do not meet minimum requirements for %3$s. The plugin requires WordPress %4$s and PHP %5$s.', 'plugin' ),
     1169                get_bloginfo( 'version' ),
     1170                phpversion(),
     1171                $plugin_headers['Name'],
     1172                $requirements['requires'],
     1173                $requirements['requires_php']
     1174            ) . $php_update_message . '</p>'
    11591175        );
    11601176    } elseif ( ! $compatible_php ) {
    11611177        return new WP_Error(
    11621178            'plugin_php_incompatible',
    1163             sprintf(
    1164                 /* translators: %s: Plugin name. */
    1165                 _x( '<strong>Error:</strong> Current PHP version does not meet minimum requirements for %s.', 'plugin' ),
    1166                 $plugin_headers['Name']
    1167             )
     1179            '<p>' . sprintf(
     1180                /* translators: 1: Current PHP version, 2: Plugin name, 3: Required PHP version. */
     1181                _x( '<strong>Error:</strong> Current PHP version (%1$s) does not meet minimum requirements for %2$s. The plugin requires PHP %3$s.', 'plugin' ),
     1182                phpversion(),
     1183                $plugin_headers['Name'],
     1184                $requirements['requires_php']
     1185            ) . $php_update_message . '</p>'
    11681186        );
    11691187    } elseif ( ! $compatible_wp ) {
    11701188        return new WP_Error(
    11711189            'plugin_wp_incompatible',
    1172             sprintf(
    1173                 /* translators: %s: Plugin name. */
    1174                 _x( '<strong>Error:</strong> Current WordPress version does not meet minimum requirements for %s.', 'plugin' ),
    1175                 $plugin_headers['Name']
    1176             )
     1190            '<p>' . sprintf(
     1191                /* translators: 1: Current WordPress version, 2: Plugin name, 3: Required WordPress version. */
     1192                _x( '<strong>Error:</strong> Current WordPress version (%1$s) does not meet minimum requirements for %2$s. The plugin requires WordPress %3$s.', 'plugin' ),
     1193                get_bloginfo( 'version' ),
     1194                $plugin_headers['Name'],
     1195                $requirements['requires']
     1196            ) . '</p>'
    11771197        );
    11781198    }
  • trunk/src/wp-admin/includes/update-core.php

    r48160 r48172  
    962962
    963963    $php_update_message = '';
     964
    964965    if ( function_exists( 'wp_get_update_php_url' ) ) {
    965966        /* translators: %s: URL to Update PHP page. */
    966         $php_update_message = '</p><p>' . sprintf( __( '<a href="%s">Learn more about updating PHP</a>.' ), esc_url( wp_get_update_php_url() ) );
     967        $php_update_message = '</p><p>' . sprintf(
     968            __( '<a href="%s">Learn more about updating PHP</a>.' ),
     969            esc_url( wp_get_update_php_url() )
     970        );
    967971
    968972        if ( function_exists( 'wp_get_update_php_annotation' ) ) {
    969973            $annotation = wp_get_update_php_annotation();
     974
    970975            if ( $annotation ) {
    971976                $php_update_message .= '</p><p><em>' . $annotation . '</em>';
  • trunk/src/wp-admin/install.php

    r48126 r48172  
    241241
    242242/* translators: %s: URL to Update PHP page. */
    243 $php_update_message = '</p><p>' . sprintf( __( '<a href="%s">Learn more about updating PHP</a>.' ), esc_url( wp_get_update_php_url() ) );
     243$php_update_message = '</p><p>' . sprintf(
     244    __( '<a href="%s">Learn more about updating PHP</a>.' ),
     245    esc_url( wp_get_update_php_url() )
     246);
    244247
    245248$annotation = wp_get_update_php_annotation();
     249
    246250if ( $annotation ) {
    247251    $php_update_message .= '</p><p><em>' . $annotation . '</em>';
     
    249253
    250254if ( ! $mysql_compat && ! $php_compat ) {
    251     /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number. */
    252     $compat = sprintf( __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), $version_url, $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) . $php_update_message;
     255    $compat = sprintf(
     256        /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number. */
     257        __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ),
     258        $version_url,
     259        $wp_version,
     260        $required_php_version,
     261        $required_mysql_version,
     262        $php_version,
     263        $mysql_version
     264    ) . $php_update_message;
    253265} elseif ( ! $php_compat ) {
    254     /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number. */
    255     $compat = sprintf( __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $wp_version, $required_php_version, $php_version ) . $php_update_message;
     266    $compat = sprintf(
     267        /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number. */
     268        __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ),
     269        $version_url,
     270        $wp_version,
     271        $required_php_version,
     272        $php_version
     273    ) . $php_update_message;
    256274} elseif ( ! $mysql_compat ) {
    257     /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number. */
    258     $compat = sprintf( __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires MySQL version %3$s or higher. You are running version %4$s.' ), $version_url, $wp_version, $required_mysql_version, $mysql_version );
     275    $compat = sprintf(
     276        /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number. */
     277        __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires MySQL version %3$s or higher. You are running version %4$s.' ),
     278        $version_url,
     279        $wp_version,
     280        $required_mysql_version,
     281        $mysql_version
     282    );
    259283}
    260284
  • trunk/src/wp-admin/update-core.php

    r48109 r48172  
    8989
    9090            $annotation = wp_get_update_php_annotation();
     91
    9192            if ( $annotation ) {
    9293                $php_update_message .= '</p><p><em>' . $annotation . '</em>';
  • trunk/src/wp-admin/upgrade.php

    r48126 r48172  
    8383
    8484    /* translators: %s: URL to Update PHP page. */
    85     $php_update_message = '</p><p>' . sprintf( __( '<a href="%s">Learn more about updating PHP</a>.' ), esc_url( wp_get_update_php_url() ) );
     85    $php_update_message = '</p><p>' . sprintf(
     86        __( '<a href="%s">Learn more about updating PHP</a>.' ),
     87        esc_url( wp_get_update_php_url() )
     88    );
    8689
    8790    $annotation = wp_get_update_php_annotation();
     91
    8892    if ( $annotation ) {
    8993        $php_update_message .= '</p><p><em>' . $annotation . '</em>';
Note: See TracChangeset for help on using the changeset viewer.