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/includes/theme.php

    r47808 r47816  
    685685
    686686        $prepared_themes[ $slug ] = array(
    687             'id'           => $slug,
    688             'name'         => $theme->display( 'Name' ),
    689             'screenshot'   => array( $theme->get_screenshot() ), // @todo Multiple screenshots.
    690             'description'  => $theme->display( 'Description' ),
    691             'author'       => $theme->display( 'Author', false, true ),
    692             'authorAndUri' => $theme->display( 'Author' ),
    693             'version'      => $theme->display( 'Version' ),
    694             'tags'         => $theme->display( 'Tags' ),
    695             'parent'       => $parent,
    696             'active'       => $slug === $current_theme,
    697             'hasUpdate'    => isset( $updates[ $slug ] ),
    698             'hasPackage'   => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ]['package'] ),
    699             'update'       => get_theme_update_available( $theme ),
    700             'actions'      => array(
     687            'id'            => $slug,
     688            'name'          => $theme->display( 'Name' ),
     689            'screenshot'    => array( $theme->get_screenshot() ), // @todo Multiple screenshots.
     690            'description'   => $theme->display( 'Description' ),
     691            'author'        => $theme->display( 'Author', false, true ),
     692            'authorAndUri'  => $theme->display( 'Author' ),
     693            'tags'          => $theme->display( 'Tags' ),
     694            'version'       => $theme->get( 'Version' ),
     695            'compatibleWP'  => is_wp_version_compatible( $theme->get( 'RequiresWP' ) ),
     696            'compatiblePHP' => is_php_version_compatible( $theme->get( 'RequiresPHP' ) ),
     697            'parent'        => $parent,
     698            'active'        => $slug === $current_theme,
     699            'hasUpdate'     => isset( $updates[ $slug ] ),
     700            'hasPackage'    => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ]['package'] ),
     701            'update'        => get_theme_update_available( $theme ),
     702            'actions'       => array(
    701703                'activate'  => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,
    702704                'customize' => $customize_action,
     
    819821                        <# } #>
    820822                    <?php } ?>
    821                     <button type="button" class="button button-primary preview-theme" data-slug="{{ data.id }}"><?php _e( 'Live Preview' ); ?></button>
     823
     824                    <# if ( data.compatibleWP && data.compatiblePHP ) { #>
     825                        <button type="button" class="button button-primary preview-theme" data-slug="{{ data.id }}"><?php _e( 'Live Preview' ); ?></button>
     826                    <# } else { #>
     827                        <button class="button button-primary disabled"><?php _e( 'Live Preview' ); ?></button>
     828                    <# } #>
    822829                <# } else { #>
    823830                    <button type="button" class="button theme-install" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></button>
Note: See TracChangeset for help on using the changeset viewer.