• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress a2z

WordPress a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / twenty_twenty_one_scripts() – Enqueue scripts and styles.

You appear to be a bot. Output may be restricted

Description

Enqueue scripts and styles.

Usage

$void = twenty_twenty_one_scripts();

Parameters

Returns

void

Source

File name: twentytwentyone/functions.php
Lines:

1 to 70 of 70
function twenty_twenty_one_scripts() {
  // Note, the is_IE global variable is defined by WordPress and is used
  // to detect if the current browser is internet explorer.
  global $is_IE, $wp_scripts;
  if ( $is_IE ) {
    // If IE 11 or below, use a flattened stylesheet with static values replacing CSS Variables.
    wp_enqueue_style( 'twenty-twenty-one-style', get_template_directory_uri() . '/assets/css/ie.css', array(), wp_get_theme()->get( 'Version' ) );
  } else {
    // If not IE, use the standard stylesheet.
    wp_enqueue_style( 'twenty-twenty-one-style', get_template_directory_uri() . '/style.css', array(), wp_get_theme()->get( 'Version' ) );
  }

  // RTL styles.
  wp_style_add_data( 'twenty-twenty-one-style', 'rtl', 'replace' );

  // Print styles.
  wp_enqueue_style( 'twenty-twenty-one-print-style', get_template_directory_uri() . '/assets/css/print.css', array(), wp_get_theme()->get( 'Version' ), 'print' );

  // Threaded comment reply styles.
  if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
    wp_enqueue_script( 'comment-reply' );
  }

  // Register the IE11 polyfill file.
  wp_register_script(
    'twenty-twenty-one-ie11-polyfills-asset',
    get_template_directory_uri() . '/assets/js/polyfills.js',
    array(),
    wp_get_theme()->get( 'Version' ),
    true
  );

  // Register the IE11 polyfill loader.
  wp_register_script(
    'twenty-twenty-one-ie11-polyfills',
    null,
    array(),
    wp_get_theme()->get( 'Version' ),
    true
  );
  wp_add_inline_script(
    'twenty-twenty-one-ie11-polyfills',
    wp_get_script_polyfill(
      $wp_scripts,
      array(
        'Element.prototype.matches && Element.prototype.closest && window.NodeList && NodeList.prototype.forEach' => 'twenty-twenty-one-ie11-polyfills-asset',
      )
    )
  );

  // Main navigation scripts.
  if ( has_nav_menu( 'primary' ) ) {
    wp_enqueue_script(
      'twenty-twenty-one-primary-navigation-script',
      get_template_directory_uri() . '/assets/js/primary-navigation.js',
      array( 'twenty-twenty-one-ie11-polyfills' ),
      wp_get_theme()->get( 'Version' ),
      true
    );
  }

  // Responsive embeds script.
  wp_enqueue_script(
    'twenty-twenty-one-responsive-embeds-script',
    get_template_directory_uri() . '/assets/js/responsive-embeds.js',
    array( 'twenty-twenty-one-ie11-polyfills' ),
    wp_get_theme()->get( 'Version' ),
    true
  );
}
 

 View on GitHub View on Trac

Published: 9th December 2020 | Last updated: 23rd February 2021

Primary Sidebar

Information

Function name: twenty_twenty_one_scripts
Plugin ref: Twenty Twenty-One
Version: 1.7
Sourcefile: functions.php
File ref: functions.php
Deprecated?: No
API Letters: O,S,T

Footer

WordPress a2z
WordPress a2z
WordPress Dynamic API Reference
WordPress 6.1.1. PHP: 8.0.28
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  wp-a2z.org
© Copyright WordPress a2z 2014-2023. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites