| 1 |
<?php |
| 2 |
/** |
| 3 |
* Merchant_Option Class. |
| 4 |
*/ |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) { |
| 7 |
exit; // Exit if accessed directly |
| 8 |
} |
| 9 |
|
| 10 |
if ( ! class_exists( 'Merchant_General_Hooks' ) ) { |
| 11 |
class Merchant_General_Hooks { |
| 12 |
|
| 13 |
/** |
| 14 |
* The single class instance. |
| 15 |
*/ |
| 16 |
private static $instance = null; |
| 17 |
|
| 18 |
/** |
| 19 |
* Instance. |
| 20 |
*/ |
| 21 |
public static function instance() { |
| 22 |
if ( is_null( self::$instance ) ) { |
| 23 |
self::$instance = new self(); |
| 24 |
} |
| 25 |
|
| 26 |
return self::$instance; |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Constructor. |
| 31 |
*/ |
| 32 |
private function __construct() { |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Attach functions to WordPress |
| 37 |
* |
| 38 |
* @return void |
| 39 |
*/ |
| 40 |
public function load_hooks() { |
| 41 |
add_action( 'init', array( $this, 'register_weekly_schedule' ) ); |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Register weekly schedule. |
| 46 |
* |
| 47 |
* @return void |
| 48 |
*/ |
| 49 |
public function register_weekly_schedule() { |
| 50 |
if ( function_exists( 'as_schedule_recurring_action' ) ) { |
| 51 |
if ( ! as_next_scheduled_action( 'merchant_weekly_schedule' ) ) { |
| 52 |
as_schedule_recurring_action( time(), WEEK_IN_SECONDS, 'merchant_weekly_schedule' ); |
| 53 |
} |
| 54 |
|
| 55 |
return; |
| 56 |
} |
| 57 |
|
| 58 |
if ( ! wp_next_scheduled( 'merchant_weekly_schedule' ) ) { |
| 59 |
wp_schedule_event( time(), 'weekly', 'merchant_weekly_schedule' ); |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
$merchant_general_hooks = Merchant_General_Hooks::instance(); |
| 66 |
$merchant_general_hooks->load_hooks(); |