From 2cb67d20995f19136e7b1280ec95da1b67314002 Mon Sep 17 00:00:00 2001 From: Clayton Collie Date: Mon, 17 Feb 2025 12:49:51 +0100 Subject: [PATCH 1/3] Remove the script loader tag filter --- mu-plugins/10up-plugin/src/Assets.php | 38 --------------------------- 1 file changed, 38 deletions(-) diff --git a/mu-plugins/10up-plugin/src/Assets.php b/mu-plugins/10up-plugin/src/Assets.php index e33db69..0bd9473 100644 --- a/mu-plugins/10up-plugin/src/Assets.php +++ b/mu-plugins/10up-plugin/src/Assets.php @@ -43,8 +43,6 @@ public function register() { // Editor styles. add_editor_style() doesn't work outside of a theme. add_filter( 'mce_css', [ $this, 'mce_css' ] ); - // Hook to allow async or defer on asset loading. - add_filter( 'script_loader_tag', [ $this, 'script_loader_tag' ], 10, 2 ); } /** @@ -209,40 +207,4 @@ public function mce_css( $stylesheets ) { 'assets/css/frontend/editor-style.css' : 'dist/css/editor-style.min.css' ); } - - /** - * Add async/defer attributes to enqueued scripts that have the specified script_execution flag. - * - * @link https://core.trac.wordpress.org/ticket/12009 - * - * @param string $tag The script tag. - * @param string $handle The script handle. - * - * @return string|null - */ - public function script_loader_tag( $tag, $handle ) { - $script_execution = wp_scripts()->get_data( $handle, 'script_execution' ); - - if ( ! $script_execution ) { - return $tag; - } - - if ( 'async' !== $script_execution && 'defer' !== $script_execution ) { - return $tag; - } - - // Abort adding async/defer for scripts that have this script as a dependency. _doing_it_wrong()? - foreach ( wp_scripts()->registered as $script ) { - if ( in_array( $handle, $script->deps, true ) ) { - return $tag; - } - } - - // Add the attribute if it hasn't already been added. - if ( ! preg_match( ":\s$script_execution(=|>|\s):", $tag ) ) { - $tag = preg_replace( ':(?=>):', " $script_execution", $tag, 1 ); - } - - return $tag; - } } From c39cfb33dfb5ec46b8271b8f94c7a778e91fb4bb Mon Sep 17 00:00:00 2001 From: Clayton Collie Date: Wed, 19 Feb 2025 13:58:45 +0100 Subject: [PATCH 2/3] Remove script loader from standard theme --- themes/10up-theme/src/Assets.php | 36 -------------------------------- 1 file changed, 36 deletions(-) diff --git a/themes/10up-theme/src/Assets.php b/themes/10up-theme/src/Assets.php index 1a2cbaa..e9064e3 100644 --- a/themes/10up-theme/src/Assets.php +++ b/themes/10up-theme/src/Assets.php @@ -43,8 +43,6 @@ public function register() { add_action( 'wp_enqueue_scripts', [ $this, 'styles' ] ); add_action( 'wp_head', [ $this, 'js_detection' ], 0 ); add_action( 'wp_head', [ $this, 'embed_ct_css' ], 0 ); - - add_filter( 'script_loader_tag', [ $this, 'script_loader_tag' ], 10, 2 ); } @@ -173,40 +171,6 @@ public function js_detection() { echo "\n"; } - /** - * Add async/defer attributes to enqueued scripts that have the specified script_execution flag. - * - * @link https://core.trac.wordpress.org/ticket/12009 - * @param string $tag The script tag. - * @param string $handle The script handle. - * @return string|null - */ - public function script_loader_tag( $tag, $handle ) { - $script_execution = wp_scripts()->get_data( $handle, 'script_execution' ); - - if ( ! $script_execution ) { - return $tag; - } - - if ( 'async' !== $script_execution && 'defer' !== $script_execution ) { - return $tag; - } - - // Abort adding async/defer for scripts that have this script as a dependency. _doing_it_wrong()? - foreach ( wp_scripts()->registered as $script ) { - if ( in_array( $handle, $script->deps, true ) ) { - return $tag; - } - } - - // Add the attribute if it hasn't already been added. - if ( ! preg_match( ":\s$script_execution(=|>|\s):", $tag ) ) { - $tag = preg_replace( ':(?=>):', " $script_execution", $tag, 1 ); - } - - return $tag; - } - /** * Inlines ct.css in the head * From f8ca14cdd33617751554a31812575b253ef3526c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20K=C3=A4gy?= Date: Wed, 26 Feb 2025 12:52:26 +0100 Subject: [PATCH 3/3] Fix includes directory path --- themes/10up-block-theme/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/10up-block-theme/functions.php b/themes/10up-block-theme/functions.php index c80db34..50269e3 100755 --- a/themes/10up-block-theme/functions.php +++ b/themes/10up-block-theme/functions.php @@ -11,7 +11,7 @@ define( 'TENUP_BLOCK_THEME_PATH', get_template_directory() . '/' ); define( 'TENUP_BLOCK_THEME_DIST_PATH', TENUP_BLOCK_THEME_PATH . 'dist/' ); define( 'TENUP_BLOCK_THEME_DIST_URL', TENUP_BLOCK_THEME_TEMPLATE_URL . '/dist/' ); -define( 'TENUP_BLOCK_THEME_INC', TENUP_BLOCK_THEME_PATH . 'blocks/' ); +define( 'TENUP_BLOCK_THEME_INC', TENUP_BLOCK_THEME_PATH . 'src/' ); define( 'TENUP_BLOCK_THEME_BLOCK_DIST_DIR', TENUP_BLOCK_THEME_DIST_PATH . '/blocks/' ); // Require Composer autoloader if it exists.