Make WordPress Core

Changeset 48638


Ignore:
Timestamp:
07/27/2020 03:02:19 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Themes: Display a message in theme grid if a theme requires a higher version of PHP or WordPress.

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

Props afragen, desrosj, SergeyBiryukov.
See #48491.

Location:
trunk/src
Files:
3 edited

Legend:

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

    r48637 r48638  
    272272        <div class="theme-screenshot blank"></div>
    273273    <# } #>
     274
     275    <# if ( data.installed ) { #>
     276        <div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>
     277    <# } #>
     278
     279    <# if ( ! data.compatible_wp || ! data.compatible_php ) { #>
     280        <div class="notice notice-error notice-alt"><p>
     281            <# if ( ! data.compatible_wp && ! data.compatible_php ) { #>
     282                <?php
     283                _e( 'This theme doesn&#8217;t work with your versions of WordPress and PHP.' );
     284                if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
     285                    printf(
     286                        /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
     287                        ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
     288                        self_admin_url( 'update-core.php' ),
     289                        esc_url( wp_get_update_php_url() )
     290                    );
     291                    wp_update_php_annotation( '</p><p><em>', '</em>' );
     292                } elseif ( current_user_can( 'update_core' ) ) {
     293                    printf(
     294                        /* translators: %s: URL to WordPress Updates screen. */
     295                        ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     296                        self_admin_url( 'update-core.php' )
     297                    );
     298                } elseif ( current_user_can( 'update_php' ) ) {
     299                    printf(
     300                        /* translators: %s: URL to Update PHP page. */
     301                        ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
     302                        esc_url( wp_get_update_php_url() )
     303                    );
     304                    wp_update_php_annotation( '</p><p><em>', '</em>' );
     305                }
     306                ?>
     307            <# } else if ( ! data.compatible_wp ) { #>
     308                <?php
     309                _e( 'This theme doesn&#8217;t work with your version of WordPress.' );
     310                if ( current_user_can( 'update_core' ) ) {
     311                    printf(
     312                        /* translators: %s: URL to WordPress Updates screen. */
     313                        ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     314                        self_admin_url( 'update-core.php' )
     315                    );
     316                }
     317                ?>
     318            <# } else if ( ! data.compatible_php ) { #>
     319                <?php
     320                _e( 'This theme doesn&#8217;t work with your version of PHP.' );
     321                if ( current_user_can( 'update_php' ) ) {
     322                    printf(
     323                        /* translators: %s: URL to Update PHP page. */
     324                        ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
     325                        esc_url( wp_get_update_php_url() )
     326                    );
     327                    wp_update_php_annotation( '</p><p><em>', '</em>' );
     328                }
     329                ?>
     330            <# } #>
     331        </p></div>
     332    <# } #>
     333
    274334    <span class="more-details"><?php _ex( 'Details &amp; Preview', 'theme' ); ?></span>
    275335    <div class="theme-author">
     
    339399        </div>
    340400    </div>
    341 
    342     <# if ( data.installed ) { #>
    343         <div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>
    344     <# } #>
    345401</script>
    346402
  • trunk/src/wp-admin/themes.php

    r48636 r48638  
    614614            <div class="update-message notice inline notice-warning notice-alt"><p><?php _e( 'New version available.' ); ?></p></div>
    615615        <# } #>
     616    <# } #>
     617
     618    <# if ( ! data.compatibleWP || ! data.compatiblePHP ) { #>
     619        <div class="notice notice-error notice-alt"><p>
     620            <# if ( ! data.compatibleWP && ! data.compatiblePHP ) { #>
     621                <?php
     622                _e( 'This theme doesn&#8217;t work with your versions of WordPress and PHP.' );
     623                if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
     624                    printf(
     625                        /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
     626                        ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
     627                        self_admin_url( 'update-core.php' ),
     628                        esc_url( wp_get_update_php_url() )
     629                    );
     630                    wp_update_php_annotation( '</p><p><em>', '</em>' );
     631                } elseif ( current_user_can( 'update_core' ) ) {
     632                    printf(
     633                        /* translators: %s: URL to WordPress Updates screen. */
     634                        ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     635                        self_admin_url( 'update-core.php' )
     636                    );
     637                } elseif ( current_user_can( 'update_php' ) ) {
     638                    printf(
     639                        /* translators: %s: URL to Update PHP page. */
     640                        ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
     641                        esc_url( wp_get_update_php_url() )
     642                    );
     643                    wp_update_php_annotation( '</p><p><em>', '</em>' );
     644                }
     645                ?>
     646            <# } else if ( ! data.compatibleWP ) { #>
     647                <?php
     648                _e( 'This theme doesn&#8217;t work with your version of WordPress.' );
     649                if ( current_user_can( 'update_core' ) ) {
     650                    printf(
     651                        /* translators: %s: URL to WordPress Updates screen. */
     652                        ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
     653                        self_admin_url( 'update-core.php' )
     654                    );
     655                }
     656                ?>
     657            <# } else if ( ! data.compatiblePHP ) { #>
     658                <?php
     659                _e( 'This theme doesn&#8217;t work with your version of PHP.' );
     660                if ( current_user_can( 'update_php' ) ) {
     661                    printf(
     662                        /* translators: %s: URL to Update PHP page. */
     663                        ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
     664                        esc_url( wp_get_update_php_url() )
     665                    );
     666                    wp_update_php_annotation( '</p><p><em>', '</em>' );
     667                }
     668                ?>
     669            <# } #>
     670        </p></div>
    616671    <# } #>
    617672
  • trunk/src/wp-includes/customize/class-wp-customize-theme-control.php

    r47819 r48638  
    106106                    </p>
    107107                </div>
     108            <# } #>
     109
     110            <# if ( ! data.theme.compatibleWP || ! data.theme.compatiblePHP ) { #>
     111                <div class="notice notice-error notice-alt"><p>
     112                    <# if ( ! data.theme.compatibleWP && ! data.theme.compatiblePHP ) { #>
     113                        <?php
     114                        _e( 'This theme 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.compatibleWP ) { #>
     139                        <?php
     140                        _e( 'This theme 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.compatiblePHP ) { #>
     150                        <?php
     151                        _e( 'This theme 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></div>
    108163            <# } #>
    109164
Note: See TracChangeset for help on using the changeset viewer.