Skip to content

Commit

Permalink
Update regex to match click and async click wp directives
Browse files Browse the repository at this point in the history
Co-authored-by: Weston Ruter <[email protected]>
  • Loading branch information
thelovekesh and westonruter authored Jun 24, 2024
1 parent 4b94713 commit f508f83
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions includes/embeds/class-amp-core-block-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ static function ( $matches ) use ( $modal_state_property, $is_interactive_block
// Replace `data-wp-on--click` or `data-wp-on-async--click` with AMP state on submenu open button.
if ( false !== strpos( $new_block_content, 'wp-block-navigation__responsive-container-open' ) ) {
$new_block_content = preg_replace(
'/\sdata-wp-on-(?:-click|async--click)="[^"]+"/',
'/\sdata-wp-on(?:-async)?--click="[^"]+"/',
sprintf( ' on="tap:AMP.setState({ %1$s: !%1$s })"', esc_attr( $modal_state_property ) ),
$new_block_content
);
Expand All @@ -398,7 +398,7 @@ static function ( $matches ) use ( $modal_state_property, $is_interactive_block
// Replace `data-wp-on--click` or `data-wp-on-async--click` with AMP state on submenu close button.
if ( false !== strpos( $new_block_content, 'wp-block-navigation__responsive-container-close' ) ) {
$new_block_content = preg_replace(
'/\sdata-wp-on-(?:-click|async--click)="[^"]+"/',
'/\sdata-wp-on(?:-async)?--click="[^"]+"/',
sprintf( ' on="tap:AMP.setState({ %1$s: !%1$s })"', esc_attr( $modal_state_property ) ),
$new_block_content
);
Expand Down

0 comments on commit f508f83

Please sign in to comment.