From bc9cf9bcdb183216b6cf7df0856d1a3312db284a Mon Sep 17 00:00:00 2001 From: willpalahnuk <90785449+willpalahnuk@users.noreply.github.com> Date: Fri, 30 Jan 2026 17:57:59 -0600 Subject: [PATCH] Update script enqueueing for WordPress version 6.9 Backwards compatible for earlier versions, changes can be simplified if we only ever need to consider 6.9+ --- lib/class-enqueue.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/class-enqueue.php b/lib/class-enqueue.php index 722eb62..b9814e1 100644 --- a/lib/class-enqueue.php +++ b/lib/class-enqueue.php @@ -52,8 +52,13 @@ class Enqueue { if ( file_exists( $theme_dir . $js_path ) ) { $version = filemtime( $theme_dir . $js_path ); wp_enqueue_script( 'jquery' ); // Needed by downstream scripts; modules can't depend on classic scripts. - wp_enqueue_script_module( 'basicwp-theme', $theme_uri . $js_path, array(), $version, true ); - wp_enqueue_script_module( 'basicwp-button', $theme_uri . '/static/js/components/button.js', array( 'basicwp-theme' ), $version, true ); + if ( version_compare( get_bloginfo('version'), '6.9', '>=' ) ) { + wp_enqueue_script_module( 'basicwp-theme', $theme_uri . $js_path, array(), $version, [ 'in_footer' => true ] ); + wp_enqueue_script_module( 'basicwp-button', $theme_uri . '/static/js/components/button.js', array( 'basicwp-theme' ), $version, [ 'in_footer' => true ] ); + } else { + wp_enqueue_script_module( 'basicwp-theme', $theme_uri . $js_path, array(), $version, true ); + wp_enqueue_script_module( 'basicwp-button', $theme_uri . '/static/js/components/button.js', array( 'basicwp-theme' ), $version, true ); + } } } @@ -92,8 +97,13 @@ class Enqueue { if ( file_exists( $theme_dir . $admin_js_path ) ) { $version = filemtime( $theme_dir . $admin_js_path ); wp_enqueue_script( 'jquery' ); // Needed by downstream scripts; modules can't depend on classic scripts. - wp_enqueue_script_module( 'basicwp-admin', $theme_uri . $admin_js_path, array(), $version, true ); - wp_enqueue_script_module( 'basicwp-button', $theme_uri . '/static/js/components/button.js', array( 'basicwp-admin' ), $version, true ); + if ( version_compare( get_bloginfo('version'), '6.9', '>=' ) ) { + wp_enqueue_script_module( 'basicwp-admin', $theme_uri . $admin_js_path, array(), $version, [ 'in_footer' => true ] ); + wp_enqueue_script_module( 'basicwp-button', $theme_uri . '/static/js/components/button.js', array( 'basicwp-admin' ), $version, [ 'in_footer' => true ] ); + } else { + wp_enqueue_script_module( 'basicwp-admin', $theme_uri . $admin_js_path, array(), $version, true ); + wp_enqueue_script_module( 'basicwp-button', $theme_uri . '/static/js/components/button.js', array( 'basicwp-admin' ), $version, true ); + } } } }