Completed
Branch master (8d1e17)
by
unknown
17:52 queued 15:40
created
core/EE_Addon.core.php 2 patches
Indentation   +848 added lines, -848 removed lines patch added patch discarded remove patch
@@ -19,859 +19,859 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * prefix to be added onto an addon's plugin slug to make a wp option name
24
-     * which will be used to store the plugin's activation history
25
-     */
26
-    const ee_addon_version_history_option_prefix = 'ee_version_history_';
27
-
28
-    /**
29
-     * @var $_version
30
-     * @type string
31
-     */
32
-    protected $_version = '';
33
-
34
-    /**
35
-     * @var $_min_core_version
36
-     * @type string
37
-     */
38
-    protected $_min_core_version = '';
39
-
40
-    /**
41
-     * derived from plugin 'main_file_path using plugin_basename()
42
-     *
43
-     * @type string $_plugin_basename
44
-     */
45
-    protected $_plugin_basename = '';
46
-
47
-    /**
48
-     * A non-internationalized name to identify this addon for use in URLs, etc
49
-     *
50
-     * @type string $_plugin_slug
51
-     */
52
-    protected $_plugin_slug = '';
53
-
54
-    /**
55
-     * A non-internationalized name to identify this addon. Eg 'Calendar','MailChimp',etc/
56
-     *
57
-     * @type string _addon_name
58
-     */
59
-    protected $_addon_name = '';
60
-
61
-    /**
62
-     * one of the EE_System::req_type_* constants
63
-     *
64
-     * @type int $_req_type
65
-     */
66
-    protected $_req_type;
67
-
68
-    /**
69
-     * page slug to be used when generating the "Settings" link on the WP plugin page
70
-     *
71
-     * @type string $_plugin_action_slug
72
-     */
73
-    protected $_plugin_action_slug = '';
74
-
75
-    /**
76
-     * if not empty, inserts a new table row after this plugin's row on the WP Plugins page
77
-     * that can be used for adding upgrading/marketing info
78
-     *
79
-     * @type array $_plugins_page_row
80
-     */
81
-    protected $_plugins_page_row = array();
82
-
83
-
84
-    /**
85
-     *    filepath to the main file, which can be used for register_activation_hook, register_deactivation_hook, etc.
86
-     *
87
-     * @type string
88
-     */
89
-    protected $_main_plugin_file;
90
-
91
-    /**
92
-     *    This is the slug used to identify this add-on within the plugin update engine.
93
-     *
94
-     * @type string
95
-     */
96
-    protected $pue_slug;
97
-
98
-
99
-    /**
100
-     * @var EE_Dependency_Map $dependency_map
101
-     */
102
-    private $dependency_map;
103
-
104
-
105
-    /**
106
-     * @var DomainInterface $domain
107
-     */
108
-    private $domain;
109
-
110
-
111
-    /**
112
-     * @param EE_Dependency_Map $dependency_map [optional]
113
-     * @param DomainInterface   $domain         [optional]
114
-     */
115
-    public function __construct(EE_Dependency_Map $dependency_map = null, DomainInterface $domain = null)
116
-    {
117
-        if ($dependency_map instanceof EE_Dependency_Map) {
118
-            $this->setDependencyMap($dependency_map);
119
-        }
120
-        if ($domain instanceof DomainInterface) {
121
-            $this->setDomain($domain);
122
-        }
123
-        add_action('AHEE__EE_System__load_controllers__load_admin_controllers', array($this, 'admin_init'));
124
-    }
125
-
126
-
127
-    /**
128
-     * @param EE_Dependency_Map $dependency_map
129
-     */
130
-    public function setDependencyMap($dependency_map)
131
-    {
132
-        $this->dependency_map = $dependency_map;
133
-    }
134
-
135
-
136
-    /**
137
-     * @return EE_Dependency_Map
138
-     */
139
-    public function dependencyMap()
140
-    {
141
-        return $this->dependency_map;
142
-    }
143
-
144
-
145
-    /**
146
-     * @param DomainInterface $domain
147
-     */
148
-    public function setDomain(DomainInterface $domain)
149
-    {
150
-        $this->domain = $domain;
151
-    }
152
-
153
-    /**
154
-     * @return DomainInterface
155
-     */
156
-    public function domain()
157
-    {
158
-        return $this->domain;
159
-    }
160
-
161
-
162
-    /**
163
-     * @param mixed $version
164
-     */
165
-    public function set_version($version = null)
166
-    {
167
-        $this->_version = $version;
168
-    }
169
-
170
-
171
-    /**
172
-     * get__version
173
-     *
174
-     * @return string
175
-     */
176
-    public function version()
177
-    {
178
-        return $this->_version;
179
-    }
180
-
181
-
182
-    /**
183
-     * @param mixed $min_core_version
184
-     */
185
-    public function set_min_core_version($min_core_version = null)
186
-    {
187
-        $this->_min_core_version = $min_core_version;
188
-    }
189
-
190
-
191
-    /**
192
-     * get__min_core_version
193
-     *
194
-     * @return string
195
-     */
196
-    public function min_core_version()
197
-    {
198
-        return $this->_min_core_version;
199
-    }
200
-
201
-
202
-    /**
203
-     * Sets addon_name
204
-     *
205
-     * @param string $addon_name
206
-     * @return bool
207
-     */
208
-    public function set_name($addon_name)
209
-    {
210
-        return $this->_addon_name = $addon_name;
211
-    }
212
-
213
-
214
-    /**
215
-     * Gets addon_name
216
-     *
217
-     * @return string
218
-     */
219
-    public function name()
220
-    {
221
-        return $this->_addon_name;
222
-    }
223
-
224
-
225
-    /**
226
-     * @return string
227
-     */
228
-    public function plugin_basename()
229
-    {
230
-
231
-        return $this->_plugin_basename;
232
-    }
233
-
234
-
235
-    /**
236
-     * @param string $plugin_basename
237
-     */
238
-    public function set_plugin_basename($plugin_basename)
239
-    {
240
-
241
-        $this->_plugin_basename = $plugin_basename;
242
-    }
243
-
244
-
245
-    /**
246
-     * @return string
247
-     */
248
-    public function plugin_slug()
249
-    {
250
-
251
-        return $this->_plugin_slug;
252
-    }
253
-
254
-
255
-    /**
256
-     * @param string $plugin_slug
257
-     */
258
-    public function set_plugin_slug($plugin_slug)
259
-    {
260
-
261
-        $this->_plugin_slug = $plugin_slug;
262
-    }
263
-
264
-
265
-    /**
266
-     * @return string
267
-     */
268
-    public function plugin_action_slug()
269
-    {
270
-
271
-        return $this->_plugin_action_slug;
272
-    }
273
-
274
-
275
-    /**
276
-     * @param string $plugin_action_slug
277
-     */
278
-    public function set_plugin_action_slug($plugin_action_slug)
279
-    {
280
-
281
-        $this->_plugin_action_slug = $plugin_action_slug;
282
-    }
283
-
284
-
285
-    /**
286
-     * @return array
287
-     */
288
-    public function get_plugins_page_row()
289
-    {
290
-
291
-        return $this->_plugins_page_row;
292
-    }
293
-
294
-
295
-    /**
296
-     * @param array $plugins_page_row
297
-     */
298
-    public function set_plugins_page_row($plugins_page_row = array())
299
-    {
300
-        // sigh.... check for example content that I stupidly merged to master and remove it if found
301
-        if (
302
-            ! is_array($plugins_page_row)
303
-            && strpos($plugins_page_row, '<h3>Promotions Addon Upsell Info</h3>') !== false
304
-        ) {
305
-            $plugins_page_row = array();
306
-        }
307
-        $this->_plugins_page_row = (array) $plugins_page_row;
308
-    }
309
-
310
-
311
-    /**
312
-     * Called when EE core detects this addon has been activated for the first time.
313
-     * If the site isn't in maintenance mode, should setup the addon's database
314
-     *
315
-     * @return void
316
-     * @throws EE_Error
317
-     */
318
-    public function new_install()
319
-    {
320
-        $classname = get_class($this);
321
-        do_action("AHEE__{$classname}__new_install");
322
-        do_action('AHEE__EE_Addon__new_install', $this);
323
-        EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
324
-        add_action(
325
-            'AHEE__EE_System__perform_activations_upgrades_and_migrations',
326
-            array($this, 'initialize_db_if_no_migrations_required')
327
-        );
328
-    }
329
-
330
-
331
-    /**
332
-     * Called when EE core detects this addon has been reactivated. When this happens,
333
-     * it's good to just check that your data is still intact
334
-     *
335
-     * @return void
336
-     * @throws EE_Error
337
-     */
338
-    public function reactivation()
339
-    {
340
-        $classname = get_class($this);
341
-        do_action("AHEE__{$classname}__reactivation");
342
-        do_action('AHEE__EE_Addon__reactivation', $this);
343
-        EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
344
-        add_action(
345
-            'AHEE__EE_System__perform_activations_upgrades_and_migrations',
346
-            array($this, 'initialize_db_if_no_migrations_required')
347
-        );
348
-    }
349
-
350
-
351
-    /**
352
-     * Called when the registered deactivation hook for this addon fires.
353
-     *
354
-     * @throws EE_Error
355
-     */
356
-    public function deactivation()
357
-    {
358
-        $classname = get_class($this);
359
-        do_action("AHEE__{$classname}__deactivation");
360
-        do_action('AHEE__EE_Addon__deactivation', $this);
361
-        // check if the site no longer needs to be in maintenance mode
362
-        EE_Register_Addon::deregister($this->name());
363
-        EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
364
-    }
365
-
366
-
367
-    /**
368
-     * Takes care of double-checking that we're not in maintenance mode, and then
369
-     * initializing this addon's necessary initial data. This is called by default on new activations
370
-     * and reactivations.
371
-     *
372
-     * @param bool $verify_schema whether to verify the database's schema for this addon, or just its data.
373
-     *                               This is a resource-intensive job so we prefer to only do it when necessary
374
-     * @return void
375
-     * @throws EE_Error
376
-     * @throws InvalidInterfaceException
377
-     * @throws InvalidDataTypeException
378
-     * @throws InvalidArgumentException
379
-     * @throws ReflectionException
380
-     */
381
-    public function initialize_db_if_no_migrations_required($verify_schema = true)
382
-    {
383
-        if ($verify_schema === '') {
384
-            // wp core bug imo: if no args are passed to `do_action('some_hook_name')` besides the hook's name
385
-            // (ie, no 2nd or 3rd arguments), instead of calling the registered callbacks with no arguments, it
386
-            // calls them with an argument of an empty string (ie ""), which evaluates to false
387
-            // so we need to treat the empty string as if nothing had been passed, and should instead use the default
388
-            $verify_schema = true;
389
-        }
390
-        if (EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
391
-            if ($verify_schema) {
392
-                $this->initialize_db();
393
-            }
394
-            $this->initialize_default_data();
395
-            // @todo: this will probably need to be adjusted in 4.4 as the array changed formats I believe
396
-            EE_Data_Migration_Manager::instance()->update_current_database_state_to(
397
-                array(
398
-                    'slug'    => $this->name(),
399
-                    'version' => $this->version(),
400
-                )
401
-            );
402
-            /* make sure core's data is a-ok
22
+	/**
23
+	 * prefix to be added onto an addon's plugin slug to make a wp option name
24
+	 * which will be used to store the plugin's activation history
25
+	 */
26
+	const ee_addon_version_history_option_prefix = 'ee_version_history_';
27
+
28
+	/**
29
+	 * @var $_version
30
+	 * @type string
31
+	 */
32
+	protected $_version = '';
33
+
34
+	/**
35
+	 * @var $_min_core_version
36
+	 * @type string
37
+	 */
38
+	protected $_min_core_version = '';
39
+
40
+	/**
41
+	 * derived from plugin 'main_file_path using plugin_basename()
42
+	 *
43
+	 * @type string $_plugin_basename
44
+	 */
45
+	protected $_plugin_basename = '';
46
+
47
+	/**
48
+	 * A non-internationalized name to identify this addon for use in URLs, etc
49
+	 *
50
+	 * @type string $_plugin_slug
51
+	 */
52
+	protected $_plugin_slug = '';
53
+
54
+	/**
55
+	 * A non-internationalized name to identify this addon. Eg 'Calendar','MailChimp',etc/
56
+	 *
57
+	 * @type string _addon_name
58
+	 */
59
+	protected $_addon_name = '';
60
+
61
+	/**
62
+	 * one of the EE_System::req_type_* constants
63
+	 *
64
+	 * @type int $_req_type
65
+	 */
66
+	protected $_req_type;
67
+
68
+	/**
69
+	 * page slug to be used when generating the "Settings" link on the WP plugin page
70
+	 *
71
+	 * @type string $_plugin_action_slug
72
+	 */
73
+	protected $_plugin_action_slug = '';
74
+
75
+	/**
76
+	 * if not empty, inserts a new table row after this plugin's row on the WP Plugins page
77
+	 * that can be used for adding upgrading/marketing info
78
+	 *
79
+	 * @type array $_plugins_page_row
80
+	 */
81
+	protected $_plugins_page_row = array();
82
+
83
+
84
+	/**
85
+	 *    filepath to the main file, which can be used for register_activation_hook, register_deactivation_hook, etc.
86
+	 *
87
+	 * @type string
88
+	 */
89
+	protected $_main_plugin_file;
90
+
91
+	/**
92
+	 *    This is the slug used to identify this add-on within the plugin update engine.
93
+	 *
94
+	 * @type string
95
+	 */
96
+	protected $pue_slug;
97
+
98
+
99
+	/**
100
+	 * @var EE_Dependency_Map $dependency_map
101
+	 */
102
+	private $dependency_map;
103
+
104
+
105
+	/**
106
+	 * @var DomainInterface $domain
107
+	 */
108
+	private $domain;
109
+
110
+
111
+	/**
112
+	 * @param EE_Dependency_Map $dependency_map [optional]
113
+	 * @param DomainInterface   $domain         [optional]
114
+	 */
115
+	public function __construct(EE_Dependency_Map $dependency_map = null, DomainInterface $domain = null)
116
+	{
117
+		if ($dependency_map instanceof EE_Dependency_Map) {
118
+			$this->setDependencyMap($dependency_map);
119
+		}
120
+		if ($domain instanceof DomainInterface) {
121
+			$this->setDomain($domain);
122
+		}
123
+		add_action('AHEE__EE_System__load_controllers__load_admin_controllers', array($this, 'admin_init'));
124
+	}
125
+
126
+
127
+	/**
128
+	 * @param EE_Dependency_Map $dependency_map
129
+	 */
130
+	public function setDependencyMap($dependency_map)
131
+	{
132
+		$this->dependency_map = $dependency_map;
133
+	}
134
+
135
+
136
+	/**
137
+	 * @return EE_Dependency_Map
138
+	 */
139
+	public function dependencyMap()
140
+	{
141
+		return $this->dependency_map;
142
+	}
143
+
144
+
145
+	/**
146
+	 * @param DomainInterface $domain
147
+	 */
148
+	public function setDomain(DomainInterface $domain)
149
+	{
150
+		$this->domain = $domain;
151
+	}
152
+
153
+	/**
154
+	 * @return DomainInterface
155
+	 */
156
+	public function domain()
157
+	{
158
+		return $this->domain;
159
+	}
160
+
161
+
162
+	/**
163
+	 * @param mixed $version
164
+	 */
165
+	public function set_version($version = null)
166
+	{
167
+		$this->_version = $version;
168
+	}
169
+
170
+
171
+	/**
172
+	 * get__version
173
+	 *
174
+	 * @return string
175
+	 */
176
+	public function version()
177
+	{
178
+		return $this->_version;
179
+	}
180
+
181
+
182
+	/**
183
+	 * @param mixed $min_core_version
184
+	 */
185
+	public function set_min_core_version($min_core_version = null)
186
+	{
187
+		$this->_min_core_version = $min_core_version;
188
+	}
189
+
190
+
191
+	/**
192
+	 * get__min_core_version
193
+	 *
194
+	 * @return string
195
+	 */
196
+	public function min_core_version()
197
+	{
198
+		return $this->_min_core_version;
199
+	}
200
+
201
+
202
+	/**
203
+	 * Sets addon_name
204
+	 *
205
+	 * @param string $addon_name
206
+	 * @return bool
207
+	 */
208
+	public function set_name($addon_name)
209
+	{
210
+		return $this->_addon_name = $addon_name;
211
+	}
212
+
213
+
214
+	/**
215
+	 * Gets addon_name
216
+	 *
217
+	 * @return string
218
+	 */
219
+	public function name()
220
+	{
221
+		return $this->_addon_name;
222
+	}
223
+
224
+
225
+	/**
226
+	 * @return string
227
+	 */
228
+	public function plugin_basename()
229
+	{
230
+
231
+		return $this->_plugin_basename;
232
+	}
233
+
234
+
235
+	/**
236
+	 * @param string $plugin_basename
237
+	 */
238
+	public function set_plugin_basename($plugin_basename)
239
+	{
240
+
241
+		$this->_plugin_basename = $plugin_basename;
242
+	}
243
+
244
+
245
+	/**
246
+	 * @return string
247
+	 */
248
+	public function plugin_slug()
249
+	{
250
+
251
+		return $this->_plugin_slug;
252
+	}
253
+
254
+
255
+	/**
256
+	 * @param string $plugin_slug
257
+	 */
258
+	public function set_plugin_slug($plugin_slug)
259
+	{
260
+
261
+		$this->_plugin_slug = $plugin_slug;
262
+	}
263
+
264
+
265
+	/**
266
+	 * @return string
267
+	 */
268
+	public function plugin_action_slug()
269
+	{
270
+
271
+		return $this->_plugin_action_slug;
272
+	}
273
+
274
+
275
+	/**
276
+	 * @param string $plugin_action_slug
277
+	 */
278
+	public function set_plugin_action_slug($plugin_action_slug)
279
+	{
280
+
281
+		$this->_plugin_action_slug = $plugin_action_slug;
282
+	}
283
+
284
+
285
+	/**
286
+	 * @return array
287
+	 */
288
+	public function get_plugins_page_row()
289
+	{
290
+
291
+		return $this->_plugins_page_row;
292
+	}
293
+
294
+
295
+	/**
296
+	 * @param array $plugins_page_row
297
+	 */
298
+	public function set_plugins_page_row($plugins_page_row = array())
299
+	{
300
+		// sigh.... check for example content that I stupidly merged to master and remove it if found
301
+		if (
302
+			! is_array($plugins_page_row)
303
+			&& strpos($plugins_page_row, '<h3>Promotions Addon Upsell Info</h3>') !== false
304
+		) {
305
+			$plugins_page_row = array();
306
+		}
307
+		$this->_plugins_page_row = (array) $plugins_page_row;
308
+	}
309
+
310
+
311
+	/**
312
+	 * Called when EE core detects this addon has been activated for the first time.
313
+	 * If the site isn't in maintenance mode, should setup the addon's database
314
+	 *
315
+	 * @return void
316
+	 * @throws EE_Error
317
+	 */
318
+	public function new_install()
319
+	{
320
+		$classname = get_class($this);
321
+		do_action("AHEE__{$classname}__new_install");
322
+		do_action('AHEE__EE_Addon__new_install', $this);
323
+		EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
324
+		add_action(
325
+			'AHEE__EE_System__perform_activations_upgrades_and_migrations',
326
+			array($this, 'initialize_db_if_no_migrations_required')
327
+		);
328
+	}
329
+
330
+
331
+	/**
332
+	 * Called when EE core detects this addon has been reactivated. When this happens,
333
+	 * it's good to just check that your data is still intact
334
+	 *
335
+	 * @return void
336
+	 * @throws EE_Error
337
+	 */
338
+	public function reactivation()
339
+	{
340
+		$classname = get_class($this);
341
+		do_action("AHEE__{$classname}__reactivation");
342
+		do_action('AHEE__EE_Addon__reactivation', $this);
343
+		EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
344
+		add_action(
345
+			'AHEE__EE_System__perform_activations_upgrades_and_migrations',
346
+			array($this, 'initialize_db_if_no_migrations_required')
347
+		);
348
+	}
349
+
350
+
351
+	/**
352
+	 * Called when the registered deactivation hook for this addon fires.
353
+	 *
354
+	 * @throws EE_Error
355
+	 */
356
+	public function deactivation()
357
+	{
358
+		$classname = get_class($this);
359
+		do_action("AHEE__{$classname}__deactivation");
360
+		do_action('AHEE__EE_Addon__deactivation', $this);
361
+		// check if the site no longer needs to be in maintenance mode
362
+		EE_Register_Addon::deregister($this->name());
363
+		EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
364
+	}
365
+
366
+
367
+	/**
368
+	 * Takes care of double-checking that we're not in maintenance mode, and then
369
+	 * initializing this addon's necessary initial data. This is called by default on new activations
370
+	 * and reactivations.
371
+	 *
372
+	 * @param bool $verify_schema whether to verify the database's schema for this addon, or just its data.
373
+	 *                               This is a resource-intensive job so we prefer to only do it when necessary
374
+	 * @return void
375
+	 * @throws EE_Error
376
+	 * @throws InvalidInterfaceException
377
+	 * @throws InvalidDataTypeException
378
+	 * @throws InvalidArgumentException
379
+	 * @throws ReflectionException
380
+	 */
381
+	public function initialize_db_if_no_migrations_required($verify_schema = true)
382
+	{
383
+		if ($verify_schema === '') {
384
+			// wp core bug imo: if no args are passed to `do_action('some_hook_name')` besides the hook's name
385
+			// (ie, no 2nd or 3rd arguments), instead of calling the registered callbacks with no arguments, it
386
+			// calls them with an argument of an empty string (ie ""), which evaluates to false
387
+			// so we need to treat the empty string as if nothing had been passed, and should instead use the default
388
+			$verify_schema = true;
389
+		}
390
+		if (EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
391
+			if ($verify_schema) {
392
+				$this->initialize_db();
393
+			}
394
+			$this->initialize_default_data();
395
+			// @todo: this will probably need to be adjusted in 4.4 as the array changed formats I believe
396
+			EE_Data_Migration_Manager::instance()->update_current_database_state_to(
397
+				array(
398
+					'slug'    => $this->name(),
399
+					'version' => $this->version(),
400
+				)
401
+			);
402
+			/* make sure core's data is a-ok
403 403
              * (at the time of writing, we especially want to verify all the caps are present
404 404
              * because payment method type capabilities are added dynamically, and it's
405 405
              * possible this addon added a payment method. But it's also possible
406 406
              * other data needs to be verified)
407 407
              */
408
-            EEH_Activation::initialize_db_content();
409
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
410
-            $rewrite_rules = LoaderFactory::getLoader()->getShared(
411
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
412
-            );
413
-            $rewrite_rules->flushRewriteRules();
414
-            // in case there are lots of addons being activated at once, let's force garbage collection
415
-            // to help avoid memory limit errors
416
-            // EEH_Debug_Tools::instance()->measure_memory( 'db content initialized for ' . get_class( $this), true );
417
-            gc_collect_cycles();
418
-        } else {
419
-            // ask the data migration manager to init this addon's data
420
-            // when migrations are finished because we can't do it now
421
-            EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for($this->name());
422
-        }
423
-    }
424
-
425
-
426
-    /**
427
-     * Used to setup this addon's database tables, but not necessarily any default
428
-     * data in them. The default is to actually use the most up-to-date data migration script
429
-     * for this addon, and just use its schema_changes_before_migration() and schema_changes_after_migration()
430
-     * methods to setup the db.
431
-     */
432
-    public function initialize_db()
433
-    {
434
-        // find the migration script that sets the database to be compatible with the code
435
-        $current_dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms($this->name());
436
-        if ($current_dms_name) {
437
-            $current_data_migration_script = EE_Registry::instance()->load_dms($current_dms_name);
438
-            $current_data_migration_script->set_migrating(false);
439
-            $current_data_migration_script->schema_changes_before_migration();
440
-            $current_data_migration_script->schema_changes_after_migration();
441
-            if ($current_data_migration_script->get_errors()) {
442
-                foreach ($current_data_migration_script->get_errors() as $error) {
443
-                    EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
444
-                }
445
-            }
446
-        }
447
-        // if not DMS was found that should be ok. This addon just doesn't require any database changes
448
-        EE_Data_Migration_Manager::instance()->update_current_database_state_to(
449
-            array(
450
-                'slug'    => $this->name(),
451
-                'version' => $this->version(),
452
-            )
453
-        );
454
-    }
455
-
456
-
457
-    /**
458
-     * If you want to setup default data for the addon, override this method, and call
459
-     * parent::initialize_default_data() from within it. This is normally called
460
-     * from EE_Addon::initialize_db_if_no_migrations_required(), just after EE_Addon::initialize_db()
461
-     * and should verify default data is present (but this is also called
462
-     * on reactivations and just after migrations, so please verify you actually want
463
-     * to ADD default data, because it may already be present).
464
-     * However, please call this parent (currently it just fires a hook which other
465
-     * addons may be depending on)
466
-     */
467
-    public function initialize_default_data()
468
-    {
469
-        /**
470
-         * Called when an addon is ensuring its default data is set (possibly called
471
-         * on a reactivation, so first check for the absence of other data before setting
472
-         * default data)
473
-         *
474
-         * @param EE_Addon $addon the addon that called this
475
-         */
476
-        do_action('AHEE__EE_Addon__initialize_default_data__begin', $this);
477
-        // override to insert default data. It is safe to use the models here
478
-        // because the site should not be in maintenance mode
479
-    }
480
-
481
-
482
-    /**
483
-     * EE Core detected that this addon has been upgraded. We should check if there
484
-     * are any new migration scripts, and if so put the site into maintenance mode until
485
-     * they're ran
486
-     *
487
-     * @return void
488
-     * @throws EE_Error
489
-     */
490
-    public function upgrade()
491
-    {
492
-        $classname = get_class($this);
493
-        do_action("AHEE__{$classname}__upgrade");
494
-        do_action('AHEE__EE_Addon__upgrade', $this);
495
-        EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
496
-        // also it's possible there is new default data that needs to be added
497
-        add_action(
498
-            'AHEE__EE_System__perform_activations_upgrades_and_migrations',
499
-            array($this, 'initialize_db_if_no_migrations_required')
500
-        );
501
-    }
502
-
503
-
504
-    /**
505
-     * If Core detects this addon has been downgraded, you may want to invoke some special logic here.
506
-     */
507
-    public function downgrade()
508
-    {
509
-        $classname = get_class($this);
510
-        do_action("AHEE__{$classname}__downgrade");
511
-        do_action('AHEE__EE_Addon__downgrade', $this);
512
-        // it's possible there's old default data that needs to be double-checked
513
-        add_action(
514
-            'AHEE__EE_System__perform_activations_upgrades_and_migrations',
515
-            array($this, 'initialize_db_if_no_migrations_required')
516
-        );
517
-    }
518
-
519
-
520
-    /**
521
-     * set_db_update_option_name
522
-     * Until we do something better, we'll just check for migration scripts upon
523
-     * plugin activation only. In the future, we'll want to do it on plugin updates too
524
-     *
525
-     * @return bool
526
-     */
527
-    public function set_db_update_option_name()
528
-    {
529
-        EE_Error::doing_it_wrong(
530
-            __FUNCTION__,
531
-            esc_html__(
532
-                'EE_Addon::set_db_update_option_name was renamed to EE_Addon::set_activation_indicator_option',
533
-                'event_espresso'
534
-            ),
535
-            '4.3.0.alpha.016'
536
-        );
537
-        // let's just handle this on the next request, ok? right now we're just not really ready
538
-        return $this->set_activation_indicator_option();
539
-    }
540
-
541
-
542
-    /**
543
-     * Returns the name of the activation indicator option
544
-     * (an option which is set temporarily to indicate that this addon was just activated)
545
-     *
546
-     * @deprecated since version 4.3.0.alpha.016
547
-     * @return string
548
-     */
549
-    public function get_db_update_option_name()
550
-    {
551
-        EE_Error::doing_it_wrong(
552
-            __FUNCTION__,
553
-            esc_html__(
554
-                'EE_Addon::get_db_update_option was renamed to EE_Addon::get_activation_indicator_option_name',
555
-                'event_espresso'
556
-            ),
557
-            '4.3.0.alpha.016'
558
-        );
559
-        return $this->get_activation_indicator_option_name();
560
-    }
561
-
562
-
563
-    /**
564
-     * When the addon is activated, this should be called to set a wordpress option that
565
-     * indicates it was activated. This is especially useful for detecting reactivations.
566
-     *
567
-     * @return bool
568
-     */
569
-    public function set_activation_indicator_option()
570
-    {
571
-        // let's just handle this on the next request, ok? right now we're just not really ready
572
-        return update_option($this->get_activation_indicator_option_name(), true);
573
-    }
574
-
575
-
576
-    /**
577
-     * Gets the name of the wp option which is used to temporarily indicate that this addon was activated
578
-     *
579
-     * @return string
580
-     */
581
-    public function get_activation_indicator_option_name()
582
-    {
583
-        return 'ee_activation_' . $this->name();
584
-    }
585
-
586
-
587
-    /**
588
-     * Used by EE_System to set the request type of this addon. Should not be used by addon developers
589
-     *
590
-     * @param int $req_type
591
-     */
592
-    public function set_req_type($req_type)
593
-    {
594
-        $this->_req_type = $req_type;
595
-    }
596
-
597
-
598
-    /**
599
-     * Returns the request type of this addon (ie, EE_System::req_type_normal, EE_System::req_type_new_activation,
600
-     * EE_System::req_type_reactivation, EE_System::req_type_upgrade, or EE_System::req_type_downgrade). This is set by
601
-     * EE_System when it is checking for new install or upgrades of addons
602
-     */
603
-    public function detect_req_type($redetect = false)
604
-    {
605
-        if ($this->_req_type === null || $redetect) {
606
-            $this->detect_activation_or_upgrade();
607
-        }
608
-        return $this->_req_type;
609
-    }
610
-
611
-
612
-    /**
613
-     * Detects the request type for this addon (whether it was just activated, upgrades, a normal request, etc.)
614
-     * Should only be called once per request
615
-     *
616
-     * @return void
617
-     * @throws EE_Error
618
-     */
619
-    public function detect_activation_or_upgrade()
620
-    {
621
-        $activation_history_for_addon = $this->get_activation_history();
622
-        $request_type = EE_System::detect_req_type_given_activation_history(
623
-            $activation_history_for_addon,
624
-            $this->get_activation_indicator_option_name(),
625
-            $this->version()
626
-        );
627
-        $this->set_req_type($request_type);
628
-        $classname = get_class($this);
629
-        switch ($request_type) {
630
-            case EE_System::req_type_new_activation:
631
-                do_action("AHEE__{$classname}__detect_activations_or_upgrades__new_activation");
632
-                do_action('AHEE__EE_Addon__detect_activations_or_upgrades__new_activation', $this);
633
-                $this->new_install();
634
-                $this->update_list_of_installed_versions($activation_history_for_addon);
635
-                break;
636
-            case EE_System::req_type_reactivation:
637
-                do_action("AHEE__{$classname}__detect_activations_or_upgrades__reactivation");
638
-                do_action('AHEE__EE_Addon__detect_activations_or_upgrades__reactivation', $this);
639
-                $this->reactivation();
640
-                $this->update_list_of_installed_versions($activation_history_for_addon);
641
-                break;
642
-            case EE_System::req_type_upgrade:
643
-                do_action("AHEE__{$classname}__detect_activations_or_upgrades__upgrade");
644
-                do_action('AHEE__EE_Addon__detect_activations_or_upgrades__upgrade', $this);
645
-                $this->upgrade();
646
-                $this->update_list_of_installed_versions($activation_history_for_addon);
647
-                break;
648
-            case EE_System::req_type_downgrade:
649
-                do_action("AHEE__{$classname}__detect_activations_or_upgrades__downgrade");
650
-                do_action('AHEE__EE_Addon__detect_activations_or_upgrades__downgrade', $this);
651
-                $this->downgrade();
652
-                $this->update_list_of_installed_versions($activation_history_for_addon);
653
-                break;
654
-            case EE_System::req_type_normal:
655
-            default:
656
-                break;
657
-        }
658
-
659
-        do_action("AHEE__{$classname}__detect_if_activation_or_upgrade__complete");
660
-    }
661
-
662
-    /**
663
-     * Updates the version history for this addon
664
-     *
665
-     * @param array  $version_history
666
-     * @param string $current_version_to_add
667
-     * @return bool success
668
-     */
669
-    public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
670
-    {
671
-        if (! $version_history) {
672
-            $version_history = $this->get_activation_history();
673
-        }
674
-        if ($current_version_to_add === null) {
675
-            $current_version_to_add = $this->version();
676
-        }
677
-        $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time());
678
-        // resave
679
-        return update_option($this->get_activation_history_option_name(), $version_history);
680
-    }
681
-
682
-    /**
683
-     * Gets the name of the wp option that stores the activation history
684
-     * of this addon
685
-     *
686
-     * @return string
687
-     */
688
-    public function get_activation_history_option_name()
689
-    {
690
-        return self::ee_addon_version_history_option_prefix . $this->name();
691
-    }
692
-
693
-
694
-    /**
695
-     * Gets the wp option which stores the activation history for this addon
696
-     *
697
-     * @return array
698
-     */
699
-    public function get_activation_history()
700
-    {
701
-        return get_option($this->get_activation_history_option_name(), null);
702
-    }
703
-
704
-
705
-    /**
706
-     * @param string $config_section
707
-     */
708
-    public function set_config_section($config_section = '')
709
-    {
710
-        $this->_config_section = ! empty($config_section) ? $config_section : 'addons';
711
-    }
712
-
713
-    /**
714
-     * Sets the filepath to the main plugin file
715
-     *
716
-     * @param string $filepath
717
-     */
718
-    public function set_main_plugin_file($filepath)
719
-    {
720
-        $this->_main_plugin_file = $filepath;
721
-    }
722
-
723
-    /**
724
-     * gets the filepath to teh main file
725
-     *
726
-     * @return string
727
-     */
728
-    public function get_main_plugin_file()
729
-    {
730
-        return $this->_main_plugin_file;
731
-    }
732
-
733
-    /**
734
-     * Gets the filename (no path) of the main file (the main file loaded
735
-     * by WP)
736
-     *
737
-     * @return string
738
-     */
739
-    public function get_main_plugin_file_basename()
740
-    {
741
-        return plugin_basename($this->get_main_plugin_file());
742
-    }
743
-
744
-    /**
745
-     * Gets the folder name which contains the main plugin file
746
-     *
747
-     * @return string
748
-     */
749
-    public function get_main_plugin_file_dirname()
750
-    {
751
-        return dirname($this->get_main_plugin_file());
752
-    }
753
-
754
-
755
-    /**
756
-     * sets hooks used in the admin
757
-     *
758
-     * @return void
759
-     */
760
-    public function admin_init()
761
-    {
762
-        // is admin and not in M-Mode ?
763
-        if (is_admin() && ! EE_Maintenance_Mode::instance()->level()) {
764
-            add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2);
765
-            add_filter('after_plugin_row_' . $this->_plugin_basename, array($this, 'after_plugin_row'), 10, 3);
766
-        }
767
-    }
768
-
769
-
770
-    /**
771
-     * plugin_actions
772
-     * Add a settings link to the Plugins page, so people can go straight from the plugin page to the settings page.
773
-     *
774
-     * @param $links
775
-     * @param $file
776
-     * @return array
777
-     */
778
-    public function plugin_action_links($links, $file)
779
-    {
780
-        if ($file === $this->plugin_basename() && $this->plugin_action_slug() !== '') {
781
-            // before other links
782
-            array_unshift(
783
-                $links,
784
-                '<a href="admin.php?page=' . $this->plugin_action_slug() . '">'
785
-                . esc_html__('Settings', 'event_espresso')
786
-                . '</a>'
787
-            );
788
-        }
789
-        return $links;
790
-    }
791
-
792
-
793
-    /**
794
-     * after_plugin_row
795
-     * Add additional content to the plugins page plugin row
796
-     * Inserts another row
797
-     *
798
-     * @param $plugin_file
799
-     * @param $plugin_data
800
-     * @param $status
801
-     * @return void
802
-     */
803
-    public function after_plugin_row($plugin_file, $plugin_data, $status)
804
-    {
805
-        $after_plugin_row = '';
806
-        $plugins_page_row = $this->get_plugins_page_row();
807
-        if (! empty($plugins_page_row) && $plugin_file === $this->plugin_basename()) {
808
-            $class = $status ? 'active' : 'inactive';
809
-            $link_text = isset($plugins_page_row['link_text']) ? $plugins_page_row['link_text'] : '';
810
-            $link_url = isset($plugins_page_row['link_url']) ? $plugins_page_row['link_url'] : '';
811
-            $description = isset($plugins_page_row['description'])
812
-                ? $plugins_page_row['description']
813
-                : '';
814
-            if (! empty($link_text) && ! empty($link_url) && ! empty($description)) {
815
-                $after_plugin_row .= '<tr id="' . sanitize_title($plugin_file) . '-ee-addon" class="' . $class . '">';
816
-                $after_plugin_row .= '<th class="check-column" scope="row"></th>';
817
-                $after_plugin_row .= '<td class="ee-addon-upsell-info-title-td plugin-title column-primary">';
818
-                $after_plugin_row .= '<p class="ee-addon-upsell-info-dv">
408
+			EEH_Activation::initialize_db_content();
409
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
410
+			$rewrite_rules = LoaderFactory::getLoader()->getShared(
411
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
412
+			);
413
+			$rewrite_rules->flushRewriteRules();
414
+			// in case there are lots of addons being activated at once, let's force garbage collection
415
+			// to help avoid memory limit errors
416
+			// EEH_Debug_Tools::instance()->measure_memory( 'db content initialized for ' . get_class( $this), true );
417
+			gc_collect_cycles();
418
+		} else {
419
+			// ask the data migration manager to init this addon's data
420
+			// when migrations are finished because we can't do it now
421
+			EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for($this->name());
422
+		}
423
+	}
424
+
425
+
426
+	/**
427
+	 * Used to setup this addon's database tables, but not necessarily any default
428
+	 * data in them. The default is to actually use the most up-to-date data migration script
429
+	 * for this addon, and just use its schema_changes_before_migration() and schema_changes_after_migration()
430
+	 * methods to setup the db.
431
+	 */
432
+	public function initialize_db()
433
+	{
434
+		// find the migration script that sets the database to be compatible with the code
435
+		$current_dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms($this->name());
436
+		if ($current_dms_name) {
437
+			$current_data_migration_script = EE_Registry::instance()->load_dms($current_dms_name);
438
+			$current_data_migration_script->set_migrating(false);
439
+			$current_data_migration_script->schema_changes_before_migration();
440
+			$current_data_migration_script->schema_changes_after_migration();
441
+			if ($current_data_migration_script->get_errors()) {
442
+				foreach ($current_data_migration_script->get_errors() as $error) {
443
+					EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
444
+				}
445
+			}
446
+		}
447
+		// if not DMS was found that should be ok. This addon just doesn't require any database changes
448
+		EE_Data_Migration_Manager::instance()->update_current_database_state_to(
449
+			array(
450
+				'slug'    => $this->name(),
451
+				'version' => $this->version(),
452
+			)
453
+		);
454
+	}
455
+
456
+
457
+	/**
458
+	 * If you want to setup default data for the addon, override this method, and call
459
+	 * parent::initialize_default_data() from within it. This is normally called
460
+	 * from EE_Addon::initialize_db_if_no_migrations_required(), just after EE_Addon::initialize_db()
461
+	 * and should verify default data is present (but this is also called
462
+	 * on reactivations and just after migrations, so please verify you actually want
463
+	 * to ADD default data, because it may already be present).
464
+	 * However, please call this parent (currently it just fires a hook which other
465
+	 * addons may be depending on)
466
+	 */
467
+	public function initialize_default_data()
468
+	{
469
+		/**
470
+		 * Called when an addon is ensuring its default data is set (possibly called
471
+		 * on a reactivation, so first check for the absence of other data before setting
472
+		 * default data)
473
+		 *
474
+		 * @param EE_Addon $addon the addon that called this
475
+		 */
476
+		do_action('AHEE__EE_Addon__initialize_default_data__begin', $this);
477
+		// override to insert default data. It is safe to use the models here
478
+		// because the site should not be in maintenance mode
479
+	}
480
+
481
+
482
+	/**
483
+	 * EE Core detected that this addon has been upgraded. We should check if there
484
+	 * are any new migration scripts, and if so put the site into maintenance mode until
485
+	 * they're ran
486
+	 *
487
+	 * @return void
488
+	 * @throws EE_Error
489
+	 */
490
+	public function upgrade()
491
+	{
492
+		$classname = get_class($this);
493
+		do_action("AHEE__{$classname}__upgrade");
494
+		do_action('AHEE__EE_Addon__upgrade', $this);
495
+		EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
496
+		// also it's possible there is new default data that needs to be added
497
+		add_action(
498
+			'AHEE__EE_System__perform_activations_upgrades_and_migrations',
499
+			array($this, 'initialize_db_if_no_migrations_required')
500
+		);
501
+	}
502
+
503
+
504
+	/**
505
+	 * If Core detects this addon has been downgraded, you may want to invoke some special logic here.
506
+	 */
507
+	public function downgrade()
508
+	{
509
+		$classname = get_class($this);
510
+		do_action("AHEE__{$classname}__downgrade");
511
+		do_action('AHEE__EE_Addon__downgrade', $this);
512
+		// it's possible there's old default data that needs to be double-checked
513
+		add_action(
514
+			'AHEE__EE_System__perform_activations_upgrades_and_migrations',
515
+			array($this, 'initialize_db_if_no_migrations_required')
516
+		);
517
+	}
518
+
519
+
520
+	/**
521
+	 * set_db_update_option_name
522
+	 * Until we do something better, we'll just check for migration scripts upon
523
+	 * plugin activation only. In the future, we'll want to do it on plugin updates too
524
+	 *
525
+	 * @return bool
526
+	 */
527
+	public function set_db_update_option_name()
528
+	{
529
+		EE_Error::doing_it_wrong(
530
+			__FUNCTION__,
531
+			esc_html__(
532
+				'EE_Addon::set_db_update_option_name was renamed to EE_Addon::set_activation_indicator_option',
533
+				'event_espresso'
534
+			),
535
+			'4.3.0.alpha.016'
536
+		);
537
+		// let's just handle this on the next request, ok? right now we're just not really ready
538
+		return $this->set_activation_indicator_option();
539
+	}
540
+
541
+
542
+	/**
543
+	 * Returns the name of the activation indicator option
544
+	 * (an option which is set temporarily to indicate that this addon was just activated)
545
+	 *
546
+	 * @deprecated since version 4.3.0.alpha.016
547
+	 * @return string
548
+	 */
549
+	public function get_db_update_option_name()
550
+	{
551
+		EE_Error::doing_it_wrong(
552
+			__FUNCTION__,
553
+			esc_html__(
554
+				'EE_Addon::get_db_update_option was renamed to EE_Addon::get_activation_indicator_option_name',
555
+				'event_espresso'
556
+			),
557
+			'4.3.0.alpha.016'
558
+		);
559
+		return $this->get_activation_indicator_option_name();
560
+	}
561
+
562
+
563
+	/**
564
+	 * When the addon is activated, this should be called to set a wordpress option that
565
+	 * indicates it was activated. This is especially useful for detecting reactivations.
566
+	 *
567
+	 * @return bool
568
+	 */
569
+	public function set_activation_indicator_option()
570
+	{
571
+		// let's just handle this on the next request, ok? right now we're just not really ready
572
+		return update_option($this->get_activation_indicator_option_name(), true);
573
+	}
574
+
575
+
576
+	/**
577
+	 * Gets the name of the wp option which is used to temporarily indicate that this addon was activated
578
+	 *
579
+	 * @return string
580
+	 */
581
+	public function get_activation_indicator_option_name()
582
+	{
583
+		return 'ee_activation_' . $this->name();
584
+	}
585
+
586
+
587
+	/**
588
+	 * Used by EE_System to set the request type of this addon. Should not be used by addon developers
589
+	 *
590
+	 * @param int $req_type
591
+	 */
592
+	public function set_req_type($req_type)
593
+	{
594
+		$this->_req_type = $req_type;
595
+	}
596
+
597
+
598
+	/**
599
+	 * Returns the request type of this addon (ie, EE_System::req_type_normal, EE_System::req_type_new_activation,
600
+	 * EE_System::req_type_reactivation, EE_System::req_type_upgrade, or EE_System::req_type_downgrade). This is set by
601
+	 * EE_System when it is checking for new install or upgrades of addons
602
+	 */
603
+	public function detect_req_type($redetect = false)
604
+	{
605
+		if ($this->_req_type === null || $redetect) {
606
+			$this->detect_activation_or_upgrade();
607
+		}
608
+		return $this->_req_type;
609
+	}
610
+
611
+
612
+	/**
613
+	 * Detects the request type for this addon (whether it was just activated, upgrades, a normal request, etc.)
614
+	 * Should only be called once per request
615
+	 *
616
+	 * @return void
617
+	 * @throws EE_Error
618
+	 */
619
+	public function detect_activation_or_upgrade()
620
+	{
621
+		$activation_history_for_addon = $this->get_activation_history();
622
+		$request_type = EE_System::detect_req_type_given_activation_history(
623
+			$activation_history_for_addon,
624
+			$this->get_activation_indicator_option_name(),
625
+			$this->version()
626
+		);
627
+		$this->set_req_type($request_type);
628
+		$classname = get_class($this);
629
+		switch ($request_type) {
630
+			case EE_System::req_type_new_activation:
631
+				do_action("AHEE__{$classname}__detect_activations_or_upgrades__new_activation");
632
+				do_action('AHEE__EE_Addon__detect_activations_or_upgrades__new_activation', $this);
633
+				$this->new_install();
634
+				$this->update_list_of_installed_versions($activation_history_for_addon);
635
+				break;
636
+			case EE_System::req_type_reactivation:
637
+				do_action("AHEE__{$classname}__detect_activations_or_upgrades__reactivation");
638
+				do_action('AHEE__EE_Addon__detect_activations_or_upgrades__reactivation', $this);
639
+				$this->reactivation();
640
+				$this->update_list_of_installed_versions($activation_history_for_addon);
641
+				break;
642
+			case EE_System::req_type_upgrade:
643
+				do_action("AHEE__{$classname}__detect_activations_or_upgrades__upgrade");
644
+				do_action('AHEE__EE_Addon__detect_activations_or_upgrades__upgrade', $this);
645
+				$this->upgrade();
646
+				$this->update_list_of_installed_versions($activation_history_for_addon);
647
+				break;
648
+			case EE_System::req_type_downgrade:
649
+				do_action("AHEE__{$classname}__detect_activations_or_upgrades__downgrade");
650
+				do_action('AHEE__EE_Addon__detect_activations_or_upgrades__downgrade', $this);
651
+				$this->downgrade();
652
+				$this->update_list_of_installed_versions($activation_history_for_addon);
653
+				break;
654
+			case EE_System::req_type_normal:
655
+			default:
656
+				break;
657
+		}
658
+
659
+		do_action("AHEE__{$classname}__detect_if_activation_or_upgrade__complete");
660
+	}
661
+
662
+	/**
663
+	 * Updates the version history for this addon
664
+	 *
665
+	 * @param array  $version_history
666
+	 * @param string $current_version_to_add
667
+	 * @return bool success
668
+	 */
669
+	public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
670
+	{
671
+		if (! $version_history) {
672
+			$version_history = $this->get_activation_history();
673
+		}
674
+		if ($current_version_to_add === null) {
675
+			$current_version_to_add = $this->version();
676
+		}
677
+		$version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time());
678
+		// resave
679
+		return update_option($this->get_activation_history_option_name(), $version_history);
680
+	}
681
+
682
+	/**
683
+	 * Gets the name of the wp option that stores the activation history
684
+	 * of this addon
685
+	 *
686
+	 * @return string
687
+	 */
688
+	public function get_activation_history_option_name()
689
+	{
690
+		return self::ee_addon_version_history_option_prefix . $this->name();
691
+	}
692
+
693
+
694
+	/**
695
+	 * Gets the wp option which stores the activation history for this addon
696
+	 *
697
+	 * @return array
698
+	 */
699
+	public function get_activation_history()
700
+	{
701
+		return get_option($this->get_activation_history_option_name(), null);
702
+	}
703
+
704
+
705
+	/**
706
+	 * @param string $config_section
707
+	 */
708
+	public function set_config_section($config_section = '')
709
+	{
710
+		$this->_config_section = ! empty($config_section) ? $config_section : 'addons';
711
+	}
712
+
713
+	/**
714
+	 * Sets the filepath to the main plugin file
715
+	 *
716
+	 * @param string $filepath
717
+	 */
718
+	public function set_main_plugin_file($filepath)
719
+	{
720
+		$this->_main_plugin_file = $filepath;
721
+	}
722
+
723
+	/**
724
+	 * gets the filepath to teh main file
725
+	 *
726
+	 * @return string
727
+	 */
728
+	public function get_main_plugin_file()
729
+	{
730
+		return $this->_main_plugin_file;
731
+	}
732
+
733
+	/**
734
+	 * Gets the filename (no path) of the main file (the main file loaded
735
+	 * by WP)
736
+	 *
737
+	 * @return string
738
+	 */
739
+	public function get_main_plugin_file_basename()
740
+	{
741
+		return plugin_basename($this->get_main_plugin_file());
742
+	}
743
+
744
+	/**
745
+	 * Gets the folder name which contains the main plugin file
746
+	 *
747
+	 * @return string
748
+	 */
749
+	public function get_main_plugin_file_dirname()
750
+	{
751
+		return dirname($this->get_main_plugin_file());
752
+	}
753
+
754
+
755
+	/**
756
+	 * sets hooks used in the admin
757
+	 *
758
+	 * @return void
759
+	 */
760
+	public function admin_init()
761
+	{
762
+		// is admin and not in M-Mode ?
763
+		if (is_admin() && ! EE_Maintenance_Mode::instance()->level()) {
764
+			add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2);
765
+			add_filter('after_plugin_row_' . $this->_plugin_basename, array($this, 'after_plugin_row'), 10, 3);
766
+		}
767
+	}
768
+
769
+
770
+	/**
771
+	 * plugin_actions
772
+	 * Add a settings link to the Plugins page, so people can go straight from the plugin page to the settings page.
773
+	 *
774
+	 * @param $links
775
+	 * @param $file
776
+	 * @return array
777
+	 */
778
+	public function plugin_action_links($links, $file)
779
+	{
780
+		if ($file === $this->plugin_basename() && $this->plugin_action_slug() !== '') {
781
+			// before other links
782
+			array_unshift(
783
+				$links,
784
+				'<a href="admin.php?page=' . $this->plugin_action_slug() . '">'
785
+				. esc_html__('Settings', 'event_espresso')
786
+				. '</a>'
787
+			);
788
+		}
789
+		return $links;
790
+	}
791
+
792
+
793
+	/**
794
+	 * after_plugin_row
795
+	 * Add additional content to the plugins page plugin row
796
+	 * Inserts another row
797
+	 *
798
+	 * @param $plugin_file
799
+	 * @param $plugin_data
800
+	 * @param $status
801
+	 * @return void
802
+	 */
803
+	public function after_plugin_row($plugin_file, $plugin_data, $status)
804
+	{
805
+		$after_plugin_row = '';
806
+		$plugins_page_row = $this->get_plugins_page_row();
807
+		if (! empty($plugins_page_row) && $plugin_file === $this->plugin_basename()) {
808
+			$class = $status ? 'active' : 'inactive';
809
+			$link_text = isset($plugins_page_row['link_text']) ? $plugins_page_row['link_text'] : '';
810
+			$link_url = isset($plugins_page_row['link_url']) ? $plugins_page_row['link_url'] : '';
811
+			$description = isset($plugins_page_row['description'])
812
+				? $plugins_page_row['description']
813
+				: '';
814
+			if (! empty($link_text) && ! empty($link_url) && ! empty($description)) {
815
+				$after_plugin_row .= '<tr id="' . sanitize_title($plugin_file) . '-ee-addon" class="' . $class . '">';
816
+				$after_plugin_row .= '<th class="check-column" scope="row"></th>';
817
+				$after_plugin_row .= '<td class="ee-addon-upsell-info-title-td plugin-title column-primary">';
818
+				$after_plugin_row .= '<p class="ee-addon-upsell-info-dv">
819 819
 	                <a class="ee-button" href="' . esc_url_raw($link_url) . '">'
820
-                    . $link_text
821
-                    . ' &nbsp;<span class="dashicons dashicons-arrow-right-alt2" style="margin:0;"></span>'
822
-                    . '</a>
820
+					. $link_text
821
+					. ' &nbsp;<span class="dashicons dashicons-arrow-right-alt2" style="margin:0;"></span>'
822
+					. '</a>
823 823
                 </p>';
824
-                $after_plugin_row .= '</td>';
825
-                $after_plugin_row .= '<td class="ee-addon-upsell-info-desc-td column-description desc">';
826
-                $after_plugin_row .= $description;
827
-                $after_plugin_row .= '</td>';
828
-                $after_plugin_row .= '</tr>';
829
-            } else {
830
-                $after_plugin_row .= $description;
831
-            }
832
-        }
833
-
834
-        echo $after_plugin_row;
835
-    }
836
-
837
-
838
-    /**
839
-     * A safe space for addons to add additional logic like setting hooks that need to be set early in the request.
840
-     * Child classes that have logic like that to run can override this method declaration.  This was not made abstract
841
-     * for back compat reasons.
842
-     *
843
-     * This will fire on the `AHEE__EE_System__load_espresso_addons__complete` hook at priority 999.
844
-     *
845
-     * It is recommended, if client code is `de-registering` an add-on, then do it on the
846
-     * `AHEE__EE_System__load_espresso_addons__complete` hook before priority 999 so as to ensure any code logic in this
847
-     * callback does not get run/set in that request.
848
-     *
849
-     * Also, keep in mind that if a registered add-on happens to be deactivated via
850
-     * EE_System::_deactivate_incompatible_addons() because its incompatible, any code executed in this method
851
-     * (including setting hooks etc) will have executed before the plugin was deactivated.  If you use
852
-     * `after_registration` to set any filter and/or action hooks and want to ensure they are removed on this add-on's
853
-     * deactivation, you can override `EE_Addon::deactivation` and unset your hooks and filters there.  Just remember
854
-     * to call `parent::deactivation`.
855
-     *
856
-     * @since 4.9.26
857
-     */
858
-    public function after_registration()
859
-    {
860
-        // cricket chirp... cricket chirp...
861
-    }
862
-
863
-    /**
864
-     * @return string
865
-     */
866
-    public function getPueSlug()
867
-    {
868
-        return $this->pue_slug;
869
-    }
870
-    /**
871
-     * @param string $pue_slug
872
-     */
873
-    public function setPueSlug($pue_slug)
874
-    {
875
-        $this->pue_slug = $pue_slug;
876
-    }
824
+				$after_plugin_row .= '</td>';
825
+				$after_plugin_row .= '<td class="ee-addon-upsell-info-desc-td column-description desc">';
826
+				$after_plugin_row .= $description;
827
+				$after_plugin_row .= '</td>';
828
+				$after_plugin_row .= '</tr>';
829
+			} else {
830
+				$after_plugin_row .= $description;
831
+			}
832
+		}
833
+
834
+		echo $after_plugin_row;
835
+	}
836
+
837
+
838
+	/**
839
+	 * A safe space for addons to add additional logic like setting hooks that need to be set early in the request.
840
+	 * Child classes that have logic like that to run can override this method declaration.  This was not made abstract
841
+	 * for back compat reasons.
842
+	 *
843
+	 * This will fire on the `AHEE__EE_System__load_espresso_addons__complete` hook at priority 999.
844
+	 *
845
+	 * It is recommended, if client code is `de-registering` an add-on, then do it on the
846
+	 * `AHEE__EE_System__load_espresso_addons__complete` hook before priority 999 so as to ensure any code logic in this
847
+	 * callback does not get run/set in that request.
848
+	 *
849
+	 * Also, keep in mind that if a registered add-on happens to be deactivated via
850
+	 * EE_System::_deactivate_incompatible_addons() because its incompatible, any code executed in this method
851
+	 * (including setting hooks etc) will have executed before the plugin was deactivated.  If you use
852
+	 * `after_registration` to set any filter and/or action hooks and want to ensure they are removed on this add-on's
853
+	 * deactivation, you can override `EE_Addon::deactivation` and unset your hooks and filters there.  Just remember
854
+	 * to call `parent::deactivation`.
855
+	 *
856
+	 * @since 4.9.26
857
+	 */
858
+	public function after_registration()
859
+	{
860
+		// cricket chirp... cricket chirp...
861
+	}
862
+
863
+	/**
864
+	 * @return string
865
+	 */
866
+	public function getPueSlug()
867
+	{
868
+		return $this->pue_slug;
869
+	}
870
+	/**
871
+	 * @param string $pue_slug
872
+	 */
873
+	public function setPueSlug($pue_slug)
874
+	{
875
+		$this->pue_slug = $pue_slug;
876
+	}
877 877
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
      */
581 581
     public function get_activation_indicator_option_name()
582 582
     {
583
-        return 'ee_activation_' . $this->name();
583
+        return 'ee_activation_'.$this->name();
584 584
     }
585 585
 
586 586
 
@@ -668,13 +668,13 @@  discard block
 block discarded – undo
668 668
      */
669 669
     public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
670 670
     {
671
-        if (! $version_history) {
671
+        if ( ! $version_history) {
672 672
             $version_history = $this->get_activation_history();
673 673
         }
674 674
         if ($current_version_to_add === null) {
675 675
             $current_version_to_add = $this->version();
676 676
         }
677
-        $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time());
677
+        $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time());
678 678
         // resave
679 679
         return update_option($this->get_activation_history_option_name(), $version_history);
680 680
     }
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
      */
688 688
     public function get_activation_history_option_name()
689 689
     {
690
-        return self::ee_addon_version_history_option_prefix . $this->name();
690
+        return self::ee_addon_version_history_option_prefix.$this->name();
691 691
     }
692 692
 
693 693
 
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
         // is admin and not in M-Mode ?
763 763
         if (is_admin() && ! EE_Maintenance_Mode::instance()->level()) {
764 764
             add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2);
765
-            add_filter('after_plugin_row_' . $this->_plugin_basename, array($this, 'after_plugin_row'), 10, 3);
765
+            add_filter('after_plugin_row_'.$this->_plugin_basename, array($this, 'after_plugin_row'), 10, 3);
766 766
         }
767 767
     }
768 768
 
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
             // before other links
782 782
             array_unshift(
783 783
                 $links,
784
-                '<a href="admin.php?page=' . $this->plugin_action_slug() . '">'
784
+                '<a href="admin.php?page='.$this->plugin_action_slug().'">'
785 785
                 . esc_html__('Settings', 'event_espresso')
786 786
                 . '</a>'
787 787
             );
@@ -804,19 +804,19 @@  discard block
 block discarded – undo
804 804
     {
805 805
         $after_plugin_row = '';
806 806
         $plugins_page_row = $this->get_plugins_page_row();
807
-        if (! empty($plugins_page_row) && $plugin_file === $this->plugin_basename()) {
807
+        if ( ! empty($plugins_page_row) && $plugin_file === $this->plugin_basename()) {
808 808
             $class = $status ? 'active' : 'inactive';
809 809
             $link_text = isset($plugins_page_row['link_text']) ? $plugins_page_row['link_text'] : '';
810 810
             $link_url = isset($plugins_page_row['link_url']) ? $plugins_page_row['link_url'] : '';
811 811
             $description = isset($plugins_page_row['description'])
812 812
                 ? $plugins_page_row['description']
813 813
                 : '';
814
-            if (! empty($link_text) && ! empty($link_url) && ! empty($description)) {
815
-                $after_plugin_row .= '<tr id="' . sanitize_title($plugin_file) . '-ee-addon" class="' . $class . '">';
814
+            if ( ! empty($link_text) && ! empty($link_url) && ! empty($description)) {
815
+                $after_plugin_row .= '<tr id="'.sanitize_title($plugin_file).'-ee-addon" class="'.$class.'">';
816 816
                 $after_plugin_row .= '<th class="check-column" scope="row"></th>';
817 817
                 $after_plugin_row .= '<td class="ee-addon-upsell-info-title-td plugin-title column-primary">';
818 818
                 $after_plugin_row .= '<p class="ee-addon-upsell-info-dv">
819
-	                <a class="ee-button" href="' . esc_url_raw($link_url) . '">'
819
+	                <a class="ee-button" href="' . esc_url_raw($link_url).'">'
820 820
                     . $link_text
821 821
                     . ' &nbsp;<span class="dashicons dashicons-arrow-right-alt2" style="margin:0;"></span>'
822 822
                     . '</a>
Please login to merge, or discard this patch.
core/services/request/sanitizers/AllowedTags.php 1 patch
Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -13,228 +13,228 @@
 block discarded – undo
13 13
 class AllowedTags
14 14
 {
15 15
 
16
-    /**
17
-     * @var array[]
18
-     */
19
-    private static $attributes = [
20
-        'accept-charset'    => 1,
21
-        'action'            => 1,
22
-        'alt'               => 1,
23
-        'allow'             => 1,
24
-        'allowfullscreen'   => 1,
25
-        'align'             => 1,
26
-        'aria-*'            => 1,
27
-        'autocomplete'      => 1,
28
-        'checked'           => 1,
29
-        'class'             => 1,
30
-        'cols'              => 1,
31
-        'content'           => 1,
32
-        'data-*'            => 1,
33
-        'dir'               => 1,
34
-        'disabled'          => 1,
35
-        'enctype'           => 1,
36
-        'for'               => 1,
37
-        'frameborder'       => 1,
38
-        'height'            => 1,
39
-        'href'              => 1,
40
-        'id'                => 1,
41
-        'itemprop'          => 1,
42
-        'itemscope'         => 1,
43
-        'itemtype'          => 1,
44
-        'label'             => 1,
45
-        'lang'              => 1,
46
-        'max'               => 1,
47
-        'maxlength'         => 1,
48
-        'method'            => 1,
49
-        'min'               => 1,
50
-        'multiple'          => 1,
51
-        'name'              => 1,
52
-        'novalidate'        => 1,
53
-        'placeholder'       => 1,
54
-        'readonly'          => 1,
55
-        'rel'               => 1,
56
-        'required'          => 1,
57
-        'rows'              => 1,
58
-        'selected'          => 1,
59
-        'src'               => 1,
60
-        'size'              => 1,
61
-        'style'             => 1,
62
-        'step'              => 1,
63
-        'tabindex'          => 1,
64
-        'target'            => 1,
65
-        'title'             => 1,
66
-        'type'              => 1,
67
-        'value'             => 1,
68
-        'width'             => 1,
69
-    ];
70
-
71
-
72
-    /**
73
-     * @var array
74
-     */
75
-    private static $tags = [
76
-        'a',
77
-        'abbr',
78
-        'b',
79
-        'br',
80
-        'code',
81
-        'div',
82
-        'em',
83
-        'h1',
84
-        'h2',
85
-        'h3',
86
-        'h4',
87
-        'h5',
88
-        'h6',
89
-        'hr',
90
-        'i',
91
-        'img',
92
-        'li',
93
-        'ol',
94
-        'p',
95
-        'pre',
96
-        'small',
97
-        'span',
98
-        'strong',
99
-        'table',
100
-        'td',
101
-        'tr',
102
-        'ul',
103
-    ];
104
-
105
-
106
-    /**
107
-     * @var array
108
-     */
109
-    private static $allowed_tags;
110
-
111
-
112
-    /**
113
-     * @var array
114
-     */
115
-    private static $allowed_with_embed_tags;
116
-
117
-
118
-    /**
119
-     * @var array
120
-     */
121
-    private static $allowed_with_form_tags;
122
-
123
-
124
-    /**
125
-     * @var array
126
-     */
127
-    private static $allowed_with_script_and_style_tags;
128
-
129
-
130
-    /**
131
-     * merges additional tags and attributes into the WP post tags
132
-     */
133
-    private static function initializeAllowedTags()
134
-    {
135
-        $allowed_post_tags = wp_kses_allowed_html('post');
136
-        $allowed_tags = [];
137
-        foreach (AllowedTags::$tags as $tag) {
138
-            $allowed_tags[ $tag ] = AllowedTags::$attributes;
139
-        }
140
-        AllowedTags::$allowed_tags = array_merge_recursive($allowed_post_tags, $allowed_tags);
141
-    }
142
-
143
-
144
-    /**
145
-     * merges embed tags and attributes into the EE all tags
146
-     */
147
-    private static function initializeWithEmbedTags()
148
-    {
149
-        $all_tags = AllowedTags::getAllowedTags();
150
-        $embed_tags = [
151
-            'iframe' => AllowedTags::$attributes
152
-        ];
153
-        AllowedTags::$allowed_with_embed_tags = array_merge_recursive($all_tags, $embed_tags);
154
-    }
155
-
156
-
157
-    /**
158
-     * merges form tags and attributes into the EE all tags
159
-     */
160
-    private static function initializeWithFormTags()
161
-    {
162
-        $all_tags = AllowedTags::getAllowedTags();
163
-        $form_tags = [
164
-            'form' => AllowedTags::$attributes,
165
-            'label' => AllowedTags::$attributes,
166
-            'input' => AllowedTags::$attributes,
167
-            'select' => AllowedTags::$attributes,
168
-            'option' => AllowedTags::$attributes,
169
-            'optgroup' => AllowedTags::$attributes,
170
-            'textarea' => AllowedTags::$attributes,
171
-            'button' => AllowedTags::$attributes,
172
-            'fieldset' => AllowedTags::$attributes,
173
-            'output' => AllowedTags::$attributes,
174
-        ];
175
-        AllowedTags::$allowed_with_form_tags = array_merge_recursive($all_tags, $form_tags);
176
-    }
177
-
178
-
179
-    /**
180
-     * merges form script and style tags and attributes into the EE all tags
181
-     */
182
-    private static function initializeWithScriptAndStyleTags()
183
-    {
184
-        $all_tags = AllowedTags::getAllowedTags();
185
-        $script_and_style_tags = [
186
-            'script' => AllowedTags::$attributes,
187
-            'style' => AllowedTags::$attributes,
188
-            'link' => AllowedTags::$attributes,
189
-        ];
190
-        AllowedTags::$allowed_with_script_and_style_tags = array_merge_recursive($all_tags, $script_and_style_tags);
191
-    }
192
-
193
-
194
-    /**
195
-     * @return array[]
196
-     */
197
-    public static function getAllowedTags()
198
-    {
199
-        if (empty(AllowedTags::$allowed_tags)) {
200
-            AllowedTags::initializeAllowedTags();
201
-        }
202
-        return AllowedTags::$allowed_tags;
203
-    }
204
-
205
-
206
-    /**
207
-     * @return array[]
208
-     */
209
-    public static function getWithEmbedTags()
210
-    {
211
-        if (empty(AllowedTags::$allowed_with_embed_tags)) {
212
-            AllowedTags::initializeWithEmbedTags();
213
-        }
214
-        return AllowedTags::$allowed_with_embed_tags;
215
-    }
216
-
217
-
218
-    /**
219
-     * @return array[]
220
-     */
221
-    public static function getWithFormTags()
222
-    {
223
-        if (empty(AllowedTags::$allowed_with_form_tags)) {
224
-            AllowedTags::initializeWithFormTags();
225
-        }
226
-        return AllowedTags::$allowed_with_form_tags;
227
-    }
228
-
229
-
230
-    /**
231
-     * @return array[]
232
-     */
233
-    public static function getWithScriptAndStyleTags()
234
-    {
235
-        if (empty(AllowedTags::$allowed_with_script_and_style_tags)) {
236
-            AllowedTags::initializeWithScriptAndStyleTags();
237
-        }
238
-        return AllowedTags::$allowed_with_script_and_style_tags;
239
-    }
16
+	/**
17
+	 * @var array[]
18
+	 */
19
+	private static $attributes = [
20
+		'accept-charset'    => 1,
21
+		'action'            => 1,
22
+		'alt'               => 1,
23
+		'allow'             => 1,
24
+		'allowfullscreen'   => 1,
25
+		'align'             => 1,
26
+		'aria-*'            => 1,
27
+		'autocomplete'      => 1,
28
+		'checked'           => 1,
29
+		'class'             => 1,
30
+		'cols'              => 1,
31
+		'content'           => 1,
32
+		'data-*'            => 1,
33
+		'dir'               => 1,
34
+		'disabled'          => 1,
35
+		'enctype'           => 1,
36
+		'for'               => 1,
37
+		'frameborder'       => 1,
38
+		'height'            => 1,
39
+		'href'              => 1,
40
+		'id'                => 1,
41
+		'itemprop'          => 1,
42
+		'itemscope'         => 1,
43
+		'itemtype'          => 1,
44
+		'label'             => 1,
45
+		'lang'              => 1,
46
+		'max'               => 1,
47
+		'maxlength'         => 1,
48
+		'method'            => 1,
49
+		'min'               => 1,
50
+		'multiple'          => 1,
51
+		'name'              => 1,
52
+		'novalidate'        => 1,
53
+		'placeholder'       => 1,
54
+		'readonly'          => 1,
55
+		'rel'               => 1,
56
+		'required'          => 1,
57
+		'rows'              => 1,
58
+		'selected'          => 1,
59
+		'src'               => 1,
60
+		'size'              => 1,
61
+		'style'             => 1,
62
+		'step'              => 1,
63
+		'tabindex'          => 1,
64
+		'target'            => 1,
65
+		'title'             => 1,
66
+		'type'              => 1,
67
+		'value'             => 1,
68
+		'width'             => 1,
69
+	];
70
+
71
+
72
+	/**
73
+	 * @var array
74
+	 */
75
+	private static $tags = [
76
+		'a',
77
+		'abbr',
78
+		'b',
79
+		'br',
80
+		'code',
81
+		'div',
82
+		'em',
83
+		'h1',
84
+		'h2',
85
+		'h3',
86
+		'h4',
87
+		'h5',
88
+		'h6',
89
+		'hr',
90
+		'i',
91
+		'img',
92
+		'li',
93
+		'ol',
94
+		'p',
95
+		'pre',
96
+		'small',
97
+		'span',
98
+		'strong',
99
+		'table',
100
+		'td',
101
+		'tr',
102
+		'ul',
103
+	];
104
+
105
+
106
+	/**
107
+	 * @var array
108
+	 */
109
+	private static $allowed_tags;
110
+
111
+
112
+	/**
113
+	 * @var array
114
+	 */
115
+	private static $allowed_with_embed_tags;
116
+
117
+
118
+	/**
119
+	 * @var array
120
+	 */
121
+	private static $allowed_with_form_tags;
122
+
123
+
124
+	/**
125
+	 * @var array
126
+	 */
127
+	private static $allowed_with_script_and_style_tags;
128
+
129
+
130
+	/**
131
+	 * merges additional tags and attributes into the WP post tags
132
+	 */
133
+	private static function initializeAllowedTags()
134
+	{
135
+		$allowed_post_tags = wp_kses_allowed_html('post');
136
+		$allowed_tags = [];
137
+		foreach (AllowedTags::$tags as $tag) {
138
+			$allowed_tags[ $tag ] = AllowedTags::$attributes;
139
+		}
140
+		AllowedTags::$allowed_tags = array_merge_recursive($allowed_post_tags, $allowed_tags);
141
+	}
142
+
143
+
144
+	/**
145
+	 * merges embed tags and attributes into the EE all tags
146
+	 */
147
+	private static function initializeWithEmbedTags()
148
+	{
149
+		$all_tags = AllowedTags::getAllowedTags();
150
+		$embed_tags = [
151
+			'iframe' => AllowedTags::$attributes
152
+		];
153
+		AllowedTags::$allowed_with_embed_tags = array_merge_recursive($all_tags, $embed_tags);
154
+	}
155
+
156
+
157
+	/**
158
+	 * merges form tags and attributes into the EE all tags
159
+	 */
160
+	private static function initializeWithFormTags()
161
+	{
162
+		$all_tags = AllowedTags::getAllowedTags();
163
+		$form_tags = [
164
+			'form' => AllowedTags::$attributes,
165
+			'label' => AllowedTags::$attributes,
166
+			'input' => AllowedTags::$attributes,
167
+			'select' => AllowedTags::$attributes,
168
+			'option' => AllowedTags::$attributes,
169
+			'optgroup' => AllowedTags::$attributes,
170
+			'textarea' => AllowedTags::$attributes,
171
+			'button' => AllowedTags::$attributes,
172
+			'fieldset' => AllowedTags::$attributes,
173
+			'output' => AllowedTags::$attributes,
174
+		];
175
+		AllowedTags::$allowed_with_form_tags = array_merge_recursive($all_tags, $form_tags);
176
+	}
177
+
178
+
179
+	/**
180
+	 * merges form script and style tags and attributes into the EE all tags
181
+	 */
182
+	private static function initializeWithScriptAndStyleTags()
183
+	{
184
+		$all_tags = AllowedTags::getAllowedTags();
185
+		$script_and_style_tags = [
186
+			'script' => AllowedTags::$attributes,
187
+			'style' => AllowedTags::$attributes,
188
+			'link' => AllowedTags::$attributes,
189
+		];
190
+		AllowedTags::$allowed_with_script_and_style_tags = array_merge_recursive($all_tags, $script_and_style_tags);
191
+	}
192
+
193
+
194
+	/**
195
+	 * @return array[]
196
+	 */
197
+	public static function getAllowedTags()
198
+	{
199
+		if (empty(AllowedTags::$allowed_tags)) {
200
+			AllowedTags::initializeAllowedTags();
201
+		}
202
+		return AllowedTags::$allowed_tags;
203
+	}
204
+
205
+
206
+	/**
207
+	 * @return array[]
208
+	 */
209
+	public static function getWithEmbedTags()
210
+	{
211
+		if (empty(AllowedTags::$allowed_with_embed_tags)) {
212
+			AllowedTags::initializeWithEmbedTags();
213
+		}
214
+		return AllowedTags::$allowed_with_embed_tags;
215
+	}
216
+
217
+
218
+	/**
219
+	 * @return array[]
220
+	 */
221
+	public static function getWithFormTags()
222
+	{
223
+		if (empty(AllowedTags::$allowed_with_form_tags)) {
224
+			AllowedTags::initializeWithFormTags();
225
+		}
226
+		return AllowedTags::$allowed_with_form_tags;
227
+	}
228
+
229
+
230
+	/**
231
+	 * @return array[]
232
+	 */
233
+	public static function getWithScriptAndStyleTags()
234
+	{
235
+		if (empty(AllowedTags::$allowed_with_script_and_style_tags)) {
236
+			AllowedTags::initializeWithScriptAndStyleTags();
237
+		}
238
+		return AllowedTags::$allowed_with_script_and_style_tags;
239
+	}
240 240
 }
Please login to merge, or discard this patch.
core/bootstrap_espresso.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -14,22 +14,22 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function espresso_load_error_handling()
16 16
 {
17
-    static $error_handling_loaded = false;
18
-    if ($error_handling_loaded) {
19
-        return;
20
-    }
21
-    // load debugging tools
22
-    if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
23
-        require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php';
24
-        EEH_Debug_Tools::instance();
25
-    }
26
-    // load error handling
27
-    if (is_readable(EE_CORE . 'EE_Error.core.php')) {
28
-        require_once EE_CORE . 'EE_Error.core.php';
29
-    } else {
30
-        wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
31
-    }
32
-    $error_handling_loaded = true;
17
+	static $error_handling_loaded = false;
18
+	if ($error_handling_loaded) {
19
+		return;
20
+	}
21
+	// load debugging tools
22
+	if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
23
+		require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php';
24
+		EEH_Debug_Tools::instance();
25
+	}
26
+	// load error handling
27
+	if (is_readable(EE_CORE . 'EE_Error.core.php')) {
28
+		require_once EE_CORE . 'EE_Error.core.php';
29
+	} else {
30
+		wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
31
+	}
32
+	$error_handling_loaded = true;
33 33
 }
34 34
 
35 35
 
@@ -43,19 +43,19 @@  discard block
 block discarded – undo
43 43
  */
44 44
 function espresso_load_required($classname, $full_path_to_file)
45 45
 {
46
-    if (is_readable($full_path_to_file)) {
47
-        require_once $full_path_to_file;
48
-    } else {
49
-        throw new EE_Error(
50
-            sprintf(
51
-                esc_html__(
52
-                    'The %s class file could not be located or is not readable due to file permissions.',
53
-                    'event_espresso'
54
-                ),
55
-                $classname
56
-            )
57
-        );
58
-    }
46
+	if (is_readable($full_path_to_file)) {
47
+		require_once $full_path_to_file;
48
+	} else {
49
+		throw new EE_Error(
50
+			sprintf(
51
+				esc_html__(
52
+					'The %s class file could not be located or is not readable due to file permissions.',
53
+					'event_espresso'
54
+				),
55
+				$classname
56
+			)
57
+		);
58
+	}
59 59
 }
60 60
 
61 61
 
@@ -73,52 +73,52 @@  discard block
 block discarded – undo
73 73
  */
74 74
 function bootstrap_espresso()
75 75
 {
76
-    require_once __DIR__ . '/espresso_definitions.php';
77
-    try {
78
-        espresso_load_error_handling();
79
-        // include WordPress shims for functions introduced in later versions of WordPress
80
-        espresso_load_required(
81
-            '',
82
-            EE_CORE . 'wordpress-shims.php'
83
-        );
84
-        espresso_load_required(
85
-            '',
86
-            EE_CORE . 'third-party-compatibility.php'
87
-        );
88
-        espresso_load_required(
89
-            'EEH_Base',
90
-            EE_CORE . 'helpers/EEH_Base.helper.php'
91
-        );
92
-        espresso_load_required(
93
-            'EEH_File',
94
-            EE_CORE . 'interfaces/EEHI_File.interface.php'
95
-        );
96
-        espresso_load_required(
97
-            'EEH_File',
98
-            EE_CORE . 'helpers/EEH_File.helper.php'
99
-        );
100
-        espresso_load_required(
101
-            'EEH_Array',
102
-            EE_CORE . 'helpers/EEH_Array.helper.php'
103
-        );
104
-        espresso_load_required(
105
-            'EE_Base',
106
-            EE_CORE . 'EE_Base.core.php'
107
-        );
108
-        // instantiate and configure PSR4 autoloader
109
-        espresso_load_required(
110
-            'Psr4Autoloader',
111
-            EE_CORE . 'Psr4Autoloader.php'
112
-        );
113
-        espresso_load_required(
114
-            'EE_Psr4AutoloaderInit',
115
-            EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
116
-        );
117
-        $AutoloaderInit = new EE_Psr4AutoloaderInit();
118
-        $AutoloaderInit->initializeAutoloader();
119
-        new EventEspresso\core\services\bootstrap\BootstrapCore();
120
-    } catch (Exception $e) {
121
-        require_once EE_CORE . 'exceptions/ExceptionStackTraceDisplay.php';
122
-        new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
123
-    }
76
+	require_once __DIR__ . '/espresso_definitions.php';
77
+	try {
78
+		espresso_load_error_handling();
79
+		// include WordPress shims for functions introduced in later versions of WordPress
80
+		espresso_load_required(
81
+			'',
82
+			EE_CORE . 'wordpress-shims.php'
83
+		);
84
+		espresso_load_required(
85
+			'',
86
+			EE_CORE . 'third-party-compatibility.php'
87
+		);
88
+		espresso_load_required(
89
+			'EEH_Base',
90
+			EE_CORE . 'helpers/EEH_Base.helper.php'
91
+		);
92
+		espresso_load_required(
93
+			'EEH_File',
94
+			EE_CORE . 'interfaces/EEHI_File.interface.php'
95
+		);
96
+		espresso_load_required(
97
+			'EEH_File',
98
+			EE_CORE . 'helpers/EEH_File.helper.php'
99
+		);
100
+		espresso_load_required(
101
+			'EEH_Array',
102
+			EE_CORE . 'helpers/EEH_Array.helper.php'
103
+		);
104
+		espresso_load_required(
105
+			'EE_Base',
106
+			EE_CORE . 'EE_Base.core.php'
107
+		);
108
+		// instantiate and configure PSR4 autoloader
109
+		espresso_load_required(
110
+			'Psr4Autoloader',
111
+			EE_CORE . 'Psr4Autoloader.php'
112
+		);
113
+		espresso_load_required(
114
+			'EE_Psr4AutoloaderInit',
115
+			EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
116
+		);
117
+		$AutoloaderInit = new EE_Psr4AutoloaderInit();
118
+		$AutoloaderInit->initializeAutoloader();
119
+		new EventEspresso\core\services\bootstrap\BootstrapCore();
120
+	} catch (Exception $e) {
121
+		require_once EE_CORE . 'exceptions/ExceptionStackTraceDisplay.php';
122
+		new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
123
+	}
124 124
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
         return;
20 20
     }
21 21
     // load debugging tools
22
-    if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
23
-        require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php';
22
+    if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) {
23
+        require_once EE_HELPERS.'EEH_Debug_Tools.helper.php';
24 24
         EEH_Debug_Tools::instance();
25 25
     }
26 26
     // load error handling
27
-    if (is_readable(EE_CORE . 'EE_Error.core.php')) {
28
-        require_once EE_CORE . 'EE_Error.core.php';
27
+    if (is_readable(EE_CORE.'EE_Error.core.php')) {
28
+        require_once EE_CORE.'EE_Error.core.php';
29 29
     } else {
30 30
         wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
31 31
     }
@@ -73,52 +73,52 @@  discard block
 block discarded – undo
73 73
  */
74 74
 function bootstrap_espresso()
75 75
 {
76
-    require_once __DIR__ . '/espresso_definitions.php';
76
+    require_once __DIR__.'/espresso_definitions.php';
77 77
     try {
78 78
         espresso_load_error_handling();
79 79
         // include WordPress shims for functions introduced in later versions of WordPress
80 80
         espresso_load_required(
81 81
             '',
82
-            EE_CORE . 'wordpress-shims.php'
82
+            EE_CORE.'wordpress-shims.php'
83 83
         );
84 84
         espresso_load_required(
85 85
             '',
86
-            EE_CORE . 'third-party-compatibility.php'
86
+            EE_CORE.'third-party-compatibility.php'
87 87
         );
88 88
         espresso_load_required(
89 89
             'EEH_Base',
90
-            EE_CORE . 'helpers/EEH_Base.helper.php'
90
+            EE_CORE.'helpers/EEH_Base.helper.php'
91 91
         );
92 92
         espresso_load_required(
93 93
             'EEH_File',
94
-            EE_CORE . 'interfaces/EEHI_File.interface.php'
94
+            EE_CORE.'interfaces/EEHI_File.interface.php'
95 95
         );
96 96
         espresso_load_required(
97 97
             'EEH_File',
98
-            EE_CORE . 'helpers/EEH_File.helper.php'
98
+            EE_CORE.'helpers/EEH_File.helper.php'
99 99
         );
100 100
         espresso_load_required(
101 101
             'EEH_Array',
102
-            EE_CORE . 'helpers/EEH_Array.helper.php'
102
+            EE_CORE.'helpers/EEH_Array.helper.php'
103 103
         );
104 104
         espresso_load_required(
105 105
             'EE_Base',
106
-            EE_CORE . 'EE_Base.core.php'
106
+            EE_CORE.'EE_Base.core.php'
107 107
         );
108 108
         // instantiate and configure PSR4 autoloader
109 109
         espresso_load_required(
110 110
             'Psr4Autoloader',
111
-            EE_CORE . 'Psr4Autoloader.php'
111
+            EE_CORE.'Psr4Autoloader.php'
112 112
         );
113 113
         espresso_load_required(
114 114
             'EE_Psr4AutoloaderInit',
115
-            EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
115
+            EE_CORE.'EE_Psr4AutoloaderInit.core.php'
116 116
         );
117 117
         $AutoloaderInit = new EE_Psr4AutoloaderInit();
118 118
         $AutoloaderInit->initializeAutoloader();
119 119
         new EventEspresso\core\services\bootstrap\BootstrapCore();
120 120
     } catch (Exception $e) {
121
-        require_once EE_CORE . 'exceptions/ExceptionStackTraceDisplay.php';
121
+        require_once EE_CORE.'exceptions/ExceptionStackTraceDisplay.php';
122 122
         new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
123 123
     }
124 124
 }
Please login to merge, or discard this patch.
core/exceptions/ExceptionStackTraceDisplay.php 2 patches
Indentation   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -20,163 +20,163 @@  discard block
 block discarded – undo
20 20
 class ExceptionStackTraceDisplay
21 21
 {
22 22
 
23
-    /**
24
-     * @var   string
25
-     * @since 4.10.24.p
26
-     */
27
-    private $class_name = '';
23
+	/**
24
+	 * @var   string
25
+	 * @since 4.10.24.p
26
+	 */
27
+	private $class_name = '';
28 28
 
29
-    /**
30
-     * @var   string
31
-     * @since 4.10.24.p
32
-     */
33
-    private $error_code = '';
29
+	/**
30
+	 * @var   string
31
+	 * @since 4.10.24.p
32
+	 */
33
+	private $error_code = '';
34 34
 
35 35
 
36
-    /**
37
-     * @param Exception $exception
38
-     * @throws Exception
39
-     */
40
-    public function __construct(Exception $exception)
41
-    {
42
-        if (WP_DEBUG && ! defined('EE_TESTS_DIR')) {
43
-            $this->displayException($exception);
44
-        } else {
45
-            throw $exception;
46
-        }
47
-    }
36
+	/**
37
+	 * @param Exception $exception
38
+	 * @throws Exception
39
+	 */
40
+	public function __construct(Exception $exception)
41
+	{
42
+		if (WP_DEBUG && ! defined('EE_TESTS_DIR')) {
43
+			$this->displayException($exception);
44
+		} else {
45
+			throw $exception;
46
+		}
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * @access protected
52
-     * @param Exception $exception
53
-     * @throws ReflectionException
54
-     */
55
-    protected function displayException(Exception $exception)
56
-    {
57
-        // get separate user and developer messages if they exist
58
-        $msg = explode('||', $exception->getMessage());
59
-        $user_msg = $msg[0];
60
-        $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
61
-        $msg = WP_DEBUG ? $dev_msg : $user_msg;
62
-        // process trace info
63
-        $trace_details = $this->traceDetails($exception);
64
-        $code          = $exception->getCode() ?: $this->error_code;
65
-        // add helpful developer messages if debugging is on
66
-        // or generic non-identifying messages for non-privileged users
67
-        $error_message = WP_DEBUG
68
-            ? $this->developerError($exception, $msg, $code, $trace_details)
69
-            : $this->genericError($msg, $code);
70
-        // start gathering output
71
-        $output = '
50
+	/**
51
+	 * @access protected
52
+	 * @param Exception $exception
53
+	 * @throws ReflectionException
54
+	 */
55
+	protected function displayException(Exception $exception)
56
+	{
57
+		// get separate user and developer messages if they exist
58
+		$msg = explode('||', $exception->getMessage());
59
+		$user_msg = $msg[0];
60
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
61
+		$msg = WP_DEBUG ? $dev_msg : $user_msg;
62
+		// process trace info
63
+		$trace_details = $this->traceDetails($exception);
64
+		$code          = $exception->getCode() ?: $this->error_code;
65
+		// add helpful developer messages if debugging is on
66
+		// or generic non-identifying messages for non-privileged users
67
+		$error_message = WP_DEBUG
68
+			? $this->developerError($exception, $msg, $code, $trace_details)
69
+			: $this->genericError($msg, $code);
70
+		// start gathering output
71
+		$output = '
72 72
         <div id="ee-error-message" class="error">
73 73
             ' . $error_message . '
74 74
         </div>';
75
-        $scripts = $this->printScripts(true);
76
-        if (defined('DOING_AJAX')) {
77
-            echo wp_json_encode(array('error' => $output . $scripts));
78
-            exit();
79
-        }
80
-        echo wp_kses($output . $scripts, AllowedTags::getWithScriptAndStyleTags());
81
-    }
75
+		$scripts = $this->printScripts(true);
76
+		if (defined('DOING_AJAX')) {
77
+			echo wp_json_encode(array('error' => $output . $scripts));
78
+			exit();
79
+		}
80
+		echo wp_kses($output . $scripts, AllowedTags::getWithScriptAndStyleTags());
81
+	}
82 82
 
83 83
 
84
-    private function genericError($msg, $code)
85
-    {
86
-        return '
84
+	private function genericError($msg, $code)
85
+	{
86
+		return '
87 87
         <p>
88 88
             <span class="ee-error-user-msg-spn">' . trim($msg) . '</span> &nbsp; <sup>' . $code . '</sup>
89 89
         </p>';
90
-    }
90
+	}
91 91
 
92 92
 
93
-    /**
94
-     * @param Exception $exception
95
-     * @param $msg
96
-     * @param $code
97
-     * @param $trace_details
98
-     * @return string
99
-     * @throws ReflectionException
100
-     */
101
-    private function developerError(Exception $exception, $msg, $code, $trace_details)
102
-    {
103
-        $time = time();
104
-        return '
93
+	/**
94
+	 * @param Exception $exception
95
+	 * @param $msg
96
+	 * @param $code
97
+	 * @param $trace_details
98
+	 * @return string
99
+	 * @throws ReflectionException
100
+	 */
101
+	private function developerError(Exception $exception, $msg, $code, $trace_details)
102
+	{
103
+		$time = time();
104
+		return '
105 105
         <div class="ee-error-dev-msg-dv">
106 106
             <p class="ee-error-dev-msg-pg">
107 107
                 '
108
-                . sprintf(
109
-                    esc_html__('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'),
110
-                    '<strong class="ee-error-dev-msg-str">',
111
-                    get_class($exception),
112
-                    '</strong>  &nbsp; <span>',
113
-                    $code . '</span>'
114
-                )
115
-                . '<br />
108
+				. sprintf(
109
+					esc_html__('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'),
110
+					'<strong class="ee-error-dev-msg-str">',
111
+					get_class($exception),
112
+					'</strong>  &nbsp; <span>',
113
+					$code . '</span>'
114
+				)
115
+				. '<br />
116 116
                 <span class="big-text">"' . trim($msg) . '"</span><br/>
117 117
                 <a id="display-ee-error-trace-1'
118
-                   . $time
119
-                   . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1'
120
-                   . $time
121
-                   . '">
118
+				   . $time
119
+				   . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1'
120
+				   . $time
121
+				   . '">
122 122
                     ' . esc_html__('click to view backtrace and class/method details', 'event_espresso') . '
123 123
                 </a><br />
124 124
                 '
125
-                . $exception->getFile()
126
-                . sprintf(
127
-                    esc_html__('%1$s( line no: %2$s )%3$s', 'event_espresso'),
128
-                    ' &nbsp; <span class="small-text lt-grey-text">',
129
-                    $exception->getLine(),
130
-                    '</span>'
131
-                )
132
-                . '
125
+				. $exception->getFile()
126
+				. sprintf(
127
+					esc_html__('%1$s( line no: %2$s )%3$s', 'event_espresso'),
128
+					' &nbsp; <span class="small-text lt-grey-text">',
129
+					$exception->getLine(),
130
+					'</span>'
131
+				)
132
+				. '
133 133
             </p>
134 134
             <div id="ee-error-trace-1'
135
-                   . $time
136
-                   . '-dv" class="ee-error-trace-dv ee-error-trace-dv--hidden">
135
+				   . $time
136
+				   . '-dv" class="ee-error-trace-dv ee-error-trace-dv--hidden">
137 137
                 '
138
-                   . $trace_details
139
-                   . $this->classDetails() . '
138
+				   . $trace_details
139
+				   . $this->classDetails() . '
140 140
             </div>
141 141
         </div>';
142
-    }
142
+	}
143 143
 
144 144
 
145
-    /**
146
-     * @throws ReflectionException
147
-     */
148
-    private function classDetails()
149
-    {
150
-        if (empty($this->class_name)) {
151
-            return '';
152
-        }
153
-        $a = new ReflectionClass($this->class_name);
154
-        return '
145
+	/**
146
+	 * @throws ReflectionException
147
+	 */
148
+	private function classDetails()
149
+	{
150
+		if (empty($this->class_name)) {
151
+			return '';
152
+		}
153
+		$a = new ReflectionClass($this->class_name);
154
+		return '
155 155
             <div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;">
156 156
                 <div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;">
157 157
                     <h3>' . esc_html__('Class Details', 'event_espresso') . '</h3>
158 158
                     <pre>' . $a . '</pre>
159 159
                 </div>
160 160
             </div>';
161
-    }
161
+	}
162 162
 
163
-    /**
164
-     * @param Exception $exception
165
-     * @return string
166
-     * @throws ReflectionException
167
-     * @since 4.10.24.p
168
-     */
169
-    private function traceDetails(Exception $exception)
170
-    {
171
-        $trace = $exception->getTrace();
172
-        if (empty($trace)) {
173
-            return esc_html__(
174
-                'Sorry, but no trace information was available for this exception.',
175
-                'event_espresso'
176
-            );
177
-        }
163
+	/**
164
+	 * @param Exception $exception
165
+	 * @return string
166
+	 * @throws ReflectionException
167
+	 * @since 4.10.24.p
168
+	 */
169
+	private function traceDetails(Exception $exception)
170
+	{
171
+		$trace = $exception->getTrace();
172
+		if (empty($trace)) {
173
+			return esc_html__(
174
+				'Sorry, but no trace information was available for this exception.',
175
+				'event_espresso'
176
+			);
177
+		}
178 178
 
179
-        $trace_details = '
179
+		$trace_details = '
180 180
         <div id="ee-trace-details">
181 181
             <table>
182 182
                 <tr>
@@ -185,180 +185,180 @@  discard block
 block discarded – undo
185 185
                     <th scope="col" class="ee-align-left" style="width:40%;">File</th>
186 186
                     <th scope="col" class="ee-align-left">
187 187
                     ' . esc_html__('Class', 'event_espresso')
188
-                              . '->'
189
-                              . esc_html__('Method( arguments )', 'event_espresso') . '
188
+							  . '->'
189
+							  . esc_html__('Method( arguments )', 'event_espresso') . '
190 190
                     </th>
191 191
                 </tr>';
192
-        $last_on_stack = count($trace) - 1;
193
-        // reverse array so that stack is in proper chronological order
194
-        $sorted_trace = array_reverse($trace);
195
-        foreach ($sorted_trace as $nmbr => $trace) {
196
-            $this->class_name = isset($trace['class']) ? $trace['class'] : '';
197
-            $file     = isset($trace['file']) ? $trace['file'] : '';
198
-            $type     = isset($trace['type']) ? $trace['type'] : '';
199
-            $function = isset($trace['function']) ? $trace['function'] : '';
200
-            $args     = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
201
-            $args     = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args;
202
-            $line     = isset($trace['line']) ? $trace['line'] : '';
203
-            if (empty($file) && ! empty($this->class_name)) {
204
-                $a    = new ReflectionClass($this->class_name);
205
-                $file = $a->getFileName();
206
-                if (empty($line) && ! empty($function)) {
207
-                    try {
208
-                        // if $function is a closure, this throws an exception
209
-                        $b    = new ReflectionMethod($this->class_name, $function);
210
-                        $line = $b->getStartLine();
211
-                    } catch (Exception $closure_exception) {
212
-                        $line = 'unknown';
213
-                    }
214
-                }
215
-            }
216
-            if ($nmbr === $last_on_stack) {
217
-                $file       = $exception->getFile() ?: $file;
218
-                $line       = $exception->getLine() ?: $line;
219
-                $this->error_code = $this->generate_error_code($file, $trace['function'], $line);
220
-            }
221
-            $file          = EEH_File::standardise_directory_separators($file);
222
-            $nmbr          = ! empty($nmbr) ? $nmbr : '&nbsp;';
223
-            $line          = ! empty($line) ? $line : '&nbsp;';
224
-            $file          = ! empty($file) ? $file : '&nbsp;';
225
-            $type          = ! empty($type) ? $type : '';
226
-            $function      = ! empty($function) ? $function : '';
227
-            $args          = ! empty($args) ? '( ' . $args . ' )' : '()';
228
-            $trace_details .= '
192
+		$last_on_stack = count($trace) - 1;
193
+		// reverse array so that stack is in proper chronological order
194
+		$sorted_trace = array_reverse($trace);
195
+		foreach ($sorted_trace as $nmbr => $trace) {
196
+			$this->class_name = isset($trace['class']) ? $trace['class'] : '';
197
+			$file     = isset($trace['file']) ? $trace['file'] : '';
198
+			$type     = isset($trace['type']) ? $trace['type'] : '';
199
+			$function = isset($trace['function']) ? $trace['function'] : '';
200
+			$args     = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
201
+			$args     = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args;
202
+			$line     = isset($trace['line']) ? $trace['line'] : '';
203
+			if (empty($file) && ! empty($this->class_name)) {
204
+				$a    = new ReflectionClass($this->class_name);
205
+				$file = $a->getFileName();
206
+				if (empty($line) && ! empty($function)) {
207
+					try {
208
+						// if $function is a closure, this throws an exception
209
+						$b    = new ReflectionMethod($this->class_name, $function);
210
+						$line = $b->getStartLine();
211
+					} catch (Exception $closure_exception) {
212
+						$line = 'unknown';
213
+					}
214
+				}
215
+			}
216
+			if ($nmbr === $last_on_stack) {
217
+				$file       = $exception->getFile() ?: $file;
218
+				$line       = $exception->getLine() ?: $line;
219
+				$this->error_code = $this->generate_error_code($file, $trace['function'], $line);
220
+			}
221
+			$file          = EEH_File::standardise_directory_separators($file);
222
+			$nmbr          = ! empty($nmbr) ? $nmbr : '&nbsp;';
223
+			$line          = ! empty($line) ? $line : '&nbsp;';
224
+			$file          = ! empty($file) ? $file : '&nbsp;';
225
+			$type          = ! empty($type) ? $type : '';
226
+			$function      = ! empty($function) ? $function : '';
227
+			$args          = ! empty($args) ? '( ' . $args . ' )' : '()';
228
+			$trace_details .= '
229 229
                 <tr>
230 230
                     <td class="ee-align-right">' . $nmbr . '</td>
231 231
                     <td class="ee-align-right">' . $line . '</td>
232 232
                     <td class="ee-align-left">' . $file . '</td>
233 233
                     <td class="ee-align-left">' . $this->class_name . $type . $function . $args . '</td>
234 234
                 </tr>';
235
-        }
236
-        $trace_details .= '
235
+		}
236
+		$trace_details .= '
237 237
             </table>
238 238
         </div>';
239
-        return $trace_details;
240
-    }
239
+		return $trace_details;
240
+	}
241 241
 
242 242
 
243
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
244
-    // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
243
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
244
+	// phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
245 245
 
246
-    /**
247
-     * generate string from exception trace args
248
-     *
249
-     * @param array $arguments
250
-     * @param int   $indent
251
-     * @param bool  $array
252
-     * @return string
253
-     */
254
-    private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false)
255
-    {
256
-        $args = array();
257
-        $args_count = count($arguments);
258
-        if ($args_count > 2) {
259
-            $indent++;
260
-            $args[] = '<br />';
261
-        }
262
-        $x = 0;
263
-        foreach ($arguments as $arg) {
264
-            $x++;
265
-            for ($i = 0; $i < $indent; $i++) {
266
-                $args[] = ' &nbsp;&nbsp; ';
267
-            }
268
-            if (is_string($arg)) {
269
-                if (! $array && strlen($arg) > 75) {
270
-                    $args[] = '<br />';
271
-                    for ($i = 0; $i <= $indent; $i++) {
272
-                        $args[] = ' &nbsp;&nbsp; ';
273
-                    }
274
-                    $args[] = "'" . $arg . "'<br />";
275
-                } else {
276
-                    $args[] = " '" . $arg . "'";
277
-                }
278
-            } elseif (is_array($arg)) {
279
-                $arg_count = count($arg);
280
-                if ($arg_count > 2) {
281
-                    $indent++;
282
-                    $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')';
283
-                    $indent--;
284
-                } elseif ($arg_count === 0) {
285
-                    $args[] = ' array()';
286
-                } else {
287
-                    $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )';
288
-                }
289
-            } elseif ($arg === null) {
290
-                $args[] = ' null';
291
-            } elseif (is_bool($arg)) {
292
-                $args[] = $arg ? ' true' : ' false';
293
-            } elseif (is_object($arg)) {
294
-                $args[] = get_class($arg);
295
-            } elseif (is_resource($arg)) {
296
-                $args[] = get_resource_type($arg);
297
-            } else {
298
-                $args[] = $arg;
299
-            }
300
-            if ($x === $args_count) {
301
-                if ($args_count > 2) {
302
-                    $args[] = '<br />';
303
-                    $indent--;
304
-                    for ($i = 1; $i < $indent; $i++) {
305
-                        $args[] = ' &nbsp;&nbsp; ';
306
-                    }
307
-                }
308
-            } else {
309
-                $args[] = $args_count > 2 ? ',<br />' : ', ';
310
-            }
311
-        }
312
-        return implode('', $args);
313
-    }
246
+	/**
247
+	 * generate string from exception trace args
248
+	 *
249
+	 * @param array $arguments
250
+	 * @param int   $indent
251
+	 * @param bool  $array
252
+	 * @return string
253
+	 */
254
+	private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false)
255
+	{
256
+		$args = array();
257
+		$args_count = count($arguments);
258
+		if ($args_count > 2) {
259
+			$indent++;
260
+			$args[] = '<br />';
261
+		}
262
+		$x = 0;
263
+		foreach ($arguments as $arg) {
264
+			$x++;
265
+			for ($i = 0; $i < $indent; $i++) {
266
+				$args[] = ' &nbsp;&nbsp; ';
267
+			}
268
+			if (is_string($arg)) {
269
+				if (! $array && strlen($arg) > 75) {
270
+					$args[] = '<br />';
271
+					for ($i = 0; $i <= $indent; $i++) {
272
+						$args[] = ' &nbsp;&nbsp; ';
273
+					}
274
+					$args[] = "'" . $arg . "'<br />";
275
+				} else {
276
+					$args[] = " '" . $arg . "'";
277
+				}
278
+			} elseif (is_array($arg)) {
279
+				$arg_count = count($arg);
280
+				if ($arg_count > 2) {
281
+					$indent++;
282
+					$args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')';
283
+					$indent--;
284
+				} elseif ($arg_count === 0) {
285
+					$args[] = ' array()';
286
+				} else {
287
+					$args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )';
288
+				}
289
+			} elseif ($arg === null) {
290
+				$args[] = ' null';
291
+			} elseif (is_bool($arg)) {
292
+				$args[] = $arg ? ' true' : ' false';
293
+			} elseif (is_object($arg)) {
294
+				$args[] = get_class($arg);
295
+			} elseif (is_resource($arg)) {
296
+				$args[] = get_resource_type($arg);
297
+			} else {
298
+				$args[] = $arg;
299
+			}
300
+			if ($x === $args_count) {
301
+				if ($args_count > 2) {
302
+					$args[] = '<br />';
303
+					$indent--;
304
+					for ($i = 1; $i < $indent; $i++) {
305
+						$args[] = ' &nbsp;&nbsp; ';
306
+					}
307
+				}
308
+			} else {
309
+				$args[] = $args_count > 2 ? ',<br />' : ', ';
310
+			}
311
+		}
312
+		return implode('', $args);
313
+	}
314 314
 
315 315
 
316
-    /**
317
-     * create error code from filepath, function name,
318
-     * and line number where exception or error was thrown
319
-     *
320
-     * @access protected
321
-     * @param string $file
322
-     * @param string $func
323
-     * @param string $line
324
-     * @return string
325
-     */
326
-    protected function generate_error_code($file = '', $func = '', $line = '')
327
-    {
328
-        $file_bits = explode('.', basename($file));
329
-        $error_code = ! empty($file_bits[0]) ? $file_bits[0] : '';
330
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
331
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
332
-        return $error_code;
333
-    }
316
+	/**
317
+	 * create error code from filepath, function name,
318
+	 * and line number where exception or error was thrown
319
+	 *
320
+	 * @access protected
321
+	 * @param string $file
322
+	 * @param string $func
323
+	 * @param string $line
324
+	 * @return string
325
+	 */
326
+	protected function generate_error_code($file = '', $func = '', $line = '')
327
+	{
328
+		$file_bits = explode('.', basename($file));
329
+		$error_code = ! empty($file_bits[0]) ? $file_bits[0] : '';
330
+		$error_code .= ! empty($func) ? ' - ' . $func : '';
331
+		$error_code .= ! empty($line) ? ' - ' . $line : '';
332
+		return $error_code;
333
+	}
334 334
 
335 335
 
336
-    /**
337
-     * _print_scripts
338
-     *
339
-     * @param bool $force_print
340
-     * @return string
341
-     */
342
-    private function printScripts($force_print = false)
343
-    {
344
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
345
-            //  if script is already enqueued then we can just get out
346
-            if (wp_script_is('ee_error_js')) {
347
-                return '';
348
-            }
349
-            if (wp_script_is('ee_error_js', 'registered')) {
350
-                wp_enqueue_style('espresso_default');
351
-                wp_enqueue_style('espresso_custom_css');
352
-                wp_enqueue_script('ee_error_js');
353
-                wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
354
-                return '';
355
-            }
356
-        }
357
-        $jquery = includes_url() . 'js/jquery/jquery.js';
358
-        $core = EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . espresso_version();
359
-        $ee_error = EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js?ver=' . espresso_version();
360
-        $style = EE_GLOBAL_ASSETS_URL . 'css/ee-exception-stack-display.css';
361
-        return '
336
+	/**
337
+	 * _print_scripts
338
+	 *
339
+	 * @param bool $force_print
340
+	 * @return string
341
+	 */
342
+	private function printScripts($force_print = false)
343
+	{
344
+		if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
345
+			//  if script is already enqueued then we can just get out
346
+			if (wp_script_is('ee_error_js')) {
347
+				return '';
348
+			}
349
+			if (wp_script_is('ee_error_js', 'registered')) {
350
+				wp_enqueue_style('espresso_default');
351
+				wp_enqueue_style('espresso_custom_css');
352
+				wp_enqueue_script('ee_error_js');
353
+				wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
354
+				return '';
355
+			}
356
+		}
357
+		$jquery = includes_url() . 'js/jquery/jquery.js';
358
+		$core = EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . espresso_version();
359
+		$ee_error = EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js?ver=' . espresso_version();
360
+		$style = EE_GLOBAL_ASSETS_URL . 'css/ee-exception-stack-display.css';
361
+		return '
362 362
             <script>
363 363
             const ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
364 364
             </script>
@@ -367,5 +367,5 @@  discard block
 block discarded – undo
367 367
             <script src="' . esc_url_raw($ee_error) . '" type="text/javascript"></script>
368 368
             <link href="' . esc_url_raw($style) . '" rel="stylesheet" />
369 369
         ';
370
-    }
370
+	}
371 371
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
         // start gathering output
71 71
         $output = '
72 72
         <div id="ee-error-message" class="error">
73
-            ' . $error_message . '
73
+            ' . $error_message.'
74 74
         </div>';
75 75
         $scripts = $this->printScripts(true);
76 76
         if (defined('DOING_AJAX')) {
77
-            echo wp_json_encode(array('error' => $output . $scripts));
77
+            echo wp_json_encode(array('error' => $output.$scripts));
78 78
             exit();
79 79
         }
80
-        echo wp_kses($output . $scripts, AllowedTags::getWithScriptAndStyleTags());
80
+        echo wp_kses($output.$scripts, AllowedTags::getWithScriptAndStyleTags());
81 81
     }
82 82
 
83 83
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     {
86 86
         return '
87 87
         <p>
88
-            <span class="ee-error-user-msg-spn">' . trim($msg) . '</span> &nbsp; <sup>' . $code . '</sup>
88
+            <span class="ee-error-user-msg-spn">' . trim($msg).'</span> &nbsp; <sup>'.$code.'</sup>
89 89
         </p>';
90 90
     }
91 91
 
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
                     '<strong class="ee-error-dev-msg-str">',
111 111
                     get_class($exception),
112 112
                     '</strong>  &nbsp; <span>',
113
-                    $code . '</span>'
113
+                    $code.'</span>'
114 114
                 )
115 115
                 . '<br />
116
-                <span class="big-text">"' . trim($msg) . '"</span><br/>
116
+                <span class="big-text">"' . trim($msg).'"</span><br/>
117 117
                 <a id="display-ee-error-trace-1'
118 118
                    . $time
119 119
                    . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1'
120 120
                    . $time
121 121
                    . '">
122
-                    ' . esc_html__('click to view backtrace and class/method details', 'event_espresso') . '
122
+                    ' . esc_html__('click to view backtrace and class/method details', 'event_espresso').'
123 123
                 </a><br />
124 124
                 '
125 125
                 . $exception->getFile()
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
                    . '-dv" class="ee-error-trace-dv ee-error-trace-dv--hidden">
137 137
                 '
138 138
                    . $trace_details
139
-                   . $this->classDetails() . '
139
+                   . $this->classDetails().'
140 140
             </div>
141 141
         </div>';
142 142
     }
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
         return '
155 155
             <div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;">
156 156
                 <div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;">
157
-                    <h3>' . esc_html__('Class Details', 'event_espresso') . '</h3>
158
-                    <pre>' . $a . '</pre>
157
+                    <h3>' . esc_html__('Class Details', 'event_espresso').'</h3>
158
+                    <pre>' . $a.'</pre>
159 159
                 </div>
160 160
             </div>';
161 161
     }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
                     <th scope="col" class="ee-align-left">
187 187
                     ' . esc_html__('Class', 'event_espresso')
188 188
                               . '->'
189
-                              . esc_html__('Method( arguments )', 'event_espresso') . '
189
+                              . esc_html__('Method( arguments )', 'event_espresso').'
190 190
                     </th>
191 191
                 </tr>';
192 192
         $last_on_stack = count($trace) - 1;
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
             $type     = isset($trace['type']) ? $trace['type'] : '';
199 199
             $function = isset($trace['function']) ? $trace['function'] : '';
200 200
             $args     = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
201
-            $args     = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args;
201
+            $args     = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />'.$args.'<br />' : $args;
202 202
             $line     = isset($trace['line']) ? $trace['line'] : '';
203 203
             if (empty($file) && ! empty($this->class_name)) {
204 204
                 $a    = new ReflectionClass($this->class_name);
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
             $file          = ! empty($file) ? $file : '&nbsp;';
225 225
             $type          = ! empty($type) ? $type : '';
226 226
             $function      = ! empty($function) ? $function : '';
227
-            $args          = ! empty($args) ? '( ' . $args . ' )' : '()';
227
+            $args          = ! empty($args) ? '( '.$args.' )' : '()';
228 228
             $trace_details .= '
229 229
                 <tr>
230
-                    <td class="ee-align-right">' . $nmbr . '</td>
231
-                    <td class="ee-align-right">' . $line . '</td>
232
-                    <td class="ee-align-left">' . $file . '</td>
233
-                    <td class="ee-align-left">' . $this->class_name . $type . $function . $args . '</td>
230
+                    <td class="ee-align-right">' . $nmbr.'</td>
231
+                    <td class="ee-align-right">' . $line.'</td>
232
+                    <td class="ee-align-left">' . $file.'</td>
233
+                    <td class="ee-align-left">' . $this->class_name.$type.$function.$args.'</td>
234 234
                 </tr>';
235 235
         }
236 236
         $trace_details .= '
@@ -266,25 +266,25 @@  discard block
 block discarded – undo
266 266
                 $args[] = ' &nbsp;&nbsp; ';
267 267
             }
268 268
             if (is_string($arg)) {
269
-                if (! $array && strlen($arg) > 75) {
269
+                if ( ! $array && strlen($arg) > 75) {
270 270
                     $args[] = '<br />';
271 271
                     for ($i = 0; $i <= $indent; $i++) {
272 272
                         $args[] = ' &nbsp;&nbsp; ';
273 273
                     }
274
-                    $args[] = "'" . $arg . "'<br />";
274
+                    $args[] = "'".$arg."'<br />";
275 275
                 } else {
276
-                    $args[] = " '" . $arg . "'";
276
+                    $args[] = " '".$arg."'";
277 277
                 }
278 278
             } elseif (is_array($arg)) {
279 279
                 $arg_count = count($arg);
280 280
                 if ($arg_count > 2) {
281 281
                     $indent++;
282
-                    $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')';
282
+                    $args[] = ' array('.$this->_convert_args_to_string($arg, $indent, true).')';
283 283
                     $indent--;
284 284
                 } elseif ($arg_count === 0) {
285 285
                     $args[] = ' array()';
286 286
                 } else {
287
-                    $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )';
287
+                    $args[] = ' array( '.$this->_convert_args_to_string($arg).' )';
288 288
                 }
289 289
             } elseif ($arg === null) {
290 290
                 $args[] = ' null';
@@ -327,8 +327,8 @@  discard block
 block discarded – undo
327 327
     {
328 328
         $file_bits = explode('.', basename($file));
329 329
         $error_code = ! empty($file_bits[0]) ? $file_bits[0] : '';
330
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
331
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
330
+        $error_code .= ! empty($func) ? ' - '.$func : '';
331
+        $error_code .= ! empty($line) ? ' - '.$line : '';
332 332
         return $error_code;
333 333
     }
334 334
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
      */
342 342
     private function printScripts($force_print = false)
343 343
     {
344
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
344
+        if ( ! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
345 345
             //  if script is already enqueued then we can just get out
346 346
             if (wp_script_is('ee_error_js')) {
347 347
                 return '';
@@ -354,18 +354,18 @@  discard block
 block discarded – undo
354 354
                 return '';
355 355
             }
356 356
         }
357
-        $jquery = includes_url() . 'js/jquery/jquery.js';
358
-        $core = EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . espresso_version();
359
-        $ee_error = EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js?ver=' . espresso_version();
360
-        $style = EE_GLOBAL_ASSETS_URL . 'css/ee-exception-stack-display.css';
357
+        $jquery = includes_url().'js/jquery/jquery.js';
358
+        $core = EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.espresso_version();
359
+        $ee_error = EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js?ver='.espresso_version();
360
+        $style = EE_GLOBAL_ASSETS_URL.'css/ee-exception-stack-display.css';
361 361
         return '
362 362
             <script>
363
-            const ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
363
+            const ee_settings = {"wp_debug":"' . WP_DEBUG.'"};
364 364
             </script>
365
-            <script src="' . esc_url_raw($jquery) . '" type="text/javascript"></script>
366
-            <script src="' . esc_url_raw($core) . '" type="text/javascript"></script>
367
-            <script src="' . esc_url_raw($ee_error) . '" type="text/javascript"></script>
368
-            <link href="' . esc_url_raw($style) . '" rel="stylesheet" />
365
+            <script src="' . esc_url_raw($jquery).'" type="text/javascript"></script>
366
+            <script src="' . esc_url_raw($core).'" type="text/javascript"></script>
367
+            <script src="' . esc_url_raw($ee_error).'" type="text/javascript"></script>
368
+            <link href="' . esc_url_raw($style).'" rel="stylesheet" />
369 369
         ';
370 370
     }
371 371
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.31.rc.002');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.31.rc.002');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
141 141
\ No newline at end of file
Please login to merge, or discard this patch.
core/EE_Front_Controller.core.php 1 patch
Indentation   +509 added lines, -509 removed lines patch added patch discarded remove patch
@@ -18,513 +18,513 @@
 block discarded – undo
18 18
 final class EE_Front_Controller
19 19
 {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
24
-    private $_template_path;
25
-
26
-    /**
27
-     * @var string
28
-     */
29
-    private $_template;
30
-
31
-    /**
32
-     * @type EE_Registry
33
-     */
34
-    protected $Registry;
35
-
36
-    /**
37
-     * @type EE_Request_Handler
38
-     */
39
-    protected $Request_Handler;
40
-
41
-    /**
42
-     * @type EE_Module_Request_Router
43
-     */
44
-    protected $Module_Request_Router;
45
-
46
-    /**
47
-     * @type CurrentPage
48
-     */
49
-    protected $current_page;
50
-
51
-
52
-    /**
53
-     *    class constructor
54
-     *    should fire after shortcode, module, addon, or other plugin's default priority init phases have run
55
-     *
56
-     * @access    public
57
-     * @param EE_Registry              $Registry
58
-     * @param CurrentPage              $EspressoPage
59
-     * @param EE_Module_Request_Router $Module_Request_Router
60
-     */
61
-    public function __construct(
62
-        EE_Registry $Registry,
63
-        CurrentPage $EspressoPage,
64
-        EE_Module_Request_Router $Module_Request_Router
65
-    ) {
66
-        $this->Registry              = $Registry;
67
-        $this->current_page          = $EspressoPage;
68
-        $this->Module_Request_Router = $Module_Request_Router;
69
-        // load other resources and begin to actually run shortcodes and modules
70
-        // analyse the incoming WP request
71
-        add_action('parse_request', array($this, 'get_request'), 1, 1);
72
-        // process request with module factory
73
-        add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1);
74
-        // before headers sent
75
-        add_action('wp', array($this, 'wp'), 5);
76
-        // primarily used to process any content shortcodes
77
-        add_action('template_redirect', array($this, 'templateRedirect'), 999);
78
-        // header
79
-        add_action('wp_head', array($this, 'header_meta_tag'), 5);
80
-        add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10);
81
-        add_filter('template_include', array($this, 'template_include'), 1);
82
-        // display errors
83
-        add_action('loop_start', array($this, 'display_errors'), 2);
84
-        // the content
85
-        // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 );
86
-        // exclude our private cpt comments
87
-        add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1);
88
-        // make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://)
89
-        add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1);
90
-        // action hook EE
91
-        do_action('AHEE__EE_Front_Controller__construct__done', $this);
92
-    }
93
-
94
-
95
-    /**
96
-     * @return EE_Request_Handler
97
-     * @deprecated 4.10.14.p
98
-     */
99
-    public function Request_Handler()
100
-    {
101
-        if (! $this->Request_Handler instanceof EE_Request_Handler) {
102
-            $this->Request_Handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler');
103
-        }
104
-        return $this->Request_Handler;
105
-    }
106
-
107
-
108
-    /**
109
-     * @return EE_Module_Request_Router
110
-     */
111
-    public function Module_Request_Router()
112
-    {
113
-        return $this->Module_Request_Router;
114
-    }
115
-
116
-
117
-    /**
118
-     * @return LegacyShortcodesManager
119
-     * @deprecated 4.10.14.p
120
-     */
121
-    public function getLegacyShortcodesManager()
122
-    {
123
-        return EE_Config::getLegacyShortcodesManager();
124
-    }
125
-
126
-
127
-
128
-
129
-
130
-    /***********************************************        INIT ACTION HOOK         ***********************************************/
131
-    /**
132
-     * filter_wp_comments
133
-     * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment
134
-     * widgets/queries done on frontend
135
-     *
136
-     * @param  array $clauses array of comment clauses setup by WP_Comment_Query
137
-     * @return array array of comment clauses with modifications.
138
-     * @throws InvalidArgumentException
139
-     * @throws InvalidDataTypeException
140
-     * @throws InvalidInterfaceException
141
-     */
142
-    public function filter_wp_comments($clauses)
143
-    {
144
-        global $wpdb;
145
-        if (strpos($clauses['join'], $wpdb->posts) !== false) {
146
-            /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
147
-            $custom_post_types = LoaderFactory::getLoader()->getShared(
148
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
149
-            );
150
-            $cpts = $custom_post_types->getPrivateCustomPostTypes();
151
-            foreach ($cpts as $cpt => $details) {
152
-                $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt);
153
-            }
154
-        }
155
-        return $clauses;
156
-    }
157
-
158
-
159
-    /**
160
-     * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend
161
-     *
162
-     * @param  string $url incoming url
163
-     * @return string         final assembled url
164
-     */
165
-    public function maybe_force_admin_ajax_ssl($url)
166
-    {
167
-        if (is_ssl() && preg_match('/admin-ajax.php/', $url)) {
168
-            $url = str_replace('http://', 'https://', $url);
169
-        }
170
-        return $url;
171
-    }
172
-
173
-
174
-
175
-
176
-
177
-
178
-    /***********************************************        WP_LOADED ACTION HOOK         ***********************************************/
179
-
180
-
181
-    /**
182
-     *    wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their
183
-     *    default priority init phases have run
184
-     *
185
-     * @access    public
186
-     * @return    void
187
-     */
188
-    public function wp_loaded()
189
-    {
190
-    }
191
-
192
-
193
-
194
-
195
-
196
-    /***********************************************        PARSE_REQUEST HOOK         ***********************************************/
197
-    /**
198
-     *    _get_request
199
-     *
200
-     * @access public
201
-     * @param WP $WP
202
-     * @return void
203
-     */
204
-    public function get_request(WP $WP)
205
-    {
206
-        do_action('AHEE__EE_Front_Controller__get_request__start');
207
-        $this->current_page->parseQueryVars($WP);
208
-        do_action('AHEE__EE_Front_Controller__get_request__complete');
209
-        remove_action('parse_request', [$this, 'get_request'], 1);
210
-    }
211
-
212
-
213
-    /**
214
-     *    pre_get_posts - basically a module factory for instantiating modules and selecting the final view template
215
-     *
216
-     * @access    public
217
-     * @param WP_Query $WP_Query
218
-     * @return    void
219
-     * @throws EE_Error
220
-     * @throws ReflectionException
221
-     */
222
-    public function pre_get_posts($WP_Query)
223
-    {
224
-        // only load Module_Request_Router if this is the main query
225
-        if (
226
-            $this->Module_Request_Router instanceof EE_Module_Request_Router
227
-            && $WP_Query->is_main_query()
228
-        ) {
229
-            // cycle thru module routes
230
-            while ($route = $this->Module_Request_Router->get_route($WP_Query)) {
231
-                // determine module and method for route
232
-                $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]);
233
-                if ($module instanceof EED_Module) {
234
-                    // get registered view for route
235
-                    $this->_template_path = $this->Module_Request_Router->get_view($route);
236
-                    // grab module name
237
-                    $module_name = $module->module_name();
238
-                    // map the module to the module objects
239
-                    $this->Registry->modules->{$module_name} = $module;
240
-                }
241
-            }
242
-        }
243
-    }
244
-
245
-
246
-
247
-
248
-
249
-    /***********************************************        WP HOOK         ***********************************************/
250
-
251
-
252
-    /**
253
-     *    wp - basically last chance to do stuff before headers sent
254
-     *
255
-     * @access    public
256
-     * @return    void
257
-     */
258
-    public function wp()
259
-    {
260
-    }
261
-
262
-
263
-
264
-    /***********************     GET_HEADER && WP_HEAD HOOK     ***********************/
265
-
266
-
267
-    /**
268
-     * callback for the "template_redirect" hook point
269
-     * checks sidebars for EE widgets
270
-     * loads resources and assets accordingly
271
-     *
272
-     * @return void
273
-     */
274
-    public function templateRedirect()
275
-    {
276
-        global $wp_query;
277
-        if (empty($wp_query->posts)) {
278
-            return;
279
-        }
280
-        // if we already know this is an espresso page, then load assets
281
-        $load_assets = $this->current_page->isEspressoPage();
282
-        // if we are already loading assets then just move along, otherwise check for widgets
283
-        $load_assets = $load_assets || $this->espresso_widgets_in_active_sidebars();
284
-        if ($load_assets) {
285
-            add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10);
286
-            add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10);
287
-        }
288
-    }
289
-
290
-
291
-    /**
292
-     * builds list of active widgets then scans active sidebars looking for them
293
-     * returns true is an EE widget is found in an active sidebar
294
-     * Please Note: this does NOT mean that the sidebar or widget
295
-     * is actually in use in a given template, as that is unfortunately not known
296
-     * until a sidebar and it's widgets are actually loaded
297
-     *
298
-     * @return boolean
299
-     */
300
-    private function espresso_widgets_in_active_sidebars()
301
-    {
302
-        $espresso_widgets = array();
303
-        foreach ($this->Registry->widgets as $widget_class => $widget) {
304
-            $id_base = EspressoWidget::getIdBase($widget_class);
305
-            if (is_active_widget(false, false, $id_base)) {
306
-                $espresso_widgets[] = $id_base;
307
-            }
308
-        }
309
-        $all_sidebar_widgets = wp_get_sidebars_widgets();
310
-        foreach ($all_sidebar_widgets as $sidebar_widgets) {
311
-            if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) {
312
-                foreach ($sidebar_widgets as $sidebar_widget) {
313
-                    foreach ($espresso_widgets as $espresso_widget) {
314
-                        if (strpos($sidebar_widget, $espresso_widget) !== false) {
315
-                            return true;
316
-                        }
317
-                    }
318
-                }
319
-            }
320
-        }
321
-        return false;
322
-    }
323
-
324
-
325
-    /**
326
-     *    header_meta_tag
327
-     *
328
-     * @access    public
329
-     * @return    void
330
-     */
331
-    public function header_meta_tag()
332
-    {
333
-        print(
334
-        apply_filters(
335
-            'FHEE__EE_Front_Controller__header_meta_tag',
336
-            '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n"
337
-        )
338
-        );
339
-
340
-        // let's exclude all event type taxonomy term archive pages from search engine indexing
341
-        // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249
342
-        // also exclude all critical pages from indexing
343
-        if (
344
-            (
345
-                is_tax('espresso_event_type')
346
-                && get_option('blog_public') !== '0'
347
-            )
348
-            || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array())
349
-        ) {
350
-            print(
351
-            apply_filters(
352
-                'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type',
353
-                '<meta name="robots" content="noindex,follow" />' . "\n"
354
-            )
355
-            );
356
-        }
357
-    }
358
-
359
-
360
-    /**
361
-     * wp_print_scripts
362
-     *
363
-     * @return void
364
-     * @throws EE_Error
365
-     */
366
-    public function wp_print_scripts()
367
-    {
368
-        global $post;
369
-        if (
370
-            isset($post->EE_Event)
371
-            && $post->EE_Event instanceof EE_Event
372
-            && get_post_type() === 'espresso_events'
373
-            && is_singular()
374
-        ) {
375
-            EEH_Schema::add_json_linked_data_for_event($post->EE_Event);
376
-        }
377
-    }
378
-
379
-
380
-    public function enqueueStyle()
381
-    {
382
-        wp_enqueue_style('espresso_default');
383
-        wp_enqueue_style('espresso_custom_css');
384
-    }
385
-
386
-
387
-
388
-    /***********************************************        WP_FOOTER         ***********************************************/
389
-
390
-
391
-    public function enqueueScripts()
392
-    {
393
-        wp_enqueue_script('espresso_core');
394
-    }
395
-
396
-
397
-    /**
398
-     * display_errors
399
-     *
400
-     * @access public
401
-     * @return void
402
-     * @throws DomainException
403
-     */
404
-    public function display_errors()
405
-    {
406
-        static $shown_already = false;
407
-        do_action('AHEE__EE_Front_Controller__display_errors__begin');
408
-        if (
409
-            ! $shown_already
410
-            && apply_filters('FHEE__EE_Front_Controller__display_errors', true)
411
-            && is_main_query()
412
-            && ! is_feed()
413
-            && in_the_loop()
414
-            && $this->current_page->isEspressoPage()
415
-        ) {
416
-            $shown_already = true;
417
-            if (did_action('wp_head')) {
418
-                echo $this->printNotices();
419
-            } else {
420
-                // block enabled themes run their query loop before headers are sent
421
-                // so we need to add our notices onto the beginning of the content
422
-                add_filter('the_content', [$this, 'prependNotices'], 1, 1);
423
-            }
424
-        }
425
-        do_action('AHEE__EE_Front_Controller__display_errors__end');
426
-    }
427
-
428
-
429
-    /**
430
-     * @param string $the_content
431
-     * @return string
432
-     * @since 4.10.30.p
433
-     */
434
-    public function prependNotices($the_content)
435
-    {
436
-        $notices = $this->printNotices();
437
-        return $notices ? $notices . $the_content : $the_content;
438
-    }
439
-
440
-
441
-    /**
442
-     * @return false|string
443
-     * @since 4.10.30.p
444
-     */
445
-    public function printNotices()
446
-    {
447
-        ob_start();
448
-        echo wp_kses(EE_Error::get_notices(), AllowedTags::getWithFormTags());
449
-        EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php');
450
-        return ob_get_clean();
451
-    }
452
-
453
-
454
-
455
-    /***********************************************        UTILITIES         ***********************************************/
456
-
457
-
458
-    /**
459
-     * @param string $template_include_path
460
-     * @return string
461
-     * @throws EE_Error
462
-     * @throws ReflectionException
463
-     */
464
-    public function template_include($template_include_path = null)
465
-    {
466
-        if ($this->current_page->isEspressoPage()) {
467
-            // despite all helpers having autoloaders set, we need to manually load the template loader
468
-            // because there are some side effects in that class for triggering template tag functions
469
-            $this->Registry->load_helper('EEH_Template');
470
-            $this->_template_path = ! empty($this->_template_path)
471
-                ? basename($this->_template_path)
472
-                : basename(
473
-                    $template_include_path
474
-                );
475
-            $template_path = EEH_Template::locate_template($this->_template_path, array(), false);
476
-            $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path;
477
-            $this->_template = basename($this->_template_path);
478
-            return $this->_template_path;
479
-        }
480
-        return $template_include_path;
481
-    }
482
-
483
-
484
-    /**
485
-     * @param bool $with_path
486
-     * @return    string
487
-     */
488
-    public function get_selected_template($with_path = false)
489
-    {
490
-        return $with_path ? $this->_template_path : $this->_template;
491
-    }
492
-
493
-
494
-    /**
495
-     * @param string $shortcode_class
496
-     * @param WP     $wp
497
-     * @throws ReflectionException
498
-     * @deprecated 4.9.26
499
-     */
500
-    public function initialize_shortcode($shortcode_class = '', WP $wp = null)
501
-    {
502
-        EE_Error::doing_it_wrong(
503
-            __METHOD__,
504
-            esc_html__(
505
-                'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.',
506
-                'event_espresso'
507
-            ),
508
-            '4.9.26'
509
-        );
510
-        $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp);
511
-    }
512
-
513
-
514
-    /**
515
-     * @return void
516
-     * @deprecated 4.9.57.p
517
-     */
518
-    public function loadPersistentAdminNoticeManager()
519
-    {
520
-    }
521
-
522
-
523
-    /**
524
-     * @return void
525
-     * @deprecated 4.9.64.p
526
-     */
527
-    public function employ_CPT_Strategy()
528
-    {
529
-    }
21
+	/**
22
+	 * @var string
23
+	 */
24
+	private $_template_path;
25
+
26
+	/**
27
+	 * @var string
28
+	 */
29
+	private $_template;
30
+
31
+	/**
32
+	 * @type EE_Registry
33
+	 */
34
+	protected $Registry;
35
+
36
+	/**
37
+	 * @type EE_Request_Handler
38
+	 */
39
+	protected $Request_Handler;
40
+
41
+	/**
42
+	 * @type EE_Module_Request_Router
43
+	 */
44
+	protected $Module_Request_Router;
45
+
46
+	/**
47
+	 * @type CurrentPage
48
+	 */
49
+	protected $current_page;
50
+
51
+
52
+	/**
53
+	 *    class constructor
54
+	 *    should fire after shortcode, module, addon, or other plugin's default priority init phases have run
55
+	 *
56
+	 * @access    public
57
+	 * @param EE_Registry              $Registry
58
+	 * @param CurrentPage              $EspressoPage
59
+	 * @param EE_Module_Request_Router $Module_Request_Router
60
+	 */
61
+	public function __construct(
62
+		EE_Registry $Registry,
63
+		CurrentPage $EspressoPage,
64
+		EE_Module_Request_Router $Module_Request_Router
65
+	) {
66
+		$this->Registry              = $Registry;
67
+		$this->current_page          = $EspressoPage;
68
+		$this->Module_Request_Router = $Module_Request_Router;
69
+		// load other resources and begin to actually run shortcodes and modules
70
+		// analyse the incoming WP request
71
+		add_action('parse_request', array($this, 'get_request'), 1, 1);
72
+		// process request with module factory
73
+		add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1);
74
+		// before headers sent
75
+		add_action('wp', array($this, 'wp'), 5);
76
+		// primarily used to process any content shortcodes
77
+		add_action('template_redirect', array($this, 'templateRedirect'), 999);
78
+		// header
79
+		add_action('wp_head', array($this, 'header_meta_tag'), 5);
80
+		add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10);
81
+		add_filter('template_include', array($this, 'template_include'), 1);
82
+		// display errors
83
+		add_action('loop_start', array($this, 'display_errors'), 2);
84
+		// the content
85
+		// add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 );
86
+		// exclude our private cpt comments
87
+		add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1);
88
+		// make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://)
89
+		add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1);
90
+		// action hook EE
91
+		do_action('AHEE__EE_Front_Controller__construct__done', $this);
92
+	}
93
+
94
+
95
+	/**
96
+	 * @return EE_Request_Handler
97
+	 * @deprecated 4.10.14.p
98
+	 */
99
+	public function Request_Handler()
100
+	{
101
+		if (! $this->Request_Handler instanceof EE_Request_Handler) {
102
+			$this->Request_Handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler');
103
+		}
104
+		return $this->Request_Handler;
105
+	}
106
+
107
+
108
+	/**
109
+	 * @return EE_Module_Request_Router
110
+	 */
111
+	public function Module_Request_Router()
112
+	{
113
+		return $this->Module_Request_Router;
114
+	}
115
+
116
+
117
+	/**
118
+	 * @return LegacyShortcodesManager
119
+	 * @deprecated 4.10.14.p
120
+	 */
121
+	public function getLegacyShortcodesManager()
122
+	{
123
+		return EE_Config::getLegacyShortcodesManager();
124
+	}
125
+
126
+
127
+
128
+
129
+
130
+	/***********************************************        INIT ACTION HOOK         ***********************************************/
131
+	/**
132
+	 * filter_wp_comments
133
+	 * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment
134
+	 * widgets/queries done on frontend
135
+	 *
136
+	 * @param  array $clauses array of comment clauses setup by WP_Comment_Query
137
+	 * @return array array of comment clauses with modifications.
138
+	 * @throws InvalidArgumentException
139
+	 * @throws InvalidDataTypeException
140
+	 * @throws InvalidInterfaceException
141
+	 */
142
+	public function filter_wp_comments($clauses)
143
+	{
144
+		global $wpdb;
145
+		if (strpos($clauses['join'], $wpdb->posts) !== false) {
146
+			/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
147
+			$custom_post_types = LoaderFactory::getLoader()->getShared(
148
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
149
+			);
150
+			$cpts = $custom_post_types->getPrivateCustomPostTypes();
151
+			foreach ($cpts as $cpt => $details) {
152
+				$clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt);
153
+			}
154
+		}
155
+		return $clauses;
156
+	}
157
+
158
+
159
+	/**
160
+	 * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend
161
+	 *
162
+	 * @param  string $url incoming url
163
+	 * @return string         final assembled url
164
+	 */
165
+	public function maybe_force_admin_ajax_ssl($url)
166
+	{
167
+		if (is_ssl() && preg_match('/admin-ajax.php/', $url)) {
168
+			$url = str_replace('http://', 'https://', $url);
169
+		}
170
+		return $url;
171
+	}
172
+
173
+
174
+
175
+
176
+
177
+
178
+	/***********************************************        WP_LOADED ACTION HOOK         ***********************************************/
179
+
180
+
181
+	/**
182
+	 *    wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their
183
+	 *    default priority init phases have run
184
+	 *
185
+	 * @access    public
186
+	 * @return    void
187
+	 */
188
+	public function wp_loaded()
189
+	{
190
+	}
191
+
192
+
193
+
194
+
195
+
196
+	/***********************************************        PARSE_REQUEST HOOK         ***********************************************/
197
+	/**
198
+	 *    _get_request
199
+	 *
200
+	 * @access public
201
+	 * @param WP $WP
202
+	 * @return void
203
+	 */
204
+	public function get_request(WP $WP)
205
+	{
206
+		do_action('AHEE__EE_Front_Controller__get_request__start');
207
+		$this->current_page->parseQueryVars($WP);
208
+		do_action('AHEE__EE_Front_Controller__get_request__complete');
209
+		remove_action('parse_request', [$this, 'get_request'], 1);
210
+	}
211
+
212
+
213
+	/**
214
+	 *    pre_get_posts - basically a module factory for instantiating modules and selecting the final view template
215
+	 *
216
+	 * @access    public
217
+	 * @param WP_Query $WP_Query
218
+	 * @return    void
219
+	 * @throws EE_Error
220
+	 * @throws ReflectionException
221
+	 */
222
+	public function pre_get_posts($WP_Query)
223
+	{
224
+		// only load Module_Request_Router if this is the main query
225
+		if (
226
+			$this->Module_Request_Router instanceof EE_Module_Request_Router
227
+			&& $WP_Query->is_main_query()
228
+		) {
229
+			// cycle thru module routes
230
+			while ($route = $this->Module_Request_Router->get_route($WP_Query)) {
231
+				// determine module and method for route
232
+				$module = $this->Module_Request_Router->resolve_route($route[0], $route[1]);
233
+				if ($module instanceof EED_Module) {
234
+					// get registered view for route
235
+					$this->_template_path = $this->Module_Request_Router->get_view($route);
236
+					// grab module name
237
+					$module_name = $module->module_name();
238
+					// map the module to the module objects
239
+					$this->Registry->modules->{$module_name} = $module;
240
+				}
241
+			}
242
+		}
243
+	}
244
+
245
+
246
+
247
+
248
+
249
+	/***********************************************        WP HOOK         ***********************************************/
250
+
251
+
252
+	/**
253
+	 *    wp - basically last chance to do stuff before headers sent
254
+	 *
255
+	 * @access    public
256
+	 * @return    void
257
+	 */
258
+	public function wp()
259
+	{
260
+	}
261
+
262
+
263
+
264
+	/***********************     GET_HEADER && WP_HEAD HOOK     ***********************/
265
+
266
+
267
+	/**
268
+	 * callback for the "template_redirect" hook point
269
+	 * checks sidebars for EE widgets
270
+	 * loads resources and assets accordingly
271
+	 *
272
+	 * @return void
273
+	 */
274
+	public function templateRedirect()
275
+	{
276
+		global $wp_query;
277
+		if (empty($wp_query->posts)) {
278
+			return;
279
+		}
280
+		// if we already know this is an espresso page, then load assets
281
+		$load_assets = $this->current_page->isEspressoPage();
282
+		// if we are already loading assets then just move along, otherwise check for widgets
283
+		$load_assets = $load_assets || $this->espresso_widgets_in_active_sidebars();
284
+		if ($load_assets) {
285
+			add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10);
286
+			add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10);
287
+		}
288
+	}
289
+
290
+
291
+	/**
292
+	 * builds list of active widgets then scans active sidebars looking for them
293
+	 * returns true is an EE widget is found in an active sidebar
294
+	 * Please Note: this does NOT mean that the sidebar or widget
295
+	 * is actually in use in a given template, as that is unfortunately not known
296
+	 * until a sidebar and it's widgets are actually loaded
297
+	 *
298
+	 * @return boolean
299
+	 */
300
+	private function espresso_widgets_in_active_sidebars()
301
+	{
302
+		$espresso_widgets = array();
303
+		foreach ($this->Registry->widgets as $widget_class => $widget) {
304
+			$id_base = EspressoWidget::getIdBase($widget_class);
305
+			if (is_active_widget(false, false, $id_base)) {
306
+				$espresso_widgets[] = $id_base;
307
+			}
308
+		}
309
+		$all_sidebar_widgets = wp_get_sidebars_widgets();
310
+		foreach ($all_sidebar_widgets as $sidebar_widgets) {
311
+			if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) {
312
+				foreach ($sidebar_widgets as $sidebar_widget) {
313
+					foreach ($espresso_widgets as $espresso_widget) {
314
+						if (strpos($sidebar_widget, $espresso_widget) !== false) {
315
+							return true;
316
+						}
317
+					}
318
+				}
319
+			}
320
+		}
321
+		return false;
322
+	}
323
+
324
+
325
+	/**
326
+	 *    header_meta_tag
327
+	 *
328
+	 * @access    public
329
+	 * @return    void
330
+	 */
331
+	public function header_meta_tag()
332
+	{
333
+		print(
334
+		apply_filters(
335
+			'FHEE__EE_Front_Controller__header_meta_tag',
336
+			'<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n"
337
+		)
338
+		);
339
+
340
+		// let's exclude all event type taxonomy term archive pages from search engine indexing
341
+		// @see https://events.codebasehq.com/projects/event-espresso/tickets/10249
342
+		// also exclude all critical pages from indexing
343
+		if (
344
+			(
345
+				is_tax('espresso_event_type')
346
+				&& get_option('blog_public') !== '0'
347
+			)
348
+			|| is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array())
349
+		) {
350
+			print(
351
+			apply_filters(
352
+				'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type',
353
+				'<meta name="robots" content="noindex,follow" />' . "\n"
354
+			)
355
+			);
356
+		}
357
+	}
358
+
359
+
360
+	/**
361
+	 * wp_print_scripts
362
+	 *
363
+	 * @return void
364
+	 * @throws EE_Error
365
+	 */
366
+	public function wp_print_scripts()
367
+	{
368
+		global $post;
369
+		if (
370
+			isset($post->EE_Event)
371
+			&& $post->EE_Event instanceof EE_Event
372
+			&& get_post_type() === 'espresso_events'
373
+			&& is_singular()
374
+		) {
375
+			EEH_Schema::add_json_linked_data_for_event($post->EE_Event);
376
+		}
377
+	}
378
+
379
+
380
+	public function enqueueStyle()
381
+	{
382
+		wp_enqueue_style('espresso_default');
383
+		wp_enqueue_style('espresso_custom_css');
384
+	}
385
+
386
+
387
+
388
+	/***********************************************        WP_FOOTER         ***********************************************/
389
+
390
+
391
+	public function enqueueScripts()
392
+	{
393
+		wp_enqueue_script('espresso_core');
394
+	}
395
+
396
+
397
+	/**
398
+	 * display_errors
399
+	 *
400
+	 * @access public
401
+	 * @return void
402
+	 * @throws DomainException
403
+	 */
404
+	public function display_errors()
405
+	{
406
+		static $shown_already = false;
407
+		do_action('AHEE__EE_Front_Controller__display_errors__begin');
408
+		if (
409
+			! $shown_already
410
+			&& apply_filters('FHEE__EE_Front_Controller__display_errors', true)
411
+			&& is_main_query()
412
+			&& ! is_feed()
413
+			&& in_the_loop()
414
+			&& $this->current_page->isEspressoPage()
415
+		) {
416
+			$shown_already = true;
417
+			if (did_action('wp_head')) {
418
+				echo $this->printNotices();
419
+			} else {
420
+				// block enabled themes run their query loop before headers are sent
421
+				// so we need to add our notices onto the beginning of the content
422
+				add_filter('the_content', [$this, 'prependNotices'], 1, 1);
423
+			}
424
+		}
425
+		do_action('AHEE__EE_Front_Controller__display_errors__end');
426
+	}
427
+
428
+
429
+	/**
430
+	 * @param string $the_content
431
+	 * @return string
432
+	 * @since 4.10.30.p
433
+	 */
434
+	public function prependNotices($the_content)
435
+	{
436
+		$notices = $this->printNotices();
437
+		return $notices ? $notices . $the_content : $the_content;
438
+	}
439
+
440
+
441
+	/**
442
+	 * @return false|string
443
+	 * @since 4.10.30.p
444
+	 */
445
+	public function printNotices()
446
+	{
447
+		ob_start();
448
+		echo wp_kses(EE_Error::get_notices(), AllowedTags::getWithFormTags());
449
+		EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php');
450
+		return ob_get_clean();
451
+	}
452
+
453
+
454
+
455
+	/***********************************************        UTILITIES         ***********************************************/
456
+
457
+
458
+	/**
459
+	 * @param string $template_include_path
460
+	 * @return string
461
+	 * @throws EE_Error
462
+	 * @throws ReflectionException
463
+	 */
464
+	public function template_include($template_include_path = null)
465
+	{
466
+		if ($this->current_page->isEspressoPage()) {
467
+			// despite all helpers having autoloaders set, we need to manually load the template loader
468
+			// because there are some side effects in that class for triggering template tag functions
469
+			$this->Registry->load_helper('EEH_Template');
470
+			$this->_template_path = ! empty($this->_template_path)
471
+				? basename($this->_template_path)
472
+				: basename(
473
+					$template_include_path
474
+				);
475
+			$template_path = EEH_Template::locate_template($this->_template_path, array(), false);
476
+			$this->_template_path = ! empty($template_path) ? $template_path : $template_include_path;
477
+			$this->_template = basename($this->_template_path);
478
+			return $this->_template_path;
479
+		}
480
+		return $template_include_path;
481
+	}
482
+
483
+
484
+	/**
485
+	 * @param bool $with_path
486
+	 * @return    string
487
+	 */
488
+	public function get_selected_template($with_path = false)
489
+	{
490
+		return $with_path ? $this->_template_path : $this->_template;
491
+	}
492
+
493
+
494
+	/**
495
+	 * @param string $shortcode_class
496
+	 * @param WP     $wp
497
+	 * @throws ReflectionException
498
+	 * @deprecated 4.9.26
499
+	 */
500
+	public function initialize_shortcode($shortcode_class = '', WP $wp = null)
501
+	{
502
+		EE_Error::doing_it_wrong(
503
+			__METHOD__,
504
+			esc_html__(
505
+				'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.',
506
+				'event_espresso'
507
+			),
508
+			'4.9.26'
509
+		);
510
+		$this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp);
511
+	}
512
+
513
+
514
+	/**
515
+	 * @return void
516
+	 * @deprecated 4.9.57.p
517
+	 */
518
+	public function loadPersistentAdminNoticeManager()
519
+	{
520
+	}
521
+
522
+
523
+	/**
524
+	 * @return void
525
+	 * @deprecated 4.9.64.p
526
+	 */
527
+	public function employ_CPT_Strategy()
528
+	{
529
+	}
530 530
 }
Please login to merge, or discard this patch.