1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\services\privacy\policy; |
4
|
|
|
|
5
|
|
|
use EventEspresso\core\exceptions\InvalidClassException; |
6
|
|
|
use EventEspresso\core\exceptions\InvalidDataTypeException; |
7
|
|
|
use EventEspresso\core\exceptions\InvalidEntityException; |
8
|
|
|
use EventEspresso\core\exceptions\InvalidFilePathException; |
9
|
|
|
use EventEspresso\core\exceptions\InvalidIdentifierException; |
10
|
|
|
use EventEspresso\core\exceptions\InvalidInterfaceException; |
11
|
|
|
use EventEspresso\core\services\collections\CollectionDetails; |
12
|
|
|
use EventEspresso\core\services\collections\CollectionInterface; |
13
|
|
|
use EventEspresso\core\services\collections\CollectionLoader; |
14
|
|
|
use WP_Screen; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class PrivacyPolicyManager |
18
|
|
|
* Manages setting up the hooks to add the EE core and add-ons' privacy policies |
19
|
|
|
* |
20
|
|
|
* @package Event Espresso |
21
|
|
|
* @author Mike Nelson |
22
|
|
|
* @since 4.9.62.p |
23
|
|
|
*/ |
24
|
|
|
class PrivacyPolicyManager |
25
|
|
|
{ |
26
|
|
|
|
27
|
|
|
public function __construct() |
28
|
|
|
{ |
29
|
|
|
add_action('current_screen', array($this, 'addPrivacyPolicy'), 9); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* For all the registered `PrivacyPolicyInterface`s, add their privacy policy content |
35
|
|
|
* |
36
|
|
|
* @param WP_Screen $screen |
37
|
|
|
* @throws InvalidClassException |
38
|
|
|
* @throws InvalidDataTypeException |
39
|
|
|
* @throws InvalidEntityException |
40
|
|
|
* @throws InvalidFilePathException |
41
|
|
|
* @throws InvalidIdentifierException |
42
|
|
|
* @throws InvalidInterfaceException |
43
|
|
|
*/ |
44
|
|
|
public function addPrivacyPolicy(WP_Screen $screen) |
45
|
|
|
{ |
46
|
|
|
if ($screen instanceof WP_Screen |
|
|
|
|
47
|
|
|
&& $screen->id === 'tools' |
48
|
|
|
&& isset($_GET['wp-privacy-policy-guide'])) { |
49
|
|
|
// load all the privacy policy stuff |
50
|
|
|
// add post policy text |
51
|
|
|
foreach ($this->loadPrivacyPolicyCollection() as $privacy_policy) { |
52
|
|
|
wp_add_privacy_policy_content($privacy_policy->getName(), $privacy_policy->getContent()); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return CollectionInterface|PrivacyPolicyInterface[] |
60
|
|
|
* @throws InvalidIdentifierException |
61
|
|
|
* @throws InvalidInterfaceException |
62
|
|
|
* @throws InvalidFilePathException |
63
|
|
|
* @throws InvalidEntityException |
64
|
|
|
* @throws InvalidDataTypeException |
65
|
|
|
* @throws InvalidClassException |
66
|
|
|
*/ |
67
|
|
|
protected function loadPrivacyPolicyCollection() |
68
|
|
|
{ |
69
|
|
|
$loader = new CollectionLoader( |
70
|
|
|
new CollectionDetails( |
71
|
|
|
// collection name |
72
|
|
|
'privacy_policies', |
73
|
|
|
// collection interface |
74
|
|
|
'EventEspresso\core\services\privacy\policy\PrivacyPolicyInterface', |
75
|
|
|
// FQCNs for classes to add (all classes within that namespace will be loaded) |
76
|
|
|
apply_filters( |
77
|
|
|
'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies', |
78
|
|
|
array('EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy') |
79
|
|
|
), |
80
|
|
|
// filepaths to classes to add |
81
|
|
|
array(), |
82
|
|
|
// file mask to use if parsing folder for files to add |
83
|
|
|
'', |
84
|
|
|
// what to use as identifier for collection entities |
85
|
|
|
// using CLASS NAME prevents duplicates (works like a singleton) |
86
|
|
|
CollectionDetails::ID_CLASS_NAME |
87
|
|
|
) |
88
|
|
|
); |
89
|
|
|
return $loader->getCollection(); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
// End of file PrivacyPolicyManager.php |
93
|
|
|
// Location: EventEspresso\core\domain\services\admin/PrivacyPolicyManager.php |
94
|
|
|
|