[ 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      printf(
  40          '<div class="error"><p>%s</p></div>',
  41          sprintf(
  42              /* translators: %s: The current WordPress version. */
  43              __( 'Twenty Seventeen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentyseventeen' ),
  44              $GLOBALS['wp_version']
  45          )
  46      );
  47  }
  48  
  49  /**
  50   * Prevents the Customizer from being loaded on WordPress versions prior to 4.7.
  51   *
  52   * @since Twenty Seventeen 1.0
  53   *
  54   * @global string $wp_version WordPress version.
  55   */
  56  function twentyseventeen_customize() {
  57      wp_die(
  58          sprintf(
  59              /* translators: %s: The current WordPress version. */
  60              __( 'Twenty Seventeen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentyseventeen' ),
  61              $GLOBALS['wp_version']
  62          ),
  63          '',
  64          array(
  65              'back_link' => true,
  66          )
  67      );
  68  }
  69  add_action( 'load-customize.php', 'twentyseventeen_customize' );
  70  
  71  /**
  72   * Prevents the Theme Preview from being loaded on WordPress versions prior to 4.7.
  73   *
  74   * @since Twenty Seventeen 1.0
  75   *
  76   * @global string $wp_version WordPress version.
  77   */
  78  function twentyseventeen_preview() {
  79      if ( isset( $_GET['preview'] ) ) {
  80          wp_die(
  81              sprintf(
  82                  /* translators: %s: The current WordPress version. */
  83                  __( 'Twenty Seventeen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentyseventeen' ),
  84                  $GLOBALS['wp_version']
  85              )
  86          );
  87      }
  88  }
  89  add_action( 'template_redirect', 'twentyseventeen_preview' );


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