Make WordPress Core

Changeset 23837


Ignore:
Timestamp:
03/28/2013 06:45:56 AM (12 years ago)
Author:
lancewillett
Message:

Twenty Thirteen: better back compat handling by moving version compare before the include to avoid loading the file altogether. Also prevent Customizer views. Props obenland, closes #23819.

Location:
trunk/wp-content/themes/twentythirteen
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentythirteen/functions.php

    r23816 r23837  
    597597 * Adds back compat handling for WP versions pre-3.6.
    598598 */
    599 require( get_template_directory() . '/inc/back-compat.php' );
     599if ( version_compare( $GLOBALS['wp_version'], '3.6-alpha', '<' ) )
     600    require( get_template_directory() . '/inc/back-compat.php' );
  • trunk/wp-content/themes/twentythirteen/inc/back-compat.php

    r23825 r23837  
    11<?php
     2/**
     3 * Prevents Twenty Thirteen from running on WordPress versions prior to 3.6.
     4 *
     5 * Twenty Thirteen is not meant to be backwards compatible, since it relies on
     6 * a lot of new functions and markup changes that were introduced in 3.6.
     7 *
     8 * @package WordPress
     9 * @subpackage Twenty_Thirteen
     10 * @since Twenty Thirteen 1.0
     11 */
     12
    213/**
    314 * Prevent switching to Twenty Thirteen on old versions of WordPress. Switches
    415 * to the previously activated theme or the default theme.
     16 *
     17 * @since Twenty Thirteen 1.0
     18 *
     19 * @param string $theme_name
     20 * @param WP_Theme $theme
     21 * @return void
    522 */
    623function twentythirteen_switch_theme( $theme_name, $theme ) {
    7     if ( version_compare( $GLOBALS['wp_version'], '3.6-alpha', '>=' ) )
    8         return;
    9 
    1024    if ( 'twentythirteen' != $theme->template )
    1125        switch_theme( $theme->template, $theme->stylesheet );
     
    1832add_action( 'after_switch_theme', 'twentythirteen_switch_theme', 10, 2 );
    1933
     34/**
     35 * Prints an update nag after an unsuccessful attempt to switch to
     36 * Twenty Thirteen on WordPress versions prior to 3.6.
     37 *
     38 * @since Twenty Thirteen 1.0
     39 *
     40 * @return void
     41 */
    2042function twentythirteen_upgrade_notice() {
    21     $message = sprintf( __( 'Twenty Thirteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.' ), $GLOBALS['wp_version'] );
     43    $message = sprintf( __( 'Twenty Thirteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.', 'twentythirteen' ), $GLOBALS['wp_version'] );
    2244    printf( '<div class="error"><p>%s</p></div>', $message );
    2345}
     46
     47/**
     48 * Prevents the Customizer from being loaded on WordPress versions prior to 3.6.
     49 *
     50 * @since Twenty Thirteen 1.0
     51 *
     52 * @return void
     53 */
     54function twentythirteen_customize() {
     55    wp_die( sprintf( __( 'Twenty Thirteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.', 'twentythirteen' ), $GLOBALS['wp_version'] ) . sprintf( ' <a href="javascript:history.go(-1);">%s</a>', __( 'Go back.', 'twentythirteen' ) ) );
     56}
     57add_action( 'load-customize.php', 'twentythirteen_customize' );
Note: See TracChangeset for help on using the changeset viewer.