@@ -16,58 +16,58 @@ |
||
16 | 16 | class EE_Register_Privacy_Policy implements EEI_Plugin_API |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * FQCN for all privacy policy generators |
|
21 | - * |
|
22 | - * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
23 | - */ |
|
24 | - protected static $privacy_policies = array(); |
|
19 | + /** |
|
20 | + * FQCN for all privacy policy generators |
|
21 | + * |
|
22 | + * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
23 | + */ |
|
24 | + protected static $privacy_policies = array(); |
|
25 | 25 | |
26 | 26 | |
27 | 27 | |
28 | - /* |
|
28 | + /* |
|
29 | 29 | * @param string $plugin_id |
30 | 30 | * @param array $FQNSs can be the fully qualified namespaces each containing only privacy policies, |
31 | 31 | * OR fully qualified class names of privacy policies |
32 | 32 | */ |
33 | - public static function register($plugin_id = null, $FQCNs = array()) |
|
34 | - { |
|
35 | - self::$privacy_policies[$plugin_id] = $FQCNs; |
|
36 | - // add to list of modules to be registered |
|
37 | - add_filter( |
|
38 | - 'FHEE__EventEspresso_core_domain_services_admin_privacy_policy_Manager__privacy_policies', |
|
39 | - array('EE_Register_Privacy_Policy', 'addPrivacyPolicies') |
|
40 | - ); |
|
41 | - } |
|
33 | + public static function register($plugin_id = null, $FQCNs = array()) |
|
34 | + { |
|
35 | + self::$privacy_policies[$plugin_id] = $FQCNs; |
|
36 | + // add to list of modules to be registered |
|
37 | + add_filter( |
|
38 | + 'FHEE__EventEspresso_core_domain_services_admin_privacy_policy_Manager__privacy_policies', |
|
39 | + array('EE_Register_Privacy_Policy', 'addPrivacyPolicies') |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * @param null $ID |
|
47 | - */ |
|
48 | - public static function deregister($ID = null) |
|
49 | - { |
|
50 | - unset(self::$privacy_policies[$ID]); |
|
51 | - } |
|
45 | + /** |
|
46 | + * @param null $ID |
|
47 | + */ |
|
48 | + public static function deregister($ID = null) |
|
49 | + { |
|
50 | + unset(self::$privacy_policies[$ID]); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Adds our privacy policiy generators registered by add-ons |
|
57 | - * |
|
58 | - * @param string[] $privacy_policies |
|
59 | - * @return string[] |
|
60 | - */ |
|
61 | - public static function addPrivacyPolicies(array $privacy_policies) |
|
62 | - { |
|
63 | - foreach (self::$privacy_policies as $privacy_policies_per_addon) { |
|
64 | - $privacy_policies = array_merge( |
|
65 | - $privacy_policies, |
|
66 | - $privacy_policies_per_addon |
|
67 | - ); |
|
68 | - } |
|
69 | - return $privacy_policies; |
|
70 | - } |
|
55 | + /** |
|
56 | + * Adds our privacy policiy generators registered by add-ons |
|
57 | + * |
|
58 | + * @param string[] $privacy_policies |
|
59 | + * @return string[] |
|
60 | + */ |
|
61 | + public static function addPrivacyPolicies(array $privacy_policies) |
|
62 | + { |
|
63 | + foreach (self::$privacy_policies as $privacy_policies_per_addon) { |
|
64 | + $privacy_policies = array_merge( |
|
65 | + $privacy_policies, |
|
66 | + $privacy_policies_per_addon |
|
67 | + ); |
|
68 | + } |
|
69 | + return $privacy_policies; |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | 73 | } |
@@ -28,71 +28,71 @@ |
||
28 | 28 | class PrivacyPolicyManager |
29 | 29 | { |
30 | 30 | |
31 | - public function __construct() |
|
32 | - { |
|
33 | - if (function_exists('wp_add_privacy_policy_content')) { |
|
34 | - add_action('edit_form_after_title', array($this, 'addPrivacyPolicy'), 9); |
|
35 | - } |
|
36 | - } |
|
37 | - |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * For all the registered `PrivacyPolicyInterface`s, add their privacy policy content |
|
42 | - * |
|
43 | - * @param WP_Post $post |
|
44 | - */ |
|
45 | - public function addPrivacyPolicy($post) |
|
46 | - { |
|
47 | - if (! ($post instanceof \WP_Post)) { |
|
48 | - return; |
|
49 | - } |
|
50 | - $policy_page_id = (int)get_option('wp_page_for_privacy_policy'); |
|
51 | - if (! $policy_page_id || $policy_page_id != $post->ID) { |
|
52 | - return; |
|
53 | - } |
|
54 | - //load all the privacy policy stuff |
|
55 | - //add post policy text |
|
56 | - foreach ($this->loadPrivacyPolicyCollection() as $privacy_policy) { |
|
57 | - wp_add_privacy_policy_content($privacy_policy->getName(), $privacy_policy->getContent()); |
|
58 | - } |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * @return CollectionInterface|PrivacyPolicyInterface[] |
|
65 | - * @throws InvalidIdentifierException |
|
66 | - * @throws InvalidInterfaceException |
|
67 | - * @throws InvalidFilePathException |
|
68 | - * @throws InvalidEntityException |
|
69 | - * @throws InvalidDataTypeException |
|
70 | - * @throws InvalidClassException |
|
71 | - */ |
|
72 | - protected function loadPrivacyPolicyCollection() |
|
73 | - { |
|
74 | - $loader = new CollectionLoader( |
|
75 | - new CollectionDetails( |
|
76 | - // collection name |
|
77 | - 'privacy_policies', |
|
78 | - // collection interface |
|
79 | - 'EventEspresso\core\services\privacy_policy\PrivacyPolicyInterface', |
|
80 | - // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
81 | - apply_filters( |
|
82 | - 'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies', |
|
83 | - array('EventEspresso\core\domain\services\admin\privacy_policy\PrivacyPolicy') |
|
84 | - ), |
|
85 | - // filepaths to classes to add |
|
86 | - array(), |
|
87 | - // file mask to use if parsing folder for files to add |
|
88 | - '', |
|
89 | - // what to use as identifier for collection entities |
|
90 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
91 | - CollectionDetails::ID_CLASS_NAME |
|
92 | - ) |
|
93 | - ); |
|
94 | - return $loader->getCollection(); |
|
95 | - } |
|
31 | + public function __construct() |
|
32 | + { |
|
33 | + if (function_exists('wp_add_privacy_policy_content')) { |
|
34 | + add_action('edit_form_after_title', array($this, 'addPrivacyPolicy'), 9); |
|
35 | + } |
|
36 | + } |
|
37 | + |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * For all the registered `PrivacyPolicyInterface`s, add their privacy policy content |
|
42 | + * |
|
43 | + * @param WP_Post $post |
|
44 | + */ |
|
45 | + public function addPrivacyPolicy($post) |
|
46 | + { |
|
47 | + if (! ($post instanceof \WP_Post)) { |
|
48 | + return; |
|
49 | + } |
|
50 | + $policy_page_id = (int)get_option('wp_page_for_privacy_policy'); |
|
51 | + if (! $policy_page_id || $policy_page_id != $post->ID) { |
|
52 | + return; |
|
53 | + } |
|
54 | + //load all the privacy policy stuff |
|
55 | + //add post policy text |
|
56 | + foreach ($this->loadPrivacyPolicyCollection() as $privacy_policy) { |
|
57 | + wp_add_privacy_policy_content($privacy_policy->getName(), $privacy_policy->getContent()); |
|
58 | + } |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * @return CollectionInterface|PrivacyPolicyInterface[] |
|
65 | + * @throws InvalidIdentifierException |
|
66 | + * @throws InvalidInterfaceException |
|
67 | + * @throws InvalidFilePathException |
|
68 | + * @throws InvalidEntityException |
|
69 | + * @throws InvalidDataTypeException |
|
70 | + * @throws InvalidClassException |
|
71 | + */ |
|
72 | + protected function loadPrivacyPolicyCollection() |
|
73 | + { |
|
74 | + $loader = new CollectionLoader( |
|
75 | + new CollectionDetails( |
|
76 | + // collection name |
|
77 | + 'privacy_policies', |
|
78 | + // collection interface |
|
79 | + 'EventEspresso\core\services\privacy_policy\PrivacyPolicyInterface', |
|
80 | + // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
81 | + apply_filters( |
|
82 | + 'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies', |
|
83 | + array('EventEspresso\core\domain\services\admin\privacy_policy\PrivacyPolicy') |
|
84 | + ), |
|
85 | + // filepaths to classes to add |
|
86 | + array(), |
|
87 | + // file mask to use if parsing folder for files to add |
|
88 | + '', |
|
89 | + // what to use as identifier for collection entities |
|
90 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
91 | + CollectionDetails::ID_CLASS_NAME |
|
92 | + ) |
|
93 | + ); |
|
94 | + return $loader->getCollection(); |
|
95 | + } |
|
96 | 96 | |
97 | 97 | |
98 | 98 |