Skip to content

Commit

Permalink
Rely on WP 6.5 functions instead of Gutenberg plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixarntz committed Mar 8, 2024
1 parent 3e603d7 commit 50adcfa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public function the_html( $attrs = array() ) {
);

// Extra attributes depending on whether or not the Interactivity API is being used.
if ( function_exists( 'gutenberg_register_module' ) ) {
if ( function_exists( 'wp_register_script_module' ) ) {
$defaults['data-wp-on--click'] = 'actions.toggleDarkMode';
$defaults['data-wp-bind--aria-pressed'] = 'state.isDarkMode';
$defaults['data-wp-class--hide'] = 'state.isDarkModeTogglerHidden';
Expand Down Expand Up @@ -376,7 +376,7 @@ public function the_html( $attrs = array() ) {
*/
public function the_script() {
// If the Interactivity API is being used, loading this JS code is not necessary.
if ( function_exists( 'gutenberg_register_module' ) ) {
if ( function_exists( 'wp_register_script_module' ) ) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions src/wp-content/themes/twentytwentyone/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,14 +443,14 @@ function twenty_twenty_one_scripts() {
);

// Use WordPress Interactivity API if available.
if ( function_exists( 'gutenberg_register_module' ) ) {
gutenberg_register_module(
if ( function_exists( 'wp_register_script_module' ) ) {
wp_register_script_module(
'@twentytwentyone/interactivity',
get_template_directory_uri() . '/assets/js/interactivity.js',
array( '@wordpress/interactivity' ),
wp_get_theme()->get( 'Version' )
);
gutenberg_enqueue_module( '@twentytwentyone/interactivity' );
wp_enqueue_script_module( '@twentytwentyone/interactivity' );
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function twenty_twenty_one_add_sub_menu_toggle( $output, $item, $depth, $args )
if ( 0 === $depth && in_array( 'menu-item-has-children', $item->classes, true ) ) {

// Extra attributes depending on whether or not the Interactivity API is being used.
if ( function_exists( 'gutenberg_register_module' ) ) {
if ( function_exists( 'wp_register_script_module' ) ) {
$extra_attr = '';
} else {
$extra_attr = ' onClick="twentytwentyoneExpandSubMenu(this)"';
Expand Down

0 comments on commit 50adcfa

Please sign in to comment.