Make WordPress Core


Ignore:
Timestamp:
07/28/2020 12:08:00 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Themes: Display a message in theme grid and Theme Details modal if a theme update requires a higher version of PHP or WordPress.

This applies to the Themes screen and the Customizer theme browser.

Props afragen, SergeyBiryukov.
See #48491.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/themes.php

    r48640 r48652  
    390390
    391391        <?php if ( $theme['hasUpdate'] ) : ?>
    392                 <div class="update-message notice inline notice-warning notice-alt">
    393                 <?php if ( $theme['hasPackage'] ) : ?>
    394                         <p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p>
     392                <?php if ( $theme['updateResponse']['compatibleWP'] && $theme['updateResponse']['compatiblePHP'] ) : ?>
     393                        <div class="update-message notice inline notice-warning notice-alt"><p>
     394                                <?php if ( $theme['hasPackage'] ) : ?>
     395                                        <?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?>
     396                                <?php else : ?>
     397                                        <?php _e( 'New version available.' ); ?>
     398                                <?php endif; ?>
     399                        </p></div>
    395400                <?php else : ?>
    396                         <p><?php _e( 'New version available.' ); ?></p>
     401                        <div class="notice inline notice-error notice-alt"><p>
     402                                <?php
     403                                if ( $theme['updateResponse']['compatibleWP'] && $theme['updateResponse']['compatiblePHP'] ) {
     404                                        _e( 'There is a new version available, but it doesn&#8217;t work with your versions of WordPress and PHP.' );
     405                                        if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
     406                                                printf(
     407                                                        /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
     408                                                        ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
     409                                                        self_admin_url( 'update-core.php' ),
     410                                                        esc_url( wp_get_update_php_url() )
     411                                                );
     412                                                wp_update_php_annotation( '</p><p><em>', '</em>' );
     413                                        } elseif ( current_user_can( 'update_core' ) ) {
     414                                                printf(
     415                                                        /* translators: %s: URL to WordPress Updates screen. */
     416                                                        ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     417                                                        self_admin_url( 'update-core.php' )
     418                                                );
     419                                        } elseif ( current_user_can( 'update_php' ) ) {
     420                                                printf(
     421                                                        /* translators: %s: URL to Update PHP page. */
     422                                                        ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
     423                                                        esc_url( wp_get_update_php_url() )
     424                                                );
     425                                                wp_update_php_annotation( '</p><p><em>', '</em>' );
     426                                        }
     427                                } elseif ( ! $theme['updateResponse']['compatibleWP'] ) {
     428                                        _e( 'There is a new version available, but it doesn&#8217;t work with your version of WordPress.' );
     429                                        if ( current_user_can( 'update_core' ) ) {
     430                                                printf(
     431                                                        /* translators: %s: URL to WordPress Updates screen. */
     432                                                        ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     433                                                        self_admin_url( 'update-core.php' )
     434                                                );
     435                                        }
     436                                } elseif ( ! $theme['updateResponse']['compatiblePHP'] ) {
     437                                        _e( 'There is a new version available, but it doesn&#8217;t work with your version of PHP.' );
     438                                        if ( current_user_can( 'update_php' ) ) {
     439                                                printf(
     440                                                        /* translators: %s: URL to Update PHP page. */
     441                                                        ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
     442                                                        esc_url( wp_get_update_php_url() )
     443                                                );
     444                                                wp_update_php_annotation( '</p><p><em>', '</em>' );
     445                                        }
     446                                }
     447                                ?>
     448                        </p></div>
    397449                <?php endif; ?>
    398                 </div>
    399450        <?php endif; ?>
    400451
     
    660711
    661712        <# if ( data.hasUpdate ) { #>
    662                 <# if ( data.hasPackage ) { #>
    663                         <div class="update-message notice inline notice-warning notice-alt"><p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p></div>
     713                <# if ( data.updateResponse.compatibleWP && data.updateResponse.compatiblePHP ) { #>
     714                        <div class="update-message notice inline notice-warning notice-alt"><p>
     715                                <# if ( data.hasPackage ) { #>
     716                                        <?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?>
     717                                <# } else { #>
     718                                        <?php _e( 'New version available.' ); ?>
     719                                <# } #>
     720                        </p></div>
    664721                <# } else { #>
    665                         <div class="update-message notice inline notice-warning notice-alt"><p><?php _e( 'New version available.' ); ?></p></div>
     722                        <div class="notice inline notice-error notice-alt"><p>
     723                                <# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #>
     724                                        <?php
     725                                        _e( 'There is a new version available, but it doesn&#8217;t work with your versions of WordPress and PHP.' );
     726                                        if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
     727                                                printf(
     728                                                        /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
     729                                                        ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
     730                                                        self_admin_url( 'update-core.php' ),
     731                                                        esc_url( wp_get_update_php_url() )
     732                                                );
     733                                                wp_update_php_annotation( '</p><p><em>', '</em>' );
     734                                        } elseif ( current_user_can( 'update_core' ) ) {
     735                                                printf(
     736                                                        /* translators: %s: URL to WordPress Updates screen. */
     737                                                        ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     738                                                        self_admin_url( 'update-core.php' )
     739                                                );
     740                                        } elseif ( current_user_can( 'update_php' ) ) {
     741                                                printf(
     742                                                        /* translators: %s: URL to Update PHP page. */
     743                                                        ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
     744                                                        esc_url( wp_get_update_php_url() )
     745                                                );
     746                                                wp_update_php_annotation( '</p><p><em>', '</em>' );
     747                                        }
     748                                        ?>
     749                                <# } else if ( ! data.updateResponse.compatibleWP ) { #>
     750                                        <?php
     751                                        _e( 'There is a new version available, but it doesn&#8217;t work with your version of WordPress.' );
     752                                        if ( current_user_can( 'update_core' ) ) {
     753                                                printf(
     754                                                        /* translators: %s: URL to WordPress Updates screen. */
     755                                                        ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     756                                                        self_admin_url( 'update-core.php' )
     757                                                );
     758                                        }
     759                                        ?>
     760                                <# } else if ( ! data.updateResponse.compatiblePHP ) { #>
     761                                        <?php
     762                                        _e( 'There is a new version available, but it doesn&#8217;t work with your version of PHP.' );
     763                                        if ( current_user_can( 'update_php' ) ) {
     764                                                printf(
     765                                                        /* translators: %s: URL to Update PHP page. */
     766                                                        ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
     767                                                        esc_url( wp_get_update_php_url() )
     768                                                );
     769                                                wp_update_php_annotation( '</p><p><em>', '</em>' );
     770                                        }
     771                                        ?>
     772                                <# } #>
     773                        </p></div>
    666774                <# } #>
    667775        <# } #>
     
    854962                                <# } #>
    855963
     964                                <# if ( data.hasUpdate ) { #>
     965                                        <# if ( data.updateResponse.compatibleWP && data.updateResponse.compatiblePHP ) { #>
     966                                                <div class="notice notice-warning notice-alt notice-large">
     967                                                        <h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3>
     968                                                        {{{ data.update }}}
     969                                                </div>
     970                                        <# } else { #>
     971                                                <div class="notice notice-error notice-alt notice-large">
     972                                                        <h3 class="notice-title"><?php _e( 'Update Incompatible' ); ?></h3>
     973                                                        <p>
     974                                                                <# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #>
     975                                                                        <?php
     976                                                                        _e( 'There is a new version available, but it doesn&#8217;t work with your versions of WordPress and PHP.' );
     977                                                                        if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
     978                                                                                printf(
     979                                                                                        /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
     980                                                                                        ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
     981                                                                                        self_admin_url( 'update-core.php' ),
     982                                                                                        esc_url( wp_get_update_php_url() )
     983                                                                                );
     984                                                                                wp_update_php_annotation( '</p><p><em>', '</em>' );
     985                                                                        } elseif ( current_user_can( 'update_core' ) ) {
     986                                                                                printf(
     987                                                                                        /* translators: %s: URL to WordPress Updates screen. */
     988                                                                                        ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     989                                                                                        self_admin_url( 'update-core.php' )
     990                                                                                );
     991                                                                        } elseif ( current_user_can( 'update_php' ) ) {
     992                                                                                printf(
     993                                                                                        /* translators: %s: URL to Update PHP page. */
     994                                                                                        ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
     995                                                                                        esc_url( wp_get_update_php_url() )
     996                                                                                );
     997                                                                                wp_update_php_annotation( '</p><p><em>', '</em>' );
     998                                                                        }
     999                                                                        ?>
     1000                                                                <# } else if ( ! data.updateResponse.compatibleWP ) { #>
     1001                                                                        <?php
     1002                                                                        _e( 'There is a new version available, but it doesn&#8217;t work with your version of WordPress.' );
     1003                                                                        if ( current_user_can( 'update_core' ) ) {
     1004                                                                                printf(
     1005                                                                                        /* translators: %s: URL to WordPress Updates screen. */
     1006                                                                                        ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     1007                                                                                        self_admin_url( 'update-core.php' )
     1008                                                                                );
     1009                                                                        }
     1010                                                                        ?>
     1011                                                                <# } else if ( ! data.updateResponse.compatiblePHP ) { #>
     1012                                                                        <?php
     1013                                                                        _e( 'There is a new version available, but it doesn&#8217;t work with your version of PHP.' );
     1014                                                                        if ( current_user_can( 'update_php' ) ) {
     1015                                                                                printf(
     1016                                                                                        /* translators: %s: URL to Update PHP page. */
     1017                                                                                        ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
     1018                                                                                        esc_url( wp_get_update_php_url() )
     1019                                                                                );
     1020                                                                                wp_update_php_annotation( '</p><p><em>', '</em>' );
     1021                                                                        }
     1022                                                                        ?>
     1023                                                                <# } #>
     1024                                                        </p>
     1025                                                </div>
     1026                                        <# } #>
     1027                                <# } #>
     1028
    8561029                                <# if ( data.actions.autoupdate ) { #>
    8571030                                        <?php echo wp_theme_auto_update_setting_template(); ?>
    858                                 <# } #>
    859 
    860                                 <# if ( data.hasUpdate ) { #>
    861                                 <div class="notice notice-warning notice-alt notice-large">
    862                                         <h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3>
    863                                         {{{ data.update }}}
    864                                 </div>
    8651031                                <# } #>
    8661032
Note: See TracChangeset for help on using the changeset viewer.