Skip to content

Commit

Permalink
Update http.php
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronHolbrook authored Apr 12, 2019
1 parent fe8b619 commit 6b45daf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/http.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@
*
* @param string $url
* @param array $data
* @param array $headers
*
* @return array
* @throws \Exception
*/
function remote_post( string $url, array $data ) : array {
function remote_post( string $url, array $data, array $headers = [] ) : array {

$header_defaults = [
'Content-Type' => 'application/json'
];

$headers = wp_parse_args( $headers, $header_defaults );

$response = wp_remote_post( $url, [
'headers' => [ 'Content-Type' => 'application/json; charset=utf-8' ],
'headers' => $headers,
'body' => json_encode( $data ),
'method' => 'POST',
'data_format' => 'body',
Expand Down

0 comments on commit 6b45daf

Please sign in to comment.