Edit File by line
/home/barbar84/www/wp-conte.../themes/twentytw...
File: functions.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Functions and definitions
[2] Fix | Delete
*
[3] Fix | Delete
* @link https://developer.wordpress.org/themes/basics/theme-functions/
[4] Fix | Delete
*
[5] Fix | Delete
* @package WordPress
[6] Fix | Delete
* @subpackage Twenty_Twenty_One
[7] Fix | Delete
* @since Twenty Twenty-One 1.0
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
// This theme requires WordPress 5.3 or later.
[11] Fix | Delete
if ( version_compare( $GLOBALS['wp_version'], '5.3', '<' ) ) {
[12] Fix | Delete
require get_template_directory() . '/inc/back-compat.php';
[13] Fix | Delete
}
[14] Fix | Delete
[15] Fix | Delete
if ( ! function_exists( 'twenty_twenty_one_setup' ) ) {
[16] Fix | Delete
/**
[17] Fix | Delete
* Sets up theme defaults and registers support for various WordPress features.
[18] Fix | Delete
*
[19] Fix | Delete
* Note that this function is hooked into the after_setup_theme hook, which
[20] Fix | Delete
* runs before the init hook. The init hook is too late for some features, such
[21] Fix | Delete
* as indicating support for post thumbnails.
[22] Fix | Delete
*
[23] Fix | Delete
* @since Twenty Twenty-One 1.0
[24] Fix | Delete
*
[25] Fix | Delete
* @return void
[26] Fix | Delete
*/
[27] Fix | Delete
function twenty_twenty_one_setup() {
[28] Fix | Delete
/*
[29] Fix | Delete
* Make theme available for translation.
[30] Fix | Delete
* Translations can be filed in the /languages/ directory.
[31] Fix | Delete
* If you're building a theme based on Twenty Twenty-One, use a find and replace
[32] Fix | Delete
* to change 'twentytwentyone' to the name of your theme in all the template files.
[33] Fix | Delete
*/
[34] Fix | Delete
load_theme_textdomain( 'twentytwentyone', get_template_directory() . '/languages' );
[35] Fix | Delete
[36] Fix | Delete
// Add default posts and comments RSS feed links to head.
[37] Fix | Delete
add_theme_support( 'automatic-feed-links' );
[38] Fix | Delete
[39] Fix | Delete
/*
[40] Fix | Delete
* Let WordPress manage the document title.
[41] Fix | Delete
* This theme does not use a hard-coded <title> tag in the document head,
[42] Fix | Delete
* WordPress will provide it for us.
[43] Fix | Delete
*/
[44] Fix | Delete
add_theme_support( 'title-tag' );
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Add post-formats support.
[48] Fix | Delete
*/
[49] Fix | Delete
add_theme_support(
[50] Fix | Delete
'post-formats',
[51] Fix | Delete
array(
[52] Fix | Delete
'link',
[53] Fix | Delete
'aside',
[54] Fix | Delete
'gallery',
[55] Fix | Delete
'image',
[56] Fix | Delete
'quote',
[57] Fix | Delete
'status',
[58] Fix | Delete
'video',
[59] Fix | Delete
'audio',
[60] Fix | Delete
'chat',
[61] Fix | Delete
)
[62] Fix | Delete
);
[63] Fix | Delete
[64] Fix | Delete
/*
[65] Fix | Delete
* Enable support for Post Thumbnails on posts and pages.
[66] Fix | Delete
*
[67] Fix | Delete
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
[68] Fix | Delete
*/
[69] Fix | Delete
add_theme_support( 'post-thumbnails' );
[70] Fix | Delete
set_post_thumbnail_size( 1568, 9999 );
[71] Fix | Delete
[72] Fix | Delete
register_nav_menus(
[73] Fix | Delete
array(
[74] Fix | Delete
'primary' => esc_html__( 'Primary menu', 'twentytwentyone' ),
[75] Fix | Delete
'footer' => __( 'Secondary menu', 'twentytwentyone' ),
[76] Fix | Delete
)
[77] Fix | Delete
);
[78] Fix | Delete
[79] Fix | Delete
/*
[80] Fix | Delete
* Switch default core markup for search form, comment form, and comments
[81] Fix | Delete
* to output valid HTML5.
[82] Fix | Delete
*/
[83] Fix | Delete
add_theme_support(
[84] Fix | Delete
'html5',
[85] Fix | Delete
array(
[86] Fix | Delete
'comment-form',
[87] Fix | Delete
'comment-list',
[88] Fix | Delete
'gallery',
[89] Fix | Delete
'caption',
[90] Fix | Delete
'style',
[91] Fix | Delete
'script',
[92] Fix | Delete
'navigation-widgets',
[93] Fix | Delete
)
[94] Fix | Delete
);
[95] Fix | Delete
[96] Fix | Delete
/**
[97] Fix | Delete
* Add support for core custom logo.
[98] Fix | Delete
*
[99] Fix | Delete
* @link https://codex.wordpress.org/Theme_Logo
[100] Fix | Delete
*/
[101] Fix | Delete
$logo_width = 300;
[102] Fix | Delete
$logo_height = 100;
[103] Fix | Delete
[104] Fix | Delete
add_theme_support(
[105] Fix | Delete
'custom-logo',
[106] Fix | Delete
array(
[107] Fix | Delete
'height' => $logo_height,
[108] Fix | Delete
'width' => $logo_width,
[109] Fix | Delete
'flex-width' => true,
[110] Fix | Delete
'flex-height' => true,
[111] Fix | Delete
'unlink-homepage-logo' => true,
[112] Fix | Delete
)
[113] Fix | Delete
);
[114] Fix | Delete
[115] Fix | Delete
// Add theme support for selective refresh for widgets.
[116] Fix | Delete
add_theme_support( 'customize-selective-refresh-widgets' );
[117] Fix | Delete
[118] Fix | Delete
// Add support for Block Styles.
[119] Fix | Delete
add_theme_support( 'wp-block-styles' );
[120] Fix | Delete
[121] Fix | Delete
// Add support for full and wide align images.
[122] Fix | Delete
add_theme_support( 'align-wide' );
[123] Fix | Delete
[124] Fix | Delete
// Add support for editor styles.
[125] Fix | Delete
add_theme_support( 'editor-styles' );
[126] Fix | Delete
$background_color = get_theme_mod( 'background_color', 'D1E4DD' );
[127] Fix | Delete
if ( 127 > Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( $background_color ) ) {
[128] Fix | Delete
add_theme_support( 'dark-editor-style' );
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
$editor_stylesheet_path = './assets/css/style-editor.css';
[132] Fix | Delete
[133] Fix | Delete
// Note, the is_IE global variable is defined by WordPress and is used
[134] Fix | Delete
// to detect if the current browser is internet explorer.
[135] Fix | Delete
global $is_IE;
[136] Fix | Delete
if ( $is_IE ) {
[137] Fix | Delete
$editor_stylesheet_path = './assets/css/ie-editor.css';
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
// Enqueue editor styles.
[141] Fix | Delete
add_editor_style( $editor_stylesheet_path );
[142] Fix | Delete
[143] Fix | Delete
// Add custom editor font sizes.
[144] Fix | Delete
add_theme_support(
[145] Fix | Delete
'editor-font-sizes',
[146] Fix | Delete
array(
[147] Fix | Delete
array(
[148] Fix | Delete
'name' => esc_html__( 'Extra small', 'twentytwentyone' ),
[149] Fix | Delete
'shortName' => esc_html_x( 'XS', 'Font size', 'twentytwentyone' ),
[150] Fix | Delete
'size' => 16,
[151] Fix | Delete
'slug' => 'extra-small',
[152] Fix | Delete
),
[153] Fix | Delete
array(
[154] Fix | Delete
'name' => esc_html__( 'Small', 'twentytwentyone' ),
[155] Fix | Delete
'shortName' => esc_html_x( 'S', 'Font size', 'twentytwentyone' ),
[156] Fix | Delete
'size' => 18,
[157] Fix | Delete
'slug' => 'small',
[158] Fix | Delete
),
[159] Fix | Delete
array(
[160] Fix | Delete
'name' => esc_html__( 'Normal', 'twentytwentyone' ),
[161] Fix | Delete
'shortName' => esc_html_x( 'M', 'Font size', 'twentytwentyone' ),
[162] Fix | Delete
'size' => 20,
[163] Fix | Delete
'slug' => 'normal',
[164] Fix | Delete
),
[165] Fix | Delete
array(
[166] Fix | Delete
'name' => esc_html__( 'Large', 'twentytwentyone' ),
[167] Fix | Delete
'shortName' => esc_html_x( 'L', 'Font size', 'twentytwentyone' ),
[168] Fix | Delete
'size' => 24,
[169] Fix | Delete
'slug' => 'large',
[170] Fix | Delete
),
[171] Fix | Delete
array(
[172] Fix | Delete
'name' => esc_html__( 'Extra large', 'twentytwentyone' ),
[173] Fix | Delete
'shortName' => esc_html_x( 'XL', 'Font size', 'twentytwentyone' ),
[174] Fix | Delete
'size' => 40,
[175] Fix | Delete
'slug' => 'extra-large',
[176] Fix | Delete
),
[177] Fix | Delete
array(
[178] Fix | Delete
'name' => esc_html__( 'Huge', 'twentytwentyone' ),
[179] Fix | Delete
'shortName' => esc_html_x( 'XXL', 'Font size', 'twentytwentyone' ),
[180] Fix | Delete
'size' => 96,
[181] Fix | Delete
'slug' => 'huge',
[182] Fix | Delete
),
[183] Fix | Delete
array(
[184] Fix | Delete
'name' => esc_html__( 'Gigantic', 'twentytwentyone' ),
[185] Fix | Delete
'shortName' => esc_html_x( 'XXXL', 'Font size', 'twentytwentyone' ),
[186] Fix | Delete
'size' => 144,
[187] Fix | Delete
'slug' => 'gigantic',
[188] Fix | Delete
),
[189] Fix | Delete
)
[190] Fix | Delete
);
[191] Fix | Delete
[192] Fix | Delete
// Custom background color.
[193] Fix | Delete
add_theme_support(
[194] Fix | Delete
'custom-background',
[195] Fix | Delete
array(
[196] Fix | Delete
'default-color' => 'd1e4dd',
[197] Fix | Delete
)
[198] Fix | Delete
);
[199] Fix | Delete
[200] Fix | Delete
// Editor color palette.
[201] Fix | Delete
$black = '#000000';
[202] Fix | Delete
$dark_gray = '#28303D';
[203] Fix | Delete
$gray = '#39414D';
[204] Fix | Delete
$green = '#D1E4DD';
[205] Fix | Delete
$blue = '#D1DFE4';
[206] Fix | Delete
$purple = '#D1D1E4';
[207] Fix | Delete
$red = '#E4D1D1';
[208] Fix | Delete
$orange = '#E4DAD1';
[209] Fix | Delete
$yellow = '#EEEADD';
[210] Fix | Delete
$white = '#FFFFFF';
[211] Fix | Delete
[212] Fix | Delete
add_theme_support(
[213] Fix | Delete
'editor-color-palette',
[214] Fix | Delete
array(
[215] Fix | Delete
array(
[216] Fix | Delete
'name' => esc_html__( 'Black', 'twentytwentyone' ),
[217] Fix | Delete
'slug' => 'black',
[218] Fix | Delete
'color' => $black,
[219] Fix | Delete
),
[220] Fix | Delete
array(
[221] Fix | Delete
'name' => esc_html__( 'Dark gray', 'twentytwentyone' ),
[222] Fix | Delete
'slug' => 'dark-gray',
[223] Fix | Delete
'color' => $dark_gray,
[224] Fix | Delete
),
[225] Fix | Delete
array(
[226] Fix | Delete
'name' => esc_html__( 'Gray', 'twentytwentyone' ),
[227] Fix | Delete
'slug' => 'gray',
[228] Fix | Delete
'color' => $gray,
[229] Fix | Delete
),
[230] Fix | Delete
array(
[231] Fix | Delete
'name' => esc_html__( 'Green', 'twentytwentyone' ),
[232] Fix | Delete
'slug' => 'green',
[233] Fix | Delete
'color' => $green,
[234] Fix | Delete
),
[235] Fix | Delete
array(
[236] Fix | Delete
'name' => esc_html__( 'Blue', 'twentytwentyone' ),
[237] Fix | Delete
'slug' => 'blue',
[238] Fix | Delete
'color' => $blue,
[239] Fix | Delete
),
[240] Fix | Delete
array(
[241] Fix | Delete
'name' => esc_html__( 'Purple', 'twentytwentyone' ),
[242] Fix | Delete
'slug' => 'purple',
[243] Fix | Delete
'color' => $purple,
[244] Fix | Delete
),
[245] Fix | Delete
array(
[246] Fix | Delete
'name' => esc_html__( 'Red', 'twentytwentyone' ),
[247] Fix | Delete
'slug' => 'red',
[248] Fix | Delete
'color' => $red,
[249] Fix | Delete
),
[250] Fix | Delete
array(
[251] Fix | Delete
'name' => esc_html__( 'Orange', 'twentytwentyone' ),
[252] Fix | Delete
'slug' => 'orange',
[253] Fix | Delete
'color' => $orange,
[254] Fix | Delete
),
[255] Fix | Delete
array(
[256] Fix | Delete
'name' => esc_html__( 'Yellow', 'twentytwentyone' ),
[257] Fix | Delete
'slug' => 'yellow',
[258] Fix | Delete
'color' => $yellow,
[259] Fix | Delete
),
[260] Fix | Delete
array(
[261] Fix | Delete
'name' => esc_html__( 'White', 'twentytwentyone' ),
[262] Fix | Delete
'slug' => 'white',
[263] Fix | Delete
'color' => $white,
[264] Fix | Delete
),
[265] Fix | Delete
)
[266] Fix | Delete
);
[267] Fix | Delete
[268] Fix | Delete
add_theme_support(
[269] Fix | Delete
'editor-gradient-presets',
[270] Fix | Delete
array(
[271] Fix | Delete
array(
[272] Fix | Delete
'name' => esc_html__( 'Purple to yellow', 'twentytwentyone' ),
[273] Fix | Delete
'gradient' => 'linear-gradient(160deg, ' . $purple . ' 0%, ' . $yellow . ' 100%)',
[274] Fix | Delete
'slug' => 'purple-to-yellow',
[275] Fix | Delete
),
[276] Fix | Delete
array(
[277] Fix | Delete
'name' => esc_html__( 'Yellow to purple', 'twentytwentyone' ),
[278] Fix | Delete
'gradient' => 'linear-gradient(160deg, ' . $yellow . ' 0%, ' . $purple . ' 100%)',
[279] Fix | Delete
'slug' => 'yellow-to-purple',
[280] Fix | Delete
),
[281] Fix | Delete
array(
[282] Fix | Delete
'name' => esc_html__( 'Green to yellow', 'twentytwentyone' ),
[283] Fix | Delete
'gradient' => 'linear-gradient(160deg, ' . $green . ' 0%, ' . $yellow . ' 100%)',
[284] Fix | Delete
'slug' => 'green-to-yellow',
[285] Fix | Delete
),
[286] Fix | Delete
array(
[287] Fix | Delete
'name' => esc_html__( 'Yellow to green', 'twentytwentyone' ),
[288] Fix | Delete
'gradient' => 'linear-gradient(160deg, ' . $yellow . ' 0%, ' . $green . ' 100%)',
[289] Fix | Delete
'slug' => 'yellow-to-green',
[290] Fix | Delete
),
[291] Fix | Delete
array(
[292] Fix | Delete
'name' => esc_html__( 'Red to yellow', 'twentytwentyone' ),
[293] Fix | Delete
'gradient' => 'linear-gradient(160deg, ' . $red . ' 0%, ' . $yellow . ' 100%)',
[294] Fix | Delete
'slug' => 'red-to-yellow',
[295] Fix | Delete
),
[296] Fix | Delete
array(
[297] Fix | Delete
'name' => esc_html__( 'Yellow to red', 'twentytwentyone' ),
[298] Fix | Delete
'gradient' => 'linear-gradient(160deg, ' . $yellow . ' 0%, ' . $red . ' 100%)',
[299] Fix | Delete
'slug' => 'yellow-to-red',
[300] Fix | Delete
),
[301] Fix | Delete
array(
[302] Fix | Delete
'name' => esc_html__( 'Purple to red', 'twentytwentyone' ),
[303] Fix | Delete
'gradient' => 'linear-gradient(160deg, ' . $purple . ' 0%, ' . $red . ' 100%)',
[304] Fix | Delete
'slug' => 'purple-to-red',
[305] Fix | Delete
),
[306] Fix | Delete
array(
[307] Fix | Delete
'name' => esc_html__( 'Red to purple', 'twentytwentyone' ),
[308] Fix | Delete
'gradient' => 'linear-gradient(160deg, ' . $red . ' 0%, ' . $purple . ' 100%)',
[309] Fix | Delete
'slug' => 'red-to-purple',
[310] Fix | Delete
),
[311] Fix | Delete
)
[312] Fix | Delete
);
[313] Fix | Delete
[314] Fix | Delete
/*
[315] Fix | Delete
* Adds starter content to highlight the theme on fresh sites.
[316] Fix | Delete
* This is done conditionally to avoid loading the starter content on every
[317] Fix | Delete
* page load, as it is a one-off operation only needed once in the customizer.
[318] Fix | Delete
*/
[319] Fix | Delete
if ( is_customize_preview() ) {
[320] Fix | Delete
require get_template_directory() . '/inc/starter-content.php';
[321] Fix | Delete
add_theme_support( 'starter-content', twenty_twenty_one_get_starter_content() );
[322] Fix | Delete
}
[323] Fix | Delete
[324] Fix | Delete
// Add support for responsive embedded content.
[325] Fix | Delete
add_theme_support( 'responsive-embeds' );
[326] Fix | Delete
[327] Fix | Delete
// Add support for custom line height controls.
[328] Fix | Delete
add_theme_support( 'custom-line-height' );
[329] Fix | Delete
[330] Fix | Delete
// Add support for experimental link color control.
[331] Fix | Delete
add_theme_support( 'experimental-link-color' );
[332] Fix | Delete
[333] Fix | Delete
// Add support for experimental cover block spacing.
[334] Fix | Delete
add_theme_support( 'custom-spacing' );
[335] Fix | Delete
[336] Fix | Delete
// Add support for custom units.
[337] Fix | Delete
// This was removed in WordPress 5.6 but is still required to properly support WP 5.5.
[338] Fix | Delete
add_theme_support( 'custom-units' );
[339] Fix | Delete
}
[340] Fix | Delete
}
[341] Fix | Delete
add_action( 'after_setup_theme', 'twenty_twenty_one_setup' );
[342] Fix | Delete
[343] Fix | Delete
/**
[344] Fix | Delete
* Register widget area.
[345] Fix | Delete
*
[346] Fix | Delete
* @since Twenty Twenty-One 1.0
[347] Fix | Delete
*
[348] Fix | Delete
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
[349] Fix | Delete
*
[350] Fix | Delete
* @return void
[351] Fix | Delete
*/
[352] Fix | Delete
function twenty_twenty_one_widgets_init() {
[353] Fix | Delete
[354] Fix | Delete
register_sidebar(
[355] Fix | Delete
array(
[356] Fix | Delete
'name' => esc_html__( 'Footer', 'twentytwentyone' ),
[357] Fix | Delete
'id' => 'sidebar-1',
[358] Fix | Delete
'description' => esc_html__( 'Add widgets here to appear in your footer.', 'twentytwentyone' ),
[359] Fix | Delete
'before_widget' => '<section id="%1$s" class="widget %2$s">',
[360] Fix | Delete
'after_widget' => '</section>',
[361] Fix | Delete
'before_title' => '<h2 class="widget-title">',
[362] Fix | Delete
'after_title' => '</h2>',
[363] Fix | Delete
)
[364] Fix | Delete
);
[365] Fix | Delete
}
[366] Fix | Delete
add_action( 'widgets_init', 'twenty_twenty_one_widgets_init' );
[367] Fix | Delete
[368] Fix | Delete
/**
[369] Fix | Delete
* Set the content width in pixels, based on the theme's design and stylesheet.
[370] Fix | Delete
*
[371] Fix | Delete
* Priority 0 to make it available to lower priority callbacks.
[372] Fix | Delete
*
[373] Fix | Delete
* @since Twenty Twenty-One 1.0
[374] Fix | Delete
*
[375] Fix | Delete
* @global int $content_width Content width.
[376] Fix | Delete
*
[377] Fix | Delete
* @return void
[378] Fix | Delete
*/
[379] Fix | Delete
function twenty_twenty_one_content_width() {
[380] Fix | Delete
// This variable is intended to be overruled from themes.
[381] Fix | Delete
// Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}.
[382] Fix | Delete
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
[383] Fix | Delete
$GLOBALS['content_width'] = apply_filters( 'twenty_twenty_one_content_width', 750 );
[384] Fix | Delete
}
[385] Fix | Delete
add_action( 'after_setup_theme', 'twenty_twenty_one_content_width', 0 );
[386] Fix | Delete
[387] Fix | Delete
/**
[388] Fix | Delete
* Enqueue scripts and styles.
[389] Fix | Delete
*
[390] Fix | Delete
* @since Twenty Twenty-One 1.0
[391] Fix | Delete
*
[392] Fix | Delete
* @return void
[393] Fix | Delete
*/
[394] Fix | Delete
function twenty_twenty_one_scripts() {
[395] Fix | Delete
// Note, the is_IE global variable is defined by WordPress and is used
[396] Fix | Delete
// to detect if the current browser is internet explorer.
[397] Fix | Delete
global $is_IE, $wp_scripts;
[398] Fix | Delete
if ( $is_IE ) {
[399] Fix | Delete
// If IE 11 or below, use a flattened stylesheet with static values replacing CSS Variables.
[400] Fix | Delete
wp_enqueue_style( 'twenty-twenty-one-style', get_template_directory_uri() . '/assets/css/ie.css', array(), wp_get_theme()->get( 'Version' ) );
[401] Fix | Delete
} else {
[402] Fix | Delete
// If not IE, use the standard stylesheet.
[403] Fix | Delete
wp_enqueue_style( 'twenty-twenty-one-style', get_template_directory_uri() . '/style.css', array(), wp_get_theme()->get( 'Version' ) );
[404] Fix | Delete
}
[405] Fix | Delete
[406] Fix | Delete
// RTL styles.
[407] Fix | Delete
wp_style_add_data( 'twenty-twenty-one-style', 'rtl', 'replace' );
[408] Fix | Delete
[409] Fix | Delete
// Print styles.
[410] Fix | Delete
wp_enqueue_style( 'twenty-twenty-one-print-style', get_template_directory_uri() . '/assets/css/print.css', array(), wp_get_theme()->get( 'Version' ), 'print' );
[411] Fix | Delete
[412] Fix | Delete
// Threaded comment reply styles.
[413] Fix | Delete
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
[414] Fix | Delete
wp_enqueue_script( 'comment-reply' );
[415] Fix | Delete
}
[416] Fix | Delete
[417] Fix | Delete
// Register the IE11 polyfill file.
[418] Fix | Delete
wp_register_script(
[419] Fix | Delete
'twenty-twenty-one-ie11-polyfills-asset',
[420] Fix | Delete
get_template_directory_uri() . '/assets/js/polyfills.js',
[421] Fix | Delete
array(),
[422] Fix | Delete
wp_get_theme()->get( 'Version' ),
[423] Fix | Delete
true
[424] Fix | Delete
);
[425] Fix | Delete
[426] Fix | Delete
// Register the IE11 polyfill loader.
[427] Fix | Delete
wp_register_script(
[428] Fix | Delete
'twenty-twenty-one-ie11-polyfills',
[429] Fix | Delete
null,
[430] Fix | Delete
array(),
[431] Fix | Delete
wp_get_theme()->get( 'Version' ),
[432] Fix | Delete
true
[433] Fix | Delete
);
[434] Fix | Delete
wp_add_inline_script(
[435] Fix | Delete
'twenty-twenty-one-ie11-polyfills',
[436] Fix | Delete
wp_get_script_polyfill(
[437] Fix | Delete
$wp_scripts,
[438] Fix | Delete
array(
[439] Fix | Delete
'Element.prototype.matches && Element.prototype.closest && window.NodeList && NodeList.prototype.forEach' => 'twenty-twenty-one-ie11-polyfills-asset',
[440] Fix | Delete
)
[441] Fix | Delete
)
[442] Fix | Delete
);
[443] Fix | Delete
[444] Fix | Delete
// Main navigation scripts.
[445] Fix | Delete
if ( has_nav_menu( 'primary' ) ) {
[446] Fix | Delete
wp_enqueue_script(
[447] Fix | Delete
'twenty-twenty-one-primary-navigation-script',
[448] Fix | Delete
get_template_directory_uri() . '/assets/js/primary-navigation.js',
[449] Fix | Delete
array( 'twenty-twenty-one-ie11-polyfills' ),
[450] Fix | Delete
wp_get_theme()->get( 'Version' ),
[451] Fix | Delete
true
[452] Fix | Delete
);
[453] Fix | Delete
}
[454] Fix | Delete
[455] Fix | Delete
// Responsive embeds script.
[456] Fix | Delete
wp_enqueue_script(
[457] Fix | Delete
'twenty-twenty-one-responsive-embeds-script',
[458] Fix | Delete
get_template_directory_uri() . '/assets/js/responsive-embeds.js',
[459] Fix | Delete
array( 'twenty-twenty-one-ie11-polyfills' ),
[460] Fix | Delete
wp_get_theme()->get( 'Version' ),
[461] Fix | Delete
true
[462] Fix | Delete
);
[463] Fix | Delete
}
[464] Fix | Delete
add_action( 'wp_enqueue_scripts', 'twenty_twenty_one_scripts' );
[465] Fix | Delete
[466] Fix | Delete
/**
[467] Fix | Delete
* Enqueue block editor script.
[468] Fix | Delete
*
[469] Fix | Delete
* @since Twenty Twenty-One 1.0
[470] Fix | Delete
*
[471] Fix | Delete
* @return void
[472] Fix | Delete
*/
[473] Fix | Delete
function twentytwentyone_block_editor_script() {
[474] Fix | Delete
[475] Fix | Delete
wp_enqueue_script( 'twentytwentyone-editor', get_theme_file_uri( '/assets/js/editor.js' ), array( 'wp-blocks', 'wp-dom' ), wp_get_theme()->get( 'Version' ), true );
[476] Fix | Delete
}
[477] Fix | Delete
[478] Fix | Delete
add_action( 'enqueue_block_editor_assets', 'twentytwentyone_block_editor_script' );
[479] Fix | Delete
[480] Fix | Delete
/**
[481] Fix | Delete
* Fix skip link focus in IE11.
[482] Fix | Delete
*
[483] Fix | Delete
* This does not enqueue the script because it is tiny and because it is only for IE11,
[484] Fix | Delete
* thus it does not warrant having an entire dedicated blocking script being loaded.
[485] Fix | Delete
*
[486] Fix | Delete
* @link https://git.io/vWdr2
[487] Fix | Delete
*/
[488] Fix | Delete
function twenty_twenty_one_skip_link_focus_fix() {
[489] Fix | Delete
[490] Fix | Delete
// If SCRIPT_DEBUG is defined and true, print the unminified file.
[491] Fix | Delete
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
[492] Fix | Delete
echo '<script>';
[493] Fix | Delete
include get_template_directory() . '/assets/js/skip-link-focus-fix.js';
[494] Fix | Delete
echo '</script>';
[495] Fix | Delete
}
[496] Fix | Delete
[497] Fix | Delete
// The following is minified via `npx terser --compress --mangle -- assets/js/skip-link-focus-fix.js`.
[498] Fix | Delete
?>
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function