[ 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      /* translators: %s: WordPress version */
  40      $message = sprintf( __( 'Twenty Nineteen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentynineteen' ), $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 Nineteen 1.0.0
  48   *
  49   * @global string $wp_version WordPress version.
  50   */
  51  function twentynineteen_customize() {
  52      wp_die(
  53          sprintf(
  54              /* translators: %s: WordPress version */
  55              __( 'Twenty Nineteen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentynineteen' ),
  56              $GLOBALS['wp_version']
  57          ),
  58          '',
  59          array(
  60              'back_link' => true,
  61          )
  62      );
  63  }
  64  add_action( 'load-customize.php', 'twentynineteen_customize' );
  65  
  66  /**
  67   * Prevents the Theme Preview from being loaded on WordPress versions prior to 4.7.
  68   *
  69   * @since Twenty Nineteen 1.0.0
  70   *
  71   * @global string $wp_version WordPress version.
  72   */
  73  function twentynineteen_preview() {
  74      if ( isset( $_GET['preview'] ) ) {
  75          /* translators: %s: WordPress version */
  76          wp_die( sprintf( __( 'Twenty Nineteen requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'twentynineteen' ), $GLOBALS['wp_version'] ) );
  77      }
  78  }
  79  add_action( 'template_redirect', 'twentynineteen_preview' );


Generated: Mon Jul 15 01:00:03 2019 Cross-referenced by PHPXref 0.7.1