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. git-svn-id: https://develop.svn.wordpress.org/trunk@48172 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9a604011ee
commit
be8b93c269
@ -1148,32 +1148,52 @@ function validate_plugin_requirements( $plugin ) {
|
||||
$compatible_wp = is_wp_version_compatible( $requirements['requires'] );
|
||||
$compatible_php = is_php_version_compatible( $requirements['requires_php'] );
|
||||
|
||||
/* translators: %s: URL to Update PHP page. */
|
||||
$php_update_message = '</p><p>' . sprintf(
|
||||
__( '<a href="%s">Learn more about updating PHP</a>.' ),
|
||||
esc_url( wp_get_update_php_url() )
|
||||
);
|
||||
|
||||
$annotation = wp_get_update_php_annotation();
|
||||
|
||||
if ( $annotation ) {
|
||||
$php_update_message .= '</p><p><em>' . $annotation . '</em>';
|
||||
}
|
||||
|
||||
if ( ! $compatible_wp && ! $compatible_php ) {
|
||||
return new WP_Error(
|
||||
'plugin_wp_php_incompatible',
|
||||
sprintf(
|
||||
/* translators: %s: Plugin name. */
|
||||
_x( '<strong>Error:</strong> Current WordPress and PHP versions do not meet minimum requirements for %s.', 'plugin' ),
|
||||
$plugin_headers['Name']
|
||||
)
|
||||
'<p>' . sprintf(
|
||||
/* translators: 1: Current WordPress version, 2: Current PHP version, 3: Plugin name, 4: Required WordPress version, 5: Required PHP version. */
|
||||
_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' ),
|
||||
get_bloginfo( 'version' ),
|
||||
phpversion(),
|
||||
$plugin_headers['Name'],
|
||||
$requirements['requires'],
|
||||
$requirements['requires_php']
|
||||
) . $php_update_message . '</p>'
|
||||
);
|
||||
} elseif ( ! $compatible_php ) {
|
||||
return new WP_Error(
|
||||
'plugin_php_incompatible',
|
||||
sprintf(
|
||||
/* translators: %s: Plugin name. */
|
||||
_x( '<strong>Error:</strong> Current PHP version does not meet minimum requirements for %s.', 'plugin' ),
|
||||
$plugin_headers['Name']
|
||||
)
|
||||
'<p>' . sprintf(
|
||||
/* translators: 1: Current PHP version, 2: Plugin name, 3: Required PHP version. */
|
||||
_x( '<strong>Error:</strong> Current PHP version (%1$s) does not meet minimum requirements for %2$s. The plugin requires PHP %3$s.', 'plugin' ),
|
||||
phpversion(),
|
||||
$plugin_headers['Name'],
|
||||
$requirements['requires_php']
|
||||
) . $php_update_message . '</p>'
|
||||
);
|
||||
} elseif ( ! $compatible_wp ) {
|
||||
return new WP_Error(
|
||||
'plugin_wp_incompatible',
|
||||
sprintf(
|
||||
/* translators: %s: Plugin name. */
|
||||
_x( '<strong>Error:</strong> Current WordPress version does not meet minimum requirements for %s.', 'plugin' ),
|
||||
$plugin_headers['Name']
|
||||
)
|
||||
'<p>' . sprintf(
|
||||
/* translators: 1: Current WordPress version, 2: Plugin name, 3: Required WordPress version. */
|
||||
_x( '<strong>Error:</strong> Current WordPress version (%1$s) does not meet minimum requirements for %2$s. The plugin requires WordPress %3$s.', 'plugin' ),
|
||||
get_bloginfo( 'version' ),
|
||||
$plugin_headers['Name'],
|
||||
$requirements['requires']
|
||||
) . '</p>'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -961,12 +961,17 @@ function update_core( $from, $to ) {
|
||||
}
|
||||
|
||||
$php_update_message = '';
|
||||
|
||||
if ( function_exists( 'wp_get_update_php_url' ) ) {
|
||||
/* translators: %s: URL to Update PHP page. */
|
||||
$php_update_message = '</p><p>' . sprintf( __( '<a href="%s">Learn more about updating PHP</a>.' ), esc_url( wp_get_update_php_url() ) );
|
||||
$php_update_message = '</p><p>' . sprintf(
|
||||
__( '<a href="%s">Learn more about updating PHP</a>.' ),
|
||||
esc_url( wp_get_update_php_url() )
|
||||
);
|
||||
|
||||
if ( function_exists( 'wp_get_update_php_annotation' ) ) {
|
||||
$annotation = wp_get_update_php_annotation();
|
||||
|
||||
if ( $annotation ) {
|
||||
$php_update_message .= '</p><p><em>' . $annotation . '</em>';
|
||||
}
|
||||
|
@ -240,22 +240,46 @@ $version_url = sprintf(
|
||||
);
|
||||
|
||||
/* translators: %s: URL to Update PHP page. */
|
||||
$php_update_message = '</p><p>' . sprintf( __( '<a href="%s">Learn more about updating PHP</a>.' ), esc_url( wp_get_update_php_url() ) );
|
||||
$php_update_message = '</p><p>' . sprintf(
|
||||
__( '<a href="%s">Learn more about updating PHP</a>.' ),
|
||||
esc_url( wp_get_update_php_url() )
|
||||
);
|
||||
|
||||
$annotation = wp_get_update_php_annotation();
|
||||
|
||||
if ( $annotation ) {
|
||||
$php_update_message .= '</p><p><em>' . $annotation . '</em>';
|
||||
}
|
||||
|
||||
if ( ! $mysql_compat && ! $php_compat ) {
|
||||
$compat = sprintf(
|
||||
/* 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. */
|
||||
$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;
|
||||
__( '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;
|
||||
} elseif ( ! $php_compat ) {
|
||||
$compat = sprintf(
|
||||
/* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number. */
|
||||
$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;
|
||||
__( '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;
|
||||
} elseif ( ! $mysql_compat ) {
|
||||
$compat = sprintf(
|
||||
/* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number. */
|
||||
$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 );
|
||||
__( '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
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! $mysql_compat || ! $php_compat ) {
|
||||
|
@ -88,6 +88,7 @@ function list_core_update( $update ) {
|
||||
);
|
||||
|
||||
$annotation = wp_get_update_php_annotation();
|
||||
|
||||
if ( $annotation ) {
|
||||
$php_update_message .= '</p><p><em>' . $annotation . '</em>';
|
||||
}
|
||||
|
@ -82,9 +82,13 @@ elseif ( ! $php_compat || ! $mysql_compat ) :
|
||||
);
|
||||
|
||||
/* translators: %s: URL to Update PHP page. */
|
||||
$php_update_message = '</p><p>' . sprintf( __( '<a href="%s">Learn more about updating PHP</a>.' ), esc_url( wp_get_update_php_url() ) );
|
||||
$php_update_message = '</p><p>' . sprintf(
|
||||
__( '<a href="%s">Learn more about updating PHP</a>.' ),
|
||||
esc_url( wp_get_update_php_url() )
|
||||
);
|
||||
|
||||
$annotation = wp_get_update_php_annotation();
|
||||
|
||||
if ( $annotation ) {
|
||||
$php_update_message .= '</p><p><em>' . $annotation . '</em>';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user