Completed
Push — dev/5.5.4 ( eb818b...9021cc )
by Sudar
02:15
created

bulk-delete.php (1 issue)

Labels
Severity

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.4-dev
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.3
18
 * @author     Sudar
19
 * @package    BulkDelete
20
 */
21
22
/**
23
 * Copyright 2009  Sudar Muthu  (email : [email protected])
24
 * This program is free software; you can redistribute it and/or modify
25
 * it under the terms of the GNU General Public License, version 2, as
26
 * published by the Free Software Foundation.
27
 * This program is distributed in the hope that it will be useful,
28
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30
 * GNU General Public License for more details.
31
 * You should have received a copy of the GNU General Public License
32
 * along with this program; if not, write to the Free Software
33
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
34
 */
35
36
defined( 'ABSPATH' ) || exit; // Exit if accessed directly
37
38
/**
39
 * Main Bulk_Delete class
40
 *
41
 * Singleton @since 5.0
42
 */
43
final class Bulk_Delete {
44
45
	/**
46
	 * @var Bulk_Delete The one true Bulk_Delete
47
	 * @since 5.0
48
	 */
49
	private static $instance;
50
51
	// version
52
	const VERSION                   = '5.5.4-dev';
53
54
	// Numeric constants
55
	const MENU_ORDER                = '26.9966';
56
57
	// page slugs
58
	const POSTS_PAGE_SLUG           = 'bulk-delete-posts';
59
	const PAGES_PAGE_SLUG           = 'bulk-delete-pages';
60
	const CRON_PAGE_SLUG            = 'bulk-delete-cron';
61
	const ADDON_PAGE_SLUG           = 'bulk-delete-addon';
62
	const INFO_PAGE_SLUG            = 'bulk-delete-info';
63
64
	// JS constants
65
	const JS_HANDLE                 = 'bulk-delete';
66
	const JS_VARIABLE               = 'BulkWP';
67
68
	const CSS_HANDLE                = 'bulk-delete';
69
70
	// Cron hooks
71
	const CRON_HOOK_CATEGORY        = 'do-bulk-delete-cat';
72
	const CRON_HOOK_POST_STATUS     = 'do-bulk-delete-post-status';
73
	const CRON_HOOK_TAG             = 'do-bulk-delete-tag';
74
	const CRON_HOOK_TAXONOMY        = 'do-bulk-delete-taxonomy';
75
	const CRON_HOOK_POST_TYPE       = 'do-bulk-delete-post-type';
76
	const CRON_HOOK_CUSTOM_FIELD    = 'do-bulk-delete-custom-field';
77
	const CRON_HOOK_TITLE           = 'do-bulk-delete-by-title';
78
	const CRON_HOOK_DUPLICATE_TITLE = 'do-bulk-delete-by-duplicate-title';
79
	const CRON_HOOK_POST_BY_ROLE    = 'do-bulk-delete-posts-by-role';
80
81
	const CRON_HOOK_PAGES_STATUS    = 'do-bulk-delete-pages-by-status';
82
83
	// meta boxes for delete posts
84
	const BOX_POST_STATUS           = 'bd_by_post_status';
85
	const BOX_CATEGORY              = 'bd_by_category';
86
	const BOX_TAG                   = 'bd_by_tag';
87
	const BOX_TAX                   = 'bd_by_tax';
88
	const BOX_POST_TYPE             = 'bd_by_post_type';
89
	const BOX_URL                   = 'bd_by_url';
90
	const BOX_POST_REVISION         = 'bd_by_post_revision';
91
	const BOX_CUSTOM_FIELD          = 'bd_by_custom_field';
92
	const BOX_TITLE                 = 'bd_by_title';
93
	const BOX_DUPLICATE_TITLE       = 'bd_by_duplicate_title';
94
	const BOX_POST_FROM_TRASH       = 'bd_posts_from_trash';
95
	const BOX_POST_BY_ROLE          = 'bd_post_by_user_role';
96
97
	// meta boxes for delete pages
98
	const BOX_PAGE_STATUS           = 'bd_by_page_status';
99
	const BOX_PAGE_FROM_TRASH       = 'bd_pages_from_trash';
100
101
	// Settings constants
102
	const SETTING_OPTION_GROUP      = 'bd_settings';
103
	const SETTING_OPTION_NAME       = 'bd_licenses';
104
	const SETTING_SECTION_ID        = 'bd_license_section';
105
106
	// Transient keys
107
	const LICENSE_CACHE_KEY_PREFIX  = 'bd-license_';
108
109
	// path variables
110
	// Ideally these should be constants, but because of PHP's limitations, these are static variables
111
	public static $PLUGIN_DIR;
112
	public static $PLUGIN_URL;
113
	public static $PLUGIN_FILE;
114
115
	// Instance variables
116
	public $translations;
117
	public $posts_page;
118
	public $pages_page;
119
	public $cron_page;
120
	public $addon_page;
121
	public $info_page;
122
	public $settings_page;
123
	public $meta_page;
124
	public $misc_page;
125
	public $display_activate_license_form = false;
126
127
	// Deprecated.
128
	// Will be removed in v6.0
129
	const CRON_HOOK_USER_ROLE = 'do-bulk-delete-users-by-role';
130
	public $users_page;
131
132
	/**
133
	 * Main Bulk_Delete Instance
134
	 *
135
	 * Insures that only one instance of Bulk_Delete exists in memory at any one
136
	 * time. Also prevents needing to define globals all over the place.
137
	 *
138
	 * @since 5.0
139
	 * @static
140
	 * @staticvar array $instance
141
	 * @see BULK_DELETE()
142
	 * @uses Bulk_Delete::setup_paths() Setup the plugin paths
143
	 * @uses Bulk_Delete::includes() Include the required files
144
	 * @uses Bulk_Delete::load_textdomain() Load text domain for translation
145
	 * @uses Bulk_Delete::setup_actions() Setup the hooks and actions
146
	 * @return Bulk_Delete The one true instance of Bulk_Delete
147
	 */
148
	public static function instance() {
149
		if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Bulk_Delete ) ) {
150
			self::$instance = new Bulk_Delete;
151
			self::$instance->setup_paths();
152
			self::$instance->includes();
153
			self::$instance->load_textdomain();
154
			self::$instance->setup_actions();
155
		}
156
		return self::$instance;
157
	}
158
159
	/**
160
	 * Throw error on object clone
161
	 *
162
	 * The whole idea of the singleton design pattern is that there is a single
163
	 * object therefore, we don't want the object to be cloned.
164
	 *
165
	 * @since  5.0
166
	 * @access protected
167
	 * @return void
168
	 */
169
	public function __clone() {
170
		// Cloning instances of the class is forbidden
171
		_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'bulk-delete' ), '5.0' );
172
	}
173
174
	/**
175
	 * Disable unserializing of the class
176
	 *
177
	 * @since  5.0
178
	 * @access protected
179
	 * @return void
180
	 */
181
	public function __wakeup() {
182
		// Unserializing instances of the class is forbidden
183
		_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'bulk-delete' ), '5.0' );
184
	}
185
186
	/**
187
	 * Setup plugin constants
188
	 *
189
	 * @access private
190
	 * @since  5.0
191
	 * @return void
192
	 */
193
	private function setup_paths() {
194
		// Plugin Folder Path
195
		self::$PLUGIN_DIR = plugin_dir_path( __FILE__ );
196
197
		// Plugin Folder URL
198
		self::$PLUGIN_URL = plugin_dir_url( __FILE__ );
199
200
		// Plugin Root File
201
		self::$PLUGIN_FILE = __FILE__;
202
	}
203
204
	/**
205
	 * Include required files
206
	 *
207
	 * @access private
208
	 * @since  5.0
209
	 * @return void
210
	 */
211
	private function includes() {
212
		require_once self::$PLUGIN_DIR . '/include/base/class-bd-meta-box-module.php';
213
		require_once self::$PLUGIN_DIR . '/include/base/users/class-bd-user-meta-box-module.php';
214
		require_once self::$PLUGIN_DIR . '/include/base/class-bd-page.php';
215
216
		require_once self::$PLUGIN_DIR . '/include/controller/controller.php';
217
218
		require_once self::$PLUGIN_DIR . '/include/ui/form.php';
219
220
		require_once self::$PLUGIN_DIR . '/include/posts/class-bulk-delete-posts.php';
221
		require_once self::$PLUGIN_DIR . '/include/pages/class-bulk-delete-pages.php';
222
223
		require_once self::$PLUGIN_DIR . '/include/users/class-bd-users-page.php';
224
		require_once self::$PLUGIN_DIR . '/include/users/modules/class-bulk-delete-users-by-user-role.php';
225
		require_once self::$PLUGIN_DIR . '/include/users/modules/class-bulk-delete-users-by-user-meta.php';
226
227
		require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-meta.php';
228
		require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-post-meta.php';
229
		require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-comment-meta.php';
230
		require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-user-meta.php';
231
232
		require_once self::$PLUGIN_DIR . '/include/misc/class-bulk-delete-misc.php';
233
		require_once self::$PLUGIN_DIR . '/include/misc/class-bulk-delete-jetpack-contact-form-messages.php';
234
235
		require_once self::$PLUGIN_DIR . '/include/settings/class-bd-settings-page.php';
236
		require_once self::$PLUGIN_DIR . '/include/settings/setting-helpers.php';
237
		require_once self::$PLUGIN_DIR . '/include/settings/class-bd-settings.php';
238
239
		require_once self::$PLUGIN_DIR . '/include/system-info/class-bulk-delete-system-info.php';
240
241
		require_once self::$PLUGIN_DIR . '/include/util/class-bd-util.php';
242
		require_once self::$PLUGIN_DIR . '/include/util/query.php';
243
244
		require_once self::$PLUGIN_DIR . '/include/compatibility/simple-login-log.php';
245
		require_once self::$PLUGIN_DIR . '/include/compatibility/the-event-calendar.php';
246
		require_once self::$PLUGIN_DIR . '/include/compatibility/woocommerce.php';
247
		require_once self::$PLUGIN_DIR . '/include/compatibility/advanced-custom-fields-pro.php';
248
249
		require_once self::$PLUGIN_DIR . '/include/deprecated/class-bulk-delete-users.php';
250
		require_once self::$PLUGIN_DIR . '/include/deprecated/deprecated.php';
251
252
		require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-addon.php';
253
		require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-base-addon.php';
254
		require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-scheduler-addon.php';
255
256
		require_once self::$PLUGIN_DIR . '/include/addons/addon-list.php';
257
		require_once self::$PLUGIN_DIR . '/include/addons/posts.php';
258
		require_once self::$PLUGIN_DIR . '/include/addons/pages.php';
259
		require_once self::$PLUGIN_DIR . '/include/addons/util.php';
260
261
		require_once self::$PLUGIN_DIR . '/include/license/class-bd-license.php';
262
		require_once self::$PLUGIN_DIR . '/include/license/class-bd-license-handler.php';
263
		require_once self::$PLUGIN_DIR . '/include/license/class-bd-edd-api-wrapper.php';
264
265
		require_once self::$PLUGIN_DIR . '/include/ui/admin-ui.php';
266
		require_once self::$PLUGIN_DIR . '/include/ui/class-bulk-delete-help-screen.php';
267
	}
268
269
	/**
270
	 * Loads the plugin language files
271
	 *
272
	 * @since  5.0
273
	 */
274
	public function load_textdomain() {
275
		// Load localization domain
276
		$this->translations = dirname( plugin_basename( self::$PLUGIN_FILE ) ) . '/languages/';
277
		load_plugin_textdomain( 'bulk-delete', false, $this->translations );
278
	}
279
280
	/**
281
	 * Loads the plugin's actions and hooks
282
	 *
283
	 * @access private
284
	 * @since  5.0
285
	 * @return void
286
	 */
287
	private function setup_actions() {
288
		$this->controller = new BD_Controller();
0 ignored issues
show
The property controller does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
289
290
		add_action( 'admin_menu', array( $this, 'add_menu' ) );
291
		add_action( 'bd_pre_bulk_action', array( $this, 'increase_timeout' ), 9 );
292
		add_action( 'bd_before_scheduler', array( $this, 'increase_timeout' ), 9 );
293
	}
294
295
	/**
296
	 * Add navigation menu
297
	 */
298
	public function add_menu() {
299
		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 );
300
301
		$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' ) );
302
		$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' ) );
303
304
		/**
305
		 * Runs just after adding all *delete* menu items to Bulk WP main menu
306
		 *
307
		 * This action is primarily for adding extra *delete* menu items to the Bulk WP main menu.
308
		 *
309
		 * @since 5.3
310
		 */
311
		do_action( 'bd_after_primary_menus' );
312
313
		/**
314
		 * Runs just before adding non-action menu items to Bulk WP main menu
315
		 *
316
		 * This action is primarily for adding extra menu items before non-action menu items to the Bulk WP main menu.
317
		 *
318
		 * @since 5.3
319
		 */
320
		do_action( 'bd_before_secondary_menus' );
321
322
		$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' ) );
323
		$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' ) );
324
		$this->info_page  = add_submenu_page( self::POSTS_PAGE_SLUG, __( 'Bulk Delete System Info', 'bulk-delete' ), __( 'System Info'   , 'bulk-delete' ), 'manage_options'  , self::INFO_PAGE_SLUG , array( 'Bulk_Delete_System_Info', 'display_system_info' ) );
325
326
		/**
327
		 * Runs just after adding all menu items to Bulk WP main menu
328
		 *
329
		 * This action is primarily for adding extra menu items to the Bulk WP main menu.
330
		 *
331
		 * @since 5.3
332
		 */
333
		do_action( 'bd_after_all_menus' );
334
335
		// enqueue JavaScript
336
		add_action( 'admin_print_scripts-' . $this->posts_page, array( $this, 'add_script' ) );
337
		add_action( 'admin_print_scripts-' . $this->pages_page, array( $this, 'add_script' ) );
338
339
		// delete posts page
340
		add_action( "load-{$this->posts_page}", array( $this, 'add_delete_posts_settings_panel' ) );
341
		add_action( "add_meta_boxes_{$this->posts_page}", array( $this, 'add_delete_posts_meta_boxes' ) );
342
343
		// delete pages page
344
		add_action( "load-{$this->pages_page}", array( $this, 'add_delete_pages_settings_panel' ) );
345
		add_action( "add_meta_boxes_{$this->pages_page}", array( $this, 'add_delete_pages_meta_boxes' ) );
346
	}
347
348
	/**
349
	 * Add settings Panel for delete posts page
350
	 */
351
	public function add_delete_posts_settings_panel() {
352
353
		/**
354
		 * Add contextual help for admin screens
355
		 *
356
		 * @since 5.1
357
		 */
358
		do_action( 'bd_add_contextual_help', $this->posts_page );
359
360
		/* Trigger the add_meta_boxes hooks to allow meta boxes to be added */
361
		do_action( 'add_meta_boxes_' . $this->posts_page, null );
362
363
		/* Enqueue WordPress' script for handling the meta boxes */
364
		wp_enqueue_script( 'postbox' );
365
	}
366
367
	/**
368
	 * Register meta boxes for delete posts page
369
	 */
370
	public function add_delete_posts_meta_boxes() {
371
		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' );
372
		add_meta_box( self::BOX_CATEGORY      , __( 'By Category'          , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_category_box'  , $this->posts_page , 'advanced' );
373
		add_meta_box( self::BOX_TAG           , __( 'By Tag'               , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_tag_box'       , $this->posts_page , 'advanced' );
374
		add_meta_box( self::BOX_TAX           , __( 'By Custom Taxonomy'   , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_taxonomy_box'  , $this->posts_page , 'advanced' );
375
		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' );
376
		add_meta_box( self::BOX_URL           , __( 'By URL'               , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_url_box'       , $this->posts_page , 'advanced' );
377
		add_meta_box( self::BOX_POST_REVISION , __( 'By Post Revision'     , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_posts_by_revision_box'         , $this->posts_page , 'advanced' );
378
379
		/**
380
		 * Add meta box in delete posts page
381
		 * This hook can be used for adding additional meta boxes in delete posts page
382
		 *
383
		 * @since 5.3
384
		 */
385
		do_action( 'bd_add_meta_box_for_posts' );
386
	}
387
388
	/**
389
	 * Setup settings panel for delete pages page
390
	 *
391
	 * @since 5.0
392
	 */
393
	public function add_delete_pages_settings_panel() {
394
395
		/**
396
		 * Add contextual help for admin screens
397
		 *
398
		 * @since 5.1
399
		 */
400
		do_action( 'bd_add_contextual_help', $this->pages_page );
401
402
		/* Trigger the add_meta_boxes hooks to allow meta boxes to be added */
403
		do_action( 'add_meta_boxes_' . $this->pages_page, null );
404
405
		/* Enqueue WordPress' script for handling the meta boxes */
406
		wp_enqueue_script( 'postbox' );
407
	}
408
409
	/**
410
	 * Register meta boxes for delete pages page
411
	 *
412
	 * @since 5.0
413
	 */
414
	public function add_delete_pages_meta_boxes() {
415
		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' );
416
417
		/**
418
		 * Add meta box in delete pages page
419
		 * This hook can be used for adding additional meta boxes in delete pages page
420
		 *
421
		 * @since 5.3
422
		 */
423
		do_action( 'bd_add_meta_box_for_pages' );
424
	}
425
426
	/**
427
	 * Enqueue Scripts and Styles.
428
	 */
429
	public function add_script() {
430
		global $wp_scripts;
431
432
		/**
433
		 * Runs just before enqueuing scripts and styles in all Bulk WP admin pages.
434
		 *
435
		 * This action is primarily for registering or deregistering additional scripts or styles.
436
		 *
437
		 * @since 5.5.1
438
		 */
439
		do_action( 'bd_before_admin_enqueue_scripts' );
440
441
		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 );
442
		wp_enqueue_style( 'jquery-ui-timepicker', plugins_url( '/assets/css/jquery-ui-timepicker-addon.min.css', __FILE__ ), array(), '1.5.4' );
443
444
		wp_enqueue_script( 'select2', plugins_url( '/assets/js/select2.min.js', __FILE__ ), array( 'jquery' ), '4.0.0', true );
445
		wp_enqueue_style( 'select2', plugins_url( '/assets/css/select2.min.css', __FILE__ ), array(), '4.0.0' );
446
447
		$postfix = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) ? '' : '.min';
448
		wp_enqueue_script( self::JS_HANDLE, plugins_url( '/assets/js/bulk-delete' . $postfix . '.js', __FILE__ ), array( 'jquery-ui-timepicker' ), self::VERSION, true );
449
		wp_enqueue_style( self::CSS_HANDLE, plugins_url( '/assets/css/bulk-delete' . $postfix . '.css', __FILE__ ), array( 'select2' ), self::VERSION );
450
451
		$ui = $wp_scripts->query( 'jquery-ui-core' );
452
		$url = "//ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/smoothness/jquery-ui.css";
453
		wp_enqueue_style( 'jquery-ui-smoothness', $url, false, $ui->ver );
454
455
		/**
456
		 * Filter JavaScript array
457
		 *
458
		 * This filter can be used to extend the array that is passed to JavaScript
459
		 *
460
		 * @since 5.4
461
		 */
462
		$translation_array = apply_filters( 'bd_javascript_array', array(
463
				'msg'            => array(),
464
				'validators'     => array(),
465
				'dt_iterators'   => array(),
466
				'pre_action_msg' => array(),
467
				'error_msg'      => array(),
468
				'pro_iterators'  => array(),
469
			) );
470
		wp_localize_script( self::JS_HANDLE, self::JS_VARIABLE, $translation_array );
471
472
		/**
473
		 * Runs just after enqueuing scripts and styles in all Bulk WP admin pages.
474
		 *
475
		 * This action is primarily for registering additional scripts or styles.
476
		 *
477
		 * @since 5.5.1
478
		 */
479
		do_action( 'bd_after_admin_enqueue_scripts' );
480
	}
481
482
	/**
483
	 * Show the delete posts page.
484
	 *
485
	 * @Todo Move this function to Bulk_Delete_Posts class
486
	 */
487
	public function display_posts_page() {
488
?>
489
<div class="wrap">
490
    <h2><?php _e( 'Bulk Delete Posts', 'bulk-delete' );?></h2>
491
    <?php settings_errors(); ?>
492
493
    <form method = "post">
494
<?php
495
		// nonce for bulk delete
496
		wp_nonce_field( 'sm-bulk-delete-posts', 'sm-bulk-delete-posts-nonce' );
497
498
		/* Used to save closed meta boxes and their order */
499
		wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
500
		wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
501
?>
502
    <div id = "poststuff">
503
        <div id="post-body" class="metabox-holder columns-2">
504
505
            <div class="notice notice-warning">
506
                <p><strong><?php _e( 'WARNING: Posts deleted once cannot be retrieved back. Use with caution.', 'bulk-delete' ); ?></strong></p>
507
            </div>
508
509
            <div id="postbox-container-1" class="postbox-container">
510
                <iframe frameBorder="0" height = "1500" src = "http://sudarmuthu.com/projects/wordpress/bulk-delete/sidebar.php?color=<?php echo get_user_option( 'admin_color' ); ?>&version=<?php echo self::VERSION; ?>"></iframe>
511
            </div>
512
513
            <div id="postbox-container-2" class="postbox-container">
514
                <?php do_meta_boxes( '', 'advanced', null ); ?>
515
            </div> <!-- #postbox-container-2 -->
516
517
        </div> <!-- #post-body -->
518
    </div><!-- #poststuff -->
519
    </form>
520
</div><!-- .wrap -->
521
522
<?php
523
		/**
524
		 * Runs just before displaying the footer text in the "Bulk Delete Posts" admin page.
525
		 *
526
		 * This action is primarily for adding extra content in the footer of "Bulk Delete Posts" admin page.
527
		 *
528
		 * @since 5.0
529
		 */
530
		do_action( 'bd_admin_footer_posts_page' );
531
	}
532
533
	/**
534
	 * Display the delete pages page
535
	 *
536
	 * @Todo Move this function to Bulk_Delete_Pages class
537
	 * @since 5.0
538
	 */
539
	public function display_pages_page() {
540
?>
541
<div class="wrap">
542
    <h2><?php _e( 'Bulk Delete Pages', 'bulk-delete' );?></h2>
543
    <?php settings_errors(); ?>
544
545
    <form method = "post">
546
<?php
547
		// nonce for bulk delete
548
		wp_nonce_field( 'sm-bulk-delete-pages', 'sm-bulk-delete-pages-nonce' );
549
550
		/* Used to save closed meta boxes and their order */
551
		wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
552
		wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
553
?>
554
    <div id = "poststuff">
555
        <div id="post-body" class="metabox-holder columns-2">
556
557
            <div class="notice notice-warning">
558
                <p><strong><?php _e( 'WARNING: Pages deleted once cannot be retrieved back. Use with caution.', 'bulk-delete' ); ?></strong></p>
559
            </div>
560
561
            <div id="postbox-container-1" class="postbox-container">
562
                <iframe frameBorder="0" height = "1500" src = "http://sudarmuthu.com/projects/wordpress/bulk-delete/sidebar.php?color=<?php echo get_user_option( 'admin_color' ); ?>&version=<?php echo self::VERSION; ?>"></iframe>
563
            </div>
564
565
            <div id="postbox-container-2" class="postbox-container">
566
                <?php do_meta_boxes( '', 'advanced', null ); ?>
567
            </div> <!-- #postbox-container-2 -->
568
569
        </div> <!-- #post-body -->
570
    </div><!-- #poststuff -->
571
    </form>
572
</div><!-- .wrap -->
573
574
<?php
575
		/**
576
		 * Runs just before displaying the footer text in the "Bulk Delete Pages" admin page.
577
		 *
578
		 * This action is primarily for adding extra content in the footer of "Bulk Delete Pages" admin page.
579
		 *
580
		 * @since 5.0
581
		 */
582
		do_action( 'bd_admin_footer_pages_page' );
583
	}
584
585
	/**
586
	 * Display the schedule page
587
	 */
588
	public function display_cron_page() {
589
590
		if ( ! class_exists( 'WP_List_Table' ) ) {
591
			require_once ABSPATH . WPINC . '/class-wp-list-table.php';
592
		}
593
594
		if ( ! class_exists( 'Cron_List_Table' ) ) {
595
			require_once self::$PLUGIN_DIR . '/include/cron/class-cron-list-table.php';
596
		}
597
598
		// Prepare Table of elements
599
		$cron_list_table = new Cron_List_Table();
600
		$cron_list_table->prepare_items();
601
?>
602
    <div class="wrap">
603
        <h2><?php _e( 'Bulk Delete Schedules', 'bulk-delete' );?></h2>
604
        <?php settings_errors(); ?>
605
<?php
606
		// Table of elements
607
		$cron_list_table->display();
608
		bd_display_available_addon_list();
609
?>
610
    </div>
611
<?php
612
		/**
613
		 * Runs just before displaying the footer text in the "Schedules" admin page.
614
		 *
615
		 * This action is primarily for adding extra content in the footer of "Schedules" admin page.
616
		 *
617
		 * @since 5.0
618
		 */
619
		do_action( 'bd_admin_footer_cron_page' );
620
	}
621
622
	/**
623
	 * Increase PHP timeout.
624
	 *
625
	 * This is to prevent bulk operations from timing out
626
	 *
627
	 * @since 5.4
628
	 */
629
	public function increase_timeout() {
630
		if ( ! ini_get( 'safe_mode' ) ) {
631
			@set_time_limit( 0 );
632
		}
633
	}
634
}
635
636
637
/**
638
 * The main function responsible for returning the one true Bulk_Delete
639
 * Instance to functions everywhere.
640
 *
641
 * Use this function like you would a global variable, except without needing
642
 * to declare the global.
643
 *
644
 * Example: `<?php $bulk_delete = BULK_DELETE(); ?>`
645
 *
646
 * @since 5.0
647
 * @return Bulk_Delete The one true Bulk_Delete Instance
648
 */
649
function BULK_DELETE() {
650
	return Bulk_Delete::instance();
651
}
652
653
// Get BULK_DELETE Running
654
BULK_DELETE();
655
?>
656