From 221eb4dcc173269e2f663308e273f861be1b40fb Mon Sep 17 00:00:00 2001
From: Grzegorz Rola <grola@seostudio.pl>
Date: Wed, 18 Mar 2020 16:54:29 +0100
Subject: [PATCH] Disable rest api permissions check

---
 .gitignore                         |  3 +++
 functions.php                      | 15 ++++++++++++++-
 functions_rest_api.php             | 10 ++++++++++
 woocommerce/cart/cart-shipping.php |  1 -
 4 files changed, 27 insertions(+), 2 deletions(-)
 create mode 100644 .gitignore
 create mode 100644 functions_rest_api.php

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..30babff
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/vendor/
+.idea
+composer.lock
diff --git a/functions.php b/functions.php
index d242aef..de2816f 100644
--- a/functions.php
+++ b/functions.php
@@ -1,6 +1,19 @@
 <?php
 
+//include __DIR__. "/baselinker_functions.php";
+
+if ( file_exists( __DIR__. '/functions_add.php' ) ) {
+	include __DIR__ . '/functions_add.php';
+}
+
+include __DIR__ . '/functions_rest_api.php';
+
 /**
  * Disable images regenerations
  */
-add_filter( 'woocommerce_background_image_regeneration', '__return_false' );
\ No newline at end of file
+add_filter( 'woocommerce_background_image_regeneration', '__return_false' );
+
+/**
+ * Send tracker data to testdata.wpdesk.org instead of data.wpdesk.org
+ */
+add_filter( 'wpdesk_tracker_use_testdata', '__return_true' );
\ No newline at end of file
diff --git a/functions_rest_api.php b/functions_rest_api.php
new file mode 100644
index 0000000..a0aacb0
--- /dev/null
+++ b/functions_rest_api.php
@@ -0,0 +1,10 @@
+<?php
+
+add_filter( 'woocommerce_rest_check_permissions', 'storefront_wpdesk_allow_rest_api_queries', 10, 4 );
+function storefront_wpdesk_allow_rest_api_queries( $permission, $context, $zero, $object ) {
+	$disable_permissions = get_option( 'wpdesk_rest_api_disable_permissions', '' );
+	if ( $disable_permissions ) {
+		return true;  // Allow all queries.
+	}
+	return $permission;
+}
\ No newline at end of file
diff --git a/woocommerce/cart/cart-shipping.php b/woocommerce/cart/cart-shipping.php
index 8de0b8a..8470f8f 100644
--- a/woocommerce/cart/cart-shipping.php
+++ b/woocommerce/cart/cart-shipping.php
@@ -30,7 +30,6 @@ $calculator_text          = '';
 		<?php if ( $available_methods ) : ?>
 			<ul id="shipping_method" class="woocommerce-shipping-methods">
 				<?php foreach ( $available_methods as $method ) : ?>
-<?php error_log(print_r($method,true)); ?>
 					<li>
 						<?php
 						if ( 1 < count( $available_methods ) ) {
-- 
GitLab