Make WordPress Core

Changeset 47819


Ignore:
Timestamp:
05/18/2020 04:01:38 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Themes: Prevent installation of themes that require a higher version of PHP or WordPress.

Props afragen.
Fixes #49653. See #48491.

Location:
trunk/src
Files:
4 edited

Legend:

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

    r47818 r47819  
    828828                    <# } #>
    829829                <# } else { #>
    830                     <button type="button" class="button theme-install" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></button>
    831                     <button type="button" class="button button-primary theme-install preview" data-slug="{{ data.id }}"><?php _e( 'Install &amp; Preview' ); ?></button>
     830                    <# if ( data.compatibleWP && data.compatiblePHP ) { #>
     831                        <button type="button" class="button theme-install" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></button>
     832                        <button type="button" class="button button-primary theme-install preview" data-slug="{{ data.id }}"><?php _e( 'Install &amp; Preview' ); ?></button>
     833                    <# } else { #>
     834                        <button type="button" class="button disabled"><?php _ex( 'Cannot Install', 'theme' ); ?></button>
     835                        <button type="button" class="button button-primary disabled"><?php _e( 'Install &amp; Preview' ); ?></button>
     836                    <# } #>
    832837                <# } #>
    833838            </div>
  • trunk/src/wp-admin/theme-install.php

    r47817 r47819  
    312312                <# } #>
    313313            <# } else { #>
    314                 <?php
    315                 /* translators: %s: Theme name. */
    316                 $aria_label = sprintf( __( 'Install %s' ), '{{ data.name }}' );
    317                 ?>
    318                 <a class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}" href="{{ data.install_url }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Install' ); ?></a>
    319                 <button class="button preview install-theme-preview"><?php _e( 'Preview' ); ?></button>
     314                <# if ( data.compatible_wp && data.compatible_php ) { #>
     315                    <?php
     316                    /* translators: %s: Theme name. */
     317                    $aria_label = sprintf( __( 'Install %s' ), '{{ data.name }}' );
     318                    ?>
     319                    <a class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}" href="{{ data.install_url }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Install' ); ?></a>
     320                    <button class="button preview install-theme-preview"><?php _e( 'Preview' ); ?></button>
     321                <# } else { #>
     322                    <?php
     323                    /* translators: %s: Theme name. */
     324                    $aria_label = sprintf( __( 'Cannot Install %s' ), '{{ data.name }}' );
     325                    ?>
     326                    <a class="button button-primary disabled" data-name="{{ data.name }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Install', 'theme' ); ?></a>
     327                    <button class="button disabled"><?php _e( 'Preview' ); ?></button>
     328                <# } #>
    320329            <# } #>
    321330        </div>
     
    334343            <button class="next-theme"><span class="screen-reader-text"><?php _e( 'Next theme' ); ?></span></button>
    335344            <# if ( data.installed ) { #>
    336                 <a class="button button-primary activate" href="{{ data.activate_url }}"><?php _e( 'Activate' ); ?></a>
     345                <# if ( data.compatible_wp && data.compatible_php ) { #>
     346                    <a class="button button-primary activate" href="{{ data.activate_url }}"><?php _e( 'Activate' ); ?></a>
     347                <# } else { #>
     348                    <a class="button button-primary disabled" ><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
     349                <# } #>
    337350            <# } else { #>
    338                 <a href="{{ data.install_url }}" class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></a>
     351                <# if ( data.compatible_wp && data.compatible_php ) { #>
     352                    <a href="{{ data.install_url }}" class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></a>
     353                <# } else { #>
     354                    <a class="button button-primary disabled" ><?php _ex( 'Cannot Install', 'theme' ); ?></a>
     355                <# } #>
    339356            <# } #>
    340357        </div>
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r47663 r47819  
    58545854
    58555855                // Map available theme properties to installed theme properties.
    5856                 $theme->id           = $theme->slug;
    5857                 $theme->screenshot   = array( $theme->screenshot_url );
    5858                 $theme->authorAndUri = wp_kses( $theme->author['display_name'], $themes_allowedtags );
     5856                $theme->id            = $theme->slug;
     5857                $theme->screenshot    = array( $theme->screenshot_url );
     5858                $theme->authorAndUri  = wp_kses( $theme->author['display_name'], $themes_allowedtags );
     5859                $theme->compatibleWP  = is_wp_version_compatible( $theme->requires );
     5860                $theme->compatiblePHP = is_php_version_compatible( $theme->requires_php );
    58595861
    58605862                if ( isset( $theme->parent ) ) {
  • trunk/src/wp-includes/customize/class-wp-customize-theme-control.php

    r47816 r47819  
    134134                    <h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
    135135                    <div class="theme-actions">
    136                         <button type="button" class="button button-primary theme-install preview" aria-label="<?php echo esc_attr( $install_label ); ?>" data-slug="{{ data.theme.id }}" data-name="{{ data.theme.name }}"><?php _e( 'Install &amp; Preview' ); ?></button>
     136                        <# if ( data.theme.compatibleWP && data.theme.compatiblePHP ) { #>
     137                            <button type="button" class="button button-primary theme-install preview" aria-label="<?php echo esc_attr( $install_label ); ?>" data-slug="{{ data.theme.id }}" data-name="{{ data.theme.name }}"><?php _e( 'Install &amp; Preview' ); ?></button>
     138                        <# } else { #>
     139                            <button type="button" class="button button-primary disabled" aria-label="<?php echo esc_attr( $install_label ); ?>" disabled><?php _e( 'Install &amp; Preview' ); ?></button>
     140                        <# } #>
    137141                    </div>
    138142                </div>
Note: See TracChangeset for help on using the changeset viewer.