Skip to content

Commit f508f83

Browse files
Update regex to match click and async click wp directives
Co-authored-by: Weston Ruter <[email protected]>
1 parent 4b94713 commit f508f83

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

includes/embeds/class-amp-core-block-handler.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ static function ( $matches ) use ( $modal_state_property, $is_interactive_block
389389
// Replace `data-wp-on--click` or `data-wp-on-async--click` with AMP state on submenu open button.
390390
if ( false !== strpos( $new_block_content, 'wp-block-navigation__responsive-container-open' ) ) {
391391
$new_block_content = preg_replace(
392-
'/\sdata-wp-on-(?:-click|async--click)="[^"]+"/',
392+
'/\sdata-wp-on(?:-async)?--click="[^"]+"/',
393393
sprintf( ' on="tap:AMP.setState({ %1$s: !%1$s })"', esc_attr( $modal_state_property ) ),
394394
$new_block_content
395395
);
@@ -398,7 +398,7 @@ static function ( $matches ) use ( $modal_state_property, $is_interactive_block
398398
// Replace `data-wp-on--click` or `data-wp-on-async--click` with AMP state on submenu close button.
399399
if ( false !== strpos( $new_block_content, 'wp-block-navigation__responsive-container-close' ) ) {
400400
$new_block_content = preg_replace(
401-
'/\sdata-wp-on-(?:-click|async--click)="[^"]+"/',
401+
'/\sdata-wp-on(?:-async)?--click="[^"]+"/',
402402
sprintf( ' on="tap:AMP.setState({ %1$s: !%1$s })"', esc_attr( $modal_state_property ) ),
403403
$new_block_content
404404
);

0 commit comments

Comments
 (0)