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 | * @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 | private $controller; |
||
52 | |||
53 | // version |
||
54 | const VERSION = '5.5.7'; |
||
55 | |||
56 | // Numeric constants |
||
57 | const MENU_ORDER = '26'; |
||
58 | |||
59 | // page slugs |
||
60 | const POSTS_PAGE_SLUG = 'bulk-delete-posts'; |
||
61 | const PAGES_PAGE_SLUG = 'bulk-delete-pages'; |
||
62 | const CRON_PAGE_SLUG = 'bulk-delete-cron'; |
||
63 | const ADDON_PAGE_SLUG = 'bulk-delete-addon'; |
||
64 | |||
65 | // JS constants |
||
66 | const JS_HANDLE = 'bulk-delete'; |
||
67 | const JS_VARIABLE = 'BulkWP'; |
||
68 | |||
69 | const CSS_HANDLE = 'bulk-delete'; |
||
70 | |||
71 | // Cron hooks |
||
72 | const CRON_HOOK_CATEGORY = 'do-bulk-delete-cat'; |
||
73 | const CRON_HOOK_POST_STATUS = 'do-bulk-delete-post-status'; |
||
74 | const CRON_HOOK_TAG = 'do-bulk-delete-tag'; |
||
75 | const CRON_HOOK_TAXONOMY = 'do-bulk-delete-taxonomy'; |
||
76 | const CRON_HOOK_POST_TYPE = 'do-bulk-delete-post-type'; |
||
77 | const CRON_HOOK_CUSTOM_FIELD = 'do-bulk-delete-custom-field'; |
||
78 | const CRON_HOOK_TITLE = 'do-bulk-delete-by-title'; |
||
79 | const CRON_HOOK_DUPLICATE_TITLE = 'do-bulk-delete-by-duplicate-title'; |
||
80 | const CRON_HOOK_POST_BY_ROLE = 'do-bulk-delete-posts-by-role'; |
||
81 | |||
82 | const CRON_HOOK_PAGES_STATUS = 'do-bulk-delete-pages-by-status'; |
||
83 | |||
84 | // meta boxes for delete posts |
||
85 | const BOX_POST_STATUS = 'bd_by_post_status'; |
||
86 | const BOX_CATEGORY = 'bd_by_category'; |
||
87 | const BOX_TAG = 'bd_by_tag'; |
||
88 | const BOX_TAX = 'bd_by_tax'; |
||
89 | const BOX_POST_TYPE = 'bd_by_post_type'; |
||
90 | const BOX_URL = 'bd_by_url'; |
||
91 | const BOX_POST_REVISION = 'bd_by_post_revision'; |
||
92 | const BOX_CUSTOM_FIELD = 'bd_by_custom_field'; |
||
93 | const BOX_TITLE = 'bd_by_title'; |
||
94 | const BOX_DUPLICATE_TITLE = 'bd_by_duplicate_title'; |
||
95 | const BOX_POST_FROM_TRASH = 'bd_posts_from_trash'; |
||
96 | const BOX_POST_BY_ROLE = 'bd_post_by_user_role'; |
||
97 | |||
98 | // meta boxes for delete pages |
||
99 | const BOX_PAGE_STATUS = 'bd_by_page_status'; |
||
100 | const BOX_PAGE_FROM_TRASH = 'bd_pages_from_trash'; |
||
101 | |||
102 | // Settings constants |
||
103 | const SETTING_OPTION_GROUP = 'bd_settings'; |
||
104 | const SETTING_OPTION_NAME = 'bd_licenses'; |
||
105 | const SETTING_SECTION_ID = 'bd_license_section'; |
||
106 | |||
107 | // Transient keys |
||
108 | const LICENSE_CACHE_KEY_PREFIX = 'bd-license_'; |
||
109 | |||
110 | // path variables |
||
111 | // Ideally these should be constants, but because of PHP's limitations, these are static variables |
||
112 | public static $PLUGIN_DIR; |
||
113 | public static $PLUGIN_URL; |
||
114 | public static $PLUGIN_FILE; |
||
115 | |||
116 | // Instance variables |
||
117 | public $translations; |
||
118 | public $posts_page; |
||
119 | public $pages_page; |
||
120 | public $cron_page; |
||
121 | public $addon_page; |
||
122 | public $settings_page; |
||
123 | public $meta_page; |
||
124 | public $misc_page; |
||
125 | public $display_activate_license_form = false; |
||
0 ignored issues
–
show
|
|||
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’ 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’ 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-base-page.php'; |
||
215 | require_once self::$PLUGIN_DIR . '/include/base/class-bd-page.php'; |
||
216 | |||
217 | require_once self::$PLUGIN_DIR . '/include/controller/class-bd-controller.php'; |
||
218 | |||
219 | require_once self::$PLUGIN_DIR . '/include/ui/form.php'; |
||
220 | |||
221 | require_once self::$PLUGIN_DIR . '/include/posts/class-bulk-delete-posts.php'; |
||
222 | require_once self::$PLUGIN_DIR . '/include/pages/class-bulk-delete-pages.php'; |
||
223 | |||
224 | require_once self::$PLUGIN_DIR . '/include/users/class-bd-users-page.php'; |
||
225 | require_once self::$PLUGIN_DIR . '/include/users/modules/class-bulk-delete-users-by-user-role.php'; |
||
226 | require_once self::$PLUGIN_DIR . '/include/users/modules/class-bulk-delete-users-by-user-meta.php'; |
||
227 | |||
228 | require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-meta.php'; |
||
229 | require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-post-meta.php'; |
||
230 | require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-comment-meta.php'; |
||
231 | require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-user-meta.php'; |
||
232 | |||
233 | require_once self::$PLUGIN_DIR . '/include/misc/class-bulk-delete-misc.php'; |
||
234 | require_once self::$PLUGIN_DIR . '/include/misc/class-bulk-delete-jetpack-contact-form-messages.php'; |
||
235 | |||
236 | require_once self::$PLUGIN_DIR . '/include/settings/class-bd-settings-page.php'; |
||
237 | require_once self::$PLUGIN_DIR . '/include/settings/setting-helpers.php'; |
||
238 | require_once self::$PLUGIN_DIR . '/include/settings/class-bd-settings.php'; |
||
239 | |||
240 | require_once self::$PLUGIN_DIR . '/include/system-info/class-bd-system-info-page.php'; |
||
241 | |||
242 | require_once self::$PLUGIN_DIR . '/include/util/class-bd-util.php'; |
||
243 | require_once self::$PLUGIN_DIR . '/include/util/query.php'; |
||
244 | |||
245 | require_once self::$PLUGIN_DIR . '/include/compatibility/simple-login-log.php'; |
||
246 | require_once self::$PLUGIN_DIR . '/include/compatibility/the-event-calendar.php'; |
||
247 | require_once self::$PLUGIN_DIR . '/include/compatibility/woocommerce.php'; |
||
248 | require_once self::$PLUGIN_DIR . '/include/compatibility/advanced-custom-fields-pro.php'; |
||
249 | |||
250 | require_once self::$PLUGIN_DIR . '/include/deprecated/class-bulk-delete-users.php'; |
||
251 | require_once self::$PLUGIN_DIR . '/include/deprecated/deprecated.php'; |
||
252 | |||
253 | require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-addon.php'; |
||
254 | require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-base-addon.php'; |
||
255 | require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-scheduler-addon.php'; |
||
256 | |||
257 | require_once self::$PLUGIN_DIR . '/include/addons/addon-list.php'; |
||
258 | require_once self::$PLUGIN_DIR . '/include/addons/posts.php'; |
||
259 | require_once self::$PLUGIN_DIR . '/include/addons/pages.php'; |
||
260 | require_once self::$PLUGIN_DIR . '/include/addons/util.php'; |
||
261 | |||
262 | require_once self::$PLUGIN_DIR . '/include/license/class-bd-license.php'; |
||
263 | require_once self::$PLUGIN_DIR . '/include/license/class-bd-license-handler.php'; |
||
264 | require_once self::$PLUGIN_DIR . '/include/license/class-bd-edd-api-wrapper.php'; |
||
265 | |||
266 | require_once self::$PLUGIN_DIR . '/include/ui/admin-ui.php'; |
||
267 | require_once self::$PLUGIN_DIR . '/include/ui/class-bulk-delete-help-screen.php'; |
||
268 | } |
||
269 | |||
270 | /** |
||
271 | * Loads the plugin language files |
||
272 | * |
||
273 | * @since 5.0 |
||
274 | */ |
||
275 | public function load_textdomain() { |
||
276 | // Load localization domain |
||
277 | $this->translations = dirname( plugin_basename( self::$PLUGIN_FILE ) ) . '/languages/'; |
||
278 | load_plugin_textdomain( 'bulk-delete', false, $this->translations ); |
||
279 | } |
||
280 | |||
281 | /** |
||
282 | * Loads the plugin's actions and hooks |
||
283 | * |
||
284 | * @access private |
||
285 | * @since 5.0 |
||
286 | * @return void |
||
287 | */ |
||
288 | private function setup_actions() { |
||
289 | $this->controller = new BD_Controller(); |
||
290 | |||
291 | add_action( 'admin_menu', array( $this, 'add_menu' ) ); |
||
292 | } |
||
293 | |||
294 | /** |
||
295 | * Add navigation menu |
||
296 | */ |
||
297 | public function add_menu() { |
||
298 | 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 ); |
||
299 | |||
300 | $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' ) ); |
||
301 | $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' ) ); |
||
302 | |||
303 | /** |
||
304 | * Runs just after adding all *delete* menu items to Bulk WP main menu |
||
305 | * |
||
306 | * This action is primarily for adding extra *delete* menu items to the Bulk WP main menu. |
||
307 | * |
||
308 | * @since 5.3 |
||
309 | */ |
||
310 | do_action( 'bd_after_primary_menus' ); |
||
311 | |||
312 | /** |
||
313 | * Runs just before adding non-action menu items to Bulk WP main menu |
||
314 | * |
||
315 | * This action is primarily for adding extra menu items before non-action menu items to the Bulk WP main menu. |
||
316 | * |
||
317 | * @since 5.3 |
||
318 | */ |
||
319 | do_action( 'bd_before_secondary_menus' ); |
||
320 | |||
321 | $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' ) ); |
||
322 | $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' ) ); |
||
323 | |||
324 | /** |
||
325 | * Runs just after adding all menu items to Bulk WP main menu |
||
326 | * |
||
327 | * This action is primarily for adding extra menu items to the Bulk WP main menu. |
||
328 | * |
||
329 | * @since 5.3 |
||
330 | */ |
||
331 | do_action( 'bd_after_all_menus' ); |
||
332 | |||
333 | // enqueue JavaScript |
||
334 | add_action( 'admin_print_scripts-' . $this->posts_page, array( $this, 'add_script' ) ); |
||
335 | add_action( 'admin_print_scripts-' . $this->pages_page, array( $this, 'add_script' ) ); |
||
336 | |||
337 | // delete posts page |
||
338 | add_action( "load-{$this->posts_page}", array( $this, 'add_delete_posts_settings_panel' ) ); |
||
339 | add_action( "add_meta_boxes_{$this->posts_page}", array( $this, 'add_delete_posts_meta_boxes' ) ); |
||
340 | |||
341 | // delete pages page |
||
342 | add_action( "load-{$this->pages_page}", array( $this, 'add_delete_pages_settings_panel' ) ); |
||
343 | add_action( "add_meta_boxes_{$this->pages_page}", array( $this, 'add_delete_pages_meta_boxes' ) ); |
||
344 | } |
||
345 | |||
346 | /** |
||
347 | * Add settings Panel for delete posts page |
||
348 | */ |
||
349 | public function add_delete_posts_settings_panel() { |
||
350 | |||
351 | /** |
||
352 | * Add contextual help for admin screens |
||
353 | * |
||
354 | * @since 5.1 |
||
355 | */ |
||
356 | do_action( 'bd_add_contextual_help', $this->posts_page ); |
||
357 | |||
358 | /* Trigger the add_meta_boxes hooks to allow meta boxes to be added */ |
||
359 | do_action( 'add_meta_boxes_' . $this->posts_page, null ); |
||
360 | |||
361 | /* Enqueue WordPress' script for handling the meta boxes */ |
||
362 | wp_enqueue_script( 'postbox' ); |
||
363 | } |
||
364 | |||
365 | /** |
||
366 | * Register meta boxes for delete posts page |
||
367 | */ |
||
368 | public function add_delete_posts_meta_boxes() { |
||
369 | 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' ); |
||
370 | add_meta_box( self::BOX_CATEGORY , __( 'By Category' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_category_box' , $this->posts_page , 'advanced' ); |
||
371 | add_meta_box( self::BOX_TAG , __( 'By Tag' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_tag_box' , $this->posts_page , 'advanced' ); |
||
372 | add_meta_box( self::BOX_TAX , __( 'By Custom Taxonomy' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_taxonomy_box' , $this->posts_page , 'advanced' ); |
||
373 | 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' ); |
||
374 | add_meta_box( self::BOX_URL , __( 'By URL' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_url_box' , $this->posts_page , 'advanced' ); |
||
375 | add_meta_box( self::BOX_POST_REVISION , __( 'By Post Revision' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_posts_by_revision_box' , $this->posts_page , 'advanced' ); |
||
376 | |||
377 | /** |
||
378 | * Add meta box in delete posts page |
||
379 | * This hook can be used for adding additional meta boxes in delete posts page |
||
380 | * |
||
381 | * @since 5.3 |
||
382 | */ |
||
383 | do_action( 'bd_add_meta_box_for_posts' ); |
||
384 | } |
||
385 | |||
386 | /** |
||
387 | * Setup settings panel for delete pages page |
||
388 | * |
||
389 | * @since 5.0 |
||
390 | */ |
||
391 | public function add_delete_pages_settings_panel() { |
||
392 | |||
393 | /** |
||
394 | * Add contextual help for admin screens |
||
395 | * |
||
396 | * @since 5.1 |
||
397 | */ |
||
398 | do_action( 'bd_add_contextual_help', $this->pages_page ); |
||
399 | |||
400 | /* Trigger the add_meta_boxes hooks to allow meta boxes to be added */ |
||
401 | do_action( 'add_meta_boxes_' . $this->pages_page, null ); |
||
402 | |||
403 | /* Enqueue WordPress' script for handling the meta boxes */ |
||
404 | wp_enqueue_script( 'postbox' ); |
||
405 | } |
||
406 | |||
407 | /** |
||
408 | * Register meta boxes for delete pages page |
||
409 | * |
||
410 | * @since 5.0 |
||
411 | */ |
||
412 | public function add_delete_pages_meta_boxes() { |
||
413 | 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' ); |
||
414 | |||
415 | /** |
||
416 | * Add meta box in delete pages page |
||
417 | * This hook can be used for adding additional meta boxes in delete pages page |
||
418 | * |
||
419 | * @since 5.3 |
||
420 | */ |
||
421 | do_action( 'bd_add_meta_box_for_pages' ); |
||
422 | } |
||
423 | |||
424 | /** |
||
425 | * Enqueue Scripts and Styles. |
||
426 | */ |
||
427 | public function add_script() { |
||
428 | global $wp_scripts; |
||
429 | |||
430 | /** |
||
431 | * Runs just before enqueuing scripts and styles in all Bulk WP admin pages. |
||
432 | * |
||
433 | * This action is primarily for registering or deregistering additional scripts or styles. |
||
434 | * |
||
435 | * @since 5.5.1 |
||
436 | */ |
||
437 | do_action( 'bd_before_admin_enqueue_scripts' ); |
||
438 | |||
439 | 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 ); |
||
440 | wp_enqueue_style( 'jquery-ui-timepicker', plugins_url( '/assets/css/jquery-ui-timepicker-addon.min.css', __FILE__ ), array(), '1.5.4' ); |
||
441 | |||
442 | wp_enqueue_script( 'select2', plugins_url( '/assets/js/select2.min.js', __FILE__ ), array( 'jquery' ), '4.0.0', true ); |
||
443 | wp_enqueue_style( 'select2', plugins_url( '/assets/css/select2.min.css', __FILE__ ), array(), '4.0.0' ); |
||
444 | |||
445 | $postfix = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) ? '' : '.min'; |
||
446 | wp_enqueue_script( self::JS_HANDLE, plugins_url( '/assets/js/bulk-delete' . $postfix . '.js', __FILE__ ), array( 'jquery-ui-timepicker' ), self::VERSION, true ); |
||
447 | wp_enqueue_style( self::CSS_HANDLE, plugins_url( '/assets/css/bulk-delete' . $postfix . '.css', __FILE__ ), array( 'select2' ), self::VERSION ); |
||
448 | |||
449 | $ui = $wp_scripts->query( 'jquery-ui-core' ); |
||
0 ignored issues
–
show
|
|||
450 | $url = "//ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/smoothness/jquery-ui.css"; |
||
451 | wp_enqueue_style( 'jquery-ui-smoothness', $url, false, $ui->ver ); |
||
452 | |||
453 | /** |
||
454 | * Filter JavaScript array |
||
455 | * |
||
456 | * This filter can be used to extend the array that is passed to JavaScript |
||
457 | * |
||
458 | * @since 5.4 |
||
459 | */ |
||
460 | $translation_array = apply_filters( 'bd_javascript_array', array( |
||
461 | 'msg' => array(), |
||
462 | 'validators' => array(), |
||
463 | 'dt_iterators' => array(), |
||
464 | 'pre_action_msg' => array(), |
||
465 | 'error_msg' => array(), |
||
466 | 'pro_iterators' => array(), |
||
467 | ) ); |
||
468 | wp_localize_script( self::JS_HANDLE, self::JS_VARIABLE, $translation_array ); |
||
469 | |||
470 | /** |
||
471 | * Runs just after enqueuing scripts and styles in all Bulk WP admin pages. |
||
472 | * |
||
473 | * This action is primarily for registering additional scripts or styles. |
||
474 | * |
||
475 | * @since 5.5.1 |
||
476 | */ |
||
477 | do_action( 'bd_after_admin_enqueue_scripts' ); |
||
478 | } |
||
479 | |||
480 | /** |
||
481 | * Show the delete posts page. |
||
482 | * |
||
483 | * @Todo Move this function to Bulk_Delete_Posts class |
||
484 | */ |
||
485 | public function display_posts_page() { |
||
486 | ?> |
||
487 | <div class="wrap"> |
||
488 | <h2><?php _e( 'Bulk Delete Posts', 'bulk-delete' );?></h2> |
||
489 | <?php settings_errors(); ?> |
||
490 | |||
491 | <form method = "post"> |
||
492 | <?php |
||
493 | // nonce for bulk delete |
||
494 | wp_nonce_field( 'sm-bulk-delete-posts', 'sm-bulk-delete-posts-nonce' ); |
||
495 | |||
496 | /* Used to save closed meta boxes and their order */ |
||
497 | wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
||
498 | wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
||
499 | ?> |
||
500 | <div id = "poststuff"> |
||
501 | <div id="post-body" class="metabox-holder columns-1"> |
||
502 | |||
503 | <div class="notice notice-warning"> |
||
504 | <p><strong><?php _e( 'WARNING: Posts deleted once cannot be retrieved back. Use with caution.', 'bulk-delete' ); ?></strong></p> |
||
505 | </div> |
||
506 | |||
507 | <div id="postbox-container-2" class="postbox-container"> |
||
508 | <?php do_meta_boxes( '', 'advanced', null ); ?> |
||
509 | </div> <!-- #postbox-container-2 --> |
||
510 | |||
511 | </div> <!-- #post-body --> |
||
512 | </div><!-- #poststuff --> |
||
513 | </form> |
||
514 | </div><!-- .wrap --> |
||
515 | |||
516 | <?php |
||
517 | /** |
||
518 | * Runs just before displaying the footer text in the "Bulk Delete Posts" admin page. |
||
519 | * |
||
520 | * This action is primarily for adding extra content in the footer of "Bulk Delete Posts" admin page. |
||
521 | * |
||
522 | * @since 5.0 |
||
523 | */ |
||
524 | do_action( 'bd_admin_footer_posts_page' ); |
||
525 | } |
||
526 | |||
527 | /** |
||
528 | * Display the delete pages page |
||
529 | * |
||
530 | * @Todo Move this function to Bulk_Delete_Pages class |
||
531 | * @since 5.0 |
||
532 | */ |
||
533 | public function display_pages_page() { |
||
534 | ?> |
||
535 | <div class="wrap"> |
||
536 | <h2><?php _e( 'Bulk Delete Pages', 'bulk-delete' );?></h2> |
||
537 | <?php settings_errors(); ?> |
||
538 | |||
539 | <form method = "post"> |
||
540 | <?php |
||
541 | // nonce for bulk delete |
||
542 | wp_nonce_field( 'sm-bulk-delete-pages', 'sm-bulk-delete-pages-nonce' ); |
||
543 | |||
544 | /* Used to save closed meta boxes and their order */ |
||
545 | wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
||
546 | wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
||
547 | ?> |
||
548 | <div id = "poststuff"> |
||
549 | <div id="post-body" class="metabox-holder columns-1"> |
||
550 | |||
551 | <div class="notice notice-warning"> |
||
552 | <p><strong><?php _e( 'WARNING: Pages deleted once cannot be retrieved back. Use with caution.', 'bulk-delete' ); ?></strong></p> |
||
553 | </div> |
||
554 | |||
555 | <div id="postbox-container-2" class="postbox-container"> |
||
556 | <?php do_meta_boxes( '', 'advanced', null ); ?> |
||
557 | </div> <!-- #postbox-container-2 --> |
||
558 | |||
559 | </div> <!-- #post-body --> |
||
560 | </div><!-- #poststuff --> |
||
561 | </form> |
||
562 | </div><!-- .wrap --> |
||
563 | |||
564 | <?php |
||
565 | /** |
||
566 | * Runs just before displaying the footer text in the "Bulk Delete Pages" admin page. |
||
567 | * |
||
568 | * This action is primarily for adding extra content in the footer of "Bulk Delete Pages" admin page. |
||
569 | * |
||
570 | * @since 5.0 |
||
571 | */ |
||
572 | do_action( 'bd_admin_footer_pages_page' ); |
||
573 | } |
||
574 | |||
575 | /** |
||
576 | * Display the schedule page |
||
577 | */ |
||
578 | public function display_cron_page() { |
||
579 | |||
580 | if ( ! class_exists( 'WP_List_Table' ) ) { |
||
581 | require_once ABSPATH . WPINC . '/class-wp-list-table.php'; |
||
582 | } |
||
583 | |||
584 | if ( ! class_exists( 'Cron_List_Table' ) ) { |
||
585 | require_once self::$PLUGIN_DIR . '/include/cron/class-cron-list-table.php'; |
||
586 | } |
||
587 | |||
588 | // Prepare Table of elements |
||
589 | $cron_list_table = new Cron_List_Table(); |
||
590 | $cron_list_table->prepare_items(); |
||
591 | ?> |
||
592 | <div class="wrap"> |
||
593 | <h2><?php _e( 'Bulk Delete Schedules', 'bulk-delete' );?></h2> |
||
594 | <?php settings_errors(); ?> |
||
595 | <?php |
||
596 | // Table of elements |
||
597 | $cron_list_table->display(); |
||
598 | bd_display_available_addon_list(); |
||
599 | ?> |
||
600 | </div> |
||
601 | <?php |
||
602 | /** |
||
603 | * Runs just before displaying the footer text in the "Schedules" admin page. |
||
604 | * |
||
605 | * This action is primarily for adding extra content in the footer of "Schedules" admin page. |
||
606 | * |
||
607 | * @since 5.0 |
||
608 | */ |
||
609 | do_action( 'bd_admin_footer_cron_page' ); |
||
610 | } |
||
611 | } |
||
612 | |||
613 | |||
614 | /** |
||
615 | * The main function responsible for returning the one true Bulk_Delete |
||
616 | * Instance to functions everywhere. |
||
617 | * |
||
618 | * Use this function like you would a global variable, except without needing |
||
619 | * to declare the global. |
||
620 | * |
||
621 | * Example: `<?php $bulk_delete = BULK_DELETE(); ?>` |
||
622 | * |
||
623 | * @since 5.0 |
||
624 | * @return Bulk_Delete The one true Bulk_Delete Instance |
||
625 | */ |
||
626 | function BULK_DELETE() { |
||
627 | return Bulk_Delete::instance(); |
||
628 | } |
||
629 | |||
630 | // Get BULK_DELETE Running |
||
631 | BULK_DELETE(); |
||
632 | ?> |
||
633 |
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.