Skip to content

Commit

Permalink
[#195] use GET method to dispatch async requests
Browse files Browse the repository at this point in the history
Workaround for issues with some hosts that are rate-limiting the admin
AJAX endpoint for POST requests. The endpoint url will always be unique
due to the nonce param, so caching should not affect the requests.
  • Loading branch information
ragulka committed Apr 18, 2017
1 parent 60bf7a2 commit 554e72b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions woocommerce/utilities/class-sv-wp-async-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ public function set_data( $data ) {
public function dispatch() {

$url = add_query_arg( $this->get_query_args(), $this->get_query_url() );
$args = $this->get_post_args();
$args = $this->get_request_args();

return wp_safe_remote_post( esc_url_raw( $url ), $args );
return wp_safe_remote_get( esc_url_raw( $url ), $args );
}


Expand Down Expand Up @@ -134,15 +134,17 @@ protected function get_query_url() {


/**
* Get post args
* Get request args
*
* In 4.7.0-dev.1 renamed from get_post_args to get_request_args
*
* @since 4.4.0
* @return array
*/
protected function get_post_args() {
protected function get_request_args() {

if ( property_exists( $this, 'post_args' ) ) {
return $this->post_args;
if ( property_exists( $this, 'request_args' ) ) {
return $this->request_args;
}

return array(
Expand Down

0 comments on commit 554e72b

Please sign in to comment.