Skip to content

Commit 697b540

Browse files
refactor: use wp_json_encode instead of json_encode
1 parent 04a1db8 commit 697b540

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/class-interaction.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public static function secure_interaction_data( $interaction_data ) {
9595
$action_value = $action['value'];
9696

9797
if ( $action_config->verify_integrity ) {
98-
$signature = hash_hmac( 'sha256', json_encode( $action_value ), interact_salt() );
98+
$signature = hash_hmac( 'sha256', wp_json_encode( $action_value ), interact_salt() );
9999

100100
// Add the signature to the data.
101101
$interaction_data['timelines'][ $timeline_index ]['actions'][ $action_index ]['signature'] = $signature;
@@ -141,7 +141,7 @@ public static function trash( $interaction_key ) {
141141
*/
142142
public function set_data( $interaction_data ) {
143143
$this->interaction_data = $interaction_data;
144-
$this->post->post_content = json_encode( $interaction_data );
144+
$this->post->post_content = wp_json_encode( $interaction_data );
145145
$this->post->post_name = $interaction_data['key'];
146146
$this->post->post_title = $interaction_data['title'];
147147
}
@@ -214,7 +214,7 @@ public function get_secure_timeline_actions() {
214214

215215
if ( ! empty( $action_config ) && $action_config->verify_integrity ) {
216216
$action_value = $action['value'];
217-
$signature = hash_hmac( 'sha256', json_encode( $action_value ), interact_salt() );
217+
$signature = hash_hmac( 'sha256', wp_json_encode( $action_value ), interact_salt() );
218218

219219
// If the signature is not valid, remove the action from the timeline.
220220
if ( ! hash_equals( $signature, $action['signature'] ) ) {

src/frontend/frontend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public function enqueue_frontend() {
137137
}
138138

139139
// Set the interactions.
140-
wp_add_inline_script( 'interact-frontend', 'InteractRunner.configure(' . json_encode( $animations ) . ');' );
140+
wp_add_inline_script( 'interact-frontend', 'InteractRunner.configure(' . wp_json_encode( $animations ) . ');' );
141141

142142
// Add the closing part of the InteractRunner check script
143143
wp_add_inline_script( 'interact-frontend',

0 commit comments

Comments
 (0)