Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Move json_encode to Store's render method
Browse files Browse the repository at this point in the history
  • Loading branch information
DAreRodz committed Jun 22, 2023
1 parent 9a45fff commit e0a3e8d
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/Interactivity/class-wc-interactivity-store.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ static function merge_data( $data ) {
self::$store = array_replace_recursive( self::$store, $data );
}

/**
* Serialize store data to JSON.
*
* @return string|false Serialized JSON data.
*/
static function serialize() {
return wp_json_encode( self::$store );
}

/**
* Reset the store data.
*/
Expand All @@ -56,7 +47,10 @@ static function render() {
if ( empty( self::$store ) ) {
return;
}
$store = self::serialize();
echo "<script id=\"wc-interactivity-store-data\" type=\"application/json\">$store</script>";

echo sprintf(
'<script id="wc-interactivity-store-data" type="application/json">%s</script>',
wp_json_encode( self::$store )
);
}
}

0 comments on commit e0a3e8d

Please sign in to comment.