From a745f035ab737d9ea235b37c3f5f11cbba42176c Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 28 Jul 2020 11:34:04 +0000 Subject: [PATCH] Themes: Display a message on Themes list table if a theme update requires a higher version of PHP or WordPress. This applies to the Themes screen in Multisite network admin. Props afragen, SergeyBiryukov. Fixes #48507. See #48491. Built from https://develop.svn.wordpress.org/trunk@48660 git-svn-id: http://core.svn.wordpress.org/trunk@48422 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../class-wp-ms-themes-list-table.php | 6 +- wp-admin/includes/update.php | 151 +++++++++++++----- wp-includes/version.php | 2 +- 3 files changed, 114 insertions(+), 45 deletions(-) diff --git a/wp-admin/includes/class-wp-ms-themes-list-table.php b/wp-admin/includes/class-wp-ms-themes-list-table.php index 83e75f49c3..f67c7bd693 100644 --- a/wp-admin/includes/class-wp-ms-themes-list-table.php +++ b/wp-admin/includes/class-wp-ms-themes-list-table.php @@ -561,7 +561,11 @@ class WP_MS_Themes_List_Table extends WP_List_Table { ); } - if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && get_option( 'stylesheet' ) !== $stylesheet && get_option( 'template' ) !== $stylesheet ) { + if ( ! $allowed && ! $this->is_site_themes + && current_user_can( 'delete_themes' ) + && get_option( 'stylesheet' ) !== $stylesheet + && get_option( 'template' ) !== $stylesheet + ) { $url = add_query_arg( array( 'action' => 'delete-selected', diff --git a/wp-admin/includes/update.php b/wp-admin/includes/update.php index 8a588921f0..7570905548 100644 --- a/wp-admin/includes/update.php +++ b/wp-admin/includes/update.php @@ -642,6 +642,12 @@ function wp_theme_update_row( $theme_key, $theme ) { $active = $theme->is_allowed( 'network' ) ? ' active' : ''; + $requires_wp = isset( $response['requires'] ) ? $response['requires'] : null; + $requires_php = isset( $response['requires_php'] ) ? $response['requires_php'] : null; + + $compatible_wp = is_wp_version_compatible( $requires_wp ); + $compatible_php = is_php_version_compatible( $compatible_php ); + printf( '' . '' . @@ -652,51 +658,110 @@ function wp_theme_update_row( $theme_key, $theme ) { $wp_list_table->get_column_count() ); - if ( ! current_user_can( 'update_themes' ) ) { - printf( - /* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */ - __( 'There is a new version of %1$s available. View version %4$s details.' ), - $theme['Name'], - esc_url( $details_url ), - sprintf( - 'class="thickbox open-plugin-details-modal" aria-label="%s"', - /* translators: 1: Theme name, 2: Version number. */ - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) - ), - $response['new_version'] - ); - } elseif ( empty( $response['package'] ) ) { - printf( - /* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */ - __( 'There is a new version of %1$s available. View version %4$s details. Automatic update is unavailable for this theme.' ), - $theme['Name'], - esc_url( $details_url ), - sprintf( - 'class="thickbox open-plugin-details-modal" aria-label="%s"', - /* translators: 1: Theme name, 2: Version number. */ - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) - ), - $response['new_version'] - ); + if ( $compatible_wp && $compatible_php ) { + if ( ! current_user_can( 'update_themes' ) ) { + printf( + /* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */ + __( 'There is a new version of %1$s available. View version %4$s details.' ), + $theme['Name'], + esc_url( $details_url ), + sprintf( + 'class="thickbox open-plugin-details-modal" aria-label="%s"', + /* translators: 1: Theme name, 2: Version number. */ + esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) + ), + $response['new_version'] + ); + } elseif ( empty( $response['package'] ) ) { + printf( + /* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */ + __( 'There is a new version of %1$s available. View version %4$s details. Automatic update is unavailable for this theme.' ), + $theme['Name'], + esc_url( $details_url ), + sprintf( + 'class="thickbox open-plugin-details-modal" aria-label="%s"', + /* translators: 1: Theme name, 2: Version number. */ + esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) + ), + $response['new_version'] + ); + } else { + printf( + /* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number, 5: Update URL, 6: Additional link attributes. */ + __( 'There is a new version of %1$s available. View version %4$s details or update now.' ), + $theme['Name'], + esc_url( $details_url ), + sprintf( + 'class="thickbox open-plugin-details-modal" aria-label="%s"', + /* translators: 1: Theme name, 2: Version number. */ + esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) + ), + $response['new_version'], + wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ), + sprintf( + 'class="update-link" aria-label="%s"', + /* translators: %s: Theme name. */ + esc_attr( sprintf( _x( 'Update %s now', 'theme' ), $theme['Name'] ) ) + ) + ); + } } else { - printf( - /* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number, 5: Update URL, 6: Additional link attributes. */ - __( 'There is a new version of %1$s available. View version %4$s details or update now.' ), - $theme['Name'], - esc_url( $details_url ), - sprintf( - 'class="thickbox open-plugin-details-modal" aria-label="%s"', - /* translators: 1: Theme name, 2: Version number. */ - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) - ), - $response['new_version'], - wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ), - sprintf( - 'class="update-link" aria-label="%s"', + if ( ! $compatible_wp && ! $compatible_php ) { + printf( /* translators: %s: Theme name. */ - esc_attr( sprintf( _x( 'Update %s now', 'theme' ), $theme['Name'] ) ) - ) - ); + __( 'There is a new version of %s available, but it doesn’t work with your versions of WordPress and PHP.' ), + $theme['Name'] + ); + if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) { + printf( + /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */ + ' ' . __( 'Please update WordPress, and then learn more about updating PHP.' ), + self_admin_url( 'update-core.php' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } elseif ( current_user_can( 'update_core' ) ) { + printf( + /* translators: %s: URL to WordPress Updates screen. */ + ' ' . __( 'Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } elseif ( current_user_can( 'update_php' ) ) { + printf( + /* translators: %s: URL to Update PHP page. */ + ' ' . __( 'Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } + } elseif ( ! $compatible_wp ) { + printf( + /* translators: %s: Theme name. */ + __( 'There is a new version of %s available, but it doesn’t work with your version of WordPress.' ), + $theme['Name'] + ); + if ( current_user_can( 'update_core' ) ) { + printf( + /* translators: %s: URL to WordPress Updates screen. */ + ' ' . __( 'Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } + } elseif ( ! $compatible_php ) { + printf( + /* translators: %s: Theme name. */ + __( 'There is a new version of %s available, but it doesn’t work with your version of PHP.' ), + $theme['Name'] + ); + if ( current_user_can( 'update_php' ) ) { + printf( + /* translators: %s: URL to Update PHP page. */ + ' ' . __( 'Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } + } } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index a9c8de3a02..de5a20449b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-beta4-48659'; +$wp_version = '5.5-beta4-48660'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.