diff --git a/src/wp-admin/css/list-tables.css b/src/wp-admin/css/list-tables.css index 8d78983993..893326ba38 100644 --- a/src/wp-admin/css/list-tables.css +++ b/src/wp-admin/css/list-tables.css @@ -1514,6 +1514,10 @@ div.action-links, content: "\f147"; } +.plugin-card .notice { + margin: 20px 20px 0 20px; +} + .plugin-icon { position: absolute; top: 20px; diff --git a/src/wp-admin/includes/class-wp-plugin-install-list-table.php b/src/wp-admin/includes/class-wp-plugin-install-list-table.php index a19729b1d4..3482c3cf7a 100644 --- a/src/wp-admin/includes/class-wp-plugin-install-list-table.php +++ b/src/wp-admin/includes/class-wp-plugin-install-list-table.php @@ -496,6 +496,12 @@ class WP_Plugin_Install_List_Table extends WP_List_Table { $author = ' ' . sprintf( __( 'By %s' ), $author ) . ''; } + $wp_version = get_bloginfo( 'version' ); + + $compatible_php = ( empty( $plugin['requires_php'] ) || version_compare( substr( phpversion(), 0, strlen( $plugin['requires_php'] ) ), $plugin['requires_php'], '>=' ) ); + $tested_wp = ( empty( $plugin['tested'] ) || version_compare( substr( $wp_version, 0, strlen( $plugin['tested'] ) ), $plugin['tested'], '<=' ) ); + $compatible_wp = ( empty( $plugin['requires'] ) || version_compare( substr( $wp_version, 0, strlen( $plugin['requires'] ) ), $plugin['requires'], '>=' ) ); + $action_links = array(); if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) { @@ -504,15 +510,22 @@ class WP_Plugin_Install_List_Table extends WP_List_Table { switch ( $status['status'] ) { case 'install': if ( $status['url'] ) { - $action_links[] = sprintf( - '%s', - esc_attr( $plugin['slug'] ), - esc_url( $status['url'] ), - /* translators: %s: plugin name and version */ - esc_attr( sprintf( __( 'Install %s now' ), $name ) ), - esc_attr( $name ), - __( 'Install Now' ) - ); + if ( $compatible_php && $compatible_wp ) { + $action_links[] = sprintf( + '%s', + esc_attr( $plugin['slug'] ), + esc_url( $status['url'] ), + /* translators: %s: plugin name and version */ + esc_attr( sprintf( __( 'Install %s now' ), $name ) ), + esc_attr( $name ), + __( 'Install Now' ) + ); + } else { + $action_links[] = sprintf( + '', + _x( 'Cannot Install', 'plugin' ) + ); + } } break; @@ -610,6 +623,45 @@ class WP_Plugin_Install_List_Table extends WP_List_Table { $last_updated_timestamp = strtotime( $plugin['last_updated'] ); ?>
'; + if ( ! $compatible_php && ! $compatible_wp ) { + _e( 'This plugin doesn’t work with your versions of WordPress and PHP. ' ); + if ( current_user_can( 'update_core' ) ) { + printf( + /* translators: 1: "Update WordPress" screen URL, 2: "Updating PHP" page URL */ + __( 'Please update WordPress, and then learn more about updating PHP.' ), + self_admin_url( 'update-core.php' ), + esc_url( __( 'https://wordpress.org/support/upgrade-php/' ) ) + ); + } else { + printf( + /* translators: %s: "Updating PHP" page URL */ + __( 'Learn more about updating PHP.' ), + esc_url( __( 'https://wordpress.org/support/upgrade-php/' ) ) + ); + } + } elseif ( ! $compatible_wp ) { + _e( 'This plugin doesn’t work with your version of WordPress. ' ); + if ( current_user_can( 'update_core' ) ) { + printf( + /* translators: %s: "Update WordPress" screen URL */ + __( 'Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } + } elseif ( ! $compatible_php ) { + _e( 'This plugin doesn’t work with your version of PHP. ' ); + printf( + /* translators: %s: "Updating PHP" page URL */ + __( 'Learn more about updating PHP.' ), + esc_url( __( 'https://wordpress.org/support/upgrade-php/' ) ) + ); + } + echo '
' . __( 'Warning: This plugin has not been tested with your current version of WordPress.' ) . '
' . __( 'Warning: This plugin has not been marked as compatible with your version of WordPress.' ) . '
'; + printf( + /* translators: "Updating PHP" page URL */ + __( 'Error: This plugin requires a newer version of PHP, so unfortunately you cannot install it. Click here to learn more about updating PHP.' ), + esc_url( __( 'https://wordpress.org/support/upgrade-php/' ) ) + ); + echo '
'; + _e( 'Warning: This plugin has not been tested with your current version of WordPress.' ); + echo '
'; + _e( 'Error: This plugin requires a newer version of WordPress.' ); + if ( current_user_can( 'update_core' ) ) { + printf( + /* translators: %s: "Update WordPress" screen URL */ + ' ' . __( 'Click here to update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } + echo '