Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /proc/thread-self/cwd/wp-content/themes/twentytwenty/classes/ |
Upload File : |
<?php
/**
* JavaScript Loader Class
*
* Allow `async` and `defer` while enqueuing JavaScript.
*
* Based on a solution in WP Rig.
*
* @package WordPress
* @subpackage Twenty_Twenty
* @since Twenty Twenty 1.0
*/
if ( ! class_exists( 'TwentyTwenty_Script_Loader' ) ) {
/**
* A class that provides a way to add `async` or `defer` attributes to scripts.
*
* @since Twenty Twenty 1.0
*/
class TwentyTwenty_Script_Loader {
/**
* Migrates legacy async/defer script data which might be used by child themes.
*
* This method is used on the `print_scripts_array` filter.
*
* @since Twenty Twenty 2.0
*
* @param string[] $to_do An array of script dependency handles.
* @return string[] Unchanged array of script dependency handles.
*/
public function migrate_legacy_strategy_script_data( $to_do ) {
foreach ( $to_do as $handle ) {
foreach ( array( 'async', 'defer' ) as $strategy ) {
if ( wp_scripts()->get_data( $handle, $strategy ) ) {
wp_script_add_data( $handle, 'strategy', $strategy );
}
}
}
return $to_do;
}
/**
* Adds async/defer attributes to enqueued / registered scripts.
*
* Now that #12009 has landed in WordPress 6.3, this method is only used for older versions of WordPress.
* This method is used on the `script_loader_tag` filter.
*
* @since Twenty Twenty 1.0
*
* @link https://core.trac.wordpress.org/ticket/12009
*
* @param string $tag The script tag.
* @param string $handle The script handle.
* @return string Script HTML string.
*/
public function filter_script_loader_tag( $tag, $handle ) {
$strategies = array(
'async' => (bool) wp_scripts()->get_data( $handle, 'async' ),
'defer' => (bool) wp_scripts()->get_data( $handle, 'defer' ),
);
$strategy = wp_scripts()->get_data( $handle, 'strategy' );
if ( $strategy && isset( $strategies[ $strategy ] ) ) {
$strategies[ $strategy ] = true;
}
foreach ( array_keys( array_filter( $strategies ) ) as $attr ) {
// Prevent adding attribute when already added in #12009.
if ( ! preg_match( ":\s$attr(=|>|\s):", $tag ) ) {
$tag = preg_replace( ':(?=></script>):', " $attr", $tag, 1 );
}
// Only allow async or defer, not both.
break;
}
return $tag;
}
}
}