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. 
Built from https://develop.svn.wordpress.org/trunk@44939


git-svn-id: http://core.svn.wordpress.org/trunk@44770 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
desrosj 2019-03-20 14:59:50 +00:00
parent c32bc04fdc
commit 22d61857fc
2 changed files with 19 additions and 4 deletions

View File

@ -294,6 +294,19 @@ function list_plugin_updates() {
$compat .= '<br />' . 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 .= '<br>' . __( 'This update doesn&#8217;t work with your version of PHP.' ) . '&nbsp;';
/* translators: %s: Update PHP page URL */
$compat .= sprintf(
__( '<a href="%s">Learn more about updating PHP.</a>' ),
esc_url( wp_get_update_php_url() )
);
$compat .= '</p><p><em>' . wp_get_update_php_annotation() . '</em>';
}
// Get the upgrade notice for the new plugin version.
if ( isset( $plugin_data->update->upgrade_notice ) ) {
$upgrade_notice = '<br />' . strip_tags( $plugin_data->update->upgrade_notice );
@ -315,6 +328,7 @@ function list_plugin_updates() {
?>
<tr>
<td class="check-column">
<?php if ( $compatible_php ) : ?>
<input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" />
<label for="<?php echo $checkbox_id; ?>" class="screen-reader-text">
<?php
@ -325,6 +339,7 @@ function list_plugin_updates() {
);
?>
</label>
<?php endif; ?>
</td>
<td class="plugin-title"><p>
<?php echo $icon; ?>

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.2-alpha-44938';
$wp_version = '5.2-alpha-44939';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.