Completed
Push — dev/5.6 ( 64b458...c3e195 )
by Sudar
01:32
created

bulk-delete.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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.5.7
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.5.7
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
	private $controller;
53
54
	// version
55
	const VERSION                   = '5.5.7';
56
57
	// Numeric constants
58
	const MENU_ORDER                = '26';
59
60
	// page slugs
61
	const POSTS_PAGE_SLUG           = 'bulk-delete-posts';
62
	const PAGES_PAGE_SLUG           = 'bulk-delete-pages';
63
	const CRON_PAGE_SLUG            = 'bulk-delete-cron';
64
	const ADDON_PAGE_SLUG           = 'bulk-delete-addon';
65
66
	// JS constants
67
	const JS_HANDLE                 = 'bulk-delete';
68
	const JS_VARIABLE               = 'BulkWP';
69
70
	const CSS_HANDLE                = 'bulk-delete';
71
72
	// Cron hooks
73
	const CRON_HOOK_CATEGORY        = 'do-bulk-delete-cat';
74
	const CRON_HOOK_POST_STATUS     = 'do-bulk-delete-post-status';
75
	const CRON_HOOK_TAG             = 'do-bulk-delete-tag';
76
	const CRON_HOOK_TAXONOMY        = 'do-bulk-delete-taxonomy';
77
	const CRON_HOOK_POST_TYPE       = 'do-bulk-delete-post-type';
78
	const CRON_HOOK_CUSTOM_FIELD    = 'do-bulk-delete-custom-field';
79
	const CRON_HOOK_TITLE           = 'do-bulk-delete-by-title';
80
	const CRON_HOOK_DUPLICATE_TITLE = 'do-bulk-delete-by-duplicate-title';
81
	const CRON_HOOK_POST_BY_ROLE    = 'do-bulk-delete-posts-by-role';
82
83
	const CRON_HOOK_PAGES_STATUS    = 'do-bulk-delete-pages-by-status';
84
85
	// meta boxes for delete posts
86
	const BOX_POST_STATUS           = 'bd_by_post_status';
87
	const BOX_CATEGORY              = 'bd_by_category';
88
	const BOX_TAG                   = 'bd_by_tag';
89
	const BOX_TAX                   = 'bd_by_tax';
90
	const BOX_POST_TYPE             = 'bd_by_post_type';
91
	const BOX_URL                   = 'bd_by_url';
92
	const BOX_POST_REVISION         = 'bd_by_post_revision';
93
	const BOX_CUSTOM_FIELD          = 'bd_by_custom_field';
94
	const BOX_TITLE                 = 'bd_by_title';
95
	const BOX_DUPLICATE_TITLE       = 'bd_by_duplicate_title';
96
	const BOX_POST_FROM_TRASH       = 'bd_posts_from_trash';
97
	const BOX_POST_BY_ROLE          = 'bd_post_by_user_role';
98
99
	// meta boxes for delete pages
100
	const BOX_PAGE_STATUS           = 'bd_by_page_status';
101
	const BOX_PAGE_FROM_TRASH       = 'bd_pages_from_trash';
102
103
	// Settings constants
104
	const SETTING_OPTION_GROUP      = 'bd_settings';
105
	const SETTING_OPTION_NAME       = 'bd_licenses';
106
	const SETTING_SECTION_ID        = 'bd_license_section';
107
108
	// Transient keys
109
	const LICENSE_CACHE_KEY_PREFIX  = 'bd-license_';
110
111
	// path variables
112
	// Ideally these should be constants, but because of PHP's limitations, these are static variables
113
	public static $PLUGIN_DIR;
114
	public static $PLUGIN_URL;
115
	public static $PLUGIN_FILE;
116
117
	// Instance variables
118
	public $translations;
119
	public $posts_page;
120
	public $pages_page;
121
	public $cron_page;
122
	public $addon_page;
123
	public $settings_page;
124
	public $meta_page;
125
	public $misc_page;
126
	public $display_activate_license_form = false;
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $display_activate_license_form exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
127
128
	// Deprecated.
129
	// Will be removed in v6.0
130
	const CRON_HOOK_USER_ROLE = 'do-bulk-delete-users-by-role';
131
	public $users_page;
132
133
	/**
134
	 * Main Bulk_Delete Instance.
135
	 *
136
	 * Insures that only one instance of Bulk_Delete exists in memory at any one
137
	 * time. Also prevents needing to define globals all over the place.
138
	 *
139
	 * @since 5.0
140
	 * @static
141
	 * @staticvar array $instance
142
	 *
143
	 * @see BULK_DELETE()
144
	 *
145
	 * @uses Bulk_Delete::setup_paths() Setup the plugin paths
146
	 * @uses Bulk_Delete::includes() Include the required files
147
	 * @uses Bulk_Delete::load_textdomain() Load text domain for translation
148
	 * @uses Bulk_Delete::setup_actions() Setup the hooks and actions
149
	 *
150
	 * @return Bulk_Delete The one true instance of Bulk_Delete
151
	 */
152
	public static function instance() {
153
		if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Bulk_Delete ) ) {
154
			self::$instance = new Bulk_Delete;
155
			self::$instance->setup_paths();
156
			self::$instance->includes();
157
			self::$instance->load_textdomain();
158
			self::$instance->setup_actions();
159
		}
160
161
		return self::$instance;
162
	}
163
164
	/**
165
	 * Throw error on object clone.
166
	 *
167
	 * The whole idea of the singleton design pattern is that there is a single
168
	 * object therefore, we don't want the object to be cloned.
169
	 *
170
	 * @since  5.0
171
	 * @access protected
172
	 *
173
	 * @return void
174
	 */
175
	public function __clone() {
176
		// Cloning instances of the class is forbidden
177
		_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'bulk-delete' ), '5.0' );
178
	}
179
180
	/**
181
	 * Disable unserializing of the class.
182
	 *
183
	 * @since  5.0
184
	 * @access protected
185
	 *
186
	 * @return void
187
	 */
188
	public function __wakeup() {
189
		// Unserializing instances of the class is forbidden
190
		_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'bulk-delete' ), '5.0' );
191
	}
192
193
	/**
194
	 * Setup plugin constants.
195
	 *
196
	 * @access private
197
	 *
198
	 * @since  5.0
199
	 *
200
	 * @return void
201
	 */
202
	private function setup_paths() {
203
		// Plugin Folder Path
204
		self::$PLUGIN_DIR = plugin_dir_path( __FILE__ );
205
206
		// Plugin Folder URL
207
		self::$PLUGIN_URL = plugin_dir_url( __FILE__ );
208
209
		// Plugin Root File
210
		self::$PLUGIN_FILE = __FILE__;
211
	}
212
213
	/**
214
	 * Include required files.
215
	 *
216
	 * @access private
217
	 *
218
	 * @since  5.0
219
	 *
220
	 * @return void
221
	 */
222
	private function includes() {
223
		require_once self::$PLUGIN_DIR . '/include/base/class-bd-meta-box-module.php';
224
		require_once self::$PLUGIN_DIR . '/include/base/users/class-bd-user-meta-box-module.php';
225
		require_once self::$PLUGIN_DIR . '/include/base/class-bd-base-page.php';
226
		require_once self::$PLUGIN_DIR . '/include/base/class-bd-page.php';
227
228
		require_once self::$PLUGIN_DIR . '/include/controller/class-bd-controller.php';
229
230
		require_once self::$PLUGIN_DIR . '/include/ui/form.php';
231
232
		require_once self::$PLUGIN_DIR . '/include/posts/class-bulk-delete-posts.php';
233
		require_once self::$PLUGIN_DIR . '/include/pages/class-bulk-delete-pages.php';
234
235
		require_once self::$PLUGIN_DIR . '/include/users/class-bd-users-page.php';
236
		require_once self::$PLUGIN_DIR . '/include/users/modules/class-bulk-delete-users-by-user-role.php';
237
		require_once self::$PLUGIN_DIR . '/include/users/modules/class-bulk-delete-users-by-user-meta.php';
238
239
		require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-meta.php';
240
		require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-post-meta.php';
241
		require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-comment-meta.php';
242
		require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-user-meta.php';
243
244
		require_once self::$PLUGIN_DIR . '/include/misc/class-bulk-delete-misc.php';
245
		require_once self::$PLUGIN_DIR . '/include/misc/class-bulk-delete-jetpack-contact-form-messages.php';
246
247
		require_once self::$PLUGIN_DIR . '/include/settings/class-bd-settings-page.php';
248
		require_once self::$PLUGIN_DIR . '/include/settings/setting-helpers.php';
249
		require_once self::$PLUGIN_DIR . '/include/settings/class-bd-settings.php';
250
251
		require_once self::$PLUGIN_DIR . '/include/system-info/class-bd-system-info-page.php';
252
253
		require_once self::$PLUGIN_DIR . '/include/util/class-bd-util.php';
254
		require_once self::$PLUGIN_DIR . '/include/util/query.php';
255
256
		require_once self::$PLUGIN_DIR . '/include/compatibility/simple-login-log.php';
257
		require_once self::$PLUGIN_DIR . '/include/compatibility/the-event-calendar.php';
258
		require_once self::$PLUGIN_DIR . '/include/compatibility/woocommerce.php';
259
		require_once self::$PLUGIN_DIR . '/include/compatibility/advanced-custom-fields-pro.php';
260
261
		require_once self::$PLUGIN_DIR . '/include/deprecated/class-bulk-delete-users.php';
262
		require_once self::$PLUGIN_DIR . '/include/deprecated/deprecated.php';
263
264
		require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-addon.php';
265
		require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-base-addon.php';
266
		require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-scheduler-addon.php';
267
268
		require_once self::$PLUGIN_DIR . '/include/addons/addon-list.php';
269
		require_once self::$PLUGIN_DIR . '/include/addons/posts.php';
270
		require_once self::$PLUGIN_DIR . '/include/addons/pages.php';
271
		require_once self::$PLUGIN_DIR . '/include/addons/util.php';
272
273
		require_once self::$PLUGIN_DIR . '/include/license/class-bd-license.php';
274
		require_once self::$PLUGIN_DIR . '/include/license/class-bd-license-handler.php';
275
		require_once self::$PLUGIN_DIR . '/include/license/class-bd-edd-api-wrapper.php';
276
277
		require_once self::$PLUGIN_DIR . '/include/ui/admin-ui.php';
278
		require_once self::$PLUGIN_DIR . '/include/ui/class-bulk-delete-help-screen.php';
279
	}
280
281
	/**
282
	 * Loads the plugin language files.
283
	 *
284
	 * @since  5.0
285
	 */
286
	public function load_textdomain() {
287
		// Load localization domain
288
		$this->translations = dirname( plugin_basename( self::$PLUGIN_FILE ) ) . '/languages/';
289
		load_plugin_textdomain( 'bulk-delete', false, $this->translations );
290
	}
291
292
	/**
293
	 * Loads the plugin's actions and hooks.
294
	 *
295
	 * @access private
296
	 *
297
	 * @since  5.0
298
	 *
299
	 * @return void
300
	 */
301
	private function setup_actions() {
302
		$this->controller = new BD_Controller();
303
304
		add_action( 'admin_menu', array( $this, 'add_menu' ) );
305
	}
306
307
	/**
308
	 * Add navigation menu.
309
	 */
310
	public function add_menu() {
311
		add_menu_page( __( 'Bulk WP', 'bulk-delete' ), __( 'Bulk WP', 'bulk-delete' ), 'manage_options', self::POSTS_PAGE_SLUG, array( $this, 'display_posts_page' ), 'dashicons-trash', self::MENU_ORDER );
312
313
		$this->posts_page = add_submenu_page( self::POSTS_PAGE_SLUG, __( 'Bulk Delete Posts', 'bulk-delete' ), __( 'Bulk Delete Posts', 'bulk-delete' ), 'delete_posts', self::POSTS_PAGE_SLUG, array( $this, 'display_posts_page' ) );
314
		$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' ) );
315
316
		/**
317
		 * Runs just after adding all *delete* menu items to Bulk WP main menu.
318
		 *
319
		 * This action is primarily for adding extra *delete* menu items to the Bulk WP main menu.
320
		 *
321
		 * @since 5.3
322
		 */
323
		do_action( 'bd_after_primary_menus' );
324
325
		/**
326
		 * Runs just before adding non-action menu items to Bulk WP main menu.
327
		 *
328
		 * This action is primarily for adding extra menu items before non-action menu items to the Bulk WP main menu.
329
		 *
330
		 * @since 5.3
331
		 */
332
		do_action( 'bd_before_secondary_menus' );
333
334
		$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' ) );
335
		$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' ) );
336
337
		/**
338
		 * Runs just after adding all menu items to Bulk WP main menu.
339
		 *
340
		 * This action is primarily for adding extra menu items to the Bulk WP main menu.
341
		 *
342
		 * @since 5.3
343
		 */
344
		do_action( 'bd_after_all_menus' );
345
346
		// enqueue JavaScript
347
		add_action( 'admin_print_scripts-' . $this->posts_page, array( $this, 'add_script' ) );
348
		add_action( 'admin_print_scripts-' . $this->pages_page, array( $this, 'add_script' ) );
349
350
		// delete posts page
351
		add_action( "load-{$this->posts_page}", array( $this, 'add_delete_posts_settings_panel' ) );
352
		add_action( "add_meta_boxes_{$this->posts_page}", array( $this, 'add_delete_posts_meta_boxes' ) );
353
354
		// delete pages page
355
		add_action( "load-{$this->pages_page}", array( $this, 'add_delete_pages_settings_panel' ) );
356
		add_action( "add_meta_boxes_{$this->pages_page}", array( $this, 'add_delete_pages_meta_boxes' ) );
357
	}
358
359
	/**
360
	 * Add settings Panel for delete posts page.
361
	 */
362
	public function add_delete_posts_settings_panel() {
363
		/**
364
		 * Add contextual help for admin screens.
365
		 *
366
		 * @since 5.1
367
		 */
368
		do_action( 'bd_add_contextual_help', $this->posts_page );
369
370
		/* Trigger the add_meta_boxes hooks to allow meta boxes to be added */
371
		do_action( 'add_meta_boxes_' . $this->posts_page, null );
372
373
		/* Enqueue WordPress' script for handling the meta boxes */
374
		wp_enqueue_script( 'postbox' );
375
	}
376
377
	/**
378
	 * Register meta boxes for delete posts page.
379
	 */
380
	public function add_delete_posts_meta_boxes() {
381
		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' );
382
		add_meta_box( self::BOX_CATEGORY      , __( 'By Category'          , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_category_box'  , $this->posts_page , 'advanced' );
383
		add_meta_box( self::BOX_TAG           , __( 'By Tag'               , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_tag_box'       , $this->posts_page , 'advanced' );
384
		add_meta_box( self::BOX_TAX           , __( 'By Custom Taxonomy'   , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_taxonomy_box'  , $this->posts_page , 'advanced' );
385
		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' );
386
		add_meta_box( self::BOX_URL           , __( 'By URL'               , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_url_box'       , $this->posts_page , 'advanced' );
387
		add_meta_box( self::BOX_POST_REVISION , __( 'By Post Revision'     , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_posts_by_revision_box'         , $this->posts_page , 'advanced' );
388
389
		/**
390
		 * Add meta box in delete posts page
391
		 * This hook can be used for adding additional meta boxes in delete posts page.
392
		 *
393
		 * @since 5.3
394
		 */
395
		do_action( 'bd_add_meta_box_for_posts' );
396
	}
397
398
	/**
399
	 * Setup settings panel for delete pages page.
400
	 *
401
	 * @since 5.0
402
	 */
403
	public function add_delete_pages_settings_panel() {
404
		/**
405
		 * Add contextual help for admin screens.
406
		 *
407
		 * @since 5.1
408
		 */
409
		do_action( 'bd_add_contextual_help', $this->pages_page );
410
411
		/* Trigger the add_meta_boxes hooks to allow meta boxes to be added */
412
		do_action( 'add_meta_boxes_' . $this->pages_page, null );
413
414
		/* Enqueue WordPress' script for handling the meta boxes */
415
		wp_enqueue_script( 'postbox' );
416
	}
417
418
	/**
419
	 * Register meta boxes for delete pages page.
420
	 *
421
	 * @since 5.0
422
	 */
423
	public function add_delete_pages_meta_boxes() {
424
		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' );
425
426
		/**
427
		 * Add meta box in delete pages page
428
		 * This hook can be used for adding additional meta boxes in delete pages page.
429
		 *
430
		 * @since 5.3
431
		 */
432
		do_action( 'bd_add_meta_box_for_pages' );
433
	}
434
435
	/**
436
	 * Enqueue Scripts and Styles.
437
	 */
438
	public function add_script() {
439
		global $wp_scripts;
440
441
		/**
442
		 * Runs just before enqueuing scripts and styles in all Bulk WP admin pages.
443
		 *
444
		 * This action is primarily for registering or deregistering additional scripts or styles.
445
		 *
446
		 * @since 5.5.1
447
		 */
448
		do_action( 'bd_before_admin_enqueue_scripts' );
449
450
		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 );
451
		wp_enqueue_style( 'jquery-ui-timepicker', plugins_url( '/assets/css/jquery-ui-timepicker-addon.min.css', __FILE__ ), array(), '1.5.4' );
452
453
		wp_enqueue_script( 'select2', plugins_url( '/assets/js/select2.min.js', __FILE__ ), array( 'jquery' ), '4.0.0', true );
454
		wp_enqueue_style( 'select2', plugins_url( '/assets/css/select2.min.css', __FILE__ ), array(), '4.0.0' );
455
456
		$postfix = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) ? '' : '.min';
457
		wp_enqueue_script( self::JS_HANDLE, plugins_url( '/assets/js/bulk-delete' . $postfix . '.js', __FILE__ ), array( 'jquery-ui-timepicker' ), self::VERSION, true );
458
		wp_enqueue_style( self::CSS_HANDLE, plugins_url( '/assets/css/bulk-delete' . $postfix . '.css', __FILE__ ), array( 'select2' ), self::VERSION );
459
460
		$ui  = $wp_scripts->query( 'jquery-ui-core' );
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $ui. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
461
		$url = "//ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/smoothness/jquery-ui.css";
462
		wp_enqueue_style( 'jquery-ui-smoothness', $url, false, $ui->ver );
463
464
		/**
465
		 * Filter JavaScript array.
466
		 *
467
		 * This filter can be used to extend the array that is passed to JavaScript
468
		 *
469
		 * @since 5.4
470
		 */
471
		$translation_array = apply_filters( 'bd_javascript_array', array(
472
				'msg'            => array(),
473
				'validators'     => array(),
474
				'dt_iterators'   => array(),
475
				'pre_action_msg' => array(),
476
				'error_msg'      => array(),
477
				'pro_iterators'  => array(),
478
			) );
479
		wp_localize_script( self::JS_HANDLE, self::JS_VARIABLE, $translation_array );
480
481
		/**
482
		 * Runs just after enqueuing scripts and styles in all Bulk WP admin pages.
483
		 *
484
		 * This action is primarily for registering additional scripts or styles.
485
		 *
486
		 * @since 5.5.1
487
		 */
488
		do_action( 'bd_after_admin_enqueue_scripts' );
489
	}
490
491
	/**
492
	 * Show the delete posts page.
493
	 *
494
	 * @Todo Move this function to Bulk_Delete_Posts class
495
	 */
496
	public function display_posts_page() {
497
?>
498
<div class="wrap">
499
    <h2><?php _e( 'Bulk Delete Posts', 'bulk-delete' );?></h2>
500
    <?php settings_errors(); ?>
501
502
    <form method = "post">
503
<?php
504
		// nonce for bulk delete
505
		wp_nonce_field( 'sm-bulk-delete-posts', 'sm-bulk-delete-posts-nonce' );
506
507
		/* Used to save closed meta boxes and their order */
508
		wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
509
		wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
510
?>
511
    <div id = "poststuff">
512
        <div id="post-body" class="metabox-holder columns-1">
513
514
            <div class="notice notice-warning">
515
                <p><strong><?php _e( 'WARNING: Posts deleted once cannot be retrieved back. Use with caution.', 'bulk-delete' ); ?></strong></p>
516
            </div>
517
518
            <div id="postbox-container-2" class="postbox-container">
519
                <?php do_meta_boxes( '', 'advanced', null ); ?>
520
            </div> <!-- #postbox-container-2 -->
521
522
        </div> <!-- #post-body -->
523
    </div><!-- #poststuff -->
524
    </form>
525
</div><!-- .wrap -->
526
527
<?php
528
		/**
529
		 * Runs just before displaying the footer text in the "Bulk Delete Posts" admin page.
530
		 *
531
		 * This action is primarily for adding extra content in the footer of "Bulk Delete Posts" admin page.
532
		 *
533
		 * @since 5.0
534
		 */
535
		do_action( 'bd_admin_footer_posts_page' );
536
	}
537
538
	/**
539
	 * Display the delete pages page.
540
	 *
541
	 * @Todo Move this function to Bulk_Delete_Pages class
542
	 *
543
	 * @since 5.0
544
	 */
545
	public function display_pages_page() {
546
?>
547
<div class="wrap">
548
    <h2><?php _e( 'Bulk Delete Pages', 'bulk-delete' );?></h2>
549
    <?php settings_errors(); ?>
550
551
    <form method = "post">
552
<?php
553
		// nonce for bulk delete
554
		wp_nonce_field( 'sm-bulk-delete-pages', 'sm-bulk-delete-pages-nonce' );
555
556
		/* Used to save closed meta boxes and their order */
557
		wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
558
		wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
559
?>
560
    <div id = "poststuff">
561
        <div id="post-body" class="metabox-holder columns-1">
562
563
            <div class="notice notice-warning">
564
                <p><strong><?php _e( 'WARNING: Pages deleted once cannot be retrieved back. Use with caution.', 'bulk-delete' ); ?></strong></p>
565
            </div>
566
567
            <div id="postbox-container-2" class="postbox-container">
568
                <?php do_meta_boxes( '', 'advanced', null ); ?>
569
            </div> <!-- #postbox-container-2 -->
570
571
        </div> <!-- #post-body -->
572
    </div><!-- #poststuff -->
573
    </form>
574
</div><!-- .wrap -->
575
576
<?php
577
		/**
578
		 * Runs just before displaying the footer text in the "Bulk Delete Pages" admin page.
579
		 *
580
		 * This action is primarily for adding extra content in the footer of "Bulk Delete Pages" admin page.
581
		 *
582
		 * @since 5.0
583
		 */
584
		do_action( 'bd_admin_footer_pages_page' );
585
	}
586
587
	/**
588
	 * Display the schedule page.
589
	 */
590
	public function display_cron_page() {
591
		if ( ! class_exists( 'WP_List_Table' ) ) {
592
			require_once ABSPATH . WPINC . '/class-wp-list-table.php';
593
		}
594
595
		if ( ! class_exists( 'Cron_List_Table' ) ) {
596
			require_once self::$PLUGIN_DIR . '/include/cron/class-cron-list-table.php';
597
		}
598
599
		// Prepare Table of elements
600
		$cron_list_table = new Cron_List_Table();
601
		$cron_list_table->prepare_items();
602
?>
603
    <div class="wrap">
604
        <h2><?php _e( 'Bulk Delete Schedules', 'bulk-delete' );?></h2>
605
        <?php settings_errors(); ?>
606
<?php
607
		// Table of elements
608
		$cron_list_table->display();
609
		bd_display_available_addon_list();
610
?>
611
    </div>
612
<?php
613
		/**
614
		 * Runs just before displaying the footer text in the "Schedules" admin page.
615
		 *
616
		 * This action is primarily for adding extra content in the footer of "Schedules" admin page.
617
		 *
618
		 * @since 5.0
619
		 */
620
		do_action( 'bd_admin_footer_cron_page' );
621
	}
622
}
623
624
/**
625
 * The main function responsible for returning the one true Bulk_Delete
626
 * Instance to functions everywhere.
627
 *
628
 * Use this function like you would a global variable, except without needing
629
 * to declare the global.
630
 *
631
 * Example: `<?php $bulk_delete = BULK_DELETE(); ?>`
632
 *
633
 * @since 5.0
634
 *
635
 * @return Bulk_Delete The one true Bulk_Delete Instance
636
 */
637
function BULK_DELETE() {
638
	return Bulk_Delete::instance();
639
}
640
641
// Get BULK_DELETE Running
642
BULK_DELETE();
643