Make WordPress Core

Ticket #48491: 48491.4.diff

File 48491.4.diff, 10.8 KB (added by jorbin, 4 years ago)
  • src/wp-admin/includes/theme.php

     
    654654                }
    655655
    656656                $prepared_themes[ $slug ] = array(
    657                         'id'           => $slug,
    658                         'name'         => $theme->display( 'Name' ),
    659                         'screenshot'   => array( $theme->get_screenshot() ), // @todo Multiple screenshots.
    660                         'description'  => $theme->display( 'Description' ),
    661                         'author'       => $theme->display( 'Author', false, true ),
    662                         'authorAndUri' => $theme->display( 'Author' ),
    663                         'version'      => $theme->display( 'Version' ),
    664                         'tags'         => $theme->display( 'Tags' ),
    665                         'parent'       => $parent,
    666                         'active'       => $slug === $current_theme,
    667                         'hasUpdate'    => isset( $updates[ $slug ] ),
    668                         'hasPackage'   => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ]['package'] ),
    669                         'update'       => get_theme_update_available( $theme ),
    670                         'actions'      => array(
     657                        'id'             => $slug,
     658                        'name'           => $theme->display( 'Name' ),
     659                        'screenshot'     => array( $theme->get_screenshot() ), // @todo Multiple screenshots.
     660                        'description'    => $theme->display( 'Description' ),
     661                        'author'         => $theme->display( 'Author', false, true ),
     662                        'authorAndUri'   => $theme->display( 'Author' ),
     663                        'version'        => $theme->display( 'Version' ),
     664                        'tags'           => $theme->display( 'Tags' ),
     665                        'requires'       => $theme->display( 'Requires' ),
     666                        'requires_php'   => $theme->display( 'RequiresPHP' ),
     667                        'wp_compatible'  => is_wp_version_compatible( $theme->display( 'Requires' ) ),
     668                        'php_compatible' => is_php_version_compatible( $theme->display( 'RequiresPHP' ) ),
     669                        'parent'         => $parent,
     670                        'active'         => $slug === $current_theme,
     671                        'hasUpdate'      => isset( $updates[ $slug ] ),
     672                        'hasPackage'     => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ]['package'] ),
     673                        'update'         => get_theme_update_available( $theme ),
     674                        'actions'        => array(
    671675                                'activate'  => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,
    672676                                'customize' => $customize_action,
    673677                                'delete'    => current_user_can( 'delete_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null,
  • src/wp-admin/themes.php

     
    323323
    324324        <?php if ( $theme['hasUpdate'] ) : ?>
    325325                <div class="update-message notice inline notice-warning notice-alt">
    326                 <?php if ( $theme['hasPackage'] ) : ?>
    327                         <p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p>
     326                <?php if ( $theme['wp_compatible'] && $theme['php_compatible'] ): ?>
     327                        <?php if ( $theme['hasPackage'] ) : ?>
     328                                <p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p>
     329                        <?php else : ?>
     330                                <p><?php _e( 'New version available.' ); ?></p>
     331                        <?php endif; ?>
    328332                <?php else : ?>
    329                         <p><?php _e( 'New version available.' ); ?></p>
     333                        <p><?php _e( 'Version update incompatible.' ); ?></p>
    330334                <?php endif; ?>
    331335                </div>
    332336        <?php endif; ?>
     
    358362                        /* translators: %s: Theme name. */
    359363                        $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
    360364                        ?>
    361                         <a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
    362                         <?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
    363                                 <a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
    364                         <?php } ?>
     365                        <?php if ( $theme['wp_compatible'] && $theme['php_compatible'] ): ?>
     366                                <a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
     367                                <?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
     368                                        <a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
     369                                <?php } ?>
     370                        <?php else : ?>
     371                                <a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
     372                                <a class="button button-primary load-customize hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
     373                        <?php endif; ?>
    365374                <?php } ?>
    366375
    367376                </div>
     
    488497        <# } #>
    489498
    490499        <# if ( data.hasUpdate ) { #>
    491                 <# if ( data.hasPackage ) { #>
    492                         <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>
     500                <# if ( data.wp_compatible && data.php_compatible ) { #>
     501                        <div class="update-message notice inline notice-warning notice-alt">
     502                        <# if ( data.hasPackage ) { #>
     503                                <p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p></div>
     504                        <# } else { #>
     505                                <div class="update-message notice inline notice-warning notice-alt"><p><?php _e( 'New   version available.' ); ?></p></div>
     506                        <# } #>
    493507                <# } else { #>
    494                         <div class="update-message notice inline notice-warning notice-alt"><p><?php _e( 'New version available.' ); ?></p></div>
     508                        <div class="notice inline notice-warning notice-alt">
     509                        <p><?php _e( 'Update incompatible.' ); ?></p></div>
    495510                <# } #>
    496511        <# } #>
    497512
     
    522537                                /* translators: %s: Theme name. */
    523538                                $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
    524539                                ?>
    525                                 <a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
    526                                 <a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
     540                                <# if ( data.wp_compatible && data.php_compatible ) { #>
     541                                        <a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
     542                                        <a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
     543                                <# } else { #>
     544                                        <a class="button disabled" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
     545                                        <a class="button button-primary load-customize hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
     546                                <# } #>
    527547                        <# } #>
    528548                </div>
    529549        </div>
     
    565585
    566586                                <# if ( data.hasUpdate ) { #>
    567587                                <div class="notice notice-warning notice-alt notice-large">
    568                                         <h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3>
    569                                         {{{ data.update }}}
     588                                        <# if ( data.wp_compatible && data.php_compatible ) { #>
     589                                                <h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3>
     590                                                {{{ data.update }}}
     591                                        <# } else { #>
     592                                                <h3 class="notice-title"><?php _e( 'Update incompatible' ); ?></h3>
     593                                                <p><?php printf(
     594                                                                /* translators: %s: WordPress version, %s: PHP version */
     595                                                                __( 'This theme is incompatible with your current installation. This theme requires at least WordPress %s and PHP %s.' ),
     596                                                                '{{{ data.requires }}}',
     597                                                                '{{{ data.requires_php }}}'
     598                                                        ); ?></p>
     599                                        <# } #>
    570600                                </div>
    571601                                <# } #>
    572602                                <p class="theme-description">{{{ data.description }}}</p>
     
    596626                                /* translators: %s: Theme name. */
    597627                                $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
    598628                                ?>
    599                                 <# if ( data.actions.activate ) { #>
     629                                <# if ( data.actions.activate && data.wp_compatible && data.php_compatible ) { #>
    600630                                        <a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
     631                                        <a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
     632                                <# } else { #>
     633                                        <a class="button disabled" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
     634                                        <a class="button button-primary load-customize hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
    601635                                <# } #>
    602                                 <a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
    603636                        </div>
    604637
    605638                        <# if ( ! data.active && data.actions['delete'] ) { #>
  • src/wp-admin/update-core.php

     
    479479        <tbody class="plugins">
    480480        <?php
    481481        foreach ( $themes as $stylesheet => $theme ) {
    482                 $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
     482                $checkbox_id    = 'checkbox_' . md5( $theme->get( 'Name' ) );
     483                $compatible_php = is_php_version_compatible( $theme->get( 'RequiresPHP' ) );
     484                $compat         = '';
     485                $annotation     = '';
     486                if ( ! $compatible_php && current_user_can( 'update_php' ) ) {
     487                        $compat .= '<br>' . __( 'This update doesn&#8217;t work with your version of PHP.' ) . '&nbsp;';
     488                        $compat .= sprintf(
     489                                /* translators: %s: URL to Update PHP page. */
     490                                __( '<a href="%s">Learn more about updating PHP</a>.' ),
     491                                esc_url( wp_get_update_php_url() )
     492                        );
     493
     494                        $annotation = wp_get_update_php_annotation();
     495
     496                        if ( $annotation ) {
     497                                $compat .= '</p><p><em>' . $annotation . '</em>';
     498                        }
     499                }
    483500                ?>
    484501        <tr>
    485502                <td class="check-column">
    486                         <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" />
    487                         <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text">
    488                                 <?php
    489                                 /* translators: %s: Theme name. */
    490                                 printf( __( 'Select %s' ), $theme->display( 'Name' ) );
    491                                 ?>
    492                         </label>
     503                        <?php if ( $compatible_php ) : ?>
     504                                <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" />
     505                                <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text">
     506                                        <?php
     507                                        /* translators: %s: Theme name. */
     508                                        printf( __( 'Select %s' ), $theme->display( 'Name' ) );
     509                                        ?>
     510                                </label>
     511                        <?php endif; ?>
    493512                </td>
    494513                <td class="plugin-title"><p>
    495514                        <img src="<?php echo esc_url( $theme->get_screenshot() ); ?>" width="85" height="64" class="updates-table-screenshot" alt="" />
     
    501520                                $theme->display( 'Version' ),
    502521                                $theme->update['new_version']
    503522                        );
     523                        echo $compat . $annotation;
    504524                        ?>
    505525                </p></td>
    506526        </tr>