Skip to content

Commit

Permalink
Remove JS&CSS if GDPR is not enabled (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
dz0ny authored Jun 9, 2021
1 parent a6925bc commit 79b7710
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION := 3.31.0
VERSION := 3.31.1
PLUGINSLUG := woocart-defaults
SRCPATH := $(shell pwd)/src

Expand Down
4 changes: 4 additions & 0 deletions src/classes/GDPR.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ public function options_page() {
* @return null
*/
public function scripts() {
$consent = get_option( 'woocommerce_allow_tracking', 'no' );
if ( 'no' !== $consent ) {
return;
}
$plugin_dir = plugin_dir_url( dirname( __FILE__ ) );

wp_enqueue_style( 'woocart-gdpr', "{$plugin_dir}assets/css/front-gdpr.css", array(), Release::Version );
Expand Down
21 changes: 2 additions & 19 deletions tests/GdprTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,11 @@ function tearDown() : void {
* @covers ::scripts
*/
public function testConstructor() {
\WP_Mock::userFunction(
'plugin_dir_url',
array(
'times' => 1,
)
);
\WP_Mock::userFunction(
'wp_enqueue_style',
array(
'times' => 1,
)
);
\WP_Mock::userFunction(
'wp_enqueue_script',
array(
'times' => 1,
)
);

\WP_Mock::userFunction(
'get_option',
array(
'times' => 2,
'times' => 3,
'return' => 'yes',
)
);
Expand Down

0 comments on commit 79b7710

Please sign in to comment.