| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Bulk Delete |
| 4 |
Plugin Script: bulk-delete.php |
| 5 |
Plugin URI: http://sudarmuthu.com/wordpress/bulk-delete |
| 6 |
Description: Bulk delete posts from selected categories or tags. Use it with caution. |
| 7 |
Donate Link: http://sudarmuthu.com/if-you-wanna-thank-me |
| 8 |
Version: 2.1 |
| 9 |
License: GPL |
| 10 |
Author: Sudar |
| 11 |
Author URI: http://sudarmuthu.com/ |
| 12 |
Text Domain: bulk-delete |
| 13 |
|
| 14 |
=== RELEASE NOTES === |
| 15 |
2009-02-02 - v0.1 - first version |
| 16 |
2009-02-03 - v0.2 - Second release - Fixed issues with pagging |
| 17 |
2009-04-05 - v0.3 - Third release - Prevented drafts from deleted when only posts are selected |
| 18 |
2009-07-05 - v0.4 - Fourth release - Added option to delete by date. |
| 19 |
2009-07-21 - v0.5 - Fifth release - Added option to delete all pending posts. |
| 20 |
2009-07-22 - v0.6 - Sixth release - Added option to delete all scheduled posts. |
| 21 |
2010-02-21 - v0.7 - Added an option to delete posts directly or send them to trash and support for translation. |
| 22 |
2010-03-17 - v0.8 - Added support for private posts. |
| 23 |
2010-06-19 - v1.0 - Proper handling of limits. |
| 24 |
2011-01-22 - v1.1 - Added support to delete posts by custom taxonomies |
| 25 |
2011-02-06 - v1.2 - Added some optimization to handle huge number of posts in underpowered servers |
| 26 |
2011-05-11 - v1.3 - Added German translations |
| 27 |
2011-08-25 - v1.4 - Added Turkish translations |
| 28 |
2011-11-13 - v1.5 - Added Spanish translations |
| 29 |
2011-11-28 - v1.6 - Added Italian translations |
| 30 |
2012-01-12 - v1.7 - Added Bulgarian translations |
| 31 |
2012-01-31 - v1.8 - Added roles and capabilities for menu |
| 32 |
2012-03-16 - v1.9 - Added support for deleting by permalink. Credit Martin Capodici |
| 33 |
- Fixed issues with translations |
| 34 |
- Added Rusian translations |
| 35 |
2012-04-01 - v2.0 (10 hours) - Fixed a major issue in how dates were handled. |
| 36 |
- Major UI revamp |
| 37 |
- Added debug information and support urls |
| 38 |
2012-04-07 - v2.1 (1 hour) - Fixed CSS issues in IE. |
| 39 |
- Added Lithuanian translations |
| 40 |
2012-07-11 - v2.2 - (Dev time: 0.5 hour) |
| 41 |
- Added Hindi translations |
| 42 |
- Added checks to see if elements are present in the array before accessing them. |
| 43 |
|
| 44 |
*/ |
| 45 |
|
| 46 |
/* Copyright 2009 Sudar Muthu (email : sudar@sudarmuthu.com) |
| 47 |
|
| 48 |
This program is free software; you can redistribute it and/or modify |
| 49 |
it under the terms of the GNU General Public License, version 2, as |
| 50 |
published by the Free Software Foundation. |
| 51 |
|
| 52 |
This program is distributed in the hope that it will be useful, |
| 53 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 54 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 55 |
GNU General Public License for more details. |
| 56 |
|
| 57 |
You should have received a copy of the GNU General Public License |
| 58 |
along with this program; if not, write to the Free Software |
| 59 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 60 |
*/ |
| 61 |
|
| 62 |
/** |
| 63 |
* Request Handler |
| 64 |
*/ |
| 65 |
|
| 66 |
if (!function_exists('smbd_request_handler')) { |
| 67 |
function smbd_request_handler() { |
| 68 |
global $wpdb; |
| 69 |
|
| 70 |
// Load localization domain |
| 71 |
load_plugin_textdomain( 'bulk-delete', false, dirname(plugin_basename(__FILE__)) . '/languages' ); |
| 72 |
|
| 73 |
if (isset($_POST['smbd_action'])) { |
| 74 |
|
| 75 |
$wp_query = new WP_Query; |
| 76 |
check_admin_referer( 'bulk-delete-posts'); |
| 77 |
|
| 78 |
switch($_POST['smbd_action']) { |
| 79 |
|
| 80 |
case "bulk-delete-cats": |
| 81 |
// delete by cats |
| 82 |
$selected_cats = array_get($_POST, 'smbd_cats'); |
| 83 |
|
| 84 |
if (array_get($_POST, 'smbd_cats_restrict', FALSE) == "true") { |
| 85 |
add_filter ('posts_where', 'smbd_cats_by_days'); |
| 86 |
} |
| 87 |
|
| 88 |
$private = array_get($_POST, 'smbd_cats_private'); |
| 89 |
|
| 90 |
if ($private == 'true') { |
| 91 |
$options = array('category__in'=>$selected_cats,'post_status'=>'private', 'post_type'=>'post'); |
| 92 |
} else { |
| 93 |
$options = array('category__in'=>$selected_cats,'post_status'=>'publish', 'post_type'=>'post'); |
| 94 |
} |
| 95 |
|
| 96 |
$limit_to = absint(array_get($_POST, 'smbd_cats_limits_to', 0)); |
| 97 |
|
| 98 |
if ($limit_to > 0) { |
| 99 |
$options['showposts'] = $limit_to; |
| 100 |
} else { |
| 101 |
$options['nopaging'] = 'true'; |
| 102 |
} |
| 103 |
|
| 104 |
$force_delete = array_get($_POST, 'smbd_cats_force_delete', 'false'); |
| 105 |
|
| 106 |
if ($force_delete == 'true') { |
| 107 |
$force_delete = true; |
| 108 |
} else { |
| 109 |
$force_delete = false; |
| 110 |
} |
| 111 |
|
| 112 |
$posts = $wp_query->query($options); |
| 113 |
foreach ($posts as $post) { |
| 114 |
wp_delete_post($post->ID, $force_delete); |
| 115 |
} |
| 116 |
|
| 117 |
break; |
| 118 |
|
| 119 |
case "bulk-delete-tags": |
| 120 |
// delete by tags |
| 121 |
$selected_tags = array_get($_POST, 'smbd_tags'); |
| 122 |
if (array_get($_POST, 'smbd_tags_restrict', 'false') == "true") { |
| 123 |
add_filter ('posts_where', 'smbd_tags_by_days'); |
| 124 |
} |
| 125 |
|
| 126 |
$private = array_get($_POST, 'smbd_tags_private', 'false'); |
| 127 |
|
| 128 |
if ($private == 'true') { |
| 129 |
$options = array('tag__in'=>$selected_tags,'post_status'=>'private', 'post_type'=>'post'); |
| 130 |
} else { |
| 131 |
$options = array('tag__in'=>$selected_tags,'post_status'=>'publish', 'post_type'=>'post'); |
| 132 |
} |
| 133 |
|
| 134 |
$limit_to = absint(array_get($_POST, 'smbd_tags_limits_to', 0)); |
| 135 |
|
| 136 |
if ($limit_to > 0) { |
| 137 |
$options['showposts'] = $limit_to; |
| 138 |
} else { |
| 139 |
$options['nopaging'] = 'true'; |
| 140 |
} |
| 141 |
|
| 142 |
$force_delete = array_get($_POST, 'smbd_tags_force_delete'); |
| 143 |
|
| 144 |
if ($force_delete == 'true') { |
| 145 |
$force_delete = true; |
| 146 |
} else { |
| 147 |
$force_delete = false; |
| 148 |
} |
| 149 |
|
| 150 |
$posts = $wp_query->query($options); |
| 151 |
|
| 152 |
foreach ($posts as $post) { |
| 153 |
wp_delete_post($post->ID, $force_delete); |
| 154 |
} |
| 155 |
|
| 156 |
break; |
| 157 |
|
| 158 |
case "bulk-delete-taxs": |
| 159 |
// delete by taxs |
| 160 |
$selected_taxs = array_get($_POST, 'smbd_taxs'); |
| 161 |
|
| 162 |
foreach ($selected_taxs as $selected_tax) { |
| 163 |
$postids = smbd_get_tax_post($selected_tax); |
| 164 |
|
| 165 |
if (array_get($_POST, 'smbd_taxs_restrict', 'false') == "true") { |
| 166 |
add_filter ('posts_where', 'smbd_taxs_by_days'); |
| 167 |
} |
| 168 |
|
| 169 |
$private = array_get($_POST, 'smbd_taxs_private'); |
| 170 |
|
| 171 |
if ($private == 'true') { |
| 172 |
$options = array('post__in'=>$postids,'post_status'=>'private', 'post_type'=>'post'); |
| 173 |
} else { |
| 174 |
$options = array('post__in'=>$postids,'post_status'=>'publish', 'post_type'=>'post'); |
| 175 |
} |
| 176 |
|
| 177 |
$limit_to = absint(array_get($_POST, 'smbd_taxs_limits_to', 0)); |
| 178 |
|
| 179 |
if ($limit_to > 0) { |
| 180 |
$options['showposts'] = $limit_to; |
| 181 |
} else { |
| 182 |
$options['nopaging'] = 'true'; |
| 183 |
} |
| 184 |
|
| 185 |
$force_delete = array_get($_POST, 'smbd_taxs_force_delete'); |
| 186 |
|
| 187 |
if ($force_delete == 'true') { |
| 188 |
$force_delete = true; |
| 189 |
} else { |
| 190 |
$force_delete = false; |
| 191 |
} |
| 192 |
|
| 193 |
$posts = $wp_query->query($options); |
| 194 |
foreach ($posts as $post) { |
| 195 |
wp_delete_post($post->ID, $force_delete); |
| 196 |
} |
| 197 |
} |
| 198 |
|
| 199 |
break; |
| 200 |
|
| 201 |
case "bulk-delete-special": |
| 202 |
$options = array(); |
| 203 |
|
| 204 |
$limit_to = absint(array_get($_POST, 'smbd_special_limit_to', 0)); |
| 205 |
|
| 206 |
if ($limit_to > 0) { |
| 207 |
$options['showposts'] = $limit_to; |
| 208 |
} else { |
| 209 |
$options['nopaging'] = 'true'; |
| 210 |
} |
| 211 |
|
| 212 |
$force_delete = array_get($_POST, 'smbd_special_force_delete'); |
| 213 |
if ($force_delete == 'true') { |
| 214 |
$force_delete = true; |
| 215 |
} else { |
| 216 |
$force_delete = false; |
| 217 |
} |
| 218 |
|
| 219 |
// Drafts |
| 220 |
if ("drafs" == array_get($_POST, 'smbd_drafs')) { |
| 221 |
$options['post_status'] = 'draft'; |
| 222 |
$drafts = $wp_query->query($options); |
| 223 |
|
| 224 |
foreach ($drafts as $draft) { |
| 225 |
wp_delete_post($draft->ID, $force_delete); |
| 226 |
} |
| 227 |
} |
| 228 |
|
| 229 |
// Revisions |
| 230 |
if ("revisions" == array_get($_POST, 'smbd_revisions')) { |
| 231 |
$revisions = $wpdb->get_results($wpdb->prepare("select ID from $wpdb->posts where post_type = 'revision'")); |
| 232 |
|
| 233 |
foreach ($revisions as $revision) { |
| 234 |
wp_delete_post($revision->ID, $force_delete); |
| 235 |
} |
| 236 |
} |
| 237 |
|
| 238 |
// Pending Posts |
| 239 |
if ("pending" == array_get($_POST, 'smbd_pending')) { |
| 240 |
$pendings = $wpdb->get_results($wpdb->prepare("select ID from $wpdb->posts where post_status = 'pending'")); |
| 241 |
|
| 242 |
foreach ($pendings as $pending) { |
| 243 |
wp_delete_post($pending->ID, $force_delete); |
| 244 |
} |
| 245 |
} |
| 246 |
|
| 247 |
// Future Posts |
| 248 |
if ("future" == array_get($_POST, 'smbd_future')) { |
| 249 |
$futures = $wpdb->get_results($wpdb->prepare("select ID from $wpdb->posts where post_status = 'future'")); |
| 250 |
|
| 251 |
foreach ($futures as $future) { |
| 252 |
wp_delete_post($future->ID, $force_delete); |
| 253 |
} |
| 254 |
} |
| 255 |
|
| 256 |
// Private Posts |
| 257 |
if ("private" == array_get($_POST, 'smbd_private')) { |
| 258 |
$privates = $wpdb->get_results($wpdb->prepare("select ID from $wpdb->posts where post_status = 'private'")); |
| 259 |
|
| 260 |
foreach ($privates as $private) { |
| 261 |
wp_delete_post($private->ID, $force_delete); |
| 262 |
} |
| 263 |
} |
| 264 |
|
| 265 |
// Pages |
| 266 |
if ("pages" == array_get($_POST, 'smbd_pages')) { |
| 267 |
$options['post_type'] = 'page'; |
| 268 |
$pages = $wp_query->query($options); |
| 269 |
|
| 270 |
foreach ($pages as $page) { |
| 271 |
wp_delete_post($page->ID, $force_delete); |
| 272 |
} |
| 273 |
} |
| 274 |
|
| 275 |
// Specific Pages |
| 276 |
if ("specificpages" == array_get($_POST, 'smdb_specific_pages')) { |
| 277 |
$urls = preg_split( '/\r\n|\r|\n/', array_get($_POST, 'smdb_specific_pages_urls') ); |
| 278 |
foreach ($urls as $url) { |
| 279 |
$checkedurl = $url; |
| 280 |
if (substr($checkedurl ,0,1) == '/') { |
| 281 |
$checkedurl = get_site_url() . $checkedurl ; |
| 282 |
} |
| 283 |
$postid = url_to_postid( $checkedurl ); |
| 284 |
wp_delete_post($postid, $force_delete); |
| 285 |
} |
| 286 |
} |
| 287 |
|
| 288 |
break; |
| 289 |
} |
| 290 |
|
| 291 |
// hook the admin notices action |
| 292 |
add_action( 'admin_notices', 'smbd_deleted_notice', 9 ); |
| 293 |
} |
| 294 |
} |
| 295 |
} |
| 296 |
|
| 297 |
/** |
| 298 |
* Show deleted notice messages |
| 299 |
*/ |
| 300 |
if (!function_exists('smbd_deleted_notice')) { |
| 301 |
function smbd_deleted_notice() { |
| 302 |
echo "<div class = 'updated'><p>" . __("All the selected posts have been successfully deleted.", 'bulk-delete') . "</p></div>"; |
| 303 |
} |
| 304 |
} |
| 305 |
|
| 306 |
/** |
| 307 |
* Show the Admin page |
| 308 |
*/ |
| 309 |
if (!function_exists('smbd_displayOptions')) { |
| 310 |
function smbd_displayOptions() { |
| 311 |
global $wpdb; |
| 312 |
?> |
| 313 |
<div class="updated fade" style="background:#ff0;text-align:center;color: red;"><p><strong><?php _e("WARNING: Posts deleted once cannot be retrieved back. Use with caution.", 'bulk-delete'); ?></strong></p></div> |
| 314 |
|
| 315 |
<div class="wrap"> |
| 316 |
<?php screen_icon(); ?> |
| 317 |
<h2>Bulk Delete</h2> |
| 318 |
|
| 319 |
<div id = "poststuff" style = "float:left; width:75%"> |
| 320 |
<div class = "postbox"> |
| 321 |
<div class = "handlediv"> |
| 322 |
<br> |
| 323 |
</div> |
| 324 |
<h3 class = "hndle"><span><?php _e("By Type", 'bulk-delete'); ?></span></h3> |
| 325 |
<div class = "inside"> |
| 326 |
<h4><?php _e("Select the posts which you want to delete", 'bulk-delete'); ?></h4> |
| 327 |
|
| 328 |
<form name="smbd_form" id = "smbd_misc_form" |
| 329 |
action="<?php echo get_bloginfo("wpurl"); ?>/wp-admin/options-general.php?page=bulk-delete.php" method="post" |
| 330 |
onsubmit="return bd_validateForm(this);"> |
| 331 |
|
| 332 |
<?php |
| 333 |
$wp_query = new WP_Query; |
| 334 |
$drafts = $wpdb->get_var($wpdb->prepare("select count(*) from $wpdb->posts where post_status = 'draft'")); |
| 335 |
$revisions = $wpdb->get_var($wpdb->prepare("select count(*) from $wpdb->posts where post_type = 'revision'")); |
| 336 |
$pending = $wpdb->get_var($wpdb->prepare("select count(*) from $wpdb->posts where post_status = 'pending'")); |
| 337 |
$future = $wpdb->get_var($wpdb->prepare("select count(*) from $wpdb->posts where post_status = 'future'")); |
| 338 |
$private = $wpdb->get_var($wpdb->prepare("select count(*) from $wpdb->posts where post_status = 'private'")); |
| 339 |
$pages = $wpdb->get_var($wpdb->prepare("select count(*) from $wpdb->posts where post_type = 'page'")); |
| 340 |
?> |
| 341 |
<fieldset class="options"> |
| 342 |
<table class="optiontable"> |
| 343 |
<tr> |
| 344 |
<td scope="row" > |
| 345 |
<input name="smbd_drafs" id ="smbd_drafs" value = "drafs" type = "checkbox" /> |
| 346 |
<label for="smbd_drafs"><?php _e("All Drafts", 'bulk-delete'); ?> (<?php echo $drafts . " "; _e("Drafts", 'bulk-delete'); ?>)</label> |
| 347 |
</td> |
| 348 |
</tr> |
| 349 |
|
| 350 |
<tr> |
| 351 |
<td> |
| 352 |
<input name="smbd_revisions" id ="smbd_revisions" value = "revisions" type = "checkbox" /> |
| 353 |
<label for="smbd_revisions"><?php _e("All Revisions", 'bulk-delete'); ?> (<?php echo $revisions . " "; _e("Revisions", 'bulk-delete'); ?>)</label> |
| 354 |
</td> |
| 355 |
</tr> |
| 356 |
|
| 357 |
<tr> |
| 358 |
<td> |
| 359 |
<input name="smbd_pending" id ="smbd_pending" value = "pending" type = "checkbox" /> |
| 360 |
<label for="smbd_pending"><?php _e("All Pending posts", 'bulk-delete'); ?> (<?php echo $pending . " "; _e("Posts", 'bulk-delete'); ?>)</label> |
| 361 |
</td> |
| 362 |
</tr> |
| 363 |
|
| 364 |
<tr> |
| 365 |
<td> |
| 366 |
<input name="smbd_future" id ="smbd_future" value = "future" type = "checkbox" /> |
| 367 |
<label for="smbd_future"><?php _e("All scheduled posts", 'bulk-delete'); ?> (<?php echo $future . " "; _e("Posts", 'bulk-delete'); ?>)</label> |
| 368 |
</td> |
| 369 |
</tr> |
| 370 |
|
| 371 |
<tr> |
| 372 |
<td> |
| 373 |
<input name="smbd_private" id ="smbd_private" value = "private" type = "checkbox" /> |
| 374 |
<label for="smbd_private"><?php _e("All private posts", 'bulk-delete'); ?> (<?php echo $private . " "; _e("Posts", 'bulk-delete'); ?>)</label> |
| 375 |
</td> |
| 376 |
</tr> |
| 377 |
|
| 378 |
<tr> |
| 379 |
<td> |
| 380 |
<input name="smbd_pages" value = "pages" type = "checkbox" /> |
| 381 |
<label for="smbd_pages"><?php _e("All Pages", 'bulk-delete'); ?> (<?php echo $pages . " "; _e("Pages", 'bulk-delete'); ?>)</label> |
| 382 |
</td> |
| 383 |
</tr> |
| 384 |
|
| 385 |
<tr> |
| 386 |
<td scope="row"> |
| 387 |
<input name="smdb_specific_pages" id="smdb_specific_pages" value = "specificpages" type = "checkbox" /> |
| 388 |
<label for="smdb_specific_pages"><?php _e("Delete these specific pages (Enter one post url (not post ids) per line)", 'bulk-delete'); ?></label> |
| 389 |
<br/> |
| 390 |
<textarea style="width: 450px; height: 80px;" id="smdb_specific_pages_urls" name="smdb_specific_pages_urls" rows="5" columns="80" ></textarea> |
| 391 |
</td> |
| 392 |
</tr> |
| 393 |
|
| 394 |
<tr> |
| 395 |
<td> |
| 396 |
<h4><?php _e("Choose your filtering options", 'bulk-delete'); ?></h4> |
| 397 |
</td> |
| 398 |
</tr> |
| 399 |
|
| 400 |
<tr> |
| 401 |
<td scope="row"> |
| 402 |
<input name="smbd_special_force_delete" value = "false" type = "radio" checked="checked" /> <?php _e('Move to Trash', 'bulk-delete'); ?> |
| 403 |
<input name="smbd_special_force_delete" value = "true" type = "radio" /> <?php _e('Delete permanently', 'bulk-delete'); ?> |
| 404 |
</td> |
| 405 |
</tr> |
| 406 |
|
| 407 |
<tr> |
| 408 |
<td scope="row"> |
| 409 |
<input name="smbd_special_limit" id="smbd_special_limit" value = "true" type = "checkbox" onclick="toggle_limit_restrict('special');" /> |
| 410 |
<?php _e("Only delete first ", 'bulk-delete');?> |
| 411 |
<input type ="textbox" name="smbd_special_limit_to" id="smbd_special_limit_to" disabled value ="0" maxlength="4" size="4" /><?php _e("posts.", 'bulk-delete');?> |
| 412 |
<?php _e("Use this option if there are more than 1000 posts and the script timesout.", 'bulk-delete') ?> |
| 413 |
</td> |
| 414 |
</tr> |
| 415 |
|
| 416 |
</table> |
| 417 |
</fieldset> |
| 418 |
|
| 419 |
<p class="submit"> |
| 420 |
<input type="submit" name="submit" class="button-primary" value="<?php _e("Bulk Delete ", 'bulk-delete') ?>»"> |
| 421 |
</p> |
| 422 |
|
| 423 |
<?php wp_nonce_field('bulk-delete-posts'); ?> |
| 424 |
|
| 425 |
<input type="hidden" name="smbd_action" value="bulk-delete-special" /> |
| 426 |
</form> |
| 427 |
</div> |
| 428 |
</div> |
| 429 |
|
| 430 |
<div class = "postbox"> |
| 431 |
<div class = "handlediv"> |
| 432 |
<br> |
| 433 |
</div> |
| 434 |
<h3 class = "hndle"><span><?php _e("By Category", 'bulk-delete'); ?></span></h3> |
| 435 |
<div class = "inside"> |
| 436 |
<h4><?php _e("Select the categories whose post you want to delete", 'bulk-delete'); ?></h4> |
| 437 |
|
| 438 |
<form name="smbd_form" id = "smbd_cat_form" |
| 439 |
action="<?php echo get_bloginfo("wpurl"); ?>/wp-admin/options-general.php?page=bulk-delete.php" method="post" onsubmit="return bd_validateForm(this);"> |
| 440 |
|
| 441 |
<fieldset class="options"> |
| 442 |
<table class="optiontable"> |
| 443 |
<?php |
| 444 |
$categories = get_categories(array('hide_empty' => false)); |
| 445 |
foreach ($categories as $category) { |
| 446 |
?> |
| 447 |
<tr> |
| 448 |
<td scope="row" > |
| 449 |
<input name="smbd_cats[]" value = "<?php echo $category->cat_ID; ?>" type = "checkbox" /> |
| 450 |
</td> |
| 451 |
<td> |
| 452 |
<label for="smbd_cats"><?php echo $category->cat_name; ?> (<?php echo $category->count . " "; _e("Posts", 'bulk-delete'); ?>)</label> |
| 453 |
</td> |
| 454 |
</tr> |
| 455 |
<?php |
| 456 |
} |
| 457 |
?> |
| 458 |
<tr> |
| 459 |
<td scope="row" > |
| 460 |
<input name="smbd_cats_all" id ="smbd_cats_all" value = "-1" type = "checkbox" onclick="bd_checkAll(document.getElementById('smbd_cat_form'));" /> |
| 461 |
</td> |
| 462 |
<td> |
| 463 |
<label for="smbd_cats_all"><?php _e("All Categories", 'bulk-delete') ?></label> |
| 464 |
</td> |
| 465 |
</tr> |
| 466 |
|
| 467 |
<tr> |
| 468 |
<td colspan="2"> |
| 469 |
<h4><?php _e("Choose your filtering options", 'bulk-delete'); ?></h4> |
| 470 |
</td> |
| 471 |
</tr> |
| 472 |
|
| 473 |
<tr> |
| 474 |
<td scope="row"> |
| 475 |
<input name="smbd_cats_restrict" id="smbd_cats_restrict" value = "true" type = "checkbox" onclick="toggle_date_restrict('cats');" /> |
| 476 |
</td> |
| 477 |
<td> |
| 478 |
<?php _e("Only restrict to posts which are ", 'bulk-delete');?> |
| 479 |
<select name="smbd_cats_op" id="smbd_cats_op" disabled> |
| 480 |
<option value ="<"><?php _e("older than", 'bulk-delete');?></option> |
| 481 |
<option value =">"><?php _e("posted within last", 'bulk-delete');?></option> |
| 482 |
</select> |
| 483 |
<input type ="textbox" name="smbd_cats_days" id="smbd_cats_days" disabled value ="0" maxlength="4" size="4" /><?php _e("days", 'bulk-delete');?> |
| 484 |
</td> |
| 485 |
</tr> |
| 486 |
|
| 487 |
<tr> |
| 488 |
<td scope="row" colspan="2"> |
| 489 |
<input name="smbd_cats_force_delete" value = "false" type = "radio" checked="checked" /> <?php _e('Move to Trash', 'bulk-delete'); ?> |
| 490 |
<input name="smbd_cats_force_delete" value = "true" type = "radio" /> <?php _e('Delete permanently', 'bulk-delete'); ?> |
| 491 |
</td> |
| 492 |
</tr> |
| 493 |
|
| 494 |
<tr> |
| 495 |
<td scope="row" colspan="2"> |
| 496 |
<input name="smbd_cats_private" value = "false" type = "radio" checked="checked" /> <?php _e('Public posts', 'bulk-delete'); ?> |
| 497 |
<input name="smbd_cats_private" value = "true" type = "radio" /> <?php _e('Private Posts', 'bulk-delete'); ?> |
| 498 |
</td> |
| 499 |
</tr> |
| 500 |
|
| 501 |
<tr> |
| 502 |
<td scope="row"> |
| 503 |
<input name="smbd_cats_limit" id="smbd_cats_limit" value = "true" type = "checkbox" onclick="toggle_limit_restrict('cats');" /> |
| 504 |
</td> |
| 505 |
<td> |
| 506 |
<?php _e("Only delete first ", 'bulk-delete');?> |
| 507 |
<input type ="textbox" name="smbd_cats_limit_to" id="smbd_cats_limit_to" disabled value ="0" maxlength="4" size="4" /><?php _e("posts.", 'bulk-delete');?> |
| 508 |
<?php _e("Use this option if there are more than 1000 posts and the script timesout.", 'bulk-delete') ?> |
| 509 |
</td> |
| 510 |
</tr> |
| 511 |
|
| 512 |
</table> |
| 513 |
</fieldset> |
| 514 |
<p class="submit"> |
| 515 |
<input type="submit" name="submit" class="button-primary" value="<?php _e("Bulk Delete ", 'bulk-delete') ?>»"> |
| 516 |
</p> |
| 517 |
|
| 518 |
<?php wp_nonce_field('bulk-delete-posts'); ?> |
| 519 |
|
| 520 |
<input type="hidden" name="smbd_action" value="bulk-delete-cats" /> |
| 521 |
</form> |
| 522 |
</div> |
| 523 |
</div> |
| 524 |
<?php |
| 525 |
$tags = get_tags(); |
| 526 |
if (count($tags) > 0) { |
| 527 |
?> |
| 528 |
<div class = "postbox"> |
| 529 |
<div class = "handlediv"> |
| 530 |
<br> |
| 531 |
</div> |
| 532 |
|
| 533 |
<h3 class = "hndle"><span><?php _e("By Tags", 'bulk-delete'); ?></span></h3> |
| 534 |
|
| 535 |
<div class = "inside"> |
| 536 |
<h4><?php _e("Select the tags whose post you want to delete", 'bulk-delete') ?></h4> |
| 537 |
|
| 538 |
<form name="smbd_form" id = "smbd_tag_form" |
| 539 |
action="<?php echo get_bloginfo("wpurl"); ?>/wp-admin/options-general.php?page=bulk-delete.php" method="post" |
| 540 |
onsubmit="return bd_validateForm(this);"> |
| 541 |
|
| 542 |
<fieldset class="options"> |
| 543 |
<table class="optiontable"> |
| 544 |
<?php |
| 545 |
foreach ($tags as $tag) { |
| 546 |
?> |
| 547 |
<tr> |
| 548 |
<td scope="row" > |
| 549 |
<input name="smbd_tags[]" value = "<?php echo $tag->term_id; ?>" type = "checkbox" /> |
| 550 |
</td> |
| 551 |
<td> |
| 552 |
<label for="smbd_tags"><?php echo $tag->name; ?> (<?php echo $tag->count . " "; _e("Posts", 'bulk-delete'); ?>)</label> |
| 553 |
</td> |
| 554 |
</tr> |
| 555 |
<?php |
| 556 |
} |
| 557 |
?> |
| 558 |
<tr> |
| 559 |
<td scope="row" > |
| 560 |
<input name="smbd_tags_all" id ="smbd_tags_all" value = "-1" type = "checkbox" onclick="bd_checkAll(document.getElementById('smbd_tag_form'));" /> |
| 561 |
</td> |
| 562 |
<td> |
| 563 |
<label for="smbd_tags_all"><?php _e("All Tags", 'bulk-delete') ?></label> |
| 564 |
</td> |
| 565 |
</tr> |
| 566 |
|
| 567 |
<tr> |
| 568 |
<td colspan="2"> |
| 569 |
<h4><?php _e("Choose your filtering options", 'bulk-delete'); ?></h4> |
| 570 |
</td> |
| 571 |
</tr> |
| 572 |
|
| 573 |
<tr> |
| 574 |
<td scope="row"> |
| 575 |
<input name="smbd_tags_restrict" id ="smbd_tags_restrict" value = "true" type = "checkbox" onclick="toggle_date_restrict('tags');" /> |
| 576 |
</td> |
| 577 |
<td> |
| 578 |
<?php _e("Only restrict to posts which are ", 'bulk-delete');?> |
| 579 |
<select name="smbd_tags_op" id="smbd_tags_op" disabled> |
| 580 |
<option value ="<"><?php _e("older than", 'bulk-delete');?></option> |
| 581 |
<option value =">"><?php _e("posted within last", 'bulk-delete');?></option> |
| 582 |
</select> |
| 583 |
<input type ="textbox" name="smbd_tags_days" id ="smbd_tags_days" value ="0" maxlength="4" size="4" disabled /><?php _e("days", 'bulk-delete');?> |
| 584 |
</td> |
| 585 |
</tr> |
| 586 |
|
| 587 |
<tr> |
| 588 |
<td scope="row" colspan="2"> |
| 589 |
<input name="smbd_tags_force_delete" value = "false" type = "radio" checked="checked" /> <?php _e('Move to Trash', 'bulk-delete'); ?> |
| 590 |
<input name="smbd_tags_force_delete" value = "true" type = "radio" /> <?php _e('Delete permanently', 'bulk-delete'); ?> |
| 591 |
</td> |
| 592 |
</tr> |
| 593 |
|
| 594 |
<tr> |
| 595 |
<td scope="row" colspan="2"> |
| 596 |
<input name="smbd_tags_private" value = "false" type = "radio" checked="checked" /> <?php _e('Public posts', 'bulk-delete'); ?> |
| 597 |
<input name="smbd_tags_private" value = "true" type = "radio" /> <?php _e('Private Posts', 'bulk-delete'); ?> |
| 598 |
</td> |
| 599 |
</tr> |
| 600 |
|
| 601 |
<tr> |
| 602 |
<td scope="row"> |
| 603 |
<input name="smbd_tags_limit" id="smbd_tags_limit" value = "true" type = "checkbox" onclick="toggle_limit_restrict('tags');" /> |
| 604 |
</td> |
| 605 |
<td> |
| 606 |
<?php _e("Only delete first ", 'bulk-delete');?> |
| 607 |
<input type ="textbox" name="smbd_tags_limit_to" id="smbd_tags_limit_to" disabled value ="0" maxlength="4" size="4" /><?php _e("posts.", 'bulk-delete');?> |
| 608 |
<?php _e("Use this option if there are more than 1000 posts and the script timesout.", 'bulk-delete') ?> |
| 609 |
</td> |
| 610 |
</tr> |
| 611 |
|
| 612 |
</table> |
| 613 |
</fieldset> |
| 614 |
<p class="submit"> |
| 615 |
<input type="submit" name="submit" class="button-primary" value="<?php _e("Bulk Delete ", 'bulk-delete') ?>»"> |
| 616 |
</p> |
| 617 |
|
| 618 |
<?php wp_nonce_field('bulk-delete-posts'); ?> |
| 619 |
|
| 620 |
<input type="hidden" name="smbd_action" value="bulk-delete-tags" /> |
| 621 |
</form> |
| 622 |
</div> |
| 623 |
</div> |
| 624 |
<?php |
| 625 |
} |
| 626 |
?> |
| 627 |
|
| 628 |
<?php |
| 629 |
$customTaxs = get_taxonomies(); |
| 630 |
if (count($customTaxs) > 0) { |
| 631 |
?> |
| 632 |
<div class = "postbox"> |
| 633 |
<div class = "handlediv"> |
| 634 |
<br> |
| 635 |
</div> |
| 636 |
<h3 class = "hndle"><span><?php _e("By Taxonomies", 'bulk-delete'); ?></span></h3> |
| 637 |
<div class = "inside"> |
| 638 |
<h4><?php _e("Select the taxonomies whose post you want to delete", 'bulk-delete') ?></h4> |
| 639 |
|
| 640 |
<form name="smbd_form" id = "smbd_tax_form" |
| 641 |
action="<?php echo get_bloginfo("wpurl"); ?>/wp-admin/options-general.php?page=bulk-delete.php" method="post" |
| 642 |
onsubmit="return bd_validateForm(this);"> |
| 643 |
|
| 644 |
<fieldset class="options"> |
| 645 |
<table class="optiontable"> |
| 646 |
<?php |
| 647 |
foreach ($customTaxs as $taxs) { |
| 648 |
|
| 649 |
$posts = smbd_get_tax_post($taxs); |
| 650 |
?> |
| 651 |
<tr> |
| 652 |
<td scope="row" > |
| 653 |
<input name="smbd_taxs[]" value = "<?php echo $taxs; ?>" type = "checkbox" /> |
| 654 |
</td> |
| 655 |
<td> |
| 656 |
<label for="smbd_taxs"><?php echo $taxs; ?> (<?php echo count($posts) . " "; _e("Posts", 'bulk-delete'); ?>)</label> |
| 657 |
</td> |
| 658 |
</tr> |
| 659 |
<?php |
| 660 |
} |
| 661 |
?> |
| 662 |
<tr> |
| 663 |
<td scope="row" > |
| 664 |
<input name="smbd_taxs_all" id ="smbd_taxs_all" value = "-1" type = "checkbox" onclick="bd_checkAll(document.getElementById('smbd_tax_form'));" /> |
| 665 |
</td> |
| 666 |
<td> |
| 667 |
<label for="smbd_taxs_all"><?php _e("All Taxonomies", 'bulk-delete') ?></label> |
| 668 |
</td> |
| 669 |
</tr> |
| 670 |
|
| 671 |
<tr> |
| 672 |
<td colspan="2"> |
| 673 |
<h4><?php _e("Choose your filtering options", 'bulk-delete'); ?></h4> |
| 674 |
</td> |
| 675 |
</tr> |
| 676 |
|
| 677 |
<tr> |
| 678 |
<td scope="row"> |
| 679 |
<input name="smbd_taxs_restrict" id ="smbd_taxs_restrict" value = "true" type = "checkbox" onclick="toggle_date_restrict('taxs');" /> |
| 680 |
</td> |
| 681 |
<td> |
| 682 |
<?php _e("Only restrict to posts which are ", 'bulk-delete');?> |
| 683 |
<select name="smbd_taxs_op" id="smbd_taxs_op" disabled> |
| 684 |
<option value ="<"><?php _e("older than", 'bulk-delete');?></option> |
| 685 |
<option value =">"><?php _e("posted within last", 'bulk-delete');?></option> |
| 686 |
</select> |
| 687 |
<input type ="textbox" name="smbd_taxs_days" id ="smbd_taxs_days" value ="0" maxlength="4" size="4" disabled /><?php _e("days", 'bulk-delete');?> |
| 688 |
</td> |
| 689 |
</tr> |
| 690 |
|
| 691 |
<tr> |
| 692 |
<td scope="row" colspan="2"> |
| 693 |
<input name="smbd_taxs_force_delete" value = "false" type = "radio" checked="checked" /> <?php _e('Move to Trash', 'bulk-delete'); ?> |
| 694 |
<input name="smbd_taxs_force_delete" value = "true" type = "radio" /> <?php _e('Delete permanently', 'bulk-delete'); ?> |
| 695 |
</td> |
| 696 |
</tr> |
| 697 |
|
| 698 |
<tr> |
| 699 |
<td scope="row" colspan="2"> |
| 700 |
<input name="smbd_taxs_private" value = "false" type = "radio" checked="checked" /> <?php _e('Public posts', 'bulk-delete'); ?> |
| 701 |
<input name="smbd_taxs_private" value = "true" type = "radio" /> <?php _e('Private Posts', 'bulk-delete'); ?> |
| 702 |
</td> |
| 703 |
</tr> |
| 704 |
|
| 705 |
<tr> |
| 706 |
<td scope="row"> |
| 707 |
<input name="smbd_taxs_limit" id="smbd_taxs_limit" value = "true" type = "checkbox" onclick="toggle_limit_restrict('taxs');" /> |
| 708 |
</td> |
| 709 |
<td> |
| 710 |
<?php _e("Only delete first ", 'bulk-delete');?> |
| 711 |
<input type ="textbox" name="smbd_taxs_limit_to" id="smbd_taxs_limit_to" disabled value ="0" maxlength="4" size="4" /><?php _e("posts.", 'bulk-delete');?> |
| 712 |
<?php _e("Use this option if there are more than 1000 posts and the script timesout.", 'bulk-delete') ?> |
| 713 |
</td> |
| 714 |
</tr> |
| 715 |
|
| 716 |
</table> |
| 717 |
</fieldset> |
| 718 |
<p class="submit"> |
| 719 |
<input type="submit" class="button-primary" name="submit" value="<?php _e("Bulk Delete ", 'bulk-delete') ?>»"> |
| 720 |
</p> |
| 721 |
|
| 722 |
<?php wp_nonce_field('bulk-delete-posts'); ?> |
| 723 |
|
| 724 |
<input type="hidden" name="smbd_action" value="bulk-delete-taxs" /> |
| 725 |
</form> |
| 726 |
</div> |
| 727 |
</div> |
| 728 |
<?php |
| 729 |
} |
| 730 |
?> |
| 731 |
<div class = "postbox"> |
| 732 |
<div class = "handlediv"> |
| 733 |
<br> |
| 734 |
</div> |
| 735 |
<h3 class = "hndle"><span><?php _e('Debug Information', 'bulk-delete'); ?></span></h3> |
| 736 |
<div class = "inside"> |
| 737 |
<p><?php _e('If you are seeing a blank page after clicking the Bulk Delete button, then ', 'bulk-delete'); ?><a href = "http://sudarmuthu.com/wordpress/bulk-delete#faq-white-screen"><?php _e('check out this FAQ', 'bulk-delete');?></a>. |
| 738 |
<?php _e('You also need need the following debug information.', 'bulk-delete'); ?></p> |
| 739 |
<table cellspacing="10"> |
| 740 |
<tr> |
| 741 |
<th align = "right"><?php _e('Available memory size ', 'bulk-delete');?></th> |
| 742 |
<td><?php echo ini_get( 'memory_limit' ); ?></td> |
| 743 |
</tr> |
| 744 |
<tr> |
| 745 |
<th align = "right"><?php _e('Script time out ', 'bulk-delete');?></th> |
| 746 |
<td><?php echo ini_get( 'max_execution_time' ); ?></td> |
| 747 |
</tr> |
| 748 |
<tr> |
| 749 |
<th align = "right"><?php _e('Script input time ', 'bulk-delete'); ?></th> |
| 750 |
<td><?php echo ini_get( 'max_input_time' ); ?></td> |
| 751 |
</tr> |
| 752 |
</table> |
| 753 |
</div> |
| 754 |
</div> |
| 755 |
|
| 756 |
<p><em><?php _e("If you are looking to move posts in bulk, instead of deleting then try out my ", 'bulk-delete'); ?> <a href = "http://sudarmuthu.com/wordpress/bulk-move"><?php _e("Bulk Move Plugin", 'bulk-delete');?></a>.</em></p> |
| 757 |
</div> |
| 758 |
|
| 759 |
<iframe frameBorder="0" height = "950" src = "http://sudarmuthu.com/projects/wordpress/bulk-delete/sidebar.php?color=<?php echo get_user_option('admin_color'); ?>"></iframe> |
| 760 |
|
| 761 |
</div> |
| 762 |
<?php |
| 763 |
|
| 764 |
// Display credits in Footer |
| 765 |
add_action( 'in_admin_footer', 'smbd_admin_footer' ); |
| 766 |
} |
| 767 |
} |
| 768 |
|
| 769 |
/** |
| 770 |
* Check whether a key is present. If present returns the value, else returns the default value |
| 771 |
* |
| 772 |
* @param <array> $array - Array whose key has to be checked |
| 773 |
* @param <string> $key - key that has to be checked |
| 774 |
* @param <string> $default - the default value that has to be used, if the key is not found (optional) |
| 775 |
* |
| 776 |
* @return <mixed> If present returns the value, else returns the default value |
| 777 |
* @author Sudar |
| 778 |
*/ |
| 779 |
function array_get($array, $key, $default = NULL) { |
| 780 |
return isset($array[$key]) ? $array[$key] : $default; |
| 781 |
} |
| 782 |
|
| 783 |
/** |
| 784 |
* function to filter posts by days |
| 785 |
* @param <type> $where |
| 786 |
* @return <type> |
| 787 |
*/ |
| 788 |
if (!function_exists('smbd_cats_by_days ')) { |
| 789 |
function smbd_cats_by_days ($where = '') { |
| 790 |
$cats_op = array_get($_POST, 'smbd_cats_op'); |
| 791 |
$cats_days = array_get($_POST, 'smbd_cats_days'); |
| 792 |
|
| 793 |
remove_filter('posts_where', 'smbd_cats_by_days'); |
| 794 |
|
| 795 |
$where .= " AND post_date $cats_op '" . date('y-m-d', strtotime("-$cats_days days")) . "'"; |
| 796 |
return $where; |
| 797 |
} |
| 798 |
} |
| 799 |
|
| 800 |
/** |
| 801 |
* function to filter posts by days |
| 802 |
* @param <type> $where |
| 803 |
* @return <type> |
| 804 |
*/ |
| 805 |
if (!function_exists('smbd_tags_by_days ')) { |
| 806 |
function smbd_tags_by_days ($where = '') { |
| 807 |
$tags_op = array_get($_POST, 'smbd_tags_op'); |
| 808 |
$tags_days = array_get($_POST, 'smbd_tags_days'); |
| 809 |
|
| 810 |
remove_filter('posts_where', 'smbd_tags_by_days'); |
| 811 |
|
| 812 |
$where .= " AND post_date $tags_op '" . date('y-m-d', strtotime("-$tags_days days")) . "'"; |
| 813 |
return $where; |
| 814 |
} |
| 815 |
} |
| 816 |
|
| 817 |
/** |
| 818 |
* function to filter custom taxonomy posts by days |
| 819 |
* @param <type> $where |
| 820 |
* @return <type> |
| 821 |
*/ |
| 822 |
if (!function_exists('smbd_taxs_by_days ')) { |
| 823 |
function smbd_taxs_by_days ($where = '') { |
| 824 |
$taxs_op = array_get($_POST, 'smbd_taxs_op'); |
| 825 |
$taxs_days = array_get($_POST, 'smbd_taxs_days'); |
| 826 |
|
| 827 |
remove_filter('posts_where', 'smbd_taxs_by_days'); |
| 828 |
|
| 829 |
$where .= " AND post_date $taxs_op '" . date('y-m-d', strtotime("-$taxs_days days")) . "'"; |
| 830 |
return $where; |
| 831 |
} |
| 832 |
} |
| 833 |
|
| 834 |
/** |
| 835 |
* Return the posts for a taxonomy |
| 836 |
* |
| 837 |
* @param <type> $tax |
| 838 |
* @return <type> |
| 839 |
*/ |
| 840 |
if (!function_exists('smbd_get_tax_post')) { |
| 841 |
function smbd_get_tax_post($tax) { |
| 842 |
global $wpdb; |
| 843 |
|
| 844 |
$query = $wpdb->prepare("select object_id from {$wpdb->prefix}term_relationships where term_taxonomy_id in (select term_taxonomy_id from {$wpdb->prefix}term_taxonomy where taxonomy = '$tax')"); |
| 845 |
$post_ids_result = $wpdb->get_results($query); |
| 846 |
|
| 847 |
$postids = array(); |
| 848 |
foreach ($post_ids_result as $post_id_result) { |
| 849 |
$postids[] = $post_id_result->object_id; |
| 850 |
} |
| 851 |
|
| 852 |
return $postids; |
| 853 |
} |
| 854 |
} |
| 855 |
|
| 856 |
/** |
| 857 |
* Add navigation menu |
| 858 |
*/ |
| 859 |
if(!function_exists('smbd_add_menu')) { |
| 860 |
function smbd_add_menu() { |
| 861 |
//Add a submenu to Manage |
| 862 |
$page = add_options_page("Bulk Delete", "Bulk Delete", 'manage_options', basename(__FILE__), "smbd_displayOptions"); |
| 863 |
} |
| 864 |
} |
| 865 |
|
| 866 |
/** |
| 867 |
* Adds the settings link in the Plugin page. Based on http://striderweb.com/nerdaphernalia/2008/06/wp-use-action-links/ |
| 868 |
* @staticvar <type> $this_plugin |
| 869 |
* @param <type> $links |
| 870 |
* @param <type> $file |
| 871 |
*/ |
| 872 |
if (!function_exists('smbd_filter_plugin_actions')) { |
| 873 |
function smbd_filter_plugin_actions($links, $file) { |
| 874 |
static $this_plugin; |
| 875 |
if( ! $this_plugin ) $this_plugin = plugin_basename(__FILE__); |
| 876 |
|
| 877 |
if( $file == $this_plugin ) { |
| 878 |
$settings_link = '<a href="options-general.php?page=bulk-delete.php">' . _('Manage') . '</a>'; |
| 879 |
array_unshift( $links, $settings_link ); // before other links |
| 880 |
} |
| 881 |
return $links; |
| 882 |
} |
| 883 |
} |
| 884 |
|
| 885 |
/** |
| 886 |
* Adds Footer links. Based on http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/ |
| 887 |
*/ |
| 888 |
if (!function_exists('smbd_admin_footer')) { |
| 889 |
function smbd_admin_footer() { |
| 890 |
$plugin_data = get_plugin_data( __FILE__ ); |
| 891 |
printf('%1$s ' . __("plugin", 'bulk-delete') .' | ' . __("Version", 'bulk-delete') . ' %2$s | '. __('by', 'bulk-delete') . ' %3$s<br />', $plugin_data['Title'], $plugin_data['Version'], $plugin_data['Author']); |
| 892 |
?> |
| 893 |
<script type="text/javascript"> |
| 894 |
|
| 895 |
/** |
| 896 |
* Toggle closing of different sections |
| 897 |
* |
| 898 |
*/ |
| 899 |
jQuery(document).ready( function() { |
| 900 |
jQuery('.postbox h3').click( function() { |
| 901 |
jQuery(jQuery(this).parent().get(0)).toggleClass('closed'); |
| 902 |
}); |
| 903 |
}); |
| 904 |
|
| 905 |
/** |
| 906 |
* Check All Checkboxes |
| 907 |
*/ |
| 908 |
function bd_checkAll(form) { |
| 909 |
for (i = 0, n = form.elements.length; i < n; i++) { |
| 910 |
if(form.elements[i].type == "checkbox" && !(form.elements[i].getAttribute('onclick',2))) { |
| 911 |
if(form.elements[i].checked == true) |
| 912 |
form.elements[i].checked = false; |
| 913 |
else |
| 914 |
form.elements[i].checked = true; |
| 915 |
} |
| 916 |
} |
| 917 |
} |
| 918 |
|
| 919 |
function toggle_date_restrict(el) { |
| 920 |
if (jQuery("#smbd_" + el + "_restrict").is(":checked")) { |
| 921 |
jQuery("#smbd_" + el + "_op").removeAttr('disabled'); |
| 922 |
jQuery("#smbd_" + el + "_days").removeAttr('disabled'); |
| 923 |
} else { |
| 924 |
jQuery("#smbd_" + el + "_op").attr('disabled', 'true'); |
| 925 |
jQuery("#smbd_" + el + "_days").attr('disabled', 'true'); |
| 926 |
} |
| 927 |
} |
| 928 |
|
| 929 |
function toggle_limit_restrict(el) { |
| 930 |
if (jQuery("#smbd_" + el + "_limit").is(":checked")) { |
| 931 |
jQuery("#smbd_" + el + "_limit_to").removeAttr('disabled'); |
| 932 |
} else { |
| 933 |
jQuery("#smbd_" + el + "_limit_to").attr('disabled', 'true'); |
| 934 |
} |
| 935 |
} |
| 936 |
|
| 937 |
/** |
| 938 |
* Validate Form |
| 939 |
*/ |
| 940 |
function bd_validateForm(form) { |
| 941 |
var valid = false; |
| 942 |
for (i = 0, n = form.elements.length; i < n; i++) { |
| 943 |
if(form.elements[i].type == "checkbox" && !(form.elements[i].getAttribute('onclick',2))) { |
| 944 |
if(form.elements[i].checked == true) { |
| 945 |
valid = true; |
| 946 |
break; |
| 947 |
} |
| 948 |
} |
| 949 |
} |
| 950 |
|
| 951 |
if (valid) { |
| 952 |
return confirm("<?php _e('Are you sure you want to delete all the selected posts', 'bulk-delete'); ?>"); |
| 953 |
} else { |
| 954 |
alert ("<?php _e('Please select at least one', 'bulk-delete'); ?>"); |
| 955 |
return false; |
| 956 |
} |
| 957 |
} |
| 958 |
</script> |
| 959 |
|
| 960 |
<?php |
| 961 |
} |
| 962 |
} |
| 963 |
|
| 964 |
add_filter( 'plugin_action_links', 'smbd_filter_plugin_actions', 10, 2 ); |
| 965 |
add_action('admin_menu', 'smbd_add_menu'); |
| 966 |
add_action('admin_init', 'smbd_request_handler'); |
| 967 |
?> |
| 968 |
|