-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwpum-personal-data.php
More file actions
247 lines (209 loc) · 5.62 KB
/
Copy pathwpum-personal-data.php
File metadata and controls
247 lines (209 loc) · 5.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<?php
/*
Plugin Name: WPUM Personal Data
Plugin URI: https://wpusermanager.com
Description: Addon for WP User Manager, allow the user to request his personal data and request erasure of personal data from the account page.
Version: 1.1.5
Author: WP User Manager
Author URI: https://wpusermanager.com/
License: GPLv3+
Text Domain: wpum-personal-data
Domain Path: /languages
*/
/**
* WPUM Personal Data.
*
* Copyright (c) 2018 Alessandro Tesoro
*
* WPUM Personal Data. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
*
* WPUM Personal Data. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* @author Alessandro Tesoro
* @version 2.0.0
* @copyright (c) 2018 Alessandro Tesoro
* @license http://www.gnu.org/licenses/gpl-3.0.txt GNU LESSER GENERAL PUBLIC LICENSE
* @package wpum-personal-data
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WPUM_Personal_Data' ) ) :
/**
* Main WPUM_Personal_Data class.
*/
final class WPUM_Personal_Data {
/**
* WPUMPD Instance.
*
* @var WPUM_Personal_Data the WPUM Instance
*/
protected static $_instance;
/**
* @var string
*/
protected $version = '1.1.5';
/**
* Main WPUMPD Instance.
*
* Ensures that only one instance of WPUMPD exists in memory at any one
* time. Also prevents needing to define globals all over the place.
*
* @return WPUM_Personal_Data
*/
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
self::$_instance->run();
}
return self::$_instance;
}
/**
* Only load the addon on the WPUM core hook, ensuring the plugin is active.
*/
public function run() {
add_action( 'after_wpum_init', array( $this, 'init' ) );
}
/**
* Get things up and running.
*/
public function init() {
if ( ! $this->autoload() ) {
return;
}
// Verify the plugin meets WP and PHP requirements.
$this->plugin_can_run();
// Verify the addon can run first. If not, disable the addon automagically.
$this->addon_can_run();
// Plugin is activated now proceed.
$this->setup_constants();
$this->includes();
$this->init_hooks();
}
/**
* Autoload composer and other required classes.
*
* @return bool
*/
protected function autoload() {
if ( ! file_exists( __DIR__ . '/vendor' ) || ! file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
add_action( 'admin_notices', array( $this, 'vendor_failed_notice' ) );
return false;
}
return require __DIR__ . '/vendor/autoload.php';
}
/**
* Load required files for the addon.
*
* @return void
*/
public function includes() {
require_once WPUMPD_PLUGIN_DIR . 'includes/actions.php';
require_once WPUMPD_PLUGIN_DIR . 'includes/custom-exporter.php';
require_once WPUMPD_PLUGIN_DIR . 'includes/custom-eraser.php';
}
/**
* Setup plugin constants
*
* @access private
* @since 1.0.0
* @return void
*/
private function setup_constants() {
// Plugin version.
if ( ! defined( 'WPUMPD_VERSION' ) ) {
define( 'WPUMPD_VERSION', $this->version );
}
// Plugin Folder Path.
if ( ! defined( 'WPUMPD_PLUGIN_DIR' ) ) {
define( 'WPUMPD_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}
// Plugin Folder URL.
if ( ! defined( 'WPUMPD_PLUGIN_URL' ) ) {
define( 'WPUMPD_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
// Plugin Root File.
if ( ! defined( 'WPUMPD_PLUGIN_FILE' ) ) {
define( 'WPUMPD_PLUGIN_FILE', __FILE__ );
}
// Plugin Slug.
if ( ! defined( 'WPUMPD_SLUG' ) ) {
define( 'WPUMPD_SLUG', plugin_basename( __FILE__ ) );
}
}
/**
* Hook in our actions and filters.
*
* @return void
*/
private function init_hooks() {
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ), 0 );
}
/**
* Load plugin textdomain.
*
* @return void
*/
public function load_textdomain() {
load_plugin_textdomain( 'wpum-personal-data', false, basename( dirname( __FILE__ ) ) . '/languages' );
}
/**
* Verify the plugin meets the WP and php requirements.
*
* @return boolean
*/
public function plugin_can_run() {
$requirements_check = new WP_Requirements_Check( array(
'title' => 'WPUM Personal Data',
'php' => '5.5',
'wp' => '4.9.5',
'file' => __FILE__,
) );
return $requirements_check->passes();
}
/**
* Verify that the current environment is supported.
*
* @return boolean
*/
private function addon_can_run() {
$requirements_check = new WPUM_Extension_Activation(
array(
'title' => 'WPUM Personal Data',
'wpum_version' => '2.0.0',
'file' => __FILE__,
)
);
return $requirements_check->passes();
}
/**
* Show the Vendor build issue notice.
*
* @since 1.0.0
* @access public
*/
public function vendor_failed_notice() { ?>
<div class="error">
<p><?php printf( '<strong>WP User Manager</strong> — The %s addon plugin cannot be activated as it is missing the vendor directory.', esc_html( 'Personal Data' ) ); ?></p>
</div>
<?php
deactivate_plugins( plugin_basename( __FILE__ ) );
}
}
endif;
/**
* Start the addon.
*
* @return WPUM_Personal_Data
*/
function WPUMPD() {
return WPUM_Personal_Data::instance();
}
WPUMPD();