1 | <?php |
||
2 | /** |
||
3 | * Plugin Name: Bulk Delete |
||
4 | * Plugin Script: bulk-delete.php |
||
5 | * Plugin URI: https://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 | * Version: 5.6.1 |
||
8 | * License: GPLv2 or later |
||
9 | * License URI: http://www.gnu.org/licenses/gpl-2.0.html |
||
10 | * Author: Sudar |
||
11 | * Author URI: https://sudarmuthu.com/ |
||
12 | * Text Domain: bulk-delete |
||
13 | * Domain Path: languages/ |
||
14 | * === RELEASE NOTES === |
||
15 | * Check readme file for full release notes. |
||
16 | */ |
||
17 | |||
18 | /** |
||
19 | * Copyright 2009 Sudar Muthu (email : [email protected]) |
||
20 | * This program is free software; you can redistribute it and/or modify |
||
21 | * it under the terms of the GNU General Public License, version 2, as |
||
22 | * published by the Free Software Foundation. |
||
23 | * |
||
24 | * This program is distributed in the hope that it will be useful, |
||
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
27 | * GNU General Public License for more details. |
||
28 | * |
||
29 | * You should have received a copy of the GNU General Public License |
||
30 | * along with this program; if not, write to the Free Software |
||
31 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
||
32 | */ |
||
33 | defined( 'ABSPATH' ) || exit; // Exit if accessed directly |
||
34 | |||
35 | /** |
||
36 | * Main Bulk_Delete class. |
||
37 | * |
||
38 | * Singleton @since 5.0 |
||
39 | */ |
||
40 | final class Bulk_Delete { |
||
41 | /** |
||
42 | * @var Bulk_Delete The one true Bulk_Delete |
||
43 | * |
||
44 | * @since 5.0 |
||
45 | */ |
||
46 | private static $instance; |
||
47 | |||
48 | /** |
||
49 | * Is the plugin is loaded? |
||
50 | * |
||
51 | * @since 5.7.0 |
||
52 | * |
||
53 | * @var bool |
||
54 | */ |
||
55 | private $loaded = false; |
||
56 | |||
57 | private $controller; |
||
58 | |||
59 | // version |
||
60 | const VERSION = '5.6.1'; |
||
61 | |||
62 | // Numeric constants |
||
63 | const MENU_ORDER = '26'; |
||
64 | |||
65 | // page slugs |
||
66 | const POSTS_PAGE_SLUG = 'bulk-delete-posts'; |
||
67 | const PAGES_PAGE_SLUG = 'bulk-delete-pages'; |
||
68 | const CRON_PAGE_SLUG = 'bulk-delete-cron'; |
||
69 | const ADDON_PAGE_SLUG = 'bulk-delete-addon'; |
||
70 | |||
71 | // JS constants |
||
72 | const JS_HANDLE = 'bulk-delete'; |
||
73 | const JS_VARIABLE = 'BulkWP'; |
||
74 | |||
75 | const CSS_HANDLE = 'bulk-delete'; |
||
76 | |||
77 | // Cron hooks |
||
78 | const CRON_HOOK_CATEGORY = 'do-bulk-delete-cat'; |
||
79 | const CRON_HOOK_POST_STATUS = 'do-bulk-delete-post-status'; |
||
80 | const CRON_HOOK_TAG = 'do-bulk-delete-tag'; |
||
81 | const CRON_HOOK_TAXONOMY = 'do-bulk-delete-taxonomy'; |
||
82 | const CRON_HOOK_POST_TYPE = 'do-bulk-delete-post-type'; |
||
83 | const CRON_HOOK_CUSTOM_FIELD = 'do-bulk-delete-custom-field'; |
||
84 | const CRON_HOOK_TITLE = 'do-bulk-delete-by-title'; |
||
85 | const CRON_HOOK_DUPLICATE_TITLE = 'do-bulk-delete-by-duplicate-title'; |
||
86 | const CRON_HOOK_POST_BY_ROLE = 'do-bulk-delete-posts-by-role'; |
||
87 | |||
88 | const CRON_HOOK_PAGES_STATUS = 'do-bulk-delete-pages-by-status'; |
||
89 | |||
90 | // meta boxes for delete posts |
||
91 | const BOX_POST_STATUS = 'bd_by_post_status'; |
||
92 | const BOX_CATEGORY = 'bd_by_category'; |
||
93 | const BOX_TAG = 'bd_by_tag'; |
||
94 | const BOX_TAX = 'bd_by_tax'; |
||
95 | const BOX_POST_TYPE = 'bd_by_post_type'; |
||
96 | const BOX_URL = 'bd_by_url'; |
||
97 | const BOX_POST_REVISION = 'bd_by_post_revision'; |
||
98 | const BOX_CUSTOM_FIELD = 'bd_by_custom_field'; |
||
99 | const BOX_TITLE = 'bd_by_title'; |
||
100 | const BOX_DUPLICATE_TITLE = 'bd_by_duplicate_title'; |
||
101 | const BOX_POST_FROM_TRASH = 'bd_posts_from_trash'; |
||
102 | const BOX_POST_BY_ROLE = 'bd_post_by_user_role'; |
||
103 | |||
104 | // meta boxes for delete pages |
||
105 | const BOX_PAGE_STATUS = 'bd_by_page_status'; |
||
106 | const BOX_PAGE_FROM_TRASH = 'bd_pages_from_trash'; |
||
107 | |||
108 | // Settings constants |
||
109 | const SETTING_OPTION_GROUP = 'bd_settings'; |
||
110 | const SETTING_OPTION_NAME = 'bd_licenses'; |
||
111 | const SETTING_SECTION_ID = 'bd_license_section'; |
||
112 | |||
113 | // Transient keys |
||
114 | const LICENSE_CACHE_KEY_PREFIX = 'bd-license_'; |
||
115 | |||
116 | // path variables |
||
117 | // Ideally these should be constants, but because of PHP's limitations, these are static variables |
||
118 | public static $PLUGIN_DIR; |
||
119 | public static $PLUGIN_URL; |
||
120 | public static $PLUGIN_FILE; |
||
121 | |||
122 | // Instance variables |
||
123 | public $translations; |
||
124 | public $posts_page; |
||
125 | public $pages_page; |
||
126 | public $cron_page; |
||
127 | public $addon_page; |
||
128 | public $settings_page; |
||
129 | public $meta_page; |
||
130 | public $misc_page; |
||
131 | public $display_activate_license_form = false; |
||
132 | |||
133 | // Deprecated. |
||
134 | // Will be removed in v6.0 |
||
135 | const CRON_HOOK_USER_ROLE = 'do-bulk-delete-users-by-role'; |
||
136 | public $users_page; |
||
137 | |||
138 | /** |
||
139 | * Main Bulk_Delete Instance. |
||
140 | * |
||
141 | * Insures that only one instance of Bulk_Delete exists in memory at any one |
||
142 | * time. Also prevents needing to define globals all over the place. |
||
143 | * |
||
144 | * @since 5.0 |
||
145 | * @static |
||
146 | * @staticvar array $instance |
||
147 | * |
||
148 | * @see BULK_DELETE() |
||
149 | * |
||
150 | * @uses Bulk_Delete::setup_paths() Setup the plugin paths |
||
151 | * @uses Bulk_Delete::includes() Include the required files |
||
152 | * @uses Bulk_Delete::load_textdomain() Load text domain for translation |
||
153 | * @uses Bulk_Delete::setup_actions() Setup the hooks and actions |
||
154 | * |
||
155 | * @return Bulk_Delete The one true instance of Bulk_Delete |
||
156 | */ |
||
157 | 5 | public static function get_instance() { |
|
158 | 5 | if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Bulk_Delete ) ) { |
|
159 | 1 | self::$instance = new Bulk_Delete(); |
|
160 | |||
161 | 1 | self::$instance->setup_paths(); |
|
162 | 1 | self::$instance->includes(); |
|
163 | } |
||
164 | |||
165 | 5 | return self::$instance; |
|
166 | } |
||
167 | |||
168 | /** |
||
169 | * Load the plugin if it is not loaded. |
||
170 | * |
||
171 | * This function will be invoked in the `plugins_loaded` hook. |
||
172 | */ |
||
173 | 1 | public function load() { |
|
174 | 1 | if ( $this->loaded ) { |
|
175 | return; |
||
176 | } |
||
177 | |||
178 | 1 | add_action( 'init', array( $this, 'on_init' ) ); |
|
179 | |||
180 | 1 | $this->setup_actions(); |
|
181 | |||
182 | 1 | $this->loaded = true; |
|
183 | |||
184 | /** |
||
185 | * Bulk Delete plugin loaded. |
||
186 | * |
||
187 | * @since 5.7.0 |
||
188 | */ |
||
189 | 1 | do_action( 'bd_loaded' ); |
|
190 | 1 | } |
|
191 | |||
192 | /** |
||
193 | * Throw error on object clone. |
||
194 | * |
||
195 | * The whole idea of the singleton design pattern is that there is a single |
||
196 | * object therefore, we don't want the object to be cloned. |
||
197 | * |
||
198 | * @since 5.0 |
||
199 | * @access protected |
||
200 | * |
||
201 | * @return void |
||
202 | */ |
||
203 | 1 | public function __clone() { |
|
204 | // Cloning instances of the class is forbidden |
||
205 | 1 | _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'bulk-delete' ), '5.0' ); |
|
206 | 1 | } |
|
207 | |||
208 | /** |
||
209 | * Disable unserializing of the class. |
||
210 | * |
||
211 | * @since 5.0 |
||
212 | * @access protected |
||
213 | * |
||
214 | * @return void |
||
215 | */ |
||
216 | 1 | public function __wakeup() { |
|
217 | // Unserializing instances of the class is forbidden |
||
218 | 1 | _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'bulk-delete' ), '5.0' ); |
|
219 | 1 | } |
|
220 | |||
221 | /** |
||
222 | * Setup plugin constants. |
||
223 | * |
||
224 | * @access private |
||
225 | * |
||
226 | * @since 5.0 |
||
227 | * |
||
228 | * @return void |
||
229 | */ |
||
230 | 1 | private function setup_paths() { |
|
231 | // Plugin Folder Path |
||
232 | 1 | self::$PLUGIN_DIR = plugin_dir_path( __FILE__ ); |
|
233 | |||
234 | // Plugin Folder URL |
||
235 | 1 | self::$PLUGIN_URL = plugin_dir_url( __FILE__ ); |
|
236 | |||
237 | // Plugin Root File |
||
238 | 1 | self::$PLUGIN_FILE = __FILE__; |
|
239 | 1 | } |
|
240 | |||
241 | /** |
||
242 | * Include required files. |
||
243 | * |
||
244 | * @access private |
||
245 | * |
||
246 | * @since 5.0 |
||
247 | * |
||
248 | * @return void |
||
249 | */ |
||
250 | 1 | private function includes() { |
|
251 | 1 | require_once self::$PLUGIN_DIR . '/include/base/class-bd-meta-box-module.php'; |
|
252 | 1 | require_once self::$PLUGIN_DIR . '/include/base/users/class-bd-user-meta-box-module.php'; |
|
253 | 1 | require_once self::$PLUGIN_DIR . '/include/base/class-bd-base-page.php'; |
|
254 | 1 | require_once self::$PLUGIN_DIR . '/include/base/class-bd-page.php'; |
|
255 | |||
256 | 1 | require_once self::$PLUGIN_DIR . '/include/controller/class-bd-controller.php'; |
|
257 | |||
258 | 1 | require_once self::$PLUGIN_DIR . '/include/ui/form.php'; |
|
259 | |||
260 | 1 | require_once self::$PLUGIN_DIR . '/include/posts/class-bulk-delete-posts.php'; |
|
261 | 1 | require_once self::$PLUGIN_DIR . '/include/pages/class-bulk-delete-pages.php'; |
|
262 | |||
263 | 1 | require_once self::$PLUGIN_DIR . '/include/users/class-bd-users-page.php'; |
|
264 | 1 | require_once self::$PLUGIN_DIR . '/include/users/modules/class-bulk-delete-users-by-user-role.php'; |
|
265 | 1 | require_once self::$PLUGIN_DIR . '/include/users/modules/class-bulk-delete-users-by-user-meta.php'; |
|
266 | |||
267 | 1 | require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-meta.php'; |
|
268 | 1 | require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-post-meta.php'; |
|
269 | 1 | require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-comment-meta.php'; |
|
270 | 1 | require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-user-meta.php'; |
|
271 | |||
272 | 1 | require_once self::$PLUGIN_DIR . '/include/misc/class-bulk-delete-misc.php'; |
|
273 | 1 | require_once self::$PLUGIN_DIR . '/include/misc/class-bulk-delete-jetpack-contact-form-messages.php'; |
|
274 | |||
275 | 1 | require_once self::$PLUGIN_DIR . '/include/settings/class-bd-settings-page.php'; |
|
276 | 1 | require_once self::$PLUGIN_DIR . '/include/settings/setting-helpers.php'; |
|
277 | 1 | require_once self::$PLUGIN_DIR . '/include/settings/class-bd-settings.php'; |
|
278 | |||
279 | 1 | require_once self::$PLUGIN_DIR . '/include/system-info/class-bd-system-info-page.php'; |
|
280 | |||
281 | 1 | require_once self::$PLUGIN_DIR . '/include/util/class-bd-util.php'; |
|
282 | 1 | require_once self::$PLUGIN_DIR . '/include/util/query.php'; |
|
283 | |||
284 | 1 | require_once self::$PLUGIN_DIR . '/include/compatibility/simple-login-log.php'; |
|
285 | 1 | require_once self::$PLUGIN_DIR . '/include/compatibility/the-event-calendar.php'; |
|
286 | 1 | require_once self::$PLUGIN_DIR . '/include/compatibility/woocommerce.php'; |
|
287 | 1 | require_once self::$PLUGIN_DIR . '/include/compatibility/advanced-custom-fields-pro.php'; |
|
288 | |||
289 | 1 | require_once self::$PLUGIN_DIR . '/include/deprecated/class-bulk-delete-users.php'; |
|
290 | 1 | require_once self::$PLUGIN_DIR . '/include/deprecated/deprecated.php'; |
|
291 | |||
292 | 1 | require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-addon.php'; |
|
293 | 1 | require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-base-addon.php'; |
|
294 | 1 | require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-scheduler-addon.php'; |
|
295 | |||
296 | 1 | require_once self::$PLUGIN_DIR . '/include/addons/addon-list.php'; |
|
297 | 1 | require_once self::$PLUGIN_DIR . '/include/addons/posts.php'; |
|
298 | 1 | require_once self::$PLUGIN_DIR . '/include/addons/pages.php'; |
|
299 | 1 | require_once self::$PLUGIN_DIR . '/include/addons/util.php'; |
|
300 | |||
301 | 1 | require_once self::$PLUGIN_DIR . '/include/license/class-bd-license.php'; |
|
302 | 1 | require_once self::$PLUGIN_DIR . '/include/license/class-bd-license-handler.php'; |
|
303 | 1 | require_once self::$PLUGIN_DIR . '/include/license/class-bd-edd-api-wrapper.php'; |
|
304 | |||
305 | 1 | require_once self::$PLUGIN_DIR . '/include/ui/admin-ui.php'; |
|
306 | 1 | require_once self::$PLUGIN_DIR . '/include/ui/class-bulk-delete-help-screen.php'; |
|
307 | 1 | } |
|
308 | |||
309 | /** |
||
310 | * Triggered when the `init` hook is fired. |
||
311 | * |
||
312 | * @since 5.7.0 |
||
313 | */ |
||
314 | 1 | public function on_init() { |
|
315 | 1 | $this->load_textdomain(); |
|
316 | 1 | } |
|
317 | |||
318 | /** |
||
319 | * Loads the plugin language files. |
||
320 | * |
||
321 | * @since 5.0 |
||
322 | */ |
||
323 | 1 | private function load_textdomain() { |
|
324 | // Load localization domain |
||
325 | 1 | $this->translations = dirname( plugin_basename( self::$PLUGIN_FILE ) ) . '/languages/'; |
|
326 | 1 | load_plugin_textdomain( 'bulk-delete', false, $this->translations ); |
|
327 | 1 | } |
|
328 | |||
329 | /** |
||
330 | * Loads the plugin's actions and hooks. |
||
331 | * |
||
332 | * @access private |
||
333 | * |
||
334 | * @since 5.0 |
||
335 | * |
||
336 | * @return void |
||
337 | */ |
||
338 | 1 | private function setup_actions() { |
|
339 | 1 | $this->controller = new BD_Controller(); |
|
0 ignored issues
–
show
|
|||
340 | |||
341 | 1 | add_action( 'admin_menu', array( $this, 'add_menu' ) ); |
|
342 | |||
343 | 1 | add_filter( 'bd_help_tooltip', 'bd_generate_help_tooltip', 10, 2 ); |
|
344 | |||
345 | 1 | if ( defined( 'BD_DEBUG' ) && BD_DEBUG ) { |
|
346 | add_action( 'bd_after_query', array( $this, 'log_sql_query' ) ); |
||
347 | } |
||
348 | 1 | } |
|
349 | |||
350 | /** |
||
351 | * Log SQL query used by Bulk Delete. |
||
352 | * |
||
353 | * Query is logged only when `BD_DEBUG` is set. |
||
354 | * |
||
355 | * @since 5.6 |
||
356 | * |
||
357 | * @param \WP_Query $wp_query WP Query object. |
||
358 | */ |
||
359 | public function log_sql_query( $wp_query ) { |
||
360 | $query = $wp_query->request; |
||
361 | |||
362 | /** |
||
363 | * Bulk Delete query is getting logged. |
||
364 | * |
||
365 | * @since 5.6 |
||
366 | * |
||
367 | * @param string $query Bulk Delete SQL Query. |
||
368 | */ |
||
369 | do_action( 'bd_log_sql_query', $query ); |
||
370 | |||
371 | error_log( 'Bulk Delete Query: ' . $query ); |
||
372 | } |
||
373 | |||
374 | /** |
||
375 | * Add navigation menu. |
||
376 | */ |
||
377 | public function add_menu() { |
||
378 | 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 ); |
||
379 | |||
380 | $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' ) ); |
||
381 | $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' ) ); |
||
382 | |||
383 | /** |
||
384 | * Runs just after adding all *delete* menu items to Bulk WP main menu. |
||
385 | * |
||
386 | * This action is primarily for adding extra *delete* menu items to the Bulk WP main menu. |
||
387 | * |
||
388 | * @since 5.3 |
||
389 | */ |
||
390 | do_action( 'bd_after_primary_menus' ); |
||
391 | |||
392 | /** |
||
393 | * Runs just before adding non-action menu items to Bulk WP main menu. |
||
394 | * |
||
395 | * This action is primarily for adding extra menu items before non-action menu items to the Bulk WP main menu. |
||
396 | * |
||
397 | * @since 5.3 |
||
398 | */ |
||
399 | do_action( 'bd_before_secondary_menus' ); |
||
400 | |||
401 | $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' ) ); |
||
402 | $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' ) ); |
||
403 | |||
404 | /** |
||
405 | * Runs just after adding all menu items to Bulk WP main menu. |
||
406 | * |
||
407 | * This action is primarily for adding extra menu items to the Bulk WP main menu. |
||
408 | * |
||
409 | * @since 5.3 |
||
410 | */ |
||
411 | do_action( 'bd_after_all_menus' ); |
||
412 | |||
413 | // enqueue JavaScript |
||
414 | add_action( 'admin_print_scripts-' . $this->posts_page, array( $this, 'add_script' ) ); |
||
415 | add_action( 'admin_print_scripts-' . $this->pages_page, array( $this, 'add_script' ) ); |
||
416 | |||
417 | // delete posts page |
||
418 | add_action( "load-{$this->posts_page}", array( $this, 'add_delete_posts_settings_panel' ) ); |
||
419 | add_action( "add_meta_boxes_{$this->posts_page}", array( $this, 'add_delete_posts_meta_boxes' ) ); |
||
420 | |||
421 | // delete pages page |
||
422 | add_action( "load-{$this->pages_page}", array( $this, 'add_delete_pages_settings_panel' ) ); |
||
423 | add_action( "add_meta_boxes_{$this->pages_page}", array( $this, 'add_delete_pages_meta_boxes' ) ); |
||
424 | } |
||
425 | |||
426 | /** |
||
427 | * Add settings Panel for delete posts page. |
||
428 | */ |
||
429 | public function add_delete_posts_settings_panel() { |
||
430 | /** |
||
431 | * Add contextual help for admin screens. |
||
432 | * |
||
433 | * @since 5.1 |
||
434 | */ |
||
435 | do_action( 'bd_add_contextual_help', $this->posts_page ); |
||
436 | |||
437 | /* Trigger the add_meta_boxes hooks to allow meta boxes to be added */ |
||
438 | do_action( 'add_meta_boxes_' . $this->posts_page, null ); |
||
439 | |||
440 | /* Enqueue WordPress' script for handling the meta boxes */ |
||
441 | wp_enqueue_script( 'postbox' ); |
||
442 | } |
||
443 | |||
444 | /** |
||
445 | * Register meta boxes for delete posts page. |
||
446 | */ |
||
447 | public function add_delete_posts_meta_boxes() { |
||
448 | add_meta_box( self::BOX_POST_STATUS , __( 'By Post Status' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_status_box' , $this->posts_page , 'advanced' ); |
||
449 | add_meta_box( self::BOX_CATEGORY , __( 'By Category' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_category_box' , $this->posts_page , 'advanced' ); |
||
450 | add_meta_box( self::BOX_TAG , __( 'By Tag' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_tag_box' , $this->posts_page , 'advanced' ); |
||
451 | add_meta_box( self::BOX_TAX , __( 'By Custom Taxonomy' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_taxonomy_box' , $this->posts_page , 'advanced' ); |
||
452 | add_meta_box( self::BOX_POST_TYPE , __( 'By Custom Post Type' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_post_type_box' , $this->posts_page , 'advanced' ); |
||
453 | add_meta_box( self::BOX_URL , __( 'By URL' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_url_box' , $this->posts_page , 'advanced' ); |
||
454 | add_meta_box( self::BOX_POST_REVISION , __( 'By Post Revision' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_posts_by_revision_box' , $this->posts_page , 'advanced' ); |
||
455 | |||
456 | /** |
||
457 | * Add meta box in delete posts page |
||
458 | * This hook can be used for adding additional meta boxes in delete posts page. |
||
459 | * |
||
460 | * @since 5.3 |
||
461 | */ |
||
462 | do_action( 'bd_add_meta_box_for_posts' ); |
||
463 | } |
||
464 | |||
465 | /** |
||
466 | * Setup settings panel for delete pages page. |
||
467 | * |
||
468 | * @since 5.0 |
||
469 | */ |
||
470 | public function add_delete_pages_settings_panel() { |
||
471 | /** |
||
472 | * Add contextual help for admin screens. |
||
473 | * |
||
474 | * @since 5.1 |
||
475 | */ |
||
476 | do_action( 'bd_add_contextual_help', $this->pages_page ); |
||
477 | |||
478 | /* Trigger the add_meta_boxes hooks to allow meta boxes to be added */ |
||
479 | do_action( 'add_meta_boxes_' . $this->pages_page, null ); |
||
480 | |||
481 | /* Enqueue WordPress' script for handling the meta boxes */ |
||
482 | wp_enqueue_script( 'postbox' ); |
||
483 | } |
||
484 | |||
485 | /** |
||
486 | * Register meta boxes for delete pages page. |
||
487 | * |
||
488 | * @since 5.0 |
||
489 | */ |
||
490 | public function add_delete_pages_meta_boxes() { |
||
491 | add_meta_box( self::BOX_PAGE_STATUS, __( 'By Page Status', 'bulk-delete' ), 'Bulk_Delete_Pages::render_delete_pages_by_status_box', $this->pages_page, 'advanced' ); |
||
492 | |||
493 | /** |
||
494 | * Add meta box in delete pages page |
||
495 | * This hook can be used for adding additional meta boxes in delete pages page. |
||
496 | * |
||
497 | * @since 5.3 |
||
498 | */ |
||
499 | do_action( 'bd_add_meta_box_for_pages' ); |
||
500 | } |
||
501 | |||
502 | /** |
||
503 | * Enqueue Scripts and Styles. |
||
504 | */ |
||
505 | public function add_script() { |
||
506 | global $wp_scripts; |
||
507 | |||
508 | /** |
||
509 | * Runs just before enqueuing scripts and styles in all Bulk WP admin pages. |
||
510 | * |
||
511 | * This action is primarily for registering or deregistering additional scripts or styles. |
||
512 | * |
||
513 | * @since 5.5.1 |
||
514 | */ |
||
515 | do_action( 'bd_before_admin_enqueue_scripts' ); |
||
516 | |||
517 | wp_enqueue_script( 'jquery-ui-timepicker', plugins_url( '/assets/js/jquery-ui-timepicker-addon.min.js', __FILE__ ), array( 'jquery-ui-slider', 'jquery-ui-datepicker' ), '1.5.4', true ); |
||
518 | wp_enqueue_style( 'jquery-ui-timepicker', plugins_url( '/assets/css/jquery-ui-timepicker-addon.min.css', __FILE__ ), array(), '1.5.4' ); |
||
519 | |||
520 | wp_enqueue_script( 'select2', plugins_url( '/assets/js/select2.min.js', __FILE__ ), array( 'jquery' ), '4.0.0', true ); |
||
521 | wp_enqueue_style( 'select2', plugins_url( '/assets/css/select2.min.css', __FILE__ ), array(), '4.0.0' ); |
||
522 | |||
523 | $postfix = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) ? '' : '.min'; |
||
524 | wp_enqueue_script( self::JS_HANDLE, plugins_url( '/assets/js/bulk-delete' . $postfix . '.js', __FILE__ ), array( 'jquery-ui-timepicker', 'jquery-ui-tooltip' ), self::VERSION, true ); |
||
525 | wp_enqueue_style( self::CSS_HANDLE, plugins_url( '/assets/css/bulk-delete' . $postfix . '.css', __FILE__ ), array( 'select2' ), self::VERSION ); |
||
526 | |||
527 | $ui = $wp_scripts->query( 'jquery-ui-core' ); |
||
528 | $url = "//ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/smoothness/jquery-ui.css"; |
||
529 | wp_enqueue_style( 'jquery-ui-smoothness', $url, false, $ui->ver ); |
||
530 | |||
531 | /** |
||
532 | * Filter JavaScript array. |
||
533 | * |
||
534 | * This filter can be used to extend the array that is passed to JavaScript |
||
535 | * |
||
536 | * @since 5.4 |
||
537 | */ |
||
538 | $translation_array = apply_filters( 'bd_javascript_array', array( |
||
539 | 'msg' => array(), |
||
540 | 'validators' => array(), |
||
541 | 'dt_iterators' => array(), |
||
542 | 'pre_action_msg' => array(), |
||
543 | 'error_msg' => array(), |
||
544 | 'pro_iterators' => array(), |
||
545 | ) ); |
||
546 | wp_localize_script( self::JS_HANDLE, self::JS_VARIABLE, $translation_array ); |
||
547 | |||
548 | /** |
||
549 | * Runs just after enqueuing scripts and styles in all Bulk WP admin pages. |
||
550 | * |
||
551 | * This action is primarily for registering additional scripts or styles. |
||
552 | * |
||
553 | * @since 5.5.1 |
||
554 | */ |
||
555 | do_action( 'bd_after_admin_enqueue_scripts' ); |
||
556 | } |
||
557 | |||
558 | /** |
||
559 | * Show the delete posts page. |
||
560 | * |
||
561 | * @Todo Move this function to Bulk_Delete_Posts class |
||
562 | */ |
||
563 | public function display_posts_page() { |
||
564 | ?> |
||
565 | <div class="wrap"> |
||
566 | <h2><?php _e( 'Bulk Delete Posts', 'bulk-delete' );?></h2> |
||
567 | <?php settings_errors(); ?> |
||
568 | |||
569 | <form method = "post"> |
||
570 | <?php |
||
571 | // nonce for bulk delete |
||
572 | wp_nonce_field( 'sm-bulk-delete-posts', 'sm-bulk-delete-posts-nonce' ); |
||
573 | |||
574 | /* Used to save closed meta boxes and their order */ |
||
575 | wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
||
576 | wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
||
577 | ?> |
||
578 | <div id = "poststuff"> |
||
579 | <div id="post-body" class="metabox-holder columns-1"> |
||
580 | |||
581 | <div class="notice notice-warning"> |
||
582 | <p><strong><?php _e( 'WARNING: Posts deleted once cannot be retrieved back. Use with caution.', 'bulk-delete' ); ?></strong></p> |
||
583 | </div> |
||
584 | |||
585 | <div id="postbox-container-2" class="postbox-container"> |
||
586 | <?php do_meta_boxes( '', 'advanced', null ); ?> |
||
587 | </div> <!-- #postbox-container-2 --> |
||
588 | |||
589 | </div> <!-- #post-body --> |
||
590 | </div><!-- #poststuff --> |
||
591 | </form> |
||
592 | </div><!-- .wrap --> |
||
593 | |||
594 | <?php |
||
595 | /** |
||
596 | * Runs just before displaying the footer text in the "Bulk Delete Posts" admin page. |
||
597 | * |
||
598 | * This action is primarily for adding extra content in the footer of "Bulk Delete Posts" admin page. |
||
599 | * |
||
600 | * @since 5.0 |
||
601 | */ |
||
602 | do_action( 'bd_admin_footer_posts_page' ); |
||
603 | } |
||
604 | |||
605 | /** |
||
606 | * Display the delete pages page. |
||
607 | * |
||
608 | * @Todo Move this function to Bulk_Delete_Pages class |
||
609 | * |
||
610 | * @since 5.0 |
||
611 | */ |
||
612 | public function display_pages_page() { |
||
613 | ?> |
||
614 | <div class="wrap"> |
||
615 | <h2><?php _e( 'Bulk Delete Pages', 'bulk-delete' );?></h2> |
||
616 | <?php settings_errors(); ?> |
||
617 | |||
618 | <form method = "post"> |
||
619 | <?php |
||
620 | // nonce for bulk delete |
||
621 | wp_nonce_field( 'sm-bulk-delete-pages', 'sm-bulk-delete-pages-nonce' ); |
||
622 | |||
623 | /* Used to save closed meta boxes and their order */ |
||
624 | wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
||
625 | wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
||
626 | ?> |
||
627 | <div id = "poststuff"> |
||
628 | <div id="post-body" class="metabox-holder columns-1"> |
||
629 | |||
630 | <div class="notice notice-warning"> |
||
631 | <p><strong><?php _e( 'WARNING: Pages deleted once cannot be retrieved back. Use with caution.', 'bulk-delete' ); ?></strong></p> |
||
632 | </div> |
||
633 | |||
634 | <div id="postbox-container-2" class="postbox-container"> |
||
635 | <?php do_meta_boxes( '', 'advanced', null ); ?> |
||
636 | </div> <!-- #postbox-container-2 --> |
||
637 | |||
638 | </div> <!-- #post-body --> |
||
639 | </div><!-- #poststuff --> |
||
640 | </form> |
||
641 | </div><!-- .wrap --> |
||
642 | |||
643 | <?php |
||
644 | /** |
||
645 | * Runs just before displaying the footer text in the "Bulk Delete Pages" admin page. |
||
646 | * |
||
647 | * This action is primarily for adding extra content in the footer of "Bulk Delete Pages" admin page. |
||
648 | * |
||
649 | * @since 5.0 |
||
650 | */ |
||
651 | do_action( 'bd_admin_footer_pages_page' ); |
||
652 | } |
||
653 | |||
654 | /** |
||
655 | * Display the schedule page. |
||
656 | */ |
||
657 | public function display_cron_page() { |
||
658 | if ( ! class_exists( 'WP_List_Table' ) ) { |
||
659 | require_once ABSPATH . WPINC . '/class-wp-list-table.php'; |
||
660 | } |
||
661 | |||
662 | if ( ! class_exists( 'Cron_List_Table' ) ) { |
||
663 | require_once self::$PLUGIN_DIR . '/include/cron/class-cron-list-table.php'; |
||
664 | } |
||
665 | |||
666 | // Prepare Table of elements |
||
667 | $cron_list_table = new Cron_List_Table(); |
||
668 | $cron_list_table->prepare_items(); |
||
669 | ?> |
||
670 | <div class="wrap"> |
||
671 | <h2><?php _e( 'Bulk Delete Schedules', 'bulk-delete' );?></h2> |
||
672 | <?php settings_errors(); ?> |
||
673 | <?php |
||
674 | // Table of elements |
||
675 | $cron_list_table->display(); |
||
676 | bd_display_available_addon_list(); |
||
677 | ?> |
||
678 | </div> |
||
679 | <?php |
||
680 | /** |
||
681 | * Runs just before displaying the footer text in the "Schedules" admin page. |
||
682 | * |
||
683 | * This action is primarily for adding extra content in the footer of "Schedules" admin page. |
||
684 | * |
||
685 | * @since 5.0 |
||
686 | */ |
||
687 | do_action( 'bd_admin_footer_cron_page' ); |
||
688 | } |
||
689 | } |
||
690 | |||
691 | /** |
||
692 | * The main function responsible for returning the one true Bulk_Delete |
||
693 | * Instance to functions everywhere. |
||
694 | * |
||
695 | * Use this function like you would a global variable, except without needing |
||
696 | * to declare the global. |
||
697 | * |
||
698 | * Example: `<?php $bulk_delete = BULK_DELETE(); ?>` |
||
699 | * |
||
700 | * @since 5.0 |
||
701 | * |
||
702 | * @return Bulk_Delete The one true Bulk_Delete Instance |
||
703 | */ |
||
704 | function BULK_DELETE() { |
||
705 | 1 | return Bulk_Delete::get_instance(); |
|
706 | } |
||
707 | |||
708 | /** |
||
709 | * Load Bulk Delete plugin. |
||
710 | * |
||
711 | * @since 5.7.0 |
||
712 | */ |
||
713 | function load_bulk_delete() { |
||
714 | 1 | $bulk_delete = BULK_DELETE(); |
|
715 | |||
716 | 1 | add_action( 'plugins_loaded', array( $bulk_delete, 'load' ), 101 ); |
|
717 | 1 | } |
|
718 | |||
719 | load_bulk_delete(); |
||
720 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths