Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #30 from woocommerce/fix/27-suspend-jp-sync-during…
Browse files Browse the repository at this point in the history
…-rest-response

Add another URI for which to disable jetpack sync
  • Loading branch information
allendav authored Jul 19, 2017
2 parents 97f3d11 + 5c0c597 commit 758fbf7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
17 changes: 13 additions & 4 deletions hotfixes/wc-api-dev-jetpack-hotfixes.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,24 @@
* See also https://core.trac.wordpress.org/ticket/41358#ticket
* See also https://github.com/Automattic/jetpack/pull/7482
*
* This can be removed once we have either of the two fixes above released
* This can be removed once we have either of the two fixes above released. The first
* trigger string is typical of a direct request (e.g. ala Postman) and the second
* trigger string is typical of a request from WordPress.com for Jetpack.
*
* See also https://github.com/woocommerce/woocommerce/pull/16158
*
* @since 0.7.0
* @version 0.7.1
*/

function wc_api_dev_jetpack_sync_sender_should_load( $sender_should_load ) {
$starts_with = '/wp-json/wc/v';
if ( $starts_with === substr( $_SERVER[ 'REQUEST_URI' ], 0, strlen( $starts_with ) ) ) {
$sender_should_load = false;
$trigger_strings = array( '/wp-json/wc/v', '/?rest_route=%2Fwc%2Fv' );

foreach( $trigger_strings as $trigger_string ) {
if ( false !== strpos( $_SERVER[ 'REQUEST_URI' ], $trigger_string ) ) {
$sender_should_load = false;
break;
}
}

return $sender_should_load;
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: automattic, woothemes
Tags: woocommerce, rest-api, api
Requires at least: 4.6
Tested up to: 4.8
Stable tag: 0.7.0
Stable tag: 0.7.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -25,6 +25,9 @@ This section describes how to install the plugin and get it working.

== Changelog ==

= 0.7.1 =
* Fix - add another URI to watch for when disabling sync during API requests

= 0.7.0 =
* Fix - disable jetpack sync during rest api requests to avoid slow responses

Expand Down
2 changes: 1 addition & 1 deletion wc-api-dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WooCommerce API Dev
* Plugin URI: https://woocommerce.com/
* Description: A feature plugin providing a bleeding edge version of the WooCommerce REST API.
* Version: 0.7.0
* Version: 0.7.1
* Author: Automattic
* Author URI: https://woocommerce.com
* Requires at least: 4.4
Expand Down

0 comments on commit 758fbf7

Please sign in to comment.