Make WordPress Core


Ignore:
Timestamp:
05/18/2020 12:30:04 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Themes: Prevent activation and live preview of themes that require a higher version of PHP or WordPress.

Props afragen, jorbin, TimothyBlynJacobs, SergeyBiryukov.
See #48491.

File:
1 edited

Legend:

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

    r47808 r47816  
    354354                                <a class="button button-primary customize load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Customize' ); ?></a>
    355355                        <?php } ?>
    356                 <?php } else { ?>
     356                <?php } elseif ( $theme['compatibleWP'] && $theme['compatiblePHP'] ) { ?>
    357357                        <?php
    358358                        /* translators: %s: Theme name. */
    … …  
    362362                        <?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
    363363                                <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 } else { ?>
     366                        <?php
     367                        /* translators: %s: Theme name. */
     368                        $aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
     369                        ?>
     370                        <a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
     371                        <?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
     372                                <a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
    364373                        <?php } ?>
    365374                <?php } ?>
    … …  
    519528                                <# } #>
    520529                        <# } else { #>
    521                                 <?php
    522                                 /* translators: %s: Theme name. */
    523                                 $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
    524                                 ?>
    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>
     530                                <# if ( data.compatibleWP && data.compatiblePHP ) { #>
     531                                        <?php
     532                                        /* translators: %s: Theme name. */
     533                                        $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
     534                                        ?>
     535                                        <a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
     536                                        <a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
     537                                <# } else { #>
     538                                        <?php
     539                                        /* translators: %s: Theme name. */
     540                                        $aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
     541                                        ?>
     542                                        <a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
     543                                        <a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
     544                                <# } #>
    527545                        <# } #>
    528546                </div>
    … …  
    593611                        </div>
    594612                        <div class="inactive-theme">
    595                                 <?php
    596                                 /* translators: %s: Theme name. */
    597                                 $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
    598                                 ?>
    599                                 <# if ( data.actions.activate ) { #>
    600                                         <a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
     613                                <# if ( data.compatibleWP && data.compatiblePHP ) { #>
     614                                        <?php
     615                                        /* translators: %s: Theme name. */
     616                                        $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
     617                                        ?>
     618                                        <# if ( data.actions.activate ) { #>
     619                                                <a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
     620                                        <# } #>
     621                                        <a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
     622                                <# } else { #>
     623                                        <?php
     624                                        /* translators: %s: Theme name. */
     625                                        $aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
     626                                        ?>
     627                                        <# if ( data.actions.activate ) { #>
     628                                                <a class="button disabled" aria-label="<?php echo $aria_label; ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
     629                                        <# } #>
     630                                        <a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
    601631                                <# } #>
    602                                 <a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
    603632                        </div>
    604633
Note: See TracChangeset for help on using the changeset viewer.