sudar /
bulk-delete
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 | * |
||
| 20 | * @package BulkDelete |
||
| 21 | */ |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Copyright 2009 Sudar Muthu (email : [email protected]) |
||
| 25 | * This program is free software; you can redistribute it and/or modify |
||
| 26 | * it under the terms of the GNU General Public License, version 2, as |
||
| 27 | * published by the Free Software Foundation. |
||
| 28 | * This program is distributed in the hope that it will be useful, |
||
| 29 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 30 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 31 | * GNU General Public License for more details. |
||
| 32 | * You should have received a copy of the GNU General Public License |
||
| 33 | * along with this program; if not, write to the Free Software |
||
| 34 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
||
| 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 | * @var Bulk_Delete The one true Bulk_Delete |
||
| 46 | * |
||
| 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 | * |
||
| 142 | * @see BULK_DELETE() |
||
| 143 | * |
||
| 144 | * @uses Bulk_Delete::setup_paths() Setup the plugin paths |
||
| 145 | * @uses Bulk_Delete::includes() Include the required files |
||
| 146 | * @uses Bulk_Delete::load_textdomain() Load text domain for translation |
||
| 147 | * @uses Bulk_Delete::setup_actions() Setup the hooks and actions |
||
| 148 | * |
||
| 149 | * @return Bulk_Delete The one true instance of Bulk_Delete |
||
| 150 | */ |
||
| 151 | public static function instance() { |
||
| 152 | if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Bulk_Delete ) ) { |
||
| 153 | self::$instance = new Bulk_Delete; |
||
| 154 | self::$instance->setup_paths(); |
||
| 155 | self::$instance->includes(); |
||
| 156 | self::$instance->load_textdomain(); |
||
| 157 | self::$instance->setup_actions(); |
||
| 158 | } |
||
| 159 | |||
| 160 | return self::$instance; |
||
| 161 | } |
||
| 162 | |||
| 163 | /** |
||
| 164 | * Throw error on object clone. |
||
| 165 | * |
||
| 166 | * The whole idea of the singleton design pattern is that there is a single |
||
| 167 | * object therefore, we don't want the object to be cloned. |
||
| 168 | * |
||
| 169 | * @since 5.0 |
||
| 170 | * @access protected |
||
| 171 | * |
||
| 172 | * @return void |
||
| 173 | */ |
||
| 174 | public function __clone() { |
||
| 175 | // Cloning instances of the class is forbidden |
||
| 176 | _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'bulk-delete' ), '5.0' ); |
||
| 177 | } |
||
| 178 | |||
| 179 | /** |
||
| 180 | * Disable unserializing of the class. |
||
| 181 | * |
||
| 182 | * @since 5.0 |
||
| 183 | * @access protected |
||
| 184 | * |
||
| 185 | * @return void |
||
| 186 | */ |
||
| 187 | public function __wakeup() { |
||
| 188 | // Unserializing instances of the class is forbidden |
||
| 189 | _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'bulk-delete' ), '5.0' ); |
||
| 190 | } |
||
| 191 | |||
| 192 | /** |
||
| 193 | * Setup plugin constants. |
||
| 194 | * |
||
| 195 | * @access private |
||
| 196 | * |
||
| 197 | * @since 5.0 |
||
| 198 | * |
||
| 199 | * @return void |
||
| 200 | */ |
||
| 201 | private function setup_paths() { |
||
| 202 | // Plugin Folder Path |
||
| 203 | self::$PLUGIN_DIR = plugin_dir_path( __FILE__ ); |
||
| 204 | |||
| 205 | // Plugin Folder URL |
||
| 206 | self::$PLUGIN_URL = plugin_dir_url( __FILE__ ); |
||
| 207 | |||
| 208 | // Plugin Root File |
||
| 209 | self::$PLUGIN_FILE = __FILE__; |
||
| 210 | } |
||
| 211 | |||
| 212 | /** |
||
| 213 | * Include required files. |
||
| 214 | * |
||
| 215 | * @access private |
||
| 216 | * |
||
| 217 | * @since 5.0 |
||
| 218 | * |
||
| 219 | * @return void |
||
| 220 | */ |
||
| 221 | private function includes() { |
||
| 222 | require_once self::$PLUGIN_DIR . '/include/base/class-bd-meta-box-module.php'; |
||
| 223 | require_once self::$PLUGIN_DIR . '/include/base/users/class-bd-user-meta-box-module.php'; |
||
| 224 | require_once self::$PLUGIN_DIR . '/include/base/class-bd-base-page.php'; |
||
| 225 | require_once self::$PLUGIN_DIR . '/include/base/class-bd-page.php'; |
||
| 226 | |||
| 227 | require_once self::$PLUGIN_DIR . '/include/controller/class-bd-controller.php'; |
||
| 228 | |||
| 229 | require_once self::$PLUGIN_DIR . '/include/ui/form.php'; |
||
| 230 | |||
| 231 | require_once self::$PLUGIN_DIR . '/include/posts/class-bulk-delete-posts.php'; |
||
| 232 | require_once self::$PLUGIN_DIR . '/include/pages/class-bulk-delete-pages.php'; |
||
| 233 | |||
| 234 | require_once self::$PLUGIN_DIR . '/include/users/class-bd-users-page.php'; |
||
| 235 | require_once self::$PLUGIN_DIR . '/include/users/modules/class-bulk-delete-users-by-user-role.php'; |
||
| 236 | require_once self::$PLUGIN_DIR . '/include/users/modules/class-bulk-delete-users-by-user-meta.php'; |
||
| 237 | |||
| 238 | require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-meta.php'; |
||
| 239 | require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-post-meta.php'; |
||
| 240 | require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-comment-meta.php'; |
||
| 241 | require_once self::$PLUGIN_DIR . '/include/meta/class-bulk-delete-user-meta.php'; |
||
| 242 | |||
| 243 | require_once self::$PLUGIN_DIR . '/include/misc/class-bulk-delete-misc.php'; |
||
| 244 | require_once self::$PLUGIN_DIR . '/include/misc/class-bulk-delete-jetpack-contact-form-messages.php'; |
||
| 245 | |||
| 246 | require_once self::$PLUGIN_DIR . '/include/settings/class-bd-settings-page.php'; |
||
| 247 | require_once self::$PLUGIN_DIR . '/include/settings/setting-helpers.php'; |
||
| 248 | require_once self::$PLUGIN_DIR . '/include/settings/class-bd-settings.php'; |
||
| 249 | |||
| 250 | require_once self::$PLUGIN_DIR . '/include/system-info/class-bd-system-info-page.php'; |
||
| 251 | |||
| 252 | require_once self::$PLUGIN_DIR . '/include/util/class-bd-util.php'; |
||
| 253 | require_once self::$PLUGIN_DIR . '/include/util/query.php'; |
||
| 254 | |||
| 255 | require_once self::$PLUGIN_DIR . '/include/compatibility/simple-login-log.php'; |
||
| 256 | require_once self::$PLUGIN_DIR . '/include/compatibility/the-event-calendar.php'; |
||
| 257 | require_once self::$PLUGIN_DIR . '/include/compatibility/woocommerce.php'; |
||
| 258 | require_once self::$PLUGIN_DIR . '/include/compatibility/advanced-custom-fields-pro.php'; |
||
| 259 | |||
| 260 | require_once self::$PLUGIN_DIR . '/include/deprecated/class-bulk-delete-users.php'; |
||
| 261 | require_once self::$PLUGIN_DIR . '/include/deprecated/deprecated.php'; |
||
| 262 | |||
| 263 | require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-addon.php'; |
||
| 264 | require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-base-addon.php'; |
||
| 265 | require_once self::$PLUGIN_DIR . '/include/addons/base/class-bd-scheduler-addon.php'; |
||
| 266 | |||
| 267 | require_once self::$PLUGIN_DIR . '/include/addons/addon-list.php'; |
||
| 268 | require_once self::$PLUGIN_DIR . '/include/addons/posts.php'; |
||
| 269 | require_once self::$PLUGIN_DIR . '/include/addons/pages.php'; |
||
| 270 | require_once self::$PLUGIN_DIR . '/include/addons/util.php'; |
||
| 271 | |||
| 272 | require_once self::$PLUGIN_DIR . '/include/license/class-bd-license.php'; |
||
| 273 | require_once self::$PLUGIN_DIR . '/include/license/class-bd-license-handler.php'; |
||
| 274 | require_once self::$PLUGIN_DIR . '/include/license/class-bd-edd-api-wrapper.php'; |
||
| 275 | |||
| 276 | require_once self::$PLUGIN_DIR . '/include/ui/admin-ui.php'; |
||
| 277 | require_once self::$PLUGIN_DIR . '/include/ui/class-bulk-delete-help-screen.php'; |
||
| 278 | } |
||
| 279 | |||
| 280 | /** |
||
| 281 | * Loads the plugin language files. |
||
| 282 | * |
||
| 283 | * @since 5.0 |
||
| 284 | */ |
||
| 285 | public function load_textdomain() { |
||
| 286 | // Load localization domain |
||
| 287 | $this->translations = dirname( plugin_basename( self::$PLUGIN_FILE ) ) . '/languages/'; |
||
| 288 | load_plugin_textdomain( 'bulk-delete', false, $this->translations ); |
||
| 289 | } |
||
| 290 | |||
| 291 | /** |
||
| 292 | * Loads the plugin's actions and hooks. |
||
| 293 | * |
||
| 294 | * @access private |
||
| 295 | * |
||
| 296 | * @since 5.0 |
||
| 297 | * |
||
| 298 | * @return void |
||
| 299 | */ |
||
| 300 | private function setup_actions() { |
||
| 301 | $this->controller = new BD_Controller(); |
||
| 302 | |||
| 303 | add_action( 'admin_menu', array( $this, 'add_menu' ) ); |
||
| 304 | } |
||
| 305 | |||
| 306 | /** |
||
| 307 | * Add navigation menu. |
||
| 308 | */ |
||
| 309 | public function add_menu() { |
||
| 310 | 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 ); |
||
| 311 | |||
| 312 | $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' ) ); |
||
| 313 | $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' ) ); |
||
| 314 | |||
| 315 | /** |
||
| 316 | * Runs just after adding all *delete* menu items to Bulk WP main menu. |
||
| 317 | * |
||
| 318 | * This action is primarily for adding extra *delete* menu items to the Bulk WP main menu. |
||
| 319 | * |
||
| 320 | * @since 5.3 |
||
| 321 | */ |
||
| 322 | do_action( 'bd_after_primary_menus' ); |
||
| 323 | |||
| 324 | /** |
||
| 325 | * Runs just before adding non-action menu items to Bulk WP main menu. |
||
| 326 | * |
||
| 327 | * This action is primarily for adding extra menu items before non-action menu items to the Bulk WP main menu. |
||
| 328 | * |
||
| 329 | * @since 5.3 |
||
| 330 | */ |
||
| 331 | do_action( 'bd_before_secondary_menus' ); |
||
| 332 | |||
| 333 | $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' ) ); |
||
| 334 | $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' ) ); |
||
| 335 | |||
| 336 | /** |
||
| 337 | * Runs just after adding all menu items to Bulk WP main menu. |
||
| 338 | * |
||
| 339 | * This action is primarily for adding extra menu items to the Bulk WP main menu. |
||
| 340 | * |
||
| 341 | * @since 5.3 |
||
| 342 | */ |
||
| 343 | do_action( 'bd_after_all_menus' ); |
||
| 344 | |||
| 345 | // enqueue JavaScript |
||
| 346 | add_action( 'admin_print_scripts-' . $this->posts_page, array( $this, 'add_script' ) ); |
||
| 347 | add_action( 'admin_print_scripts-' . $this->pages_page, array( $this, 'add_script' ) ); |
||
| 348 | |||
| 349 | // delete posts page |
||
| 350 | add_action( "load-{$this->posts_page}", array( $this, 'add_delete_posts_settings_panel' ) ); |
||
| 351 | add_action( "add_meta_boxes_{$this->posts_page}", array( $this, 'add_delete_posts_meta_boxes' ) ); |
||
| 352 | |||
| 353 | // delete pages page |
||
| 354 | add_action( "load-{$this->pages_page}", array( $this, 'add_delete_pages_settings_panel' ) ); |
||
| 355 | add_action( "add_meta_boxes_{$this->pages_page}", array( $this, 'add_delete_pages_meta_boxes' ) ); |
||
| 356 | } |
||
| 357 | |||
| 358 | /** |
||
| 359 | * Add settings Panel for delete posts page. |
||
| 360 | */ |
||
| 361 | public function add_delete_posts_settings_panel() { |
||
| 362 | /** |
||
| 363 | * Add contextual help for admin screens. |
||
| 364 | * |
||
| 365 | * @since 5.1 |
||
| 366 | */ |
||
| 367 | do_action( 'bd_add_contextual_help', $this->posts_page ); |
||
| 368 | |||
| 369 | /* Trigger the add_meta_boxes hooks to allow meta boxes to be added */ |
||
| 370 | do_action( 'add_meta_boxes_' . $this->posts_page, null ); |
||
| 371 | |||
| 372 | /* Enqueue WordPress' script for handling the meta boxes */ |
||
| 373 | wp_enqueue_script( 'postbox' ); |
||
| 374 | } |
||
| 375 | |||
| 376 | /** |
||
| 377 | * Register meta boxes for delete posts page. |
||
| 378 | */ |
||
| 379 | public function add_delete_posts_meta_boxes() { |
||
| 380 | 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' ); |
||
| 381 | add_meta_box( self::BOX_CATEGORY , __( 'By Category' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_category_box' , $this->posts_page , 'advanced' ); |
||
| 382 | add_meta_box( self::BOX_TAG , __( 'By Tag' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_tag_box' , $this->posts_page , 'advanced' ); |
||
| 383 | add_meta_box( self::BOX_TAX , __( 'By Custom Taxonomy' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_taxonomy_box' , $this->posts_page , 'advanced' ); |
||
| 384 | 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' ); |
||
| 385 | add_meta_box( self::BOX_URL , __( 'By URL' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_delete_posts_by_url_box' , $this->posts_page , 'advanced' ); |
||
| 386 | add_meta_box( self::BOX_POST_REVISION , __( 'By Post Revision' , 'bulk-delete' ) , 'Bulk_Delete_Posts::render_posts_by_revision_box' , $this->posts_page , 'advanced' ); |
||
| 387 | |||
| 388 | /** |
||
| 389 | * Add meta box in delete posts page |
||
| 390 | * This hook can be used for adding additional meta boxes in delete posts page. |
||
| 391 | * |
||
| 392 | * @since 5.3 |
||
| 393 | */ |
||
| 394 | do_action( 'bd_add_meta_box_for_posts' ); |
||
| 395 | } |
||
| 396 | |||
| 397 | /** |
||
| 398 | * Setup settings panel for delete pages page. |
||
| 399 | * |
||
| 400 | * @since 5.0 |
||
| 401 | */ |
||
| 402 | public function add_delete_pages_settings_panel() { |
||
| 403 | /** |
||
| 404 | * Add contextual help for admin screens. |
||
| 405 | * |
||
| 406 | * @since 5.1 |
||
| 407 | */ |
||
| 408 | do_action( 'bd_add_contextual_help', $this->pages_page ); |
||
| 409 | |||
| 410 | /* Trigger the add_meta_boxes hooks to allow meta boxes to be added */ |
||
| 411 | do_action( 'add_meta_boxes_' . $this->pages_page, null ); |
||
| 412 | |||
| 413 | /* Enqueue WordPress' script for handling the meta boxes */ |
||
| 414 | wp_enqueue_script( 'postbox' ); |
||
| 415 | } |
||
| 416 | |||
| 417 | /** |
||
| 418 | * Register meta boxes for delete pages page. |
||
| 419 | * |
||
| 420 | * @since 5.0 |
||
| 421 | */ |
||
| 422 | public function add_delete_pages_meta_boxes() { |
||
| 423 | 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' ); |
||
| 424 | |||
| 425 | /** |
||
| 426 | * Add meta box in delete pages page |
||
| 427 | * This hook can be used for adding additional meta boxes in delete pages page. |
||
| 428 | * |
||
| 429 | * @since 5.3 |
||
| 430 | */ |
||
| 431 | do_action( 'bd_add_meta_box_for_pages' ); |
||
| 432 | } |
||
| 433 | |||
| 434 | /** |
||
| 435 | * Enqueue Scripts and Styles. |
||
| 436 | */ |
||
| 437 | public function add_script() { |
||
| 438 | global $wp_scripts; |
||
| 439 | |||
| 440 | /** |
||
| 441 | * Runs just before enqueuing scripts and styles in all Bulk WP admin pages. |
||
| 442 | * |
||
| 443 | * This action is primarily for registering or deregistering additional scripts or styles. |
||
| 444 | * |
||
| 445 | * @since 5.5.1 |
||
| 446 | */ |
||
| 447 | do_action( 'bd_before_admin_enqueue_scripts' ); |
||
| 448 | |||
| 449 | 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 ); |
||
| 450 | wp_enqueue_style( 'jquery-ui-timepicker', plugins_url( '/assets/css/jquery-ui-timepicker-addon.min.css', __FILE__ ), array(), '1.5.4' ); |
||
| 451 | |||
| 452 | wp_enqueue_script( 'select2', plugins_url( '/assets/js/select2.min.js', __FILE__ ), array( 'jquery' ), '4.0.0', true ); |
||
| 453 | wp_enqueue_style( 'select2', plugins_url( '/assets/css/select2.min.css', __FILE__ ), array(), '4.0.0' ); |
||
| 454 | |||
| 455 | $postfix = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) ? '' : '.min'; |
||
| 456 | wp_enqueue_script( self::JS_HANDLE, plugins_url( '/assets/js/bulk-delete' . $postfix . '.js', __FILE__ ), array( 'jquery-ui-timepicker' ), self::VERSION, true ); |
||
| 457 | wp_enqueue_style( self::CSS_HANDLE, plugins_url( '/assets/css/bulk-delete' . $postfix . '.css', __FILE__ ), array( 'select2' ), self::VERSION ); |
||
| 458 | |||
| 459 | $ui = $wp_scripts->query( 'jquery-ui-core' ); |
||
|
0 ignored issues
–
show
|
|||
| 460 | $url = "//ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/smoothness/jquery-ui.css"; |
||
| 461 | wp_enqueue_style( 'jquery-ui-smoothness', $url, false, $ui->ver ); |
||
| 462 | |||
| 463 | /** |
||
| 464 | * Filter JavaScript array. |
||
| 465 | * |
||
| 466 | * This filter can be used to extend the array that is passed to JavaScript |
||
| 467 | * |
||
| 468 | * @since 5.4 |
||
| 469 | */ |
||
| 470 | $translation_array = apply_filters( 'bd_javascript_array', array( |
||
| 471 | 'msg' => array(), |
||
| 472 | 'validators' => array(), |
||
| 473 | 'dt_iterators' => array(), |
||
| 474 | 'pre_action_msg' => array(), |
||
| 475 | 'error_msg' => array(), |
||
| 476 | 'pro_iterators' => array(), |
||
| 477 | ) ); |
||
| 478 | wp_localize_script( self::JS_HANDLE, self::JS_VARIABLE, $translation_array ); |
||
| 479 | |||
| 480 | /** |
||
| 481 | * Runs just after enqueuing scripts and styles in all Bulk WP admin pages. |
||
| 482 | * |
||
| 483 | * This action is primarily for registering additional scripts or styles. |
||
| 484 | * |
||
| 485 | * @since 5.5.1 |
||
| 486 | */ |
||
| 487 | do_action( 'bd_after_admin_enqueue_scripts' ); |
||
| 488 | } |
||
| 489 | |||
| 490 | /** |
||
| 491 | * Show the delete posts page. |
||
| 492 | * |
||
| 493 | * @Todo Move this function to Bulk_Delete_Posts class |
||
| 494 | */ |
||
| 495 | public function display_posts_page() { |
||
| 496 | ?> |
||
| 497 | <div class="wrap"> |
||
| 498 | <h2><?php _e( 'Bulk Delete Posts', 'bulk-delete' );?></h2> |
||
| 499 | <?php settings_errors(); ?> |
||
| 500 | |||
| 501 | <form method = "post"> |
||
| 502 | <?php |
||
| 503 | // nonce for bulk delete |
||
| 504 | wp_nonce_field( 'sm-bulk-delete-posts', 'sm-bulk-delete-posts-nonce' ); |
||
| 505 | |||
| 506 | /* Used to save closed meta boxes and their order */ |
||
| 507 | wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
||
| 508 | wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
||
| 509 | ?> |
||
| 510 | <div id = "poststuff"> |
||
| 511 | <div id="post-body" class="metabox-holder columns-1"> |
||
| 512 | |||
| 513 | <div class="notice notice-warning"> |
||
| 514 | <p><strong><?php _e( 'WARNING: Posts deleted once cannot be retrieved back. Use with caution.', 'bulk-delete' ); ?></strong></p> |
||
| 515 | </div> |
||
| 516 | |||
| 517 | <div id="postbox-container-2" class="postbox-container"> |
||
| 518 | <?php do_meta_boxes( '', 'advanced', null ); ?> |
||
| 519 | </div> <!-- #postbox-container-2 --> |
||
| 520 | |||
| 521 | </div> <!-- #post-body --> |
||
| 522 | </div><!-- #poststuff --> |
||
| 523 | </form> |
||
| 524 | </div><!-- .wrap --> |
||
| 525 | |||
| 526 | <?php |
||
| 527 | /** |
||
| 528 | * Runs just before displaying the footer text in the "Bulk Delete Posts" admin page. |
||
| 529 | * |
||
| 530 | * This action is primarily for adding extra content in the footer of "Bulk Delete Posts" admin page. |
||
| 531 | * |
||
| 532 | * @since 5.0 |
||
| 533 | */ |
||
| 534 | do_action( 'bd_admin_footer_posts_page' ); |
||
| 535 | } |
||
| 536 | |||
| 537 | /** |
||
| 538 | * Display the delete pages page. |
||
| 539 | * |
||
| 540 | * @Todo Move this function to Bulk_Delete_Pages class |
||
| 541 | * |
||
| 542 | * @since 5.0 |
||
| 543 | */ |
||
| 544 | public function display_pages_page() { |
||
| 545 | ?> |
||
| 546 | <div class="wrap"> |
||
| 547 | <h2><?php _e( 'Bulk Delete Pages', 'bulk-delete' );?></h2> |
||
| 548 | <?php settings_errors(); ?> |
||
| 549 | |||
| 550 | <form method = "post"> |
||
| 551 | <?php |
||
| 552 | // nonce for bulk delete |
||
| 553 | wp_nonce_field( 'sm-bulk-delete-pages', 'sm-bulk-delete-pages-nonce' ); |
||
| 554 | |||
| 555 | /* Used to save closed meta boxes and their order */ |
||
| 556 | wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
||
| 557 | wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
||
| 558 | ?> |
||
| 559 | <div id = "poststuff"> |
||
| 560 | <div id="post-body" class="metabox-holder columns-1"> |
||
| 561 | |||
| 562 | <div class="notice notice-warning"> |
||
| 563 | <p><strong><?php _e( 'WARNING: Pages deleted once cannot be retrieved back. Use with caution.', 'bulk-delete' ); ?></strong></p> |
||
| 564 | </div> |
||
| 565 | |||
| 566 | <div id="postbox-container-2" class="postbox-container"> |
||
| 567 | <?php do_meta_boxes( '', 'advanced', null ); ?> |
||
| 568 | </div> <!-- #postbox-container-2 --> |
||
| 569 | |||
| 570 | </div> <!-- #post-body --> |
||
| 571 | </div><!-- #poststuff --> |
||
| 572 | </form> |
||
| 573 | </div><!-- .wrap --> |
||
| 574 | |||
| 575 | <?php |
||
| 576 | /** |
||
| 577 | * Runs just before displaying the footer text in the "Bulk Delete Pages" admin page. |
||
| 578 | * |
||
| 579 | * This action is primarily for adding extra content in the footer of "Bulk Delete Pages" admin page. |
||
| 580 | * |
||
| 581 | * @since 5.0 |
||
| 582 | */ |
||
| 583 | do_action( 'bd_admin_footer_pages_page' ); |
||
| 584 | } |
||
| 585 | |||
| 586 | /** |
||
| 587 | * Display the schedule page. |
||
| 588 | */ |
||
| 589 | public function display_cron_page() { |
||
| 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 | /** |
||
| 624 | * The main function responsible for returning the one true Bulk_Delete |
||
| 625 | * Instance to functions everywhere. |
||
| 626 | * |
||
| 627 | * Use this function like you would a global variable, except without needing |
||
| 628 | * to declare the global. |
||
| 629 | * |
||
| 630 | * Example: `<?php $bulk_delete = BULK_DELETE(); ?>` |
||
| 631 | * |
||
| 632 | * @since 5.0 |
||
| 633 | * |
||
| 634 | * @return Bulk_Delete The one true Bulk_Delete Instance |
||
| 635 | */ |
||
| 636 | function BULK_DELETE() { |
||
| 637 | return Bulk_Delete::instance(); |
||
| 638 | } |
||
| 639 | |||
| 640 | // Get BULK_DELETE Running |
||
| 641 | BULK_DELETE(); |
||
| 642 |
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.