[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

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


Generated: Thu Nov 21 01:00:03 2024 Cross-referenced by PHPXref 0.7.1