|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
namespace lsx_health_plan\classes; |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* Contains the endpoints |
|
6
|
|
|
* |
|
7
|
|
|
* @package lsx-health-plan |
|
8
|
|
|
*/ |
|
9
|
|
|
class Modals { |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Holds class instance |
|
13
|
|
|
* |
|
14
|
|
|
* @since 1.0.0 |
|
15
|
|
|
* |
|
16
|
|
|
* @var object \lsx_health_plan\classes\Modals() |
|
17
|
|
|
*/ |
|
18
|
|
|
protected static $instance = null; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Holds the modals to be outputted |
|
22
|
|
|
* |
|
23
|
|
|
* @var array |
|
24
|
|
|
*/ |
|
25
|
|
|
public $modals = array(); |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Constructor |
|
29
|
|
|
*/ |
|
30
|
|
|
public function __construct() { |
|
|
|
|
|
|
31
|
|
|
add_action( 'wp_footer', array( $this, 'output_modals' ) ); |
|
32
|
|
|
} |
|
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Return an instance of this class. |
|
36
|
|
|
* |
|
37
|
|
|
* @since 1.0.0 |
|
38
|
|
|
* |
|
39
|
|
|
* @return object \lsx_health_plan\classes\Endpoints() A single instance of this class. |
|
40
|
|
|
*/ |
|
41
|
|
|
public static function get_instance() { |
|
42
|
|
|
// If the single instance hasn't been set, set it now. |
|
43
|
|
|
if ( null === self::$instance ) { |
|
|
|
|
|
|
44
|
|
|
self::$instance = new self(); |
|
45
|
|
|
} |
|
|
|
|
|
|
46
|
|
|
return self::$instance; |
|
47
|
|
|
} |
|
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Registers a modal to be outputted |
|
51
|
|
|
* |
|
52
|
|
|
* @param array $modal |
|
|
|
|
|
|
53
|
|
|
* @param string $index |
|
|
|
|
|
|
54
|
|
|
* @return void |
|
55
|
|
|
*/ |
|
56
|
|
|
public function register_modal( $modal = array(), $index = '' ) { |
|
57
|
|
|
if ( '' !== $index && ! empty( $modal ) ) { |
|
|
|
|
|
|
58
|
|
|
$modal['id'] = $index; |
|
|
|
|
|
|
59
|
|
|
$this->modals[ $index ] = $modal; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Registers the rewrites. |
|
65
|
|
|
*/ |
|
66
|
|
|
public function output_modals() { |
|
67
|
|
|
if ( ! empty( $this->modals ) ) { |
|
|
|
|
|
|
68
|
|
|
wp_enqueue_script( 'lsx-health-plan-modals', LSX_HEALTH_PLAN_URL . 'assets/js/lsx-health-plan-modals.min.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true ); |
|
69
|
|
|
|
|
70
|
|
|
foreach ( $this->modals as $index => $modal ) { |
|
|
|
|
|
|
71
|
|
|
\lsx_health_plan\functions\output_modal( $modal ); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
|
|
|
|
|
75
|
|
|
} |
|
76
|
|
|
|