Add ignores for already escaped output, Remove no longer used props passed to Drawer::render

This commit is contained in:
Sam Seay 2024-09-10 12:31:26 +08:00
parent 12c5fb2f88
commit 290401458b
No known key found for this signature in database
GPG Key ID: 2223711A9151668A
2 changed files with 11 additions and 3 deletions

View File

@ -467,6 +467,13 @@ class MiniCartInteractivity extends AbstractBlock {
<?php
}
/**
* Get the template part contents container.
*
* @param string $template_contents The template part contents.
*
* @return string
*/
protected function get_template_part_contents_container( $template_contents ) {
ob_start();
?>
@ -520,13 +527,15 @@ class MiniCartInteractivity extends AbstractBlock {
echo $this->render_mini_cart_button( $attributes, $cart_item_count, false );
?>
<?php
// Output is already escaped by Drawer::render.
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo Drawer::render(
array(
'is_initially_open' => false,
// Output is already escaped by Drawer::render_close_button.
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'children' => $close_button . $this->get_template_part_contents_container( $template_part_contents ),
// TODO - clean up this concept.
'is_open_context_property' => 'woocommerce/mini-cart-interactivity::context.drawerOpen',
'on_open' => 'woocommerce/mini-cart-interactivity::actions.renderMiniCart',
)
);
?>

View File

@ -19,7 +19,6 @@ class Drawer {
*/
public static function render( $props ) {
wp_enqueue_script( 'wc-interactivity-drawer' );
// wp_enqueue_style( 'wc-interactivity-drawer' );
$namespace = wp_json_encode( array( 'namespace' => 'woocommerce/interactivity-drawer' ), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP );
$context = array(