1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* GeoDirectory abstract privacy class. |
4
|
|
|
* |
5
|
|
|
* @since 1.6.26 |
6
|
|
|
* @package GeoDirectory |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
defined( 'ABSPATH' ) || exit; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Abstract class that is intended to be extended by specific privacy class. |
13
|
|
|
* It handles the display of the privacy message of the privacy id to the admin, |
14
|
|
|
* privacy data to be exported and privacy data to be deleted. |
15
|
|
|
* |
16
|
|
|
* @version 1.6.26 |
17
|
|
|
* @package GeoDirectory |
18
|
|
|
*/ |
19
|
|
|
abstract class GeoDir_Abstract_Privacy { |
20
|
|
|
/** |
21
|
|
|
* This is the name of this object type. |
22
|
|
|
* |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
public $name; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* This is a list of exporters. |
29
|
|
|
* |
30
|
|
|
* @var array |
31
|
|
|
*/ |
32
|
|
|
protected $exporters = array(); |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* This is a list of erasers. |
36
|
|
|
* |
37
|
|
|
* @var array |
38
|
|
|
*/ |
39
|
|
|
protected $erasers = array(); |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Constructor |
43
|
|
|
* |
44
|
|
|
* @param string $name Plugin identifier. |
45
|
|
|
*/ |
46
|
|
|
public function __construct( $name = '' ) { |
47
|
|
|
$this->name = $name; |
48
|
|
|
$this->init(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Hook in events. |
53
|
|
|
*/ |
54
|
|
|
protected function init() { |
55
|
|
|
add_action( 'admin_init', array( $this, 'add_privacy_message' ) ); |
56
|
|
|
// Register data exporters |
57
|
|
|
add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_exporters' ), 5 ); |
58
|
|
|
// Register data erasers |
59
|
|
|
add_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_erasers' ) ); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Adds the privacy message on GeoDirectory privacy page. |
64
|
|
|
*/ |
65
|
|
|
public function add_privacy_message() { |
66
|
|
|
$content = $this->get_privacy_message(); |
67
|
|
|
|
68
|
|
|
if ( $content ) { |
69
|
|
|
wp_add_privacy_policy_content( $this->name, $this->get_privacy_message() ); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Gets the message of the privacy to display. |
75
|
|
|
* To be overloaded by the implementor. |
76
|
|
|
* |
77
|
|
|
* @return string |
78
|
|
|
*/ |
79
|
|
|
public function get_privacy_message() { |
80
|
|
|
return ''; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Integrate this exporter implementation within the WordPress core exporters. |
85
|
|
|
* |
86
|
|
|
* @param array $exporters List of exporter callbacks. |
87
|
|
|
* @return array |
88
|
|
|
*/ |
89
|
|
|
public function register_exporters( $exporters = array() ) { |
90
|
|
|
foreach ( $this->exporters as $id => $exporter ) { |
91
|
|
|
$exporters[ $id ] = $exporter; |
92
|
|
|
} |
93
|
|
|
return $exporters; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Integrate this eraser implementation within the WordPress core erasers. |
98
|
|
|
* |
99
|
|
|
* @param array $erasers List of eraser callbacks. |
100
|
|
|
* @return array |
101
|
|
|
*/ |
102
|
|
|
public function register_erasers( $erasers = array() ) { |
103
|
|
|
foreach ( $this->erasers as $id => $eraser ) { |
104
|
|
|
$erasers[ $id ] = $eraser; |
105
|
|
|
} |
106
|
|
|
return $erasers; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Add exporter to list of exporters. |
111
|
|
|
* |
112
|
|
|
* @param string $id ID of the Exporter. |
113
|
|
|
* @param string $name Exporter name. |
114
|
|
|
* @param string $callback Exporter callback. |
115
|
|
|
*/ |
116
|
|
|
public function add_exporter( $id, $name, $callback ) { |
117
|
|
|
$this->exporters[ $id ] = array( |
118
|
|
|
'exporter_friendly_name' => $name, |
119
|
|
|
'callback' => $callback, |
120
|
|
|
); |
121
|
|
|
return $this->exporters; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Add eraser to list of erasers. |
126
|
|
|
* |
127
|
|
|
* @param string $id ID of the Eraser. |
128
|
|
|
* @param string $name Exporter name. |
129
|
|
|
* @param string $callback Exporter callback. |
130
|
|
|
*/ |
131
|
|
|
public function add_eraser( $id, $name, $callback ) { |
132
|
|
|
$this->erasers[ $id ] = array( |
133
|
|
|
'eraser_friendly_name' => $name, |
134
|
|
|
'callback' => $callback, |
135
|
|
|
); |
136
|
|
|
return $this->erasers; |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|