Skip to content

Commit

Permalink
🐛 fix(Helper.php): skip promo notices if pro license is active to pre…
Browse files Browse the repository at this point in the history
…vent displaying unnecessary promotions

✨ feat(Helper.php): add is_pro_license_active() method to check if Dokan pro-license is active
  • Loading branch information
nurul-umbhiya committed Nov 30, 2023
1 parent 535045a commit 3b649ed
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions includes/Admin/Notices/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public static function dokan_get_promo_notices() {
continue;
}

if ( wc_string_to_bool( $promo['pro_only'] ) && self::is_pro_license_active() ) {
continue;
}

if ( $est_time_now >= $promo['start_date'] && $est_time_now <= $promo['end_date'] ) {
$notices[] = [
'type' => 'promotion',
Expand Down Expand Up @@ -100,6 +104,32 @@ public static function dokan_get_promo_notices() {
return array_values( $notices );
}

/**
* Check if dokan pro-license is active
*
* @since DOKAN_SINCE
*
* @return bool
*/
public static function is_pro_license_active(): bool {
if ( ! dokan()->is_pro_exists() ) {
return false;
}

if ( ! property_exists( dokan_pro(), 'license' ) ) {
// this is old version of dokan pro
return false;
}

$license = dokan_pro()->license->plugin_update_message();
if ( ! empty( $license ) ) {
// if the plugin update message is not empty, then the license is not active
return false;
}

return true;
}

/**
* Check has new version in dokan lite and pro
*
Expand Down

0 comments on commit 3b649ed

Please sign in to comment.