[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Twenty Nineteen back compat functionality
   4   *
   5   * Prevents Twenty Nineteen 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_Nineteen
  11   * @since Twenty Nineteen 1.0.0
  12   */
  13  
  14  /**
  15   * Prevent switching to Twenty Nineteen on old versions of WordPress.
  16   *
  17   * Switches to the default theme.
  18   *
  19   * @since Twenty Nineteen 1.0.0
  20   */
  21  function twentynineteen_switch_theme() {
  22      switch_theme( WP_DEFAULT_THEME );
  23      unset( $_GET['activated'] );
  24      add_action( 'admin_notices', 'twentynineteen_upgrade_notice' );
  25  }
  26  add_action( 'after_switch_theme', 'twentynineteen_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 Nineteen on WordPress versions prior to 4.7.
  33   *
  34   * @since Twenty Nineteen 1.0.0
  35   *
  36   * @global string $wp_version WordPress version.
  37   */
  38  function twentynineteen_upgrade_notice() {
  39      printf(
  40          '<div class="error"><p>%s</p></div>',
  41          sprintf(
  42              /* translators: %s: WordPress version. */
  43              __( 'Twenty Nineteen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentynineteen' ),
  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 Nineteen 1.0.0
  53   *
  54   * @global string $wp_version WordPress version.
  55   */
  56  function twentynineteen_customize() {
  57      wp_die(
  58          sprintf(
  59              /* translators: %s: WordPress version. */
  60              __( 'Twenty Nineteen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentynineteen' ),
  61              $GLOBALS['wp_version']
  62          ),
  63          '',
  64          array(
  65              'back_link' => true,
  66          )
  67      );
  68  }
  69  add_action( 'load-customize.php', 'twentynineteen_customize' );
  70  
  71  /**
  72   * Prevents the Theme Preview from being loaded on WordPress versions prior to 4.7.
  73   *
  74   * @since Twenty Nineteen 1.0.0
  75   *
  76   * @global string $wp_version WordPress version.
  77   */
  78  function twentynineteen_preview() {
  79      if ( isset( $_GET['preview'] ) ) {
  80          wp_die(
  81              sprintf(
  82                  /* translators: %s: WordPress version. */
  83                  __( 'Twenty Nineteen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentynineteen' ),
  84                  $GLOBALS['wp_version']
  85              )
  86          );
  87      }
  88  }
  89  add_action( 'template_redirect', 'twentynineteen_preview' );


Generated: Sat Nov 23 01:00:02 2024 Cross-referenced by PHPXref 0.7.1