Completed
Push — 137-feature/construct-post-mod... ( 2fadb4...c92423 )
by Maria Daniel Deepak
03:42
created

bulk-delete.php (2 issues)

1
<?php
2
/**
3
 * Plugin Name: Bulk Delete
4
 * Plugin Script: bulk-delete.php
5
 * Plugin URI: http://bulkwp.com
6
 * Description: Bulk delete users and posts from selected categories, tags, post types, custom taxonomies or by post status like drafts, scheduled posts, revisions etc.
7
 * Donate Link: http://sudarmuthu.com/if-you-wanna-thank-me
8
 * Version: 5.6.0
9
 * License: GPL
10
 * Author: Sudar
11
 * Author URI: http://sudarmuthu.com/
12
 * Text Domain: bulk-delete
13
 * Domain Path: languages/
14
 * === RELEASE NOTES ===
15
 * Check readme file for full release notes.
16
 *
17
 * @version    5.6.0
18
 *
19
 * @author     Sudar
20
 *
21
 * @package    BulkDelete
22
 */
23
24
/**
25
 * Copyright 2009  Sudar Muthu  (email : [email protected])
26
 * This program is free software; you can redistribute it and/or modify
27
 * it under the terms of the GNU General Public License, version 2, as
28
 * published by the Free Software Foundation.
29
 * This program is distributed in the hope that it will be useful,
30
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
 * GNU General Public License for more details.
33
 * You should have received a copy of the GNU General Public License
34
 * along with this program; if not, write to the Free Software
35
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
36
 */
37
defined( 'ABSPATH' ) || exit; // Exit if accessed directly
38
39
/**
40
 * Main Bulk_Delete class.
41
 *
42
 * Singleton @since 5.0
43
 */
44
final class Bulk_Delete {
45
	/**
46
	 * @var Bulk_Delete The one true Bulk_Delete
47
	 *
48
	 * @since 5.0
49
	 */
50
	private static $instance;
51
52
	/**
53
	 * Is the plugin is loaded?
54
	 *
55
	 * @since 5.7.0
56
	 *
57
	 * @var bool
58
	 */
59
	private $loaded = false;
60
61
	private $controller;
62
63
	// version
64
	const VERSION                   = '5.6.0';
65
66
	// Numeric constants
67
	const MENU_ORDER                = '26';
68
69
	// page slugs
70
	const POSTS_PAGE_SLUG           = 'bulk-delete-posts';
71
	const PAGES_PAGE_SLUG           = 'bulk-delete-pages';
72
	const CRON_PAGE_SLUG            = 'bulk-delete-cron';
73
	const ADDON_PAGE_SLUG           = 'bulk-delete-addon';
74
75
	// JS constants
76
	const JS_HANDLE                 = 'bulk-delete';
77
	const JS_VARIABLE               = 'BulkWP';
78
79
	const CSS_HANDLE                = 'bulk-delete';
80
81
	// Cron hooks
82
	const CRON_HOOK_CATEGORY        = 'do-bulk-delete-cat';
83
	const CRON_HOOK_POST_STATUS     = 'do-bulk-delete-post-status';
84
	const CRON_HOOK_TAG             = 'do-bulk-delete-tag';
85
	const CRON_HOOK_TAXONOMY        = 'do-bulk-delete-taxonomy';
86
	const CRON_HOOK_POST_TYPE       = 'do-bulk-delete-post-type';
87
	const CRON_HOOK_CUSTOM_FIELD    = 'do-bulk-delete-custom-field';
88
	const CRON_HOOK_TITLE           = 'do-bulk-delete-by-title';
89
	const CRON_HOOK_DUPLICATE_TITLE = 'do-bulk-delete-by-duplicate-title';
90
	const CRON_HOOK_POST_BY_ROLE    = 'do-bulk-delete-posts-by-role';
91
92
	const CRON_HOOK_PAGES_STATUS    = 'do-bulk-delete-pages-by-status';
93
94
	// meta boxes for delete posts
95
	const BOX_POST_STATUS           = 'bd_by_post_status';
96
	const BOX_CATEGORY              = 'bd_by_category';
97
	const BOX_TAG                   = 'bd_by_tag';
98
	const BOX_TAX                   = 'bd_by_tax';
99
	const BOX_POST_TYPE             = 'bd_by_post_type';
100
	const BOX_URL                   = 'bd_by_url';
101
	const BOX_POST_REVISION         = 'bd_by_post_revision';
102
	const BOX_CUSTOM_FIELD          = 'bd_by_custom_field';
103
	const BOX_TITLE                 = 'bd_by_title';
104
	const BOX_DUPLICATE_TITLE       = 'bd_by_duplicate_title';
105
	const BOX_POST_FROM_TRASH       = 'bd_posts_from_trash';
106
	const BOX_POST_BY_ROLE          = 'bd_post_by_user_role';
107
108
	// meta boxes for delete pages
109
	const BOX_PAGE_STATUS           = 'bd_by_page_status';
110
	const BOX_PAGE_FROM_TRASH       = 'bd_pages_from_trash';
111
112
	// Settings constants
113
	const SETTING_OPTION_GROUP      = 'bd_settings';
114
	const SETTING_OPTION_NAME       = 'bd_licenses';
115
	const SETTING_SECTION_ID        = 'bd_license_section';
116
117
	// Transient keys
118
	const LICENSE_CACHE_KEY_PREFIX  = 'bd-license_';
119
120
	// path variables
121
	// Ideally these should be constants, but because of PHP's limitations, these are static variables
122
	public static $PLUGIN_DIR;
123
	public static $PLUGIN_URL;
124
	public static $PLUGIN_FILE;
125
126
	// Instance variables
127
	public $translations;
128
	public $posts_page;
129
	public $pages_page;
130
	public $cron_page;
131
	public $addon_page;
132
	public $settings_page;
133
	public $meta_page;
134
	public $misc_page;
135
	public $display_activate_license_form = false;
136
137
	// Deprecated.
138
	// Will be removed in v6.0
139
	const CRON_HOOK_USER_ROLE = 'do-bulk-delete-users-by-role';
140
	public $users_page;
141
142
	/**
143
	 * Main Bulk_Delete Instance.
144
	 *
145
	 * Insures that only one instance of Bulk_Delete exists in memory at any one
146
	 * time. Also prevents needing to define globals all over the place.
147
	 *
148
	 * @since 5.0
149
	 * @static
150
	 * @staticvar array $instance
151
	 *
152
	 * @see BULK_DELETE()
153
	 *
154
	 * @uses Bulk_Delete::setup_paths() Setup the plugin paths
155
	 * @uses Bulk_Delete::includes() Include the required files
156
	 * @uses Bulk_Delete::load_textdomain() Load text domain for translation
157
	 * @uses Bulk_Delete::setup_actions() Setup the hooks and actions
158
	 *
159
	 * @return Bulk_Delete The one true instance of Bulk_Delete
160
	 */
161 5
	public static function get_instance() {
162 5
		if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Bulk_Delete ) ) {
163 1
			self::$instance = new Bulk_Delete();
164
165 1
			self::$instance->setup_paths();
166 1
			self::$instance->includes();
167
		}
168
169 5
		return self::$instance;
170
	}
171
172
	/**
173
	 * Load the plugin if it is not loaded.
174
	 *
175
	 * This function will be invoked in the `plugins_loaded` hook.
176
	 */
177 1
	public function load() {
178 1
		if ( $this->loaded ) {
179
			return;
180
		}
181
182 1
		add_action( 'init', array( $this, 'on_init' ) );
183
184 1
		$this->setup_actions();
185
186 1
		$this->loaded = true;
187
188
		/**
189
		 * Bulk Delete plugin loaded.
190
		 *
191
		 * @since 5.7.0
192
		 */
193 1
		do_action( 'bd_loaded' );
194 1
	}
195
196
	/**
197
	 * Throw error on object clone.
198
	 *
199
	 * The whole idea of the singleton design pattern is that there is a single
200
	 * object therefore, we don't want the object to be cloned.
201
	 *
202
	 * @since  5.0
203
	 * @access protected
204
	 *
205
	 * @return void
206
	 */
207 1
	public function __clone() {
208
		// Cloning instances of the class is forbidden
209 1
		_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'bulk-delete' ), '5.0' );
210 1
	}
211
212
	/**
213
	 * Disable unserializing of the class.
214
	 *
215
	 * @since  5.0
216
	 * @access protected
217
	 *
218
	 * @return void
219
	 */
220 1
	public function __wakeup() {
221
		// Unserializing instances of the class is forbidden
222 1
		_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'bulk-delete' ), '5.0' );
223 1
	}
224
225
	/**
226
	 * Setup plugin constants.
227
	 *
228
	 * @access private
229
	 *
230
	 * @since  5.0
231
	 *
232
	 * @return void
233
	 */
234 1
	private function setup_paths() {
235
		// Plugin Folder Path
236 1
		self::$PLUGIN_DIR = plugin_dir_path( __FILE__ );
237
238
		// Plugin Folder URL
239 1
		self::$PLUGIN_URL = plugin_dir_url( __FILE__ );
240
241
		// Plugin Root File
242 1
		self::$PLUGIN_FILE = __FILE__;
243 1
	}
244
245
	/**
246
	 * Include required files.
247
	 *
248
	 * @access private
249
	 *
250
	 * @since  5.0
251
	 *
252
	 * @return void
253
	 */
254 1
	private function includes() {
255 1
		require_once self::$PLUGIN_DIR . '/include/base/class-bd-meta-box-module.php';
256 1
		require_once self::$PLUGIN_DIR . '/include/base/users/class-bd-user-meta-box-module.php';
257 1
		require_once self::$PLUGIN_DIR . '/include/base/class-bd-base-page.php';
258 1
		require_once self::$PLUGIN_DIR . '/include/base/class-bd-page.php';
259
260 1
		require_once self::$PLUGIN_DIR . '/include/controller/class-bd-controller.php';
261
262 1
		require_once self::$PLUGIN_DIR . '/include/ui/form.php';
263
264
		//require_once self::$PLUGIN_DIR . '/include/posts/class-bulk-delete-posts.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
265 1
		require_once self::$PLUGIN_DIR . '/include/posts/class-bd-posts-page.php';
266 1
		require_once self::$PLUGIN_DIR . '/include/pages/class-bulk-delete-pages.php';
267
268 1
		require_once self::$PLUGIN_DIR . '/include/users/class-bd-users-page.php';
269 1
		require_once self::$PLUGIN_DIR . '/include/users/modules/class-bulk-delete-users-by-user-role.php';
270 1
		require_once self::$PLUGIN_DIR . '/include/users/modules/class-bulk-delete-users-by-user-meta.php';
271
272 1
		require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-meta.php';
273 1
		require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-post-meta.php';
274 1
		require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-comment-meta.php';
275 1
		require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-user-meta.php';
276
277 1
		require_once self::$PLUGIN_DIR . '/include/misc/class-bulk-delete-misc.php';
278 1
		require_once self::$PLUGIN_DIR . '/include/misc/class-bulk-delete-jetpack-contact-form-messages.php';
279
280 1
		require_once self::$PLUGIN_DIR . '/include/settings/class-bd-settings-page.php';
281 1
		require_once self::$PLUGIN_DIR . '/include/settings/setting-helpers.php';
282 1
		require_once self::$PLUGIN_DIR . '/include/settings/class-bd-settings.php';
283
284 1
		require_once self::$PLUGIN_DIR . '/include/system-info/class-bd-system-info-page.php';
285
286 1
		require_once self::$PLUGIN_DIR . '/include/util/class-bd-util.php';
287 1
		require_once self::$PLUGIN_DIR . '/include/util/query.php';
288
289 1
		require_once self::$PLUGIN_DIR . '/include/compatibility/simple-login-log.php';
290 1
		require_once self::$PLUGIN_DIR . '/include/compatibility/the-event-calendar.php';
291 1
		require_once self::$PLUGIN_DIR . '/include/compatibility/woocommerce.php';
292 1
		require_once self::$PLUGIN_DIR . '/include/compatibility/advanced-custom-fields-pro.php';
293
294 1
		require_once self::$PLUGIN_DIR . '/include/deprecated/class-bulk-delete-users.php';
295 1
		require_once self::$PLUGIN_DIR . '/include/deprecated/deprecated.php';
296
297 1
		require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-addon.php';
298 1
		require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-base-addon.php';
299 1
		require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-scheduler-addon.php';
300
301 1
		require_once self::$PLUGIN_DIR . '/include/addons/addon-list.php';
302 1
		require_once self::$PLUGIN_DIR . '/include/addons/posts.php';
303 1
		require_once self::$PLUGIN_DIR . '/include/addons/pages.php';
304 1
		require_once self::$PLUGIN_DIR . '/include/addons/util.php';
305
306 1
		require_once self::$PLUGIN_DIR . '/include/license/class-bd-license.php';
307 1
		require_once self::$PLUGIN_DIR . '/include/license/class-bd-license-handler.php';
308 1
		require_once self::$PLUGIN_DIR . '/include/license/class-bd-edd-api-wrapper.php';
309
310 1
		require_once self::$PLUGIN_DIR . '/include/ui/admin-ui.php';
311 1
		require_once self::$PLUGIN_DIR . '/include/ui/class-bulk-delete-help-screen.php';
312 1
	}
313
314
	/**
315
	 * Triggered when the `init` hook is fired.
316
	 *
317
	 * @since 5.7.0
318
	 */
319 1
	public function on_init() {
320 1
		$this->load_textdomain();
321 1
	}
322
323
	/**
324
	 * Loads the plugin language files.
325
	 *
326
	 * @since  5.0
327
	 */
328 1
	private function load_textdomain() {
329
		// Load localization domain
330 1
		$this->translations = dirname( plugin_basename( self::$PLUGIN_FILE ) ) . '/languages/';
331 1
		load_plugin_textdomain( 'bulk-delete', false, $this->translations );
332 1
	}
333
334
	/**
335
	 * Loads the plugin's actions and hooks.
336
	 *
337
	 * @access private
338
	 *
339
	 * @since  5.0
340
	 *
341
	 * @return void
342
	 */
343 1
	private function setup_actions() {
344 1
		$this->controller = new BD_Controller();
345
346 1
		add_action( 'admin_menu', array( $this, 'add_menu' ) );
347
348 1
		add_filter( 'bd_help_tooltip', 'bd_generate_help_tooltip', 10, 2 );
349
350 1
		if ( defined( 'BD_DEBUG' ) && BD_DEBUG ) {
351
			add_action( 'bd_after_query', array( $this, 'log_sql_query' ) );
352
		}
353 1
	}
354
355
	/**
356
	 * Log SQL query used by Bulk Delete.
357
	 *
358
	 * Query is logged only when `BD_DEBUG` is set.
359
	 *
360
	 * @since 5.6
361
	 *
362
	 * @param \WP_Query $wp_query WP Query object.
363
	 */
364
	public function log_sql_query( $wp_query ) {
365
		$query = $wp_query->request;
366
367
		/**
368
		 * Bulk Delete query is getting logged.
369
		 *
370
		 * @since 5.6
371
		 *
372
		 * @param string $query Bulk Delete SQL Query.
373
		 */
374
		do_action( 'bd_log_sql_query', $query );
375
376
		error_log( 'Bulk Delete Query: ' . $query );
377
	}
378
379
	/**
380
	 * Add navigation menu.
381
	 */
382
	public function add_menu() {
383
		$this->pages_page = add_submenu_page( self::POSTS_PAGE_SLUG, __( 'Bulk Delete Pages', 'bulk-delete' ), __( 'Bulk Delete Pages', 'bulk-delete' ), 'delete_pages', self::PAGES_PAGE_SLUG, array( $this, 'display_pages_page' ) );
384
385
		/**
386
		 * Runs just after adding all *delete* menu items to Bulk WP main menu.
387
		 *
388
		 * This action is primarily for adding extra *delete* menu items to the Bulk WP main menu.
389
		 *
390
		 * @since 5.3
391
		 */
392
		do_action( 'bd_after_primary_menus' );
393
394
		/**
395
		 * Runs just before adding non-action menu items to Bulk WP main menu.
396
		 *
397
		 * This action is primarily for adding extra menu items before non-action menu items to the Bulk WP main menu.
398
		 *
399
		 * @since 5.3
400
		 */
401
		do_action( 'bd_before_secondary_menus' );
402
403
		$this->cron_page  = add_submenu_page( self::POSTS_PAGE_SLUG, __( 'Bulk Delete Schedules', 'bulk-delete' ), __( 'Scheduled Jobs', 'bulk-delete' ), 'delete_posts'    , self::CRON_PAGE_SLUG , array( $this, 'display_cron_page' ) );
404
		$this->addon_page = add_submenu_page( self::POSTS_PAGE_SLUG, __( 'Addon Licenses'       , 'bulk-delete' ), __( 'Addon Licenses', 'bulk-delete' ), 'activate_plugins', self::ADDON_PAGE_SLUG, array( 'BD_License', 'display_addon_page' ) );
405
406
		/**
407
		 * Runs just after adding all menu items to Bulk WP main menu.
408
		 *
409
		 * This action is primarily for adding extra menu items to the Bulk WP main menu.
410
		 *
411
		 * @since 5.3
412
		 */
413
		do_action( 'bd_after_all_menus' );
414
415
		add_action( 'admin_print_scripts-' . $this->pages_page, array( $this, 'add_script' ) );
416
417
		// delete posts page
418
		//add_action( "load-{$this->posts_page}", array( $this, 'add_delete_posts_settings_panel' ) );
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
419
		add_action( "add_meta_boxes_{$this->posts_page}", array( $this, 'add_delete_posts_meta_boxes' ) );
420
421
		// delete pages page
422
		add_action( "load-{$this->pages_page}", array( $this, 'add_delete_pages_settings_panel' ) );
423
		add_action( "add_meta_boxes_{$this->pages_page}", array( $this, 'add_delete_pages_meta_boxes' ) );
424
	}
425
426
	/**
427
	 * Add settings Panel for delete posts page.
428
	 */
429
	public function add_delete_posts_settings_panel() {
430
		/**
431
		 * Add contextual help for admin screens.
432
		 *
433
		 * @since 5.1
434
		 */
435
		do_action( 'bd_add_contextual_help', $this->posts_page );
436
437
		/* Trigger the add_meta_boxes hooks to allow meta boxes to be added */
438
		do_action( 'add_meta_boxes_' . $this->posts_page, null );
439
440
		/* Enqueue WordPress' script for handling the meta boxes */
441
		wp_enqueue_script( 'postbox' );
442
	}
443
444
	/**
445
	 * Register meta boxes for delete posts page.
446
	 */
447
	public function add_delete_posts_meta_boxes() {
448
		add_meta_box( self::BOX_POST_STATUS   , __( 'By Post Status'       , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_status_box'    , $this->posts_page , 'advanced' );
449
		add_meta_box( self::BOX_CATEGORY      , __( 'By Category'          , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_category_box'  , $this->posts_page , 'advanced' );
450
		add_meta_box( self::BOX_TAG           , __( 'By Tag'               , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_tag_box'       , $this->posts_page , 'advanced' );
451
		add_meta_box( self::BOX_TAX           , __( 'By Custom Taxonomy'   , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_taxonomy_box'  , $this->posts_page , 'advanced' );
452
		add_meta_box( self::BOX_POST_TYPE     , __( 'By Custom Post Type'  , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_post_type_box' , $this->posts_page , 'advanced' );
453
		add_meta_box( self::BOX_URL           , __( 'By URL'               , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_url_box'       , $this->posts_page , 'advanced' );
454
		add_meta_box( self::BOX_POST_REVISION , __( 'By Post Revision'     , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_posts_by_revision_box'         , $this->posts_page , 'advanced' );
455
456
		/**
457
		 * Add meta box in delete posts page
458
		 * This hook can be used for adding additional meta boxes in delete posts page.
459
		 *
460
		 * @since 5.3
461
		 */
462
		do_action( 'bd_add_meta_box_for_posts' );
463
	}
464
465
	/**
466
	 * Setup settings panel for delete pages page.
467
	 *
468
	 * @since 5.0
469
	 */
470
	public function add_delete_pages_settings_panel() {
471
		/**
472
		 * Add contextual help for admin screens.
473
		 *
474
		 * @since 5.1
475
		 */
476
		do_action( 'bd_add_contextual_help', $this->pages_page );
477
478
		/* Trigger the add_meta_boxes hooks to allow meta boxes to be added */
479
		do_action( 'add_meta_boxes_' . $this->pages_page, null );
480
481
		/* Enqueue WordPress' script for handling the meta boxes */
482
		wp_enqueue_script( 'postbox' );
483
	}
484
485
	/**
486
	 * Register meta boxes for delete pages page.
487
	 *
488
	 * @since 5.0
489
	 */
490
	public function add_delete_pages_meta_boxes() {
491
		add_meta_box( self::BOX_PAGE_STATUS, __( 'By Page Status', 'bulk-delete' ), 'Bulk_Delete_Pages::render_delete_pages_by_status_box', $this->pages_page, 'advanced' );
492
493
		/**
494
		 * Add meta box in delete pages page
495
		 * This hook can be used for adding additional meta boxes in delete pages page.
496
		 *
497
		 * @since 5.3
498
		 */
499
		do_action( 'bd_add_meta_box_for_pages' );
500
	}
501
502
	/**
503
	 * Enqueue Scripts and Styles.
504
	 */
505
	public function add_script() {
506
		global $wp_scripts;
507
508
		/**
509
		 * Runs just before enqueuing scripts and styles in all Bulk WP admin pages.
510
		 *
511
		 * This action is primarily for registering or deregistering additional scripts or styles.
512
		 *
513
		 * @since 5.5.1
514
		 */
515
		do_action( 'bd_before_admin_enqueue_scripts' );
516
517
		wp_enqueue_script( 'jquery-ui-timepicker', plugins_url( '/assets/js/jquery-ui-timepicker-addon.min.js', __FILE__ ), array( 'jquery-ui-slider', 'jquery-ui-datepicker' ), '1.5.4', true );
518
		wp_enqueue_style( 'jquery-ui-timepicker', plugins_url( '/assets/css/jquery-ui-timepicker-addon.min.css', __FILE__ ), array(), '1.5.4' );
519
520
		wp_enqueue_script( 'select2', plugins_url( '/assets/js/select2.min.js', __FILE__ ), array( 'jquery' ), '4.0.0', true );
521
		wp_enqueue_style( 'select2', plugins_url( '/assets/css/select2.min.css', __FILE__ ), array(), '4.0.0' );
522
523
		$postfix = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) ? '' : '.min';
524
		wp_enqueue_script( self::JS_HANDLE, plugins_url( '/assets/js/bulk-delete' . $postfix . '.js', __FILE__ ), array( 'jquery-ui-timepicker', 'jquery-ui-tooltip' ), self::VERSION, true );
525
		wp_enqueue_style( self::CSS_HANDLE, plugins_url( '/assets/css/bulk-delete' . $postfix . '.css', __FILE__ ), array( 'select2' ), self::VERSION );
526
527
		$ui  = $wp_scripts->query( 'jquery-ui-core' );
528
		$url = "//ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/smoothness/jquery-ui.css";
529
		wp_enqueue_style( 'jquery-ui-smoothness', $url, false, $ui->ver );
530
531
		/**
532
		 * Filter JavaScript array.
533
		 *
534
		 * This filter can be used to extend the array that is passed to JavaScript
535
		 *
536
		 * @since 5.4
537
		 */
538
		$translation_array = apply_filters( 'bd_javascript_array', array(
539
				'msg'            => array(),
540
				'validators'     => array(),
541
				'dt_iterators'   => array(),
542
				'pre_action_msg' => array(),
543
				'error_msg'      => array(),
544
				'pro_iterators'  => array(),
545
			) );
546
		wp_localize_script( self::JS_HANDLE, self::JS_VARIABLE, $translation_array );
547
548
		/**
549
		 * Runs just after enqueuing scripts and styles in all Bulk WP admin pages.
550
		 *
551
		 * This action is primarily for registering additional scripts or styles.
552
		 *
553
		 * @since 5.5.1
554
		 */
555
		do_action( 'bd_after_admin_enqueue_scripts' );
556
	}
557
558
	/**
559
	 * Display the delete pages page.
560
	 *
561
	 * @Todo Move this function to Bulk_Delete_Pages class
562
	 *
563
	 * @since 5.0
564
	 */
565
	public function display_pages_page() {
566
?>
567
<div class="wrap">
568
    <h2><?php _e( 'Bulk Delete Pages', 'bulk-delete' );?></h2>
569
    <?php settings_errors(); ?>
570
571
    <form method = "post">
572
<?php
573
		// nonce for bulk delete
574
		wp_nonce_field( 'sm-bulk-delete-pages', 'sm-bulk-delete-pages-nonce' );
575
576
		/* Used to save closed meta boxes and their order */
577
		wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
578
		wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
579
?>
580
    <div id = "poststuff">
581
        <div id="post-body" class="metabox-holder columns-1">
582
583
            <div class="notice notice-warning">
584
                <p><strong><?php _e( 'WARNING: Pages deleted once cannot be retrieved back. Use with caution.', 'bulk-delete' ); ?></strong></p>
585
            </div>
586
587
            <div id="postbox-container-2" class="postbox-container">
588
                <?php do_meta_boxes( '', 'advanced', null ); ?>
589
            </div> <!-- #postbox-container-2 -->
590
591
        </div> <!-- #post-body -->
592
    </div><!-- #poststuff -->
593
    </form>
594
</div><!-- .wrap -->
595
596
<?php
597
		/**
598
		 * Runs just before displaying the footer text in the "Bulk Delete Pages" admin page.
599
		 *
600
		 * This action is primarily for adding extra content in the footer of "Bulk Delete Pages" admin page.
601
		 *
602
		 * @since 5.0
603
		 */
604
		do_action( 'bd_admin_footer_pages_page' );
605
	}
606
607
	/**
608
	 * Display the schedule page.
609
	 */
610
	public function display_cron_page() {
611
		if ( ! class_exists( 'WP_List_Table' ) ) {
612
			require_once ABSPATH . WPINC . '/class-wp-list-table.php';
613
		}
614
615
		if ( ! class_exists( 'Cron_List_Table' ) ) {
616
			require_once self::$PLUGIN_DIR . '/include/cron/class-cron-list-table.php';
617
		}
618
619
		// Prepare Table of elements
620
		$cron_list_table = new Cron_List_Table();
621
		$cron_list_table->prepare_items();
622
?>
623
    <div class="wrap">
624
        <h2><?php _e( 'Bulk Delete Schedules', 'bulk-delete' );?></h2>
625
        <?php settings_errors(); ?>
626
<?php
627
		// Table of elements
628
		$cron_list_table->display();
629
		bd_display_available_addon_list();
630
?>
631
    </div>
632
<?php
633
		/**
634
		 * Runs just before displaying the footer text in the "Schedules" admin page.
635
		 *
636
		 * This action is primarily for adding extra content in the footer of "Schedules" admin page.
637
		 *
638
		 * @since 5.0
639
		 */
640
		do_action( 'bd_admin_footer_cron_page' );
641
	}
642
}
643
644
/**
645
 * The main function responsible for returning the one true Bulk_Delete
646
 * Instance to functions everywhere.
647
 *
648
 * Use this function like you would a global variable, except without needing
649
 * to declare the global.
650
 *
651
 * Example: `<?php $bulk_delete = BULK_DELETE(); ?>`
652
 *
653
 * @since 5.0
654
 *
655
 * @return Bulk_Delete The one true Bulk_Delete Instance
656
 */
657
function BULK_DELETE() {
658 1
	return Bulk_Delete::get_instance();
659
}
660
661
/**
662
 * Load Bulk Delete plugin.
663
 *
664
 * @since 5.7.0
665
 */
666
function load_bulk_delete() {
667 1
	$bulk_delete = BULK_DELETE();
668
669 1
	add_action( 'plugins_loaded', array( $bulk_delete, 'load' ), 101 );
670 1
}
671
672
load_bulk_delete();
673