Completed
Push — 247-fix/delete-term-meta ( d5f818...2a1fe3 )
by Sudar
67:09 queued 61:16
created

BulkDelete::load_primary_pages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 0
dl 0
loc 21
ccs 0
cts 12
cp 0
crap 2
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
namespace BulkWP\BulkDelete\Core;
4
5
use BulkWP\BulkDelete\Core\Addon\Upseller;
6
use BulkWP\BulkDelete\Core\Base\BasePage;
7
use BulkWP\BulkDelete\Core\Cron\CronListPage;
8
use BulkWP\BulkDelete\Core\Metas\DeleteMetasPage;
9
use BulkWP\BulkDelete\Core\Metas\Modules\DeleteCommentMetaModule;
10
use BulkWP\BulkDelete\Core\Metas\Modules\DeletePostMetaModule;
11
use BulkWP\BulkDelete\Core\Metas\Modules\DeleteTermMetaModule;
12
use BulkWP\BulkDelete\Core\Metas\Modules\DeleteUserMetaModule;
13
use BulkWP\BulkDelete\Core\Pages\DeletePagesPage;
14
use BulkWP\BulkDelete\Core\Pages\Modules\DeletePagesByStatusModule;
15
use BulkWP\BulkDelete\Core\Posts\DeletePostsPage;
16
use BulkWP\BulkDelete\Core\Posts\Modules\DeletePostsByCategoryModule;
17
use BulkWP\BulkDelete\Core\Posts\Modules\DeletePostsByCommentsModule;
18
use BulkWP\BulkDelete\Core\Posts\Modules\DeletePostsByPostTypeModule;
19
use BulkWP\BulkDelete\Core\Posts\Modules\DeletePostsByRevisionModule;
20
use BulkWP\BulkDelete\Core\Posts\Modules\DeletePostsByStatusModule;
21
use BulkWP\BulkDelete\Core\Posts\Modules\DeletePostsByStickyPostModule;
22
use BulkWP\BulkDelete\Core\Posts\Modules\DeletePostsByTagModule;
23
use BulkWP\BulkDelete\Core\Posts\Modules\DeletePostsByTaxonomyModule;
24
use BulkWP\BulkDelete\Core\Posts\Modules\DeletePostsByURLModule;
25
use BulkWP\BulkDelete\Core\SystemInfo\SystemInfoPage;
26
use BulkWP\BulkDelete\Core\Terms\DeleteTermsPage;
27
use BulkWP\BulkDelete\Core\Terms\Modules\DeleteTermsByNameModule;
28
use BulkWP\BulkDelete\Core\Terms\Modules\DeleteTermsByPostCountModule;
29
use BulkWP\BulkDelete\Core\Users\DeleteUsersPage;
30
use BulkWP\BulkDelete\Core\Users\Modules\DeleteUsersByUserMetaModule;
31
use BulkWP\BulkDelete\Core\Users\Modules\DeleteUsersByUserRoleModule;
32
33 1
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
34
35
/**
36
 * Main Plugin class.
37
 *
38
 * @since 5.0 Converted to Singleton
39
 * @since 6.0.0 Renamed to BulkDelete and added namespace.
40
 */
41
final class BulkDelete {
42
	/**
43
	 * The one true BulkDelete instance.
44
	 *
45
	 * @var BulkDelete
46
	 *
47
	 * @since 5.0
48
	 */
49
	private static $instance;
50
51
	/**
52
	 * Path to the main plugin file.
53
	 *
54
	 * @var string
55
	 */
56
	private $plugin_file;
57
58
	/**
59
	 * Path where translations are stored.
60
	 *
61
	 * @var string
62
	 */
63
	private $translations_path;
64
65
	/**
66
	 * Has the plugin loaded?
67
	 *
68
	 * @since 6.0.0
69
	 *
70
	 * @var bool
71
	 */
72
	private $loaded = false;
73
74
	/**
75
	 * Controller that handles all requests and nonce checks.
76
	 *
77
	 * @var \BulkWP\BulkDelete\Core\Controller
78
	 */
79
	private $controller;
80
81
	/**
82
	 * Upseller responsible for upselling add-ons.
83
	 *
84
	 * @since 6.0.0
85
	 *
86
	 * @var \BulkWP\BulkDelete\Core\Addon\Upseller
87
	 */
88
	private $upseller;
89
90
	/**
91
	 * Bulk Delete Autoloader.
92
	 *
93
	 * Will be used by add-ons to extend the namespace.
94
	 *
95
	 * @var \BulkWP\BulkDelete\BulkDeleteAutoloader
96
	 */
97
	private $loader;
98
99
	/**
100
	 * List of Primary Admin pages.
101
	 *
102
	 * @var \BulkWP\BulkDelete\Core\Base\BaseDeletePage[]
103
	 *
104
	 * @since 6.0.0
105
	 */
106
	private $primary_pages = array();
107
108
	/**
109
	 * List of Secondary Admin pages.
110
	 *
111
	 * @var BasePage[]
112
	 *
113
	 * @since 6.0.0
114
	 */
115
	private $secondary_pages = array();
116
117
	/**
118
	 * Plugin version.
119
	 */
120
	const VERSION = '6.0.1';
121
122
	/**
123
	 * Set the BulkDelete constructor as private.
124
	 *
125
	 * An instance should be created by calling the `get_instance` method.
126
	 *
127
	 * @see BulkDelete::get_instance()
128
	 */
129
	private function __construct() {}
130
131
	/**
132
	 * Main BulkDelete Instance.
133
	 *
134
	 * Insures that only one instance of BulkDelete exists in memory at any one
135
	 * time. Also prevents needing to define globals all over the place.
136
	 *
137
	 * @since     5.0
138
	 * @static
139
	 * @staticvar array $instance
140
	 *
141
	 * @return BulkDelete The one true instance of BulkDelete.
142
	 */
143 4
	public static function get_instance() {
144 4
		if ( ! isset( self::$instance ) && ! ( self::$instance instanceof BulkDelete ) ) {
145 1
			self::$instance = new BulkDelete();
146
		}
147
148 4
		return self::$instance;
149
	}
150
151
	/**
152
	 * Load the plugin if it is not loaded.
153
	 * The plugin will be loaded only it is an admin request or a cron request.
154
	 *
155
	 * This function will be invoked in the `plugins_loaded` hook.
156
	 */
157
	public function load() {
158
		if ( $this->loaded ) {
159
			return;
160
		}
161
162
		if ( ! $this->is_admin_or_cron() ) {
163
			return;
164
		}
165
166
		$this->load_dependencies();
167
		$this->setup_actions();
168
169
		$this->loaded = true;
170
171
		/**
172
		 * Bulk Delete plugin loaded.
173
		 *
174
		 * @since 6.0.0
175
		 *
176
		 * @param string Plugin main file.
177
		 */
178
		do_action( 'bd_loaded', $this->get_plugin_file() );
179
180
		$this->load_primary_pages();
181
	}
182
183
	/**
184
	 * Throw error on object clone.
185
	 *
186
	 * The whole idea of the singleton design pattern is that there is a single
187
	 * object therefore, we don't want the object to be cloned.
188
	 *
189
	 * @since  5.0
190
	 * @access protected
191
	 *
192
	 * @return void
193
	 */
194 1
	public function __clone() {
195 1
		_doing_it_wrong( __FUNCTION__, __( "This class can't be cloned. Use `get_instance()` method to get an instance.", 'bulk-delete' ), '5.0' );
196 1
	}
197
198
	/**
199
	 * Disable unserializing of the class.
200
	 *
201
	 * @since  5.0
202
	 * @access protected
203
	 *
204
	 * @return void
205
	 */
206 1
	public function __wakeup() {
207 1
		_doing_it_wrong( __FUNCTION__, __( "This class can't be serialized. Use `get_instance()` method to get an instance.", 'bulk-delete' ), '5.0' );
208 1
	}
209
210
	/**
211
	 * Load all dependencies.
212
	 *
213
	 * @since 6.0.0
214
	 */
215
	private function load_dependencies() {
216
		$this->controller = new Controller();
217
		$this->controller->load();
218
219
		$this->upseller = new Upseller();
220
		$this->upseller->load();
221
	}
222
223
	/**
224
	 * Loads the plugin's actions and hooks.
225
	 *
226
	 * @access private
227
	 *
228
	 * @since  5.0
229
	 *
230
	 * @return void
231
	 */
232
	private function setup_actions() {
233
		add_action( 'init', array( $this, 'on_init' ) );
234
235
		add_action( 'admin_menu', array( $this, 'on_admin_menu' ) );
236
	}
237
238
	/**
239
	 * Triggered when the `init` hook is fired.
240
	 *
241
	 * @since 6.0.0
242
	 */
243 1
	public function on_init() {
244 1
		$this->load_textdomain();
245 1
	}
246
247
	/**
248
	 * Loads the plugin language files.
249
	 *
250
	 * @since  5.0
251
	 */
252 1
	private function load_textdomain() {
253 1
		load_plugin_textdomain( 'bulk-delete', false, $this->get_translations_path() );
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type string expected by parameter $deprecated of load_plugin_textdomain(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

253
		load_plugin_textdomain( 'bulk-delete', /** @scrutinizer ignore-type */ false, $this->get_translations_path() );
Loading history...
254 1
	}
255
256
	/**
257
	 * Triggered when the `admin_menu` hook is fired.
258
	 *
259
	 * Register all admin pages.
260
	 *
261
	 * @since 6.0.0
262
	 */
263
	public function on_admin_menu() {
264
		foreach ( $this->get_primary_pages() as $page ) {
265
			$page->register();
266
		}
267
268
		\Bulk_Delete_Misc::add_menu();
269
270
		/**
271
		 * Runs just after adding all *delete* menu items to Bulk WP main menu.
272
		 *
273
		 * This action is primarily for adding extra *delete* menu items to the Bulk WP main menu.
274
		 *
275
		 * @since 5.3
276
		 */
277
		do_action( 'bd_after_primary_menus' );
278
279
		/**
280
		 * Runs just before adding non-action menu items to Bulk WP main menu.
281
		 *
282
		 * This action is primarily for adding extra menu items before non-action menu items to the Bulk WP main menu.
283
		 *
284
		 * @since 5.3
285
		 */
286
		do_action( 'bd_before_secondary_menus' );
287
288
		foreach ( $this->get_secondary_pages() as $page ) {
289
			$page->register();
290
		}
291
292
		$this->addon_page = add_submenu_page(
0 ignored issues
show
Bug Best Practice introduced by
The property addon_page does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
293
			\Bulk_Delete::POSTS_PAGE_SLUG,
294
			__( 'Addon Licenses', 'bulk-delete' ),
295
			__( 'Addon Licenses', 'bulk-delete' ),
296
			'activate_plugins',
297
			\Bulk_Delete::ADDON_PAGE_SLUG,
298
			array( 'BD_License', 'display_addon_page' )
299
		);
300
301
		/**
302
		 * Runs just after adding all menu items to Bulk WP main menu.
303
		 *
304
		 * This action is primarily for adding extra menu items to the Bulk WP main menu.
305
		 *
306
		 * @since 5.3
307
		 */
308
		do_action( 'bd_after_all_menus' );
309
	}
310
311
	/**
312
	 * Get the list of registered admin pages.
313
	 *
314
	 * @since 6.0.0
315
	 *
316
	 * @return \BulkWP\BulkDelete\Core\Base\BaseDeletePage[] List of Primary Admin pages.
317
	 */
318
	private function get_primary_pages() {
319
		if ( empty( $this->primary_pages ) ) {
320
			$this->load_primary_pages();
321
		}
322
323
		return $this->primary_pages;
324
	}
325
326
	/**
327
	 * Load Primary admin pages.
328
	 *
329
	 * The pages need to be loaded in `init` hook, since the association between page and modules is needed in cron requests.
330
	 */
331
	private function load_primary_pages() {
332
		$posts_page = $this->get_delete_posts_admin_page();
333
		$pages_page = $this->get_delete_pages_admin_page();
334
		$users_page = $this->get_delete_users_admin_page();
335
		$metas_page = $this->get_delete_metas_admin_page();
336
		$terms_page = $this->get_delete_terms_admin_page();
337
338
		$this->primary_pages[ $posts_page->get_page_slug() ] = $posts_page;
339
		$this->primary_pages[ $pages_page->get_page_slug() ] = $pages_page;
340
		$this->primary_pages[ $users_page->get_page_slug() ] = $users_page;
341
		$this->primary_pages[ $metas_page->get_page_slug() ] = $metas_page;
342
		$this->primary_pages[ $terms_page->get_page_slug() ] = $terms_page;
343
344
		/**
345
		 * List of primary admin pages.
346
		 *
347
		 * @since 6.0.0
348
		 *
349
		 * @param \BulkWP\BulkDelete\Core\Base\BaseDeletePage[] List of Admin pages.
350
		 */
351
		$this->primary_pages = apply_filters( 'bd_primary_pages', $this->primary_pages );
352
	}
353
354
	/**
355
	 * Get Bulk Delete Posts admin page.
356
	 *
357
	 * @return \BulkWP\BulkDelete\Core\Posts\DeletePostsPage
358
	 */
359
	private function get_delete_posts_admin_page() {
360
		$posts_page = new DeletePostsPage( $this->get_plugin_file() );
361
362
		$posts_page->add_module( new DeletePostsByStatusModule() );
363
		$posts_page->add_module( new DeletePostsByCategoryModule() );
364
		$posts_page->add_module( new DeletePostsByTagModule() );
365
		$posts_page->add_module( new DeletePostsByTaxonomyModule() );
366
		$posts_page->add_module( new DeletePostsByPostTypeModule() );
367
		$posts_page->add_module( new DeletePostsByCommentsModule() );
368
		$posts_page->add_module( new DeletePostsByURLModule() );
369
		$posts_page->add_module( new DeletePostsByRevisionModule() );
370
		$posts_page->add_module( new DeletePostsByStickyPostModule() );
371
372
		/**
373
		 * After the modules are registered in the delete posts page.
374
		 *
375
		 * @since 6.0.0
376
		 *
377
		 * @param DeletePostsPage $posts_page The page in which the modules are registered.
378
		 */
379
		do_action( "bd_after_modules_{$posts_page->get_page_slug()}", $posts_page );
380
381
		/**
382
		 * After the modules are registered in a delete page.
383
		 *
384
		 * @since 6.0.0
385
		 *
386
		 * @param BasePage $posts_page The page in which the modules are registered.
387
		 */
388
		do_action( 'bd_after_modules', $posts_page );
389
390
		return $posts_page;
391
	}
392
393
	/**
394
	 * Get Bulk Delete Pages admin page.
395
	 *
396
	 * @since 6.0.0
397
	 *
398
	 * @return \BulkWP\BulkDelete\Core\Pages\DeletePagesPage
399
	 */
400
	private function get_delete_pages_admin_page() {
401
		$pages_page = new DeletePagesPage( $this->get_plugin_file() );
402
403
		$pages_page->add_module( new DeletePagesByStatusModule() );
404
405
		/**
406
		 * After the modules are registered in the delete pages page.
407
		 *
408
		 * @since 6.0.0
409
		 *
410
		 * @param DeletePagesPage $pages_page The page in which the modules are registered.
411
		 */
412
		do_action( "bd_after_modules_{$pages_page->get_page_slug()}", $pages_page );
413
414
		/**
415
		 * After the modules are registered in a delete page.
416
		 *
417
		 * @since 6.0.0
418
		 *
419
		 * @param BasePage $pages_page The page in which the modules are registered.
420
		 */
421
		do_action( 'bd_after_modules', $pages_page );
422
423
		return $pages_page;
424
	}
425
426
	/**
427
	 * Get Bulk Delete Users admin page.
428
	 *
429
	 * @since 6.0.0
430
	 *
431
	 * @return \BulkWP\BulkDelete\Core\Users\DeleteUsersPage
432
	 */
433
	private function get_delete_users_admin_page() {
434
		$users_page = new DeleteUsersPage( $this->get_plugin_file() );
435
436
		$users_page->add_module( new DeleteUsersByUserRoleModule() );
437
		$users_page->add_module( new DeleteUsersByUserMetaModule() );
438
439
		/**
440
		 * After the modules are registered in the delete users page.
441
		 *
442
		 * @since 6.0.0
443
		 *
444
		 * @param DeleteUsersPage $users_page The page in which the modules are registered.
445
		 */
446
		do_action( "bd_after_modules_{$users_page->get_page_slug()}", $users_page );
447
448
		/**
449
		 * After the modules are registered in a delete page.
450
		 *
451
		 * @since 6.0.0
452
		 *
453
		 * @param BasePage $users_page The page in which the modules are registered.
454
		 */
455
		do_action( 'bd_after_modules', $users_page );
456
457
		return $users_page;
458
	}
459
460
	/**
461
	 * Get Bulk Delete Metas admin page.
462
	 *
463
	 * @since 6.0.0
464
	 *
465
	 * @return \BulkWP\BulkDelete\Core\Metas\DeleteMetasPage
466
	 */
467
	private function get_delete_metas_admin_page() {
468
		$metas_page = new DeleteMetasPage( $this->get_plugin_file() );
469
470
		$metas_page->add_module( new DeletePostMetaModule() );
471
		$metas_page->add_module( new DeleteUserMetaModule() );
472
		$metas_page->add_module( new DeleteCommentMetaModule() );
473
		$metas_page->add_module( new DeleteTermMetaModule() );
474
475
		/**
476
		 * After the modules are registered in the delete metas page.
477
		 *
478
		 * @since 6.0.0
479
		 *
480
		 * @param DeleteMetasPage $metas_page The page in which the modules are registered.
481
		 */
482
		do_action( "bd_after_modules_{$metas_page->get_page_slug()}", $metas_page );
483
484
		/**
485
		 * After the modules are registered in a delete page.
486
		 *
487
		 * @since 6.0.0
488
		 *
489
		 * @param BasePage $metas_page The page in which the modules are registered.
490
		 */
491
		do_action( 'bd_after_modules', $metas_page );
492
493
		return $metas_page;
494
	}
495
496
	/**
497
	 * Get Bulk Delete Terms admin page.
498
	 *
499
	 * @since 6.0.0
500
	 *
501
	 * @return \BulkWP\BulkDelete\Core\Terms\DeleteTermsPage
502
	 */
503
	private function get_delete_terms_admin_page() {
504
		$terms_page = new DeleteTermsPage( $this->get_plugin_file() );
505
506
		$terms_page->add_module( new DeleteTermsByNameModule() );
507
		$terms_page->add_module( new DeleteTermsByPostCountModule() );
508
509
		/**
510
		 * After the modules are registered in the delete terms page.
511
		 *
512
		 * @since 6.0.0
513
		 *
514
		 * @param DeleteTermsPage $terms_page The page in which the modules are registered.
515
		 */
516
		do_action( "bd_after_modules_{$terms_page->get_page_slug()}", $terms_page );
517
518
		/**
519
		 * After the modules are registered in a delete page.
520
		 *
521
		 * @since 6.0.0
522
		 *
523
		 * @param BasePage $terms_page The page in which the modules are registered.
524
		 */
525
		do_action( 'bd_after_modules', $terms_page );
526
527
		return $terms_page;
528
	}
529
530
	/**
531
	 * Get the Cron List admin page.
532
	 *
533
	 * @since 6.0.0
534
	 *
535
	 * @return \BulkWP\BulkDelete\Core\Cron\CronListPage
536
	 */
537
	private function get_cron_list_admin_page() {
538
		$cron_list_page = new CronListPage( $this->get_plugin_file() );
539
540
		return $cron_list_page;
541
	}
542
543
	/**
544
	 * Get the System Info page.
545
	 *
546
	 * @since 6.0.0
547
	 *
548
	 * @return \BulkWP\BulkDelete\Core\SystemInfo\SystemInfoPage
549
	 */
550
	private function get_system_info_page() {
551
		$system_info_page = new SystemInfoPage( $this->get_plugin_file() );
552
553
		return $system_info_page;
554
	}
555
556
	/**
557
	 * Get the list of secondary pages.
558
	 *
559
	 * @return BasePage[] Secondary Pages.
560
	 */
561
	private function get_secondary_pages() {
562
		if ( empty( $this->secondary_pages ) ) {
563
			$cron_list_page   = $this->get_cron_list_admin_page();
564
			$system_info_page = $this->get_system_info_page();
565
566
			$this->secondary_pages[ $cron_list_page->get_page_slug() ]   = $cron_list_page;
567
			$this->secondary_pages[ $system_info_page->get_page_slug() ] = $system_info_page;
568
		}
569
570
		/**
571
		 * List of secondary admin pages.
572
		 *
573
		 * @since 6.0.0
574
		 *
575
		 * @param BasePage[] List of Admin pages.
576
		 */
577
		return apply_filters( 'bd_secondary_pages', $this->secondary_pages );
578
	}
579
580
	/**
581
	 * Get path to main plugin file.
582
	 *
583
	 * @return string Plugin file.
584
	 */
585 1
	public function get_plugin_file() {
586 1
		return $this->plugin_file;
587
	}
588
589
	/**
590
	 * Set path to main plugin file.
591
	 *
592
	 * @param string $plugin_file Path to main plugin file.
593
	 */
594 1
	public function set_plugin_file( $plugin_file ) {
595 1
		$this->plugin_file       = $plugin_file;
596 1
		$this->translations_path = dirname( plugin_basename( $this->get_plugin_file() ) ) . '/languages/';
597 1
	}
598
599
	/**
600
	 * Get path to translations.
601
	 *
602
	 * @return string Translations path.
603
	 */
604 1
	public function get_translations_path() {
605 1
		return $this->translations_path;
606
	}
607
608
	/**
609
	 * Get the hook suffix of a page.
610
	 *
611
	 * @param string $page_slug Page slug.
612
	 *
613
	 * @return string|null Hook suffix if found, null otherwise.
614
	 */
615
	public function get_page_hook_suffix( $page_slug ) {
616
		$admin_page = '';
617
618
		if ( array_key_exists( $page_slug, $this->get_primary_pages() ) ) {
619
			$admin_page = $this->primary_pages[ $page_slug ];
620
		}
621
622
		if ( array_key_exists( $page_slug, $this->get_secondary_pages() ) ) {
623
			$admin_page = $this->secondary_pages[ $page_slug ];
624
		}
625
626
		if ( $admin_page instanceof BasePage ) {
627
			return $admin_page->get_hook_suffix();
628
		}
629
630
		return null;
631
	}
632
633
	/**
634
	 * Register Add-on Namespace.
635
	 *
636
	 * @param \BulkWP\BulkDelete\Core\Addon\AddonInfo $addon_info Add-on Info.
637
	 */
638
	public function register_addon_namespace( $addon_info ) {
639
		$this->loader->add_namespace( 'BulkWP\BulkDelete', $addon_info->get_addon_directory() . 'includes' );
640
	}
641
642
	/**
643
	 * Setter for Autoloader.
644
	 *
645
	 * @param \BulkWP\BulkDelete\BulkDeleteAutoloader $loader Autoloader.
646
	 */
647
	public function set_loader( $loader ) {
648
		$this->loader = $loader;
649
	}
650
651
	/**
652
	 * Get the module object instance by page slug and module class name.
653
	 *
654
	 * @param string $page_slug         Page Slug.
655
	 * @param string $module_class_name Module class name.
656
	 *
657
	 * @return \BulkWP\BulkDelete\Core\Base\BaseModule|null Module object instance or null if no match found.
658
	 */
659
	public function get_module( $page_slug, $module_class_name ) {
660
		$page = $this->get_page( $page_slug );
661
662
		if ( is_null( $page ) ) {
663
			return null;
664
		}
665
666
		return $page->get_module( $module_class_name );
667
	}
668
669
	/**
670
	 * Get the page object instance by page slug.
671
	 *
672
	 * @param string $page_slug Page slug.
673
	 *
674
	 * @return \BulkWP\BulkDelete\Core\Base\BaseDeletePage|null Page object instance or null if no match found.
675
	 */
676
	public function get_page( $page_slug ) {
677
		$pages = $this->get_primary_pages();
678
679
		if ( ! isset( $pages[ $page_slug ] ) ) {
680
			return null;
681
		}
682
683
		return $pages[ $page_slug ];
684
	}
685
686
	/**
687
	 * Is the current request an admin or cron request?
688
	 *
689
	 * @return bool True, if yes, False otherwise.
690
	 */
691
	private function is_admin_or_cron() {
692
		return is_admin() || defined( 'DOING_CRON' ) || isset( $_GET['doing_wp_cron'] );
693
	}
694
}
695