Skip to content

Commit 6152845

Browse files
committed
Update WP Admin hooks registration for 6.7
WordPress 6.7 deprecates one of these hooks and does not register it. This causes the condition to pass and the deprecated hook to be registered. Add a condition to compare the WordPress version against 6.6.
1 parent 9941965 commit 6152845

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

html-api-debugger/html-api-debugger.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,17 @@ function init() {
3232
}
3333
$done = true;
3434

35-
// WP 6.5 doesn't support script modules or Interactivity API in wp-admin.
36-
if ( ! has_action( 'admin_print_footer_scripts', array( wp_script_modules(), 'print_import_map' ) ) ) {
37-
add_action( 'admin_print_footer_scripts', array( wp_script_modules(), 'print_import_map' ) );
38-
add_action( 'admin_print_footer_scripts', array( wp_script_modules(), 'print_enqueued_script_modules' ) );
39-
add_action( 'admin_print_footer_scripts', array( wp_script_modules(), 'print_script_module_preloads' ) );
40-
}
41-
if ( ! has_action( 'admin_enqueue_scripts', array( wp_interactivity(), 'register_script_modules' ) ) ) {
42-
add_action( 'admin_enqueue_scripts', array( wp_interactivity(), 'register_script_modules' ) );
43-
add_action( 'admin_print_footer_scripts', array( wp_interactivity(), 'print_client_interactivity_data' ) );
35+
// WP < 6.6 doesn't support script modules or Interactivity API in wp-admin.
36+
if ( version_compare( get_bloginfo( 'version' ), '6.6', '<' ) ) {
37+
if ( ! has_action( 'admin_print_footer_scripts', array( wp_script_modules(), 'print_import_map' ) ) ) {
38+
add_action( 'admin_print_footer_scripts', array( wp_script_modules(), 'print_import_map' ) );
39+
add_action( 'admin_print_footer_scripts', array( wp_script_modules(), 'print_enqueued_script_modules' ) );
40+
add_action( 'admin_print_footer_scripts', array( wp_script_modules(), 'print_script_module_preloads' ) );
41+
}
42+
if ( ! has_action( 'admin_enqueue_scripts', array( wp_interactivity(), 'register_script_modules' ) ) ) {
43+
add_action( 'admin_enqueue_scripts', array( wp_interactivity(), 'register_script_modules' ) );
44+
add_action( 'admin_print_footer_scripts', array( wp_interactivity(), 'print_client_interactivity_data' ) );
45+
}
4446
}
4547

4648
add_action(

html-api-debugger/readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,4 @@ Add a page to wp-admin for debugging the HTML API.
8383

8484
= 1.7 =
8585
* Update DOM tree when HTML document is mutated.
86+
* Fix deprecation notice on WordPress 6.7.

0 commit comments

Comments
 (0)