Make WordPress Core


Ignore:
Timestamp:
07/28/2020 12:08:00 AM (5 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-includes/customize/class-wp-customize-theme-control.php

    r48638 r48652  
    9191
    9292            <# if ( 'installed' === data.theme.type && data.theme.hasUpdate ) { #>
    93                 <div class="update-message notice inline notice-warning notice-alt" data-slug="{{ data.theme.id }}">
    94                     <p>
    95                         <?php
    96                         if ( is_multisite() ) {
    97                             _e( 'New version available.' );
    98                         } else {
    99                             printf(
    100                                 /* translators: %s: "Update now" button. */
    101                                 __( 'New version available. %s' ),
    102                                 '<button class="button-link update-theme" type="button">' . __( 'Update now' ) . '</button>'
    103                             );
    104                         }
    105                         ?>
    106                     </p>
    107                 </div>
     93                <# if ( data.theme.updateResponse.compatibleWP && data.theme.updateResponse.compatiblePHP ) { #>
     94                    <div class="update-message notice inline notice-warning notice-alt" data-slug="{{ data.theme.id }}">
     95                        <p>
     96                            <?php
     97                            if ( is_multisite() ) {
     98                                _e( 'New version available.' );
     99                            } else {
     100                                printf(
     101                                    /* translators: %s: "Update now" button. */
     102                                    __( 'New version available. %s' ),
     103                                    '<button class="button-link update-theme" type="button">' . __( 'Update now' ) . '</button>'
     104                                );
     105                            }
     106                            ?>
     107                        </p>
     108                    </div>
     109                <# } else { #>
     110                    <div class="update-message notice inline notice-warning notice-alt" data-slug="{{ data.theme.id }}">
     111                        <p>
     112                            <# if ( ! data.theme.updateResponse.compatibleWP && ! data.theme.updateResponse.compatiblePHP ) { #>
     113                                <?php
     114                                _e( 'There is a new version available, but it doesn&#8217;t work with your versions of WordPress and PHP.' );
     115                                if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
     116                                    printf(
     117                                        /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
     118                                        ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
     119                                        self_admin_url( 'update-core.php' ),
     120                                        esc_url( wp_get_update_php_url() )
     121                                    );
     122                                    wp_update_php_annotation( '</p><p><em>', '</em>' );
     123                                } elseif ( current_user_can( 'update_core' ) ) {
     124                                    printf(
     125                                        /* translators: %s: URL to WordPress Updates screen. */
     126                                        ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     127                                        self_admin_url( 'update-core.php' )
     128                                    );
     129                                } elseif ( current_user_can( 'update_php' ) ) {
     130                                    printf(
     131                                        /* translators: %s: URL to Update PHP page. */
     132                                        ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
     133                                        esc_url( wp_get_update_php_url() )
     134                                    );
     135                                    wp_update_php_annotation( '</p><p><em>', '</em>' );
     136                                }
     137                                ?>
     138                            <# } else if ( ! data.theme.updateResponse.compatibleWP ) { #>
     139                                <?php
     140                                _e( 'There is a new version available, but it doesn&#8217;t work with your version of WordPress.' );
     141                                if ( current_user_can( 'update_core' ) ) {
     142                                    printf(
     143                                        /* translators: %s: URL to WordPress Updates screen. */
     144                                        ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     145                                        self_admin_url( 'update-core.php' )
     146                                    );
     147                                }
     148                                ?>
     149                            <# } else if ( ! data.theme.updateResponse.compatiblePHP ) { #>
     150                                <?php
     151                                _e( 'There is a new version available, but it doesn&#8217;t work with your version of PHP.' );
     152                                if ( current_user_can( 'update_php' ) ) {
     153                                    printf(
     154                                        /* translators: %s: URL to Update PHP page. */
     155                                        ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
     156                                        esc_url( wp_get_update_php_url() )
     157                                    );
     158                                    wp_update_php_annotation( '</p><p><em>', '</em>' );
     159                                }
     160                                ?>
     161                            <# } #>
     162                        </p>
     163                    </div>
     164                <# } #>
    108165            <# } #>
    109166
Note: See TracChangeset for help on using the changeset viewer.