From a6b129132d5b3d0a54c8e9e267422a80470ac5d0 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Wed, 20 Mar 2019 14:58:03 +0000 Subject: [PATCH] Plugins: Block plugin updates on the update screen if required PHP version is not supported. This brings the changes in [44937] to the WordPress Updates page in the admin. Now, when a site does not meet the minimum PHP version requirements for a plugin update, the user will not be able to update. Instead, they will be presented with educational information to guide them through the process of updating PHP. Props afragen, miyauchi, TimothyBlynJacobs, desrosj. Fixes #44350. git-svn-id: https://develop.svn.wordpress.org/trunk@44939 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/update-core.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/update-core.php b/src/wp-admin/update-core.php index d157a46764..7239243333 100644 --- a/src/wp-admin/update-core.php +++ b/src/wp-admin/update-core.php @@ -294,6 +294,19 @@ function list_plugin_updates() { $compat .= '
' . sprintf( __( 'Compatibility with WordPress %1$s: Unknown' ), $core_update_version ); } } + + $compatible_php = ( empty( $plugin_data->update->requires_php ) || version_compare( phpversion(), $plugin_data->update->requires_php, '>=' ) ); + + if ( ! $compatible_php && current_user_can( 'update_php' ) ) { + $compat .= '
' . __( 'This update doesn’t work with your version of PHP.' ) . ' '; + /* translators: %s: Update PHP page URL */ + $compat .= sprintf( + __( 'Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + $compat .= '

' . wp_get_update_php_annotation() . ''; + } + // Get the upgrade notice for the new plugin version. if ( isset( $plugin_data->update->upgrade_notice ) ) { $upgrade_notice = '
' . strip_tags( $plugin_data->update->upgrade_notice ); @@ -315,6 +328,7 @@ function list_plugin_updates() { ?> + +

- + Name; ?> Version, $plugin_data->update->new_version ); - echo ' ' . $details . $compat . $upgrade_notice; + echo ' ' . $details . $compat . $upgrade_notice; ?>

-