Make WordPress Core

Changeset 48654


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

Themes: Display a message in theme updates list if an update requires a higher version of PHP or WordPress.

This applies to the WordPress Updates screen.

Props afragen, SergeyBiryukov.
Fixes #48491.

File:
1 edited

Legend:

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

    r48589 r48654  
    410410        <tr>
    411411                <td class="check-column">
    412                 <?php if ( $compatible_php ) : ?>
    413                         <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" />
    414                         <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text">
    415                                 <?php
    416                                 /* translators: %s: Plugin name. */
    417                                 printf( __( 'Select %s' ), $plugin_data->Name );
    418                                 ?>
    419                         </label>
    420                 <?php endif; ?>
     412                        <?php if ( $compatible_php ) : ?>
     413                                <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" />
     414                                <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text">
     415                                        <?php
     416                                        /* translators: %s: Plugin name. */
     417                                        printf( __( 'Select %s' ), $plugin_data->Name );
     418                                        ?>
     419                                </label>
     420                        <?php endif; ?>
    421421                </td>
    422422                <td class="plugin-title"><p>
     
    430430                                $plugin_data->update->new_version
    431431                        );
     432
    432433                        echo ' ' . $details . $compat . $upgrade_notice;
     434
    433435                        if ( in_array( $plugin_file, $auto_updates, true ) ) {
    434436                                echo $auto_update_notice;
     
    437439                </p></td>
    438440        </tr>
    439                 <?php
     441                        <?php
    440442        }
    441443        ?>
     
    500502
    501503        foreach ( $themes as $stylesheet => $theme ) {
     504                $requires_wp  = isset( $theme->update['requires'] ) ? $theme->update['requires'] : null;
     505                $requires_php = isset( $theme->update['requires_php'] ) ? $theme->update['requires_php'] : null;
     506
     507                $compatible_wp  = is_wp_version_compatible( $requires_wp );
     508                $compatible_php = is_php_version_compatible( $requires_php );
     509
     510                $compat = '';
     511
     512                if ( ! $compatible_wp && ! $compatible_php ) {
     513                        $compat .= '<br>' . __( 'This update doesn&#8217;t work with your versions of WordPress and PHP.' ) . '&nbsp;';
     514                        if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
     515                                $compat .= sprintf(
     516                                        /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
     517                                        __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
     518                                        self_admin_url( 'update-core.php' ),
     519                                        esc_url( wp_get_update_php_url() )
     520                                );
     521
     522                                $annotation = wp_get_update_php_annotation();
     523
     524                                if ( $annotation ) {
     525                                        $compat .= '</p><p><em>' . $annotation . '</em>';
     526                                }
     527                        } elseif ( current_user_can( 'update_core' ) ) {
     528                                $compat .= sprintf(
     529                                        /* translators: %s: URL to WordPress Updates screen. */
     530                                        __( '<a href="%s">Please update WordPress</a>.' ),
     531                                        self_admin_url( 'update-core.php' )
     532                                );
     533                        } elseif ( current_user_can( 'update_php' ) ) {
     534                                $compat .= sprintf(
     535                                        /* translators: %s: URL to Update PHP page. */
     536                                        __( '<a href="%s">Learn more about updating PHP</a>.' ),
     537                                        esc_url( wp_get_update_php_url() )
     538                                );
     539
     540                                $annotation = wp_get_update_php_annotation();
     541
     542                                if ( $annotation ) {
     543                                        $compat .= '</p><p><em>' . $annotation . '</em>';
     544                                }
     545                        }
     546                } elseif ( ! $compatible_wp ) {
     547                        $compat .= '<br>' . __( 'This update doesn&#8217;t work with your version of WordPress.' ) . '&nbsp;';
     548                        if ( current_user_can( 'update_core' ) ) {
     549                                $compat .= sprintf(
     550                                        /* translators: %s: URL to WordPress Updates screen. */
     551                                        __( '<a href="%s">Please update WordPress</a>.' ),
     552                                        self_admin_url( 'update-core.php' )
     553                                );
     554                        }
     555                } elseif ( ! $compatible_php ) {
     556                        $compat .= '<br>' . __( 'This update doesn&#8217;t work with your version of PHP.' ) . '&nbsp;';
     557                        if ( current_user_can( 'update_php' ) ) {
     558                                $compat .= sprintf(
     559                                        /* translators: %s: URL to Update PHP page. */
     560                                        __( '<a href="%s">Learn more about updating PHP</a>.' ),
     561                                        esc_url( wp_get_update_php_url() )
     562                                );
     563
     564                                $annotation = wp_get_update_php_annotation();
     565
     566                                if ( $annotation ) {
     567                                        $compat .= '</p><p><em>' . $annotation . '</em>';
     568                                }
     569                        }
     570                }
     571
    502572                $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
    503 
    504573                ?>
    505574        <tr>
    506575                <td class="check-column">
    507                         <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" />
    508                         <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text">
    509                                 <?php
    510                                 /* translators: %s: Theme name. */
    511                                 printf( __( 'Select %s' ), $theme->display( 'Name' ) );
    512                                 ?>
    513                         </label>
     576                        <?php if ( $compatible_wp && $compatible_php ) : ?>
     577                                <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" />
     578                                <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text">
     579                                        <?php
     580                                        /* translators: %s: Theme name. */
     581                                        printf( __( 'Select %s' ), $theme->display( 'Name' ) );
     582                                        ?>
     583                                </label>
     584                        <?php endif; ?>
    514585                </td>
    515586                <td class="plugin-title"><p>
     
    523594                                $theme->update['new_version']
    524595                        );
     596
     597                        echo ' ' . $compat;
     598
    525599                        if ( in_array( $stylesheet, $auto_updates, true ) ) {
    526600                                echo $auto_update_notice;
Note: See TracChangeset for help on using the changeset viewer.