Skip to content

Commit

Permalink
Fixing prefixes for globals
Browse files Browse the repository at this point in the history
  • Loading branch information
aldavigdis committed Jul 19, 2024
1 parent e3941c1 commit 815f4ff
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
8 changes: 3 additions & 5 deletions src/Hooks/WooMetaboxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,15 @@ public function save_product_meta(
): void {
// As the hook seems to be run twice for some reason, this should
// prevent the function to run twice during the same HTTP request.
global $nineteen_eighty_four_woo_dk_meta_update_has_run;
if ( isset( $nineteen_eighty_four_woo_dk_meta_update_has_run ) ) {
if ( defined( '1984_DK_WOO_META_UPDATE_HAS_RUN' ) ) {
return;
}

define( '1984_DK_WOO_META_UPDATE_HAS_RUN', true );

self::set_product_sync_meta_from_post( $wc_product, 'price' );
self::set_product_sync_meta_from_post( $wc_product, 'stock' );
self::set_product_sync_meta_from_post( $wc_product, 'name' );

$nineteen_eighty_four_woo_dk_meta_update_has_run = true;
global $nineteen_eighty_four_woo_dk_meta_update_has_run;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Hooks/WooUpdateProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function on_product_update(
return;
}

if ( defined( 'DOING_DK_SYNC' ) ) {
if ( defined( '1984_DK_WOO_DOING_SYNC' ) ) {
return;
}

Expand Down Expand Up @@ -104,7 +104,7 @@ public static function before_post_delete( int $post_id ): void {
return;
}

if ( defined( 'DOING_DK_SYNC' ) ) {
if ( defined( '1984_DK_WOO_DOING_SYNC' ) ) {
return;
}

Expand Down Expand Up @@ -156,7 +156,7 @@ public static function post_status_change(
return;
}

if ( defined( 'DOING_DK_SYNC' ) ) {
if ( defined( '1984_DK_WOO_DOING_SYNC' ) ) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Import/Currencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ class Currencies {
* Fetches all the currency rates from DK
*/
public static function save_all_from_dk(): void {
if ( defined( 'DOING_DK_SYNC' ) ) {
if ( defined( '1984_DK_WOO_DOING_SYNC' ) ) {
return;
}

define( 'DOING_DK_SYNC', true );
define( '1984_DK_WOO_DOING_SYNC', true );

$json_objects = self::get_all_from_dk();

Expand Down
4 changes: 2 additions & 2 deletions src/Import/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class Products {
* This should be run at least nightly as a wp-cron job.
*/
public static function save_all_from_dk(): void {
if ( ! defined( 'DOING_DK_SYNC' ) ) {
define( 'DOING_DK_SYNC', true );
if ( ! defined( '1984_DK_WOO_DOING_SYNC' ) ) {
define( '1984_DK_WOO_DOING_SYNC', true );
}

$json_objects = self::get_all_from_dk();
Expand Down

0 comments on commit 815f4ff

Please sign in to comment.