[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Back compat functionality
   4   *
   5   * Prevents the theme from running on WordPress versions prior to 5.3,
   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 5.3.
   8   *
   9   * @package WordPress
  10   * @subpackage Twenty_Twenty_One
  11   * @since Twenty Twenty-One 1.0
  12   */
  13  
  14  /**
  15   * Display upgrade notice on theme switch.
  16   *
  17   * @since Twenty Twenty-One 1.0
  18   *
  19   * @return void
  20   */
  21  function twenty_twenty_one_switch_theme() {
  22      add_action( 'admin_notices', 'twenty_twenty_one_upgrade_notice' );
  23  }
  24  add_action( 'after_switch_theme', 'twenty_twenty_one_switch_theme' );
  25  
  26  /**
  27   * Adds a message for unsuccessful theme switch.
  28   *
  29   * Prints an update nag after an unsuccessful attempt to switch to
  30   * the theme on WordPress versions prior to 5.3.
  31   *
  32   * @since Twenty Twenty-One 1.0
  33   *
  34   * @global string $wp_version WordPress version.
  35   *
  36   * @return void
  37   */
  38  function twenty_twenty_one_upgrade_notice() {
  39      echo '<div class="error"><p>';
  40      printf(
  41          /* translators: %s: WordPress Version. */
  42          esc_html__( 'This theme requires WordPress 5.3 or newer. You are running version %s. Please upgrade.', 'twentytwentyone' ),
  43          esc_html( $GLOBALS['wp_version'] )
  44      );
  45      echo '</p></div>';
  46  }
  47  
  48  /**
  49   * Prevents the Customizer from being loaded on WordPress versions prior to 5.3.
  50   *
  51   * @since Twenty Twenty-One 1.0
  52   *
  53   * @global string $wp_version WordPress version.
  54   *
  55   * @return void
  56   */
  57  function twenty_twenty_one_customize() {
  58      wp_die(
  59          sprintf(
  60              /* translators: %s: WordPress Version. */
  61              esc_html__( 'This theme requires WordPress 5.3 or newer. You are running version %s. Please upgrade.', 'twentytwentyone' ),
  62              esc_html( $GLOBALS['wp_version'] )
  63          ),
  64          '',
  65          array(
  66              'back_link' => true,
  67          )
  68      );
  69  }
  70  add_action( 'load-customize.php', 'twenty_twenty_one_customize' );
  71  
  72  /**
  73   * Prevents the Theme Preview from being loaded on WordPress versions prior to 5.3.
  74   *
  75   * @since Twenty Twenty-One 1.0
  76   *
  77   * @global string $wp_version WordPress version.
  78   *
  79   * @return void
  80   */
  81  function twenty_twenty_one_preview() {
  82      if ( isset( $_GET['preview'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
  83          wp_die(
  84              sprintf(
  85                  /* translators: %s: WordPress Version. */
  86                  esc_html__( 'This theme requires WordPress 5.3 or newer. You are running version %s. Please upgrade.', 'twentytwentyone' ),
  87                  esc_html( $GLOBALS['wp_version'] )
  88              )
  89          );
  90      }
  91  }
  92  add_action( 'template_redirect', 'twenty_twenty_one_preview' );


Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref