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_Post; |
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 $VID:$ |
23
|
|
|
*/ |
24
|
|
|
class PrivacyPolicyManager |
25
|
|
|
{ |
26
|
|
|
|
27
|
|
|
public function __construct() |
28
|
|
|
{ |
29
|
|
|
add_action('admin_init', array($this, 'addPrivacyPolicy'), 9); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* For all the registered `PrivacyPolicyInterface`s, add their privacy policy content |
35
|
|
|
* |
36
|
|
|
* @param WP_Post $post |
|
|
|
|
37
|
|
|
*/ |
38
|
|
|
public function addPrivacyPolicy() |
39
|
|
|
{ |
40
|
|
|
$policy_page_id = (int) get_option('wp_page_for_privacy_policy'); |
41
|
|
|
if (! $policy_page_id) { |
42
|
|
|
return; |
43
|
|
|
} |
44
|
|
|
// load all the privacy policy stuff |
45
|
|
|
// add post policy text |
46
|
|
|
foreach ($this->loadPrivacyPolicyCollection() as $privacy_policy) { |
|
|
|
|
47
|
|
|
wp_add_privacy_policy_content($privacy_policy->getName(), $privacy_policy->getContent()); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return CollectionInterface|PrivacyPolicyInterface[] |
54
|
|
|
* @throws InvalidIdentifierException |
55
|
|
|
* @throws InvalidInterfaceException |
56
|
|
|
* @throws InvalidFilePathException |
57
|
|
|
* @throws InvalidEntityException |
58
|
|
|
* @throws InvalidDataTypeException |
59
|
|
|
* @throws InvalidClassException |
60
|
|
|
*/ |
61
|
|
View Code Duplication |
protected function loadPrivacyPolicyCollection() |
62
|
|
|
{ |
63
|
|
|
$loader = new CollectionLoader( |
64
|
|
|
new CollectionDetails( |
65
|
|
|
// collection name |
66
|
|
|
'privacy_policies', |
67
|
|
|
// collection interface |
68
|
|
|
'EventEspresso\core\services\privacy\policy\PrivacyPolicyInterface', |
69
|
|
|
// FQCNs for classes to add (all classes within that namespace will be loaded) |
70
|
|
|
apply_filters( |
71
|
|
|
'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies', |
72
|
|
|
array('EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy') |
73
|
|
|
), |
74
|
|
|
// filepaths to classes to add |
75
|
|
|
array(), |
76
|
|
|
// file mask to use if parsing folder for files to add |
77
|
|
|
'', |
78
|
|
|
// what to use as identifier for collection entities |
79
|
|
|
// using CLASS NAME prevents duplicates (works like a singleton) |
80
|
|
|
CollectionDetails::ID_CLASS_NAME |
81
|
|
|
) |
82
|
|
|
); |
83
|
|
|
return $loader->getCollection(); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
// End of file PrivacyPolicyManager.php |
87
|
|
|
// Location: EventEspresso\core\domain\services\admin/PrivacyPolicyManager.php |
88
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.