[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Twenty Seventeen back compat functionality
   4   *
   5   * Prevents Twenty Seventeen from running on WordPress versions prior to 4.7,
   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.7.
   8   *
   9   * @package WordPress
  10   * @subpackage Twenty_Seventeen
  11   * @since Twenty Seventeen 1.0
  12   */
  13  
  14  /**
  15   * Prevent switching to Twenty Seventeen on old versions of WordPress.
  16   *
  17   * Switches to the default theme.
  18   *
  19   * @since Twenty Seventeen 1.0
  20   */
  21  function twentyseventeen_switch_theme() {
  22      switch_theme( WP_DEFAULT_THEME );
  23      unset( $_GET['activated'] );
  24      add_action( 'admin_notices', 'twentyseventeen_upgrade_notice' );
  25  }
  26  add_action( 'after_switch_theme', 'twentyseventeen_switch_theme' );
  27  
  28  /**
  29   * Adds a message for unsuccessful theme switch.
  30   *
  31   * Prints an update nag after an unsuccessful attempt to switch to
  32   * Twenty Seventeen on WordPress versions prior to 4.7.
  33   *
  34   * @since Twenty Seventeen 1.0
  35   *
  36   * @global string $wp_version WordPress version.
  37   */
  38  function twentyseventeen_upgrade_notice() {
  39      /* translators: %s: The current WordPress version */
  40      $message = sprintf( __( 'Twenty Seventeen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentyseventeen' ), $GLOBALS['wp_version'] );
  41      printf( '<div class="error"><p>%s</p></div>', $message );
  42  }
  43  
  44  /**
  45   * Prevents the Customizer from being loaded on WordPress versions prior to 4.7.
  46   *
  47   * @since Twenty Seventeen 1.0
  48   *
  49   * @global string $wp_version WordPress version.
  50   */
  51  function twentyseventeen_customize() {
  52      wp_die(
  53          /* translators: %s: The current WordPress version */
  54          sprintf( __( 'Twenty Seventeen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentyseventeen' ), $GLOBALS['wp_version'] ),
  55          '',
  56          array(
  57              'back_link' => true,
  58          )
  59      );
  60  }
  61  add_action( 'load-customize.php', 'twentyseventeen_customize' );
  62  
  63  /**
  64   * Prevents the Theme Preview from being loaded on WordPress versions prior to 4.7.
  65   *
  66   * @since Twenty Seventeen 1.0
  67   *
  68   * @global string $wp_version WordPress version.
  69   */
  70  function twentyseventeen_preview() {
  71      if ( isset( $_GET['preview'] ) ) {
  72          /* translators: %s: The current WordPress version */
  73          wp_die( sprintf( __( 'Twenty Seventeen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentyseventeen' ), $GLOBALS['wp_version'] ) );
  74      }
  75  }
  76  add_action( 'template_redirect', 'twentyseventeen_preview' );


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