Make WordPress Core


Ignore:
Timestamp:
05/18/2020 12:30:04 PM (4 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/customize.php

    r47474 r47816  
    178178    <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
    179179        <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>
     180            <?php
     181            $compatible_wp  = is_wp_version_compatible( $wp_customize->theme()->get( 'RequiresWP' ) );
     182            $compatible_php = is_php_version_compatible( $wp_customize->theme()->get( 'RequiresPHP' ) );
     183            ?>
     184            <?php if ( $compatible_wp && $compatible_php ) : ?>
     185                <?php $save_text = $wp_customize->is_theme_active() ? __( 'Publish' ) : __( 'Activate &amp; Publish' ); ?>
     186                <div id="customize-save-button-wrapper" class="customize-save-button-wrapper" >
     187                    <?php submit_button( $save_text, 'primary save', 'save', false ); ?>
     188                    <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>
     189                </div>
     190            <?php else : ?>
     191                <?php $save_text = _x( 'Cannot Activate', 'theme' ); ?>
     192                <div id="customize-save-button-wrapper" class="customize-save-button-wrapper disabled" >
     193                    <button class="button button-primary disabled" aria-label="<?php esc_attr_e( 'Publish Settings' ); ?>" aria-expanded="false" disabled><?php echo $save_text; ?></button>
     194                </div>
     195            <?php endif; ?>
    185196            <span class="spinner"></span>
    186197            <button type="button" class="customize-controls-preview-toggle">
Note: See TracChangeset for help on using the changeset viewer.