[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-content/themes/twentyfourteen/inc/ -> back-compat.php (source)

   1  <?php
   2  /**
   3   * Twenty Fourteen back compat functionality
   4   *
   5   * Prevents Twenty Fourteen from running on WordPress versions prior to 3.6,
   6   * since this theme is not meant to be backward compatible beyond that
   7   * and relies on many newer functions and markup changes introduced in 3.6.
   8   *
   9   * @package WordPress
  10   * @subpackage Twenty_Fourteen
  11   * @since Twenty Fourteen 1.0
  12   */
  13  
  14  /**
  15   * Prevent switching to Twenty Fourteen on old versions of WordPress.
  16   *
  17   * Switches to the default theme.
  18   *
  19   * @since Twenty Fourteen 1.0
  20   */
  21  function twentyfourteen_switch_theme() {
  22      switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
  23      unset( $_GET['activated'] );
  24      add_action( 'admin_notices', 'twentyfourteen_upgrade_notice' );
  25  }
  26  add_action( 'after_switch_theme', 'twentyfourteen_switch_theme' );
  27  
  28  /**
  29   * Add message for unsuccessful theme switch.
  30   *
  31   * Prints an update nag after an unsuccessful attempt to switch to
  32   * Twenty Fourteen on WordPress versions prior to 3.6.
  33   *
  34   * @since Twenty Fourteen 1.0
  35   */
  36  function twentyfourteen_upgrade_notice() {
  37      /* translators: %s: WordPress version */
  38      $message = sprintf( __( 'Twenty Fourteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.', 'twentyfourteen' ), $GLOBALS['wp_version'] );
  39      printf( '<div class="error"><p>%s</p></div>', $message );
  40  }
  41  
  42  /**
  43   * Prevent the Customizer from being loaded on WordPress versions prior to 3.6.
  44   *
  45   * @since Twenty Fourteen 1.0
  46   */
  47  function twentyfourteen_customize() {
  48      wp_die(
  49          /* translators: %s: WordPress version */
  50          sprintf( __( 'Twenty Fourteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.', 'twentyfourteen' ), $GLOBALS['wp_version'] ),
  51          '',
  52          array(
  53              'back_link' => true,
  54          )
  55      );
  56  }
  57  add_action( 'load-customize.php', 'twentyfourteen_customize' );
  58  
  59  /**
  60   * Prevent the Theme Preview from being loaded on WordPress versions prior to 3.4.
  61   *
  62   * @since Twenty Fourteen 1.0
  63   */
  64  function twentyfourteen_preview() {
  65      if ( isset( $_GET['preview'] ) ) {
  66          /* translators: %s: WordPress version */
  67          wp_die( sprintf( __( 'Twenty Fourteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.', 'twentyfourteen' ), $GLOBALS['wp_version'] ) );
  68      }
  69  }
  70  add_action( 'template_redirect', 'twentyfourteen_preview' );


Generated: Sun Jul 21 01:00:03 2019 Cross-referenced by PHPXref 0.7.1