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.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; |
||
0 ignored issues
–
show
|
|||
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’ 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’ 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 | 1 | require_once self::$PLUGIN_DIR . '/include/posts/class-bulk-delete-posts.php'; |
|
265 | 1 | require_once self::$PLUGIN_DIR . '/include/pages/class-bulk-delete-pages.php'; |
|
266 | |||
267 | 1 | require_once self::$PLUGIN_DIR . '/include/users/class-bd-users-page.php'; |
|
268 | 1 | require_once self::$PLUGIN_DIR . '/include/users/modules/class-bulk-delete-users-by-user-role.php'; |
|
269 | 1 | require_once self::$PLUGIN_DIR . '/include/users/modules/class-bulk-delete-users-by-user-meta.php'; |
|
270 | |||
271 | 1 | require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-meta.php'; |
|
272 | 1 | require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-post-meta.php'; |
|
273 | 1 | require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-comment-meta.php'; |
|
274 | 1 | require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-user-meta.php'; |
|
275 | |||
276 | 1 | require_once self::$PLUGIN_DIR . '/include/misc/class-bulk-delete-misc.php'; |
|
277 | 1 | require_once self::$PLUGIN_DIR . '/include/misc/class-bulk-delete-jetpack-contact-form-messages.php'; |
|
278 | |||
279 | 1 | require_once self::$PLUGIN_DIR . '/include/settings/class-bd-settings-page.php'; |
|
280 | 1 | require_once self::$PLUGIN_DIR . '/include/settings/setting-helpers.php'; |
|
281 | 1 | require_once self::$PLUGIN_DIR . '/include/settings/class-bd-settings.php'; |
|
282 | |||
283 | 1 | require_once self::$PLUGIN_DIR . '/include/system-info/class-bd-system-info-page.php'; |
|
284 | |||
285 | 1 | require_once self::$PLUGIN_DIR . '/include/util/class-bd-util.php'; |
|
286 | 1 | require_once self::$PLUGIN_DIR . '/include/util/query.php'; |
|
287 | |||
288 | 1 | require_once self::$PLUGIN_DIR . '/include/compatibility/simple-login-log.php'; |
|
289 | 1 | require_once self::$PLUGIN_DIR . '/include/compatibility/the-event-calendar.php'; |
|
290 | 1 | require_once self::$PLUGIN_DIR . '/include/compatibility/woocommerce.php'; |
|
291 | 1 | require_once self::$PLUGIN_DIR . '/include/compatibility/advanced-custom-fields-pro.php'; |
|
292 | |||
293 | 1 | require_once self::$PLUGIN_DIR . '/include/deprecated/class-bulk-delete-users.php'; |
|
294 | 1 | require_once self::$PLUGIN_DIR . '/include/deprecated/deprecated.php'; |
|
295 | |||
296 | 1 | require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-addon.php'; |
|
297 | 1 | require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-base-addon.php'; |
|
298 | 1 | require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-scheduler-addon.php'; |
|
299 | |||
300 | 1 | require_once self::$PLUGIN_DIR . '/include/addons/addon-list.php'; |
|
301 | 1 | require_once self::$PLUGIN_DIR . '/include/addons/posts.php'; |
|
302 | 1 | require_once self::$PLUGIN_DIR . '/include/addons/pages.php'; |
|
303 | 1 | require_once self::$PLUGIN_DIR . '/include/addons/util.php'; |
|
304 | |||
305 | 1 | require_once self::$PLUGIN_DIR . '/include/license/class-bd-license.php'; |
|
306 | 1 | require_once self::$PLUGIN_DIR . '/include/license/class-bd-license-handler.php'; |
|
307 | 1 | require_once self::$PLUGIN_DIR . '/include/license/class-bd-edd-api-wrapper.php'; |
|
308 | |||
309 | 1 | require_once self::$PLUGIN_DIR . '/include/ui/admin-ui.php'; |
|
310 | 1 | require_once self::$PLUGIN_DIR . '/include/ui/class-bulk-delete-help-screen.php'; |
|
311 | 1 | } |
|
312 | |||
313 | /** |
||
314 | * Triggered when the `init` hook is fired. |
||
315 | * |
||
316 | * @since 5.7.0 |
||
317 | */ |
||
318 | 1 | public function on_init() { |
|
319 | 1 | $this->load_textdomain(); |
|
320 | 1 | } |
|
321 | |||
322 | /** |
||
323 | * Loads the plugin language files. |
||
324 | * |
||
325 | * @since 5.0 |
||
326 | */ |
||
327 | 1 | private function load_textdomain() { |
|
328 | // Load localization domain |
||
329 | 1 | $this->translations = dirname( plugin_basename( self::$PLUGIN_FILE ) ) . '/languages/'; |
|
330 | 1 | load_plugin_textdomain( 'bulk-delete', false, $this->translations ); |
|
331 | 1 | } |
|
332 | |||
333 | /** |
||
334 | * Loads the plugin's actions and hooks. |
||
335 | * |
||
336 | * @access private |
||
337 | * |
||
338 | * @since 5.0 |
||
339 | * |
||
340 | * @return void |
||
341 | */ |
||
342 | 1 | private function setup_actions() { |
|
343 | 1 | $this->controller = new BD_Controller(); |
|
344 | |||
345 | 1 | add_action( 'admin_menu', array( $this, 'add_menu' ) ); |
|
346 | |||
347 | 1 | add_filter( 'bd_help_tooltip', 'bd_generate_help_tooltip', 10, 2 ); |
|
348 | |||
349 | 1 | if ( defined( 'BD_DEBUG' ) && BD_DEBUG ) { |
|
350 | add_action( 'bd_after_query', array( $this, 'log_sql_query' ) ); |
||
351 | } |
||
352 | 1 | } |
|
353 | |||
354 | /** |
||
355 | * Log SQL query used by Bulk Delete. |
||
356 | * |
||
357 | * Query is logged only when `BD_DEBUG` is set. |
||
358 | * |
||
359 | * @since 5.6 |
||
360 | * |
||
361 | * @param \WP_Query $wp_query WP Query object. |
||
362 | */ |
||
363 | public function log_sql_query( $wp_query ) { |
||
364 | $query = $wp_query->request; |
||
365 | |||
366 | /** |
||
367 | * Bulk Delete query is getting logged. |
||
368 | * |
||
369 | * @since 5.6 |
||
370 | * |
||
371 | * @param string $query Bulk Delete SQL Query. |
||
372 | */ |
||
373 | do_action( 'bd_log_sql_query', $query ); |
||
374 | |||
375 | error_log( 'Bulk Delete Query: ' . $query ); |
||
376 | } |
||
377 | |||
378 | /** |
||
379 | * Add navigation menu. |
||
380 | */ |
||
381 | public function add_menu() { |
||
382 | 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 ); |
||
383 | |||
384 | $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' ) ); |
||
385 | $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' ) ); |
||
386 | |||
387 | /** |
||
388 | * Runs just after adding all *delete* menu items to Bulk WP main menu. |
||
389 | * |
||
390 | * This action is primarily for adding extra *delete* menu items to the Bulk WP main menu. |
||
391 | * |
||
392 | * @since 5.3 |
||
393 | */ |
||
394 | do_action( 'bd_after_primary_menus' ); |
||
395 | |||
396 | /** |
||
397 | * Runs just before adding non-action menu items to Bulk WP main menu. |
||
398 | * |
||
399 | * This action is primarily for adding extra menu items before non-action menu items to the Bulk WP main menu. |
||
400 | * |
||
401 | * @since 5.3 |
||
402 | */ |
||
403 | do_action( 'bd_before_secondary_menus' ); |
||
404 | |||
405 | $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' ) ); |
||
406 | $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' ) ); |
||
407 | |||
408 | /** |
||
409 | * Runs just after adding all menu items to Bulk WP main menu. |
||
410 | * |
||
411 | * This action is primarily for adding extra menu items to the Bulk WP main menu. |
||
412 | * |
||
413 | * @since 5.3 |
||
414 | */ |
||
415 | do_action( 'bd_after_all_menus' ); |
||
416 | |||
417 | // enqueue JavaScript |
||
418 | add_action( 'admin_print_scripts-' . $this->posts_page, array( $this, 'add_script' ) ); |
||
419 | add_action( 'admin_print_scripts-' . $this->pages_page, array( $this, 'add_script' ) ); |
||
420 | |||
421 | // delete posts page |
||
422 | add_action( "load-{$this->posts_page}", array( $this, 'add_delete_posts_settings_panel' ) ); |
||
423 | add_action( "add_meta_boxes_{$this->posts_page}", array( $this, 'add_delete_posts_meta_boxes' ) ); |
||
424 | |||
425 | // delete pages page |
||
426 | add_action( "load-{$this->pages_page}", array( $this, 'add_delete_pages_settings_panel' ) ); |
||
427 | add_action( "add_meta_boxes_{$this->pages_page}", array( $this, 'add_delete_pages_meta_boxes' ) ); |
||
428 | } |
||
429 | |||
430 | /** |
||
431 | * Add settings Panel for delete posts page. |
||
432 | */ |
||
433 | public function add_delete_posts_settings_panel() { |
||
434 | /** |
||
435 | * Add contextual help for admin screens. |
||
436 | * |
||
437 | * @since 5.1 |
||
438 | */ |
||
439 | do_action( 'bd_add_contextual_help', $this->posts_page ); |
||
440 | |||
441 | /* Trigger the add_meta_boxes hooks to allow meta boxes to be added */ |
||
442 | do_action( 'add_meta_boxes_' . $this->posts_page, null ); |
||
443 | |||
444 | /* Enqueue WordPress' script for handling the meta boxes */ |
||
445 | wp_enqueue_script( 'postbox' ); |
||
446 | } |
||
447 | |||
448 | /** |
||
449 | * Register meta boxes for delete posts page. |
||
450 | */ |
||
451 | public function add_delete_posts_meta_boxes() { |
||
452 | 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' ); |
||
453 | add_meta_box( self::BOX_CATEGORY , __( 'By Category' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_category_box' , $this->posts_page , 'advanced' ); |
||
454 | add_meta_box( self::BOX_TAG , __( 'By Tag' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_tag_box' , $this->posts_page , 'advanced' ); |
||
455 | add_meta_box( self::BOX_TAX , __( 'By Custom Taxonomy' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_taxonomy_box' , $this->posts_page , 'advanced' ); |
||
456 | 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' ); |
||
457 | add_meta_box( self::BOX_URL , __( 'By URL' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_url_box' , $this->posts_page , 'advanced' ); |
||
458 | add_meta_box( self::BOX_POST_REVISION , __( 'By Post Revision' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_posts_by_revision_box' , $this->posts_page , 'advanced' ); |
||
459 | |||
460 | /** |
||
461 | * Add meta box in delete posts page |
||
462 | * This hook can be used for adding additional meta boxes in delete posts page. |
||
463 | * |
||
464 | * @since 5.3 |
||
465 | */ |
||
466 | do_action( 'bd_add_meta_box_for_posts' ); |
||
467 | } |
||
468 | |||
469 | /** |
||
470 | * Setup settings panel for delete pages page. |
||
471 | * |
||
472 | * @since 5.0 |
||
473 | */ |
||
474 | public function add_delete_pages_settings_panel() { |
||
475 | /** |
||
476 | * Add contextual help for admin screens. |
||
477 | * |
||
478 | * @since 5.1 |
||
479 | */ |
||
480 | do_action( 'bd_add_contextual_help', $this->pages_page ); |
||
481 | |||
482 | /* Trigger the add_meta_boxes hooks to allow meta boxes to be added */ |
||
483 | do_action( 'add_meta_boxes_' . $this->pages_page, null ); |
||
484 | |||
485 | /* Enqueue WordPress' script for handling the meta boxes */ |
||
486 | wp_enqueue_script( 'postbox' ); |
||
487 | } |
||
488 | |||
489 | /** |
||
490 | * Register meta boxes for delete pages page. |
||
491 | * |
||
492 | * @since 5.0 |
||
493 | */ |
||
494 | public function add_delete_pages_meta_boxes() { |
||
495 | 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' ); |
||
496 | |||
497 | /** |
||
498 | * Add meta box in delete pages page |
||
499 | * This hook can be used for adding additional meta boxes in delete pages page. |
||
500 | * |
||
501 | * @since 5.3 |
||
502 | */ |
||
503 | do_action( 'bd_add_meta_box_for_pages' ); |
||
504 | } |
||
505 | |||
506 | /** |
||
507 | * Enqueue Scripts and Styles. |
||
508 | */ |
||
509 | public function add_script() { |
||
510 | global $wp_scripts; |
||
511 | |||
512 | /** |
||
513 | * Runs just before enqueuing scripts and styles in all Bulk WP admin pages. |
||
514 | * |
||
515 | * This action is primarily for registering or deregistering additional scripts or styles. |
||
516 | * |
||
517 | * @since 5.5.1 |
||
518 | */ |
||
519 | do_action( 'bd_before_admin_enqueue_scripts' ); |
||
520 | |||
521 | 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 ); |
||
522 | wp_enqueue_style( 'jquery-ui-timepicker', plugins_url( '/assets/css/jquery-ui-timepicker-addon.min.css', __FILE__ ), array(), '1.5.4' ); |
||
523 | |||
524 | wp_enqueue_script( 'select2', plugins_url( '/assets/js/select2.min.js', __FILE__ ), array( 'jquery' ), '4.0.0', true ); |
||
525 | wp_enqueue_style( 'select2', plugins_url( '/assets/css/select2.min.css', __FILE__ ), array(), '4.0.0' ); |
||
526 | |||
527 | $postfix = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) ? '' : '.min'; |
||
528 | 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 ); |
||
529 | wp_enqueue_style( self::CSS_HANDLE, plugins_url( '/assets/css/bulk-delete' . $postfix . '.css', __FILE__ ), array( 'select2' ), self::VERSION ); |
||
530 | |||
531 | $ui = $wp_scripts->query( 'jquery-ui-core' ); |
||
0 ignored issues
–
show
|
|||
532 | $url = "//ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/smoothness/jquery-ui.css"; |
||
533 | wp_enqueue_style( 'jquery-ui-smoothness', $url, false, $ui->ver ); |
||
534 | |||
535 | /** |
||
536 | * Filter JavaScript array. |
||
537 | * |
||
538 | * This filter can be used to extend the array that is passed to JavaScript |
||
539 | * |
||
540 | * @since 5.4 |
||
541 | */ |
||
542 | $translation_array = apply_filters( 'bd_javascript_array', array( |
||
543 | 'msg' => array(), |
||
544 | 'validators' => array(), |
||
545 | 'dt_iterators' => array(), |
||
546 | 'pre_action_msg' => array(), |
||
547 | 'error_msg' => array(), |
||
548 | 'pro_iterators' => array(), |
||
549 | ) ); |
||
550 | wp_localize_script( self::JS_HANDLE, self::JS_VARIABLE, $translation_array ); |
||
551 | |||
552 | /** |
||
553 | * Runs just after enqueuing scripts and styles in all Bulk WP admin pages. |
||
554 | * |
||
555 | * This action is primarily for registering additional scripts or styles. |
||
556 | * |
||
557 | * @since 5.5.1 |
||
558 | */ |
||
559 | do_action( 'bd_after_admin_enqueue_scripts' ); |
||
560 | } |
||
561 | |||
562 | /** |
||
563 | * Show the delete posts page. |
||
564 | * |
||
565 | * @Todo Move this function to Bulk_Delete_Posts class |
||
566 | */ |
||
567 | public function display_posts_page() { |
||
568 | ?> |
||
569 | <div class="wrap"> |
||
570 | <h2><?php _e( 'Bulk Delete Posts', 'bulk-delete' );?></h2> |
||
571 | <?php settings_errors(); ?> |
||
572 | |||
573 | <form method = "post"> |
||
574 | <?php |
||
575 | // nonce for bulk delete |
||
576 | wp_nonce_field( 'sm-bulk-delete-posts', 'sm-bulk-delete-posts-nonce' ); |
||
577 | |||
578 | /* Used to save closed meta boxes and their order */ |
||
579 | wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
||
580 | wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
||
581 | ?> |
||
582 | <div id = "poststuff"> |
||
583 | <div id="post-body" class="metabox-holder columns-1"> |
||
584 | |||
585 | <div class="notice notice-warning"> |
||
586 | <p><strong><?php _e( 'WARNING: Posts deleted once cannot be retrieved back. Use with caution.', 'bulk-delete' ); ?></strong></p> |
||
587 | </div> |
||
588 | |||
589 | <div id="postbox-container-2" class="postbox-container"> |
||
590 | <?php do_meta_boxes( '', 'advanced', null ); ?> |
||
591 | </div> <!-- #postbox-container-2 --> |
||
592 | |||
593 | </div> <!-- #post-body --> |
||
594 | </div><!-- #poststuff --> |
||
595 | </form> |
||
596 | </div><!-- .wrap --> |
||
597 | |||
598 | <?php |
||
599 | /** |
||
600 | * Runs just before displaying the footer text in the "Bulk Delete Posts" admin page. |
||
601 | * |
||
602 | * This action is primarily for adding extra content in the footer of "Bulk Delete Posts" admin page. |
||
603 | * |
||
604 | * @since 5.0 |
||
605 | */ |
||
606 | do_action( 'bd_admin_footer_posts_page' ); |
||
607 | } |
||
608 | |||
609 | /** |
||
610 | * Display the delete pages page. |
||
611 | * |
||
612 | * @Todo Move this function to Bulk_Delete_Pages class |
||
613 | * |
||
614 | * @since 5.0 |
||
615 | */ |
||
616 | public function display_pages_page() { |
||
617 | ?> |
||
618 | <div class="wrap"> |
||
619 | <h2><?php _e( 'Bulk Delete Pages', 'bulk-delete' );?></h2> |
||
620 | <?php settings_errors(); ?> |
||
621 | |||
622 | <form method = "post"> |
||
623 | <?php |
||
624 | // nonce for bulk delete |
||
625 | wp_nonce_field( 'sm-bulk-delete-pages', 'sm-bulk-delete-pages-nonce' ); |
||
626 | |||
627 | /* Used to save closed meta boxes and their order */ |
||
628 | wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
||
629 | wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
||
630 | ?> |
||
631 | <div id = "poststuff"> |
||
632 | <div id="post-body" class="metabox-holder columns-1"> |
||
633 | |||
634 | <div class="notice notice-warning"> |
||
635 | <p><strong><?php _e( 'WARNING: Pages deleted once cannot be retrieved back. Use with caution.', 'bulk-delete' ); ?></strong></p> |
||
636 | </div> |
||
637 | |||
638 | <div id="postbox-container-2" class="postbox-container"> |
||
639 | <?php do_meta_boxes( '', 'advanced', null ); ?> |
||
640 | </div> <!-- #postbox-container-2 --> |
||
641 | |||
642 | </div> <!-- #post-body --> |
||
643 | </div><!-- #poststuff --> |
||
644 | </form> |
||
645 | </div><!-- .wrap --> |
||
646 | |||
647 | <?php |
||
648 | /** |
||
649 | * Runs just before displaying the footer text in the "Bulk Delete Pages" admin page. |
||
650 | * |
||
651 | * This action is primarily for adding extra content in the footer of "Bulk Delete Pages" admin page. |
||
652 | * |
||
653 | * @since 5.0 |
||
654 | */ |
||
655 | do_action( 'bd_admin_footer_pages_page' ); |
||
656 | } |
||
657 | |||
658 | /** |
||
659 | * Display the schedule page. |
||
660 | */ |
||
661 | public function display_cron_page() { |
||
662 | if ( ! class_exists( 'WP_List_Table' ) ) { |
||
663 | require_once ABSPATH . WPINC . '/class-wp-list-table.php'; |
||
664 | } |
||
665 | |||
666 | if ( ! class_exists( 'Cron_List_Table' ) ) { |
||
667 | require_once self::$PLUGIN_DIR . '/include/cron/class-cron-list-table.php'; |
||
668 | } |
||
669 | |||
670 | // Prepare Table of elements |
||
671 | $cron_list_table = new Cron_List_Table(); |
||
672 | $cron_list_table->prepare_items(); |
||
673 | ?> |
||
674 | <div class="wrap"> |
||
675 | <h2><?php _e( 'Bulk Delete Schedules', 'bulk-delete' );?></h2> |
||
676 | <?php settings_errors(); ?> |
||
677 | <?php |
||
678 | // Table of elements |
||
679 | $cron_list_table->display(); |
||
680 | bd_display_available_addon_list(); |
||
681 | ?> |
||
682 | </div> |
||
683 | <?php |
||
684 | /** |
||
685 | * Runs just before displaying the footer text in the "Schedules" admin page. |
||
686 | * |
||
687 | * This action is primarily for adding extra content in the footer of "Schedules" admin page. |
||
688 | * |
||
689 | * @since 5.0 |
||
690 | */ |
||
691 | do_action( 'bd_admin_footer_cron_page' ); |
||
692 | } |
||
693 | } |
||
694 | |||
695 | /** |
||
696 | * The main function responsible for returning the one true Bulk_Delete |
||
697 | * Instance to functions everywhere. |
||
698 | * |
||
699 | * Use this function like you would a global variable, except without needing |
||
700 | * to declare the global. |
||
701 | * |
||
702 | * Example: `<?php $bulk_delete = BULK_DELETE(); ?>` |
||
703 | * |
||
704 | * @since 5.0 |
||
705 | * |
||
706 | * @return Bulk_Delete The one true Bulk_Delete Instance |
||
707 | */ |
||
708 | function BULK_DELETE() { |
||
709 | 1 | return Bulk_Delete::get_instance(); |
|
710 | } |
||
711 | |||
712 | /** |
||
713 | * Load Bulk Delete plugin. |
||
714 | * |
||
715 | * @since 5.7.0 |
||
716 | */ |
||
717 | function load_bulk_delete() { |
||
718 | 1 | $bulk_delete = BULK_DELETE(); |
|
719 | |||
720 | 1 | add_action( 'plugins_loaded', array( $bulk_delete, 'load' ), 101 ); |
|
721 | 1 | } |
|
722 | |||
723 | load_bulk_delete(); |
||
724 |
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.