|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace EventEspresso\core\domain\services\admin\privacy\policy; |
|
4
|
|
|
|
|
5
|
|
|
use EE_Offsite_Gateway; |
|
6
|
|
|
use EE_Onsite_Gateway; |
|
7
|
|
|
use EEH_Template; |
|
8
|
|
|
use EEM_Payment_Method; |
|
9
|
|
|
use EventEspresso\core\domain\values\session\SessionLifespan; |
|
10
|
|
|
use EventEspresso\core\services\privacy\policy\PrivacyPolicyInterface; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class PrivacyPolicy |
|
14
|
|
|
* Class describes the Event Espresso core plugin's privacy policy. |
|
15
|
|
|
* |
|
16
|
|
|
* @package Event Espresso |
|
17
|
|
|
* @author Mike Nelson |
|
18
|
|
|
* @since $VID:$ |
|
19
|
|
|
*/ |
|
20
|
|
|
class PrivacyPolicy implements PrivacyPolicyInterface |
|
21
|
|
|
{ |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var EEM_Payment_Method |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $payment_method_model; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var SessionLifespan |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $session_lifespan; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* PrivacyPolicy constructor. |
|
35
|
|
|
* |
|
36
|
|
|
* @param EEM_Payment_Method $payment_method_model |
|
37
|
|
|
* @param SessionLifespan $session_lifespan |
|
38
|
|
|
*/ |
|
39
|
|
|
public function __construct(EEM_Payment_Method $payment_method_model, SessionLifespan $session_lifespan) |
|
40
|
|
|
{ |
|
41
|
|
|
$this->payment_method_model = $payment_method_model; |
|
42
|
|
|
$this->session_lifespan = $session_lifespan; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Returns the name of the plugin and will be shown in the privacy policy's postbox header |
|
48
|
|
|
* |
|
49
|
|
|
* @return string |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getName() |
|
52
|
|
|
{ |
|
53
|
|
|
return esc_html__('Event Espresso', 'event_espresso'); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Gets the HTML for the privacy policy. May be dynamic |
|
59
|
|
|
* |
|
60
|
|
|
* @return string |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getContent() |
|
63
|
|
|
{ |
|
64
|
|
|
// do they have any offsite payment methods? or onsite payment methods? |
|
65
|
|
|
$active_payment_methods = $this->payment_method_model->get_all_active(EEM_Payment_Method::scope_cart); |
|
66
|
|
|
$active_onsite_pms = array(); |
|
67
|
|
|
$active_offsite_pms = array(); |
|
68
|
|
|
foreach ($active_payment_methods as $payment_method) { |
|
69
|
|
|
if ($payment_method->type_obj() instanceof \EE_PMT_Base) { |
|
70
|
|
|
if ($payment_method->type_obj()->get_gateway() instanceof EE_Onsite_Gateway) { |
|
71
|
|
|
$active_onsite_pms[] = $payment_method->name(); |
|
72
|
|
|
} elseif ($payment_method->type_obj()->get_gateway() instanceof EE_Offsite_Gateway) { |
|
73
|
|
|
$active_offsite_pms[] = $payment_method->name(); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
$session_lifespan_in_hours = round($this->session_lifespan->inSeconds() / HOUR_IN_SECONDS); |
|
78
|
|
|
return (string) EEH_Template::display_template( |
|
79
|
|
|
__DIR__ . '/privacy_policy.template.php', |
|
80
|
|
|
array( |
|
81
|
|
|
'active_onsite_payment_methods' => $active_onsite_pms, |
|
82
|
|
|
'active_offsite_payment_methods' => $active_offsite_pms, |
|
83
|
|
|
'session_lifespan' => sprintf( |
|
84
|
|
|
_nx( |
|
85
|
|
|
'%1$s hour', |
|
86
|
|
|
'%1$s hours', |
|
87
|
|
|
$session_lifespan_in_hours, |
|
88
|
|
|
'2 hours', |
|
89
|
|
|
'event_espresso' |
|
90
|
|
|
), |
|
91
|
|
|
$session_lifespan_in_hours |
|
92
|
|
|
) |
|
93
|
|
|
), |
|
94
|
|
|
true |
|
95
|
|
|
); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
// End of file PrivacyPolicy.php |
|
99
|
|
|
// Location: EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy.php |
|
100
|
|
|
|