diff --git a/src/wp-admin/includes/class-wp-plugins-list-table.php b/src/wp-admin/includes/class-wp-plugins-list-table.php index fa40ba9a36..f83473af4d 100644 --- a/src/wp-admin/includes/class-wp-plugins-list-table.php +++ b/src/wp-admin/includes/class-wp-plugins-list-table.php @@ -746,9 +746,10 @@ class WP_Plugins_List_Table extends WP_List_Table { } - $class = $is_active ? 'active' : 'inactive'; - $checkbox_id = 'checkbox_' . md5( $plugin_data['Name'] ); - if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ) ) ) { + $compatible_php = ( empty( $plugin_data['requires_php'] ) || version_compare( phpversion(), $plugin_data['requires_php'], '>=' ) ); + $class = $is_active ? 'active' : 'inactive'; + $checkbox_id = 'checkbox_' . md5( $plugin_data['Name'] ); + if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ) ) || ! $compatible_php ) { $checkbox = ''; } else { /* translators: %s: plugin name */ diff --git a/src/wp-admin/includes/plugin-install.php b/src/wp-admin/includes/plugin-install.php index f2607cb9ef..99939b04b9 100644 --- a/src/wp-admin/includes/plugin-install.php +++ b/src/wp-admin/includes/plugin-install.php @@ -769,8 +769,8 @@ function install_plugin_information() { ' ' . __( 'Click here to learn more about updating PHP.' ), esc_url( wp_get_update_php_url() ) ); - echo '

'; - wp_update_php_annotation(); + + wp_update_php_annotation( '

', '' ); } else { echo '

'; } @@ -827,7 +827,14 @@ function install_plugin_information() { break; case 'update_available': if ( $status['url'] ) { - echo '' . __( 'Install Update Now' ) . ''; + if ( $compatible_php ) { + echo '' . __( 'Install Update Now' ) . ''; + } else { + printf( + '', + _x( 'Cannot Update', 'plugin' ) + ); + } } break; case 'newer_installed': diff --git a/src/wp-admin/includes/update.php b/src/wp-admin/includes/update.php index 43db04b523..7dd083bbf1 100644 --- a/src/wp-admin/includes/update.php +++ b/src/wp-admin/includes/update.php @@ -400,7 +400,10 @@ function wp_plugin_update_row( $file, $plugin_data ) { $active_class = is_plugin_active( $file ) ? ' active' : ''; } - echo '

'; + $compatible_php = ( empty( $response->requires_php ) || version_compare( phpversion(), $response->requires_php, '>=' ) ); + $notice_type = $compatible_php ? 'notice-warning' : 'notice-error'; + + echo '

'; if ( ! current_user_can( 'update_plugins' ) ) { /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number */ @@ -413,7 +416,7 @@ function wp_plugin_update_row( $file, $plugin_data ) { /* translators: 1: plugin name, 2: version number */ esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) ), - $response->new_version + esc_attr( $response->new_version ) ); } elseif ( empty( $response->package ) ) { /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number */ @@ -426,27 +429,44 @@ function wp_plugin_update_row( $file, $plugin_data ) { /* translators: 1: plugin name, 2: version number */ esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) ), - $response->new_version + esc_attr( $response->new_version ) ); } else { - /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */ - printf( - __( 'There is a new version of %1$s available. View version %4$s details or update now.' ), - $plugin_name, - esc_url( $details_url ), - sprintf( - 'class="thickbox open-plugin-details-modal" aria-label="%s"', - /* translators: 1: plugin name, 2: version number */ - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) - ), - $response->new_version, - wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ), - sprintf( - 'class="update-link" aria-label="%s"', - /* translators: %s: plugin name */ - esc_attr( sprintf( __( 'Update %s now' ), $plugin_name ) ) - ) - ); + if ( $compatible_php ) { + /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */ + printf( + __( 'There is a new version of %1$s available. View version %4$s details or update now.' ), + $plugin_name, + esc_url( $details_url ), + sprintf( + 'class="thickbox open-plugin-details-modal" aria-label="%s"', + /* translators: 1: plugin name, 2: version number */ + esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) + ), + esc_attr( $response->new_version ), + wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ), + sprintf( + 'class="update-link" aria-label="%s"', + /* translators: %s: plugin name */ + esc_attr( sprintf( __( 'Update %s now' ), $plugin_name ) ) + ) + ); + } else { + /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number 5: Update PHP page URL */ + printf( + __( 'There is a new version of %1$s available, but it doesn’t work with your version of PHP. View version %4$s details or learn more about updating PHP.' ), + $plugin_name, + esc_url( $details_url ), + sprintf( + 'class="thickbox open-plugin-details-modal" aria-label="%s"', + /* translators: 1: plugin name, 2: version number */ + esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) + ), + esc_attr( $response->new_version ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '
', '' ); + } } /**