Make WordPress Core

Changeset 48660


Ignore:
Timestamp:
07/28/2020 11:32:53 AM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src/wp-admin/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-ms-themes-list-table.php

    r48418 r48660  
    562562        }
    563563
    564         if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && get_option( 'stylesheet' ) !== $stylesheet && get_option( 'template' ) !== $stylesheet ) {
     564        if ( ! $allowed && ! $this->is_site_themes
     565            && current_user_can( 'delete_themes' )
     566            && get_option( 'stylesheet' ) !== $stylesheet
     567            && get_option( 'template' ) !== $stylesheet
     568        ) {
    565569            $url = add_query_arg(
    566570                array(
  • trunk/src/wp-admin/includes/update.php

    r48520 r48660  
    643643    $active = $theme->is_allowed( 'network' ) ? ' active' : '';
    644644
     645    $requires_wp  = isset( $response['requires'] ) ? $response['requires'] : null;
     646    $requires_php = isset( $response['requires_php'] ) ? $response['requires_php'] : null;
     647
     648    $compatible_wp  = is_wp_version_compatible( $requires_wp );
     649    $compatible_php = is_php_version_compatible( $compatible_php );
     650
    645651    printf(
    646652        '<tr class="plugin-update-tr%s" id="%s" data-slug="%s">' .
     
    653659    );
    654660
    655     if ( ! current_user_can( 'update_themes' ) ) {
    656         printf(
    657             /* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */
    658             __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ),
    659             $theme['Name'],
    660             esc_url( $details_url ),
    661             sprintf(
    662                 'class="thickbox open-plugin-details-modal" aria-label="%s"',
    663                 /* translators: 1: Theme name, 2: Version number. */
    664                 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
    665             ),
    666             $response['new_version']
    667         );
    668     } elseif ( empty( $response['package'] ) ) {
    669         printf(
    670             /* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */
    671             __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ),
    672             $theme['Name'],
    673             esc_url( $details_url ),
    674             sprintf(
    675                 'class="thickbox open-plugin-details-modal" aria-label="%s"',
    676                 /* translators: 1: Theme name, 2: Version number. */
    677                 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
    678             ),
    679             $response['new_version']
    680         );
     661    if ( $compatible_wp && $compatible_php ) {
     662        if ( ! current_user_can( 'update_themes' ) ) {
     663            printf(
     664                /* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */
     665                __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ),
     666                $theme['Name'],
     667                esc_url( $details_url ),
     668                sprintf(
     669                    'class="thickbox open-plugin-details-modal" aria-label="%s"',
     670                    /* translators: 1: Theme name, 2: Version number. */
     671                    esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
     672                ),
     673                $response['new_version']
     674            );
     675        } elseif ( empty( $response['package'] ) ) {
     676            printf(
     677                /* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number. */
     678                __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ),
     679                $theme['Name'],
     680                esc_url( $details_url ),
     681                sprintf(
     682                    'class="thickbox open-plugin-details-modal" aria-label="%s"',
     683                    /* translators: 1: Theme name, 2: Version number. */
     684                    esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
     685                ),
     686                $response['new_version']
     687            );
     688        } else {
     689            printf(
     690                /* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number, 5: Update URL, 6: Additional link attributes. */
     691                __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ),
     692                $theme['Name'],
     693                esc_url( $details_url ),
     694                sprintf(
     695                    'class="thickbox open-plugin-details-modal" aria-label="%s"',
     696                    /* translators: 1: Theme name, 2: Version number. */
     697                    esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
     698                ),
     699                $response['new_version'],
     700                wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ),
     701                sprintf(
     702                    'class="update-link" aria-label="%s"',
     703                    /* translators: %s: Theme name. */
     704                    esc_attr( sprintf( _x( 'Update %s now', 'theme' ), $theme['Name'] ) )
     705                )
     706            );
     707        }
    681708    } else {
    682         printf(
    683             /* translators: 1: Theme name, 2: Details URL, 3: Additional link attributes, 4: Version number, 5: Update URL, 6: Additional link attributes. */
    684             __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ),
    685             $theme['Name'],
    686             esc_url( $details_url ),
    687             sprintf(
    688                 'class="thickbox open-plugin-details-modal" aria-label="%s"',
    689                 /* translators: 1: Theme name, 2: Version number. */
    690                 esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) )
    691             ),
    692             $response['new_version'],
    693             wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ),
    694             sprintf(
    695                 'class="update-link" aria-label="%s"',
     709        if ( ! $compatible_wp && ! $compatible_php ) {
     710            printf(
    696711                /* translators: %s: Theme name. */
    697                 esc_attr( sprintf( _x( 'Update %s now', 'theme' ), $theme['Name'] ) )
    698             )
    699         );
     712                __( 'There is a new version of %s available, but it doesn&#8217;t work with your versions of WordPress and PHP.' ),
     713                $theme['Name']
     714            );
     715            if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
     716                printf(
     717                    /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
     718                    ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
     719                    self_admin_url( 'update-core.php' ),
     720                    esc_url( wp_get_update_php_url() )
     721                );
     722                wp_update_php_annotation( '</p><p><em>', '</em>' );
     723            } elseif ( current_user_can( 'update_core' ) ) {
     724                printf(
     725                    /* translators: %s: URL to WordPress Updates screen. */
     726                    ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     727                    self_admin_url( 'update-core.php' )
     728                );
     729            } elseif ( current_user_can( 'update_php' ) ) {
     730                printf(
     731                    /* translators: %s: URL to Update PHP page. */
     732                    ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
     733                    esc_url( wp_get_update_php_url() )
     734                );
     735                wp_update_php_annotation( '</p><p><em>', '</em>' );
     736            }
     737        } elseif ( ! $compatible_wp ) {
     738            printf(
     739                /* translators: %s: Theme name. */
     740                __( 'There is a new version of %s available, but it doesn&#8217;t work with your version of WordPress.' ),
     741                $theme['Name']
     742            );
     743            if ( current_user_can( 'update_core' ) ) {
     744                printf(
     745                    /* translators: %s: URL to WordPress Updates screen. */
     746                    ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     747                    self_admin_url( 'update-core.php' )
     748                );
     749            }
     750        } elseif ( ! $compatible_php ) {
     751            printf(
     752                /* translators: %s: Theme name. */
     753                __( 'There is a new version of %s available, but it doesn&#8217;t work with your version of PHP.' ),
     754                $theme['Name']
     755            );
     756            if ( current_user_can( 'update_php' ) ) {
     757                printf(
     758                    /* translators: %s: URL to Update PHP page. */
     759                    ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
     760                    esc_url( wp_get_update_php_url() )
     761                );
     762                wp_update_php_annotation( '</p><p><em>', '</em>' );
     763            }
     764        }
    700765    }
    701766
Note: See TracChangeset for help on using the changeset viewer.