Skip to content

Commit

Permalink
Use wp_get_inline_script_tag() in build_dropdown_script_block_core_ca…
Browse files Browse the repository at this point in the history
…tegories() (#54637)
  • Loading branch information
westonruter committed Sep 21, 2023
1 parent 6f653f3 commit 883ac8e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/block-library/src/categories/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ function render_block_core_categories( $attributes ) {
function build_dropdown_script_block_core_categories( $dropdown_id ) {
ob_start();
?>
<script type='text/javascript'>
/* <![CDATA[ */
<script>
( function() {
var dropdown = document.getElementById( '<?php echo esc_js( $dropdown_id ); ?>' );
function onCatChange() {
Expand All @@ -81,10 +80,9 @@ function onCatChange() {
}
dropdown.onchange = onCatChange;
})();
/* ]]> */
</script>
<?php
return ob_get_clean();
return wp_get_inline_script_tag( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
}

/**
Expand Down

0 comments on commit 883ac8e

Please sign in to comment.