Make WordPress Core

Ticket #48491: 48491.6.diff

File 48491.6.diff, 19.6 KB (added by afragen, 4 years ago)

minor updates to patch

  • wp-admin/customize.php

    diff --git a/wp-admin/customize.php b/wp-admin/customize.php
    index 4954ca99ba..d1032fb5eb 100644
    a b do_action( 'customize_controls_print_styles' ); 
    171171 * @since 3.4.0
    172172 */
    173173do_action( 'customize_controls_print_scripts' );
     174
     175// Need to use \ReflectionObject as $wp_customize->theme is protected class.
     176$reflection_obj   = new \ReflectionObject( $wp_customize );
     177$reflection_theme = $reflection_obj->getProperty( 'theme' );
     178$reflection_theme->setAccessible( true );
     179$customize_theme = $reflection_theme->getValue( $wp_customize );
     180$wp_compatible   = is_wp_version_compatible( $customize_theme->get( 'RequiresWP' ) );
     181$php_compatible  = is_php_version_compatible( $customize_theme->get( 'RequiresPHP' ) );
     182
    174183?>
    175184</head>
    176185<body class="<?php echo esc_attr( $body_class ); ?>">
    177186<div class="wp-full-overlay expanded">
    178187        <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
    179188                <div id="customize-header-actions" class="wp-full-overlay-header">
    180                         <?php $save_text = $wp_customize->is_theme_active() ? __( 'Publish' ) : __( 'Activate &amp; Publish' ); ?>
    181                         <div id="customize-save-button-wrapper" class="customize-save-button-wrapper" >
    182                                 <?php submit_button( $save_text, 'primary save', 'save', false ); ?>
    183                                 <button id="publish-settings" class="publish-settings button-primary button dashicons dashicons-admin-generic" aria-label="<?php esc_attr_e( 'Publish Settings' ); ?>" aria-expanded="false" disabled></button>
    184                         </div>
     189                        <?php if ( $wp_customize && $php_compatible ) : ?>
     190                                <?php $save_text = $wp_customize->is_theme_active() ? __( 'Publish' ) : __( 'Activate &amp; Publish' ); ?>
     191                                <div id="customize-save-button-wrapper" class="customize-save-button-wrapper" >
     192                                        <?php submit_button( $save_text, 'primary save', 'save', false ); ?>
     193                                        <button id="publish-settings" class="publish-settings button-primary button dashicons dashicons-admin-generic" aria-label="<?php esc_attr_e( 'Publish Settings' ); ?>" aria-expanded="false" disabled></button>
     194                                </div>
     195                        <?php else: ?>
     196                                <?php $save_text = $wp_customize->is_theme_active() ? __( 'Publish' ) : __( 'Activate &amp; Publish' ); ?>
     197                                <div id="customize-save-button-wrapper" class="customize-save-button-wrapper disabled" >
     198                                        <a class="button disabled"><?php esc_html_e( $save_text ); ?></a>
     199                                </div>
     200                        <?php endif; ?>
    185201                        <span class="spinner"></span>
    186202                        <button type="button" class="customize-controls-preview-toggle">
    187203                                <span class="controls"><?php _e( 'Customize' ); ?></span>
  • wp-admin/includes/theme.php

    diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php
    index 47168057e0..4a5a32c0f5 100644
    a b function wp_prepare_themes_for_js( $themes = null ) { 
    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( 'RequiresWP' ),
     666                        'requires_php'   => $theme->display( 'RequiresPHP' ),
     667                        'wp_compatible'  => is_wp_version_compatible( $theme->display( 'RequiresWP' ) ),
     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&amp;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&amp;stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null,
    function customize_themes_print_templates() { 
    754758
    755759                                        <# if ( data.hasUpdate ) { #>
    756760                                                <div class="notice notice-warning notice-alt notice-large" data-slug="{{ data.id }}">
     761                                                <# if ( data.wp_compatible && data.php_compatible ) { #>
    757762                                                        <h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3>
    758763                                                        {{{ data.update }}}
     764                                                <# } else { #>
     765                                                        <h3 class="notice-title"><?php _e( 'Update incompatible' ); ?></h3>
     766                                                        <p><?php printf(
     767                                                                /* translators: %s: WordPress version, %s: PHP version */
     768                                                                __( 'This theme is incompatible with your current installation. This theme requires at least WordPress %s and PHP %s.' ),
     769                                                                '{{{ data.requires }}}',
     770                                                                '{{{ data.requires_php }}}'
     771                                                                ); ?></p>
     772                                                <# } #>
    759773                                                </div>
    760774                                        <# } #>
    761775
  • wp-admin/theme-install.php

    diff --git a/wp-admin/theme-install.php b/wp-admin/theme-install.php
    index 944e9d7d0a..52900a6bdd 100644
    a b if ( $tab ) { 
    285285                                $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
    286286                                ?>
    287287                                <# if ( data.activate_url ) { #>
    288                                         <a class="button button-primary activate" href="{{ data.activate_url }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
     288                                        <# if ( data.wp_compatible && data.php_compatible ) { #>
     289                                                <a class="button button-primary activate" href="{{ data.activate_url }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
     290                                        <# } else { #>
     291                                                <a class="button button-primary disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
     292                                        <# } #>
    289293                                <# } #>
    290294                                <# if ( data.customize_url ) { #>
    291295                                        <a class="button load-customize" href="{{ data.customize_url }}"><?php _e( 'Live Preview' ); ?></a>
    if ( $tab ) { 
    315319                        <button class="previous-theme"><span class="screen-reader-text"><?php _e( 'Previous theme' ); ?></span></button>
    316320                        <button class="next-theme"><span class="screen-reader-text"><?php _e( 'Next theme' ); ?></span></button>
    317321                        <# if ( data.installed ) { #>
    318                                 <a class="button button-primary activate" href="{{ data.activate_url }}"><?php _e( 'Activate' ); ?></a>
    319                         <# } else { #>
    320                                 <a href="{{ data.install_url }}" class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></a>
     322                                <# if ( data.wp_compatible && data.php_compatible ) { #>
     323                                        <a class="button button-primary activate" href="{{ data.activate_url }}"><?php _e( 'Activate' ); ?></a>
     324                                <# } else { #>
     325                                        <a class="button button-primary disabled"><?php _e( 'Activate' ); ?></a>
     326                                <# } #>
     327                        <# } else { #>
     328                                <# <?php if ( $wp_compatible  && $php_compatible ) : ?> #>
     329                                        <a href="{{ data.install_url }}" class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></a>
     330                                <# <?php else: ?> #>
     331                                        <a class="button button-primary theme-install disabled"><?php _e( 'Install' ); ?></a>
     332                                <# <?php endif; ?> #>
    321333                        <# } #>
    322334                </div>
    323335                <div class="wp-full-overlay-sidebar-content">
  • wp-admin/themes.php

    diff --git a/wp-admin/themes.php b/wp-admin/themes.php
    index 53bb1049a7..f7b03d675f 100644
    a b foreach ( $themes as $theme ) : 
    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; ?>
    foreach ( $themes as $theme ) : 
    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>
    if ( ! is_multisite() && current_user_can( 'edit_themes' ) && $broken_themes ) { 
    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
    if ( ! is_multisite() && current_user_can( 'edit_themes' ) && $broken_themes ) { 
    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>
    if ( ! is_multisite() && current_user_can( 'edit_themes' ) && $broken_themes ) { 
    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>
    if ( ! is_multisite() && current_user_can( 'edit_themes' ) && $broken_themes ) { 
    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'] ) { #>
  • wp-admin/update-core.php

    diff --git a/wp-admin/update-core.php b/wp-admin/update-core.php
    index 9d21ac8c2c..b147fa363f 100644
    a b function list_theme_updates() { 
    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="" />
    function list_theme_updates() { 
    501520                                $theme->display( 'Version' ),
    502521                                $theme->update['new_version']
    503522                        );
     523                        echo $compat . $annotation;
    504524                        ?>
    505525                </p></td>
    506526        </tr>
  • wp-includes/customize/class-wp-customize-theme-control.php

    diff --git a/wp-includes/customize/class-wp-customize-theme-control.php b/wp-includes/customize/class-wp-customize-theme-control.php
    index 10f09d180b..5dd0873d40 100644
    a b class WP_Customize_Theme_Control extends WP_Customize_Control { 
    9090                        </div>
    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.wp_compatible && data.theme.php_compatible ) { #>
     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                                                        <?php _e( 'Update Incompatible.' ); ?>
     113                                                </p>
     114                                        </div>
     115                                <# } #>
    108116                        <# } #>
    109117
    110118                        <# if ( data.theme.active ) { #>
    class WP_Customize_Theme_Control extends WP_Customize_Control { 
    121129                                <div class="theme-id-container">
    122130                                        <h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
    123131                                        <div class="theme-actions">
    124                                                 <button type="button" class="button button-primary preview-theme" aria-label="<?php echo esc_attr( $preview_label ); ?>" data-slug="{{ data.theme.id }}"><?php _e( 'Live Preview' ); ?></button>
     132                                                <# if ( data.theme.wp_compatible && data.theme.php_compatible ) { #>
     133                                                        <button type="button" class="button button-primary preview-theme" aria-label="<?php echo esc_attr( $preview_label ); ?>" data-slug="{{ data.theme.id }}"><?php _e( 'Live Preview' ); ?></button>
     134                                                <# } else { #>
     135                                                        <button class="button button-primary disabled" aria-label="<?php echo esc_attr( $preview_label ); ?>"><?php _e( 'Live Preview' ); ?></button>
     136                                                <# } #>
    125137                                        </div>
    126138                                </div>
    127139                                <div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>