| 1 |
<?php |
| 2 |
/** |
| 3 |
* Utils class. |
| 4 |
* |
| 5 |
* @package SureCookie\Inc\Modules\Nudges |
| 6 |
* @since 0.0.1 |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace SureCookie\Inc\Modules\Nudges; |
| 10 |
|
| 11 |
use SureCookie\Inc\Traits\GetInstance; |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; // Exit if accessed directly. |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* The Utils class. |
| 19 |
* |
| 20 |
* @package SureCookie\Inc\Modules\Nudges |
| 21 |
* @since 0.0.1 |
| 22 |
*/ |
| 23 |
class Utils { |
| 24 |
use GetInstance; |
| 25 |
|
| 26 |
/** |
| 27 |
* Get Pro Nudges. |
| 28 |
* |
| 29 |
* @return array<string, array<string, mixed>> |
| 30 |
*/ |
| 31 |
public function get_nudges() { |
| 32 |
$nudges = get_option( SURECOOKIE_NUDGES, [] ); |
| 33 |
|
| 34 |
if ( empty( $nudges ) ) { |
| 35 |
return []; |
| 36 |
} |
| 37 |
|
| 38 |
foreach ( $nudges as $key => $nudge ) { |
| 39 |
|
| 40 |
if ( isset( $nudge['display'] ) && $nudge['display'] === false ) { |
| 41 |
continue; |
| 42 |
} |
| 43 |
|
| 44 |
if ( isset( $nudge['next_time_to_display'] ) && time() < $nudge['next_time_to_display'] ) { |
| 45 |
$nudges[ $key ]['display'] = false; |
| 46 |
} |
| 47 |
} |
| 48 |
return $nudges; |
| 49 |
} |
| 50 |
} |
| 51 |
|