Skip to content

Commit

Permalink
use wp_json_encode() in favor of json_encode()
Browse files Browse the repository at this point in the history
  • Loading branch information
stklcode committed Nov 10, 2023
1 parent f0124ce commit 9a553e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inc/class-antivirus-safebrowsing.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function check_safe_browsing() {
'headers' => array(
'Content-Type' => 'application/json',
),
'body' => json_encode(
'body' => wp_json_encode(
array(
'client' => array(
'clientId' => 'wpantivirus',
Expand Down
15 changes: 15 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,18 @@ public function parent() {
return $this->get( 'parent' );
}
}

// phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed

/**
* Encodes a variable into JSON, with some sanity checks.
*
* @param mixed $data Variable (usually an array or object) to encode as JSON.
* @param int $options Optional. Options to be passed to json_encode(). Default 0.
* @param int $depth Optional. Maximum depth to walk through $data. Must be
* greater than 0. Default 512.
* @return string|false The JSON encoded string, or false if it cannot be encoded.
*/
function wp_json_encode( $data, $options = 0, $depth = 512 ) {
return json_encode( $data, $options, $depth );
}

0 comments on commit 9a553e8

Please sign in to comment.