Version Description
Download this release
Release Info
Developer | sudar |
Plugin | Bulk Delete |
Version | 0.4 |
Comparing to | |
See all releases |
Code changes from version 0.3 to 0.4
- bulk-delete.php +103 -16
- readme.txt +23 -5
bulk-delete.php
CHANGED
@@ -4,7 +4,7 @@ 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 |
-
Version: 0.
|
8 |
License: GPL
|
9 |
Author: Sudar
|
10 |
Author URI: http://sudarmuthu.com/
|
@@ -13,6 +13,7 @@ Author URI: http://sudarmuthu.com/
|
|
13 |
2009-02-02 - v0.1 - first version
|
14 |
2009-02-03 - v0.2 - Second release - Fixed issues with pagging
|
15 |
2009-04-05 - v0.3 - Third release - Prevented drafts from deleted when only posts are selected
|
|
|
16 |
|
17 |
*/
|
18 |
|
@@ -24,6 +25,7 @@ Author URI: http://sudarmuthu.com/
|
|
24 |
if (!function_exists('smbd_request_handler')) {
|
25 |
function smbd_request_handler() {
|
26 |
global $wpdb;
|
|
|
27 |
if (isset($_POST['smbd_action'])) {
|
28 |
|
29 |
$wp_query = new WP_Query;
|
@@ -34,8 +36,14 @@ if (!function_exists('smbd_request_handler')) {
|
|
34 |
case "bulk-delete-cats":
|
35 |
// delete by cats
|
36 |
$selected_cats = $_POST['smbd_cats'];
|
37 |
-
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
foreach ($posts as $post) {
|
40 |
wp_delete_post($post->ID);
|
41 |
}
|
@@ -45,6 +53,13 @@ if (!function_exists('smbd_request_handler')) {
|
|
45 |
case "bulk-delete-tags":
|
46 |
// delete by tags
|
47 |
$selected_tags = $_POST['smbd_tags'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
$posts = $wp_query->query(array('tag__in'=>$selected_tags, 'post_status'=>'publish', 'post_type'=>'post', 'nopaging'=>'true'));
|
49 |
|
50 |
foreach ($posts as $post) {
|
@@ -104,10 +119,10 @@ if (!function_exists('smbd_displayOptions')) {
|
|
104 |
global $wpdb;
|
105 |
?>
|
106 |
<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."); ?></strong></p></div>
|
107 |
-
|
108 |
-
|
109 |
|
110 |
-
|
111 |
|
112 |
<form name="smbd_form" id = "smbd_misc_form"
|
113 |
action="<?php echo get_bloginfo("wpurl"); ?>/wp-admin/options-general.php?page=bulk-delete.php" method="post"
|
@@ -120,7 +135,7 @@ if (!function_exists('smbd_displayOptions')) {
|
|
120 |
$pages = $wp_query->query(array('post_type'=>'page'));
|
121 |
?>
|
122 |
<fieldset class="options">
|
123 |
-
|
124 |
<tr>
|
125 |
<td scope="row" >
|
126 |
<input name="smbd_drafs" id ="smbd_drafs" value = "drafs" type = "checkbox" />
|
@@ -142,16 +157,16 @@ if (!function_exists('smbd_displayOptions')) {
|
|
142 |
</td>
|
143 |
</tr>
|
144 |
|
145 |
-
|
146 |
-
|
147 |
<p class="submit">
|
148 |
-
|
149 |
</p>
|
150 |
|
151 |
-
<?php wp_nonce_field('bulk-delete-posts'); ?>
|
152 |
|
153 |
-
|
154 |
-
|
155 |
|
156 |
<h3><?php _e("By Category"); ?></h3>
|
157 |
<h4><?php _e("Select the categories whose post you want to delete") ?></h4>
|
@@ -161,7 +176,7 @@ if (!function_exists('smbd_displayOptions')) {
|
|
161 |
onsubmit="return bd_validateForm(this);">
|
162 |
|
163 |
<fieldset class="options">
|
164 |
-
|
165 |
<?php
|
166 |
$categories = get_categories(array('hide_empty' => false));
|
167 |
foreach ($categories as $category) {
|
@@ -185,9 +200,26 @@ if (!function_exists('smbd_displayOptions')) {
|
|
185 |
<label for="smbd_cats_all"><?php _e("All Categories") ?></label>
|
186 |
</td>
|
187 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
|
189 |
-
|
190 |
-
|
191 |
<p class="submit">
|
192 |
<input type="submit" name="submit" value="<?php _e("Bulk Delete ") ?>»">
|
193 |
</p>
|
@@ -232,6 +264,24 @@ if (!function_exists('smbd_displayOptions')) {
|
|
232 |
</td>
|
233 |
</tr>
|
234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
</table>
|
236 |
</fieldset>
|
237 |
<p class="submit">
|
@@ -275,6 +325,15 @@ function smbd_print_scripts() {
|
|
275 |
}
|
276 |
}
|
277 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
/**
|
279 |
* Validate Form
|
280 |
*/
|
@@ -300,6 +359,34 @@ function smbd_print_scripts() {
|
|
300 |
<?php
|
301 |
}
|
302 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
/**
|
304 |
* Add navigation menu
|
305 |
*/
|
@@ -331,7 +418,7 @@ function smbd_filter_plugin_actions($links, $file) {
|
|
331 |
* Adds Footer links. Based on http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/
|
332 |
*/
|
333 |
function smbd_admin_footer() {
|
334 |
-
|
335 |
printf('%1$s ' . __("plugin") .' | ' . __("Version") . ' %2$s | '. __('by') . ' %3$s<br />', $plugin_data['Title'], $plugin_data['Version'], $plugin_data['Author']);
|
336 |
}
|
337 |
|
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 |
+
Version: 0.4
|
8 |
License: GPL
|
9 |
Author: Sudar
|
10 |
Author URI: http://sudarmuthu.com/
|
13 |
2009-02-02 - v0.1 - first version
|
14 |
2009-02-03 - v0.2 - Second release - Fixed issues with pagging
|
15 |
2009-04-05 - v0.3 - Third release - Prevented drafts from deleted when only posts are selected
|
16 |
+
2009-07-05 - v0.4 - Fourth release - Added option to delete by date.
|
17 |
|
18 |
*/
|
19 |
|
25 |
if (!function_exists('smbd_request_handler')) {
|
26 |
function smbd_request_handler() {
|
27 |
global $wpdb;
|
28 |
+
|
29 |
if (isset($_POST['smbd_action'])) {
|
30 |
|
31 |
$wp_query = new WP_Query;
|
36 |
case "bulk-delete-cats":
|
37 |
// delete by cats
|
38 |
$selected_cats = $_POST['smbd_cats'];
|
39 |
+
if ($_POST['smbd_cats_restrict'] == "true") {
|
40 |
|
41 |
+
add_option('cats_op', $_POST['smbd_cats_op']);
|
42 |
+
add_option('cats_days', $_POST['smbd_cats_days']);
|
43 |
+
|
44 |
+
add_filter ('posts_where', 'cats_by_days');
|
45 |
+
}
|
46 |
+
$posts = $wp_query->query(array('category__in'=>$selected_cats,'post_status'=>'publish', 'post_type'=>'post', 'nopaging'=>'true'));
|
47 |
foreach ($posts as $post) {
|
48 |
wp_delete_post($post->ID);
|
49 |
}
|
53 |
case "bulk-delete-tags":
|
54 |
// delete by tags
|
55 |
$selected_tags = $_POST['smbd_tags'];
|
56 |
+
if ($_POST['smbd_tags_restrict'] == "true") {
|
57 |
+
|
58 |
+
add_option('tags_op', $_POST['smbd_tags_op']);
|
59 |
+
add_option('tags_days', $_POST['smbd_tags_days']);
|
60 |
+
|
61 |
+
add_filter ('posts_where', 'tags_by_days');
|
62 |
+
}
|
63 |
$posts = $wp_query->query(array('tag__in'=>$selected_tags, 'post_status'=>'publish', 'post_type'=>'post', 'nopaging'=>'true'));
|
64 |
|
65 |
foreach ($posts as $post) {
|
119 |
global $wpdb;
|
120 |
?>
|
121 |
<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."); ?></strong></p></div>
|
122 |
+
<div class="wrap">
|
123 |
+
<h2>Bulk Delete</h2>
|
124 |
|
125 |
+
<h3><?php _e("Select the posts which you want to delete"); ?></h3>
|
126 |
|
127 |
<form name="smbd_form" id = "smbd_misc_form"
|
128 |
action="<?php echo get_bloginfo("wpurl"); ?>/wp-admin/options-general.php?page=bulk-delete.php" method="post"
|
135 |
$pages = $wp_query->query(array('post_type'=>'page'));
|
136 |
?>
|
137 |
<fieldset class="options">
|
138 |
+
<table class="optiontable">
|
139 |
<tr>
|
140 |
<td scope="row" >
|
141 |
<input name="smbd_drafs" id ="smbd_drafs" value = "drafs" type = "checkbox" />
|
157 |
</td>
|
158 |
</tr>
|
159 |
|
160 |
+
</table>
|
161 |
+
</fieldset>
|
162 |
<p class="submit">
|
163 |
+
<input type="submit" name="submit" value="<?php _e("Bulk Delete ") ?>»">
|
164 |
</p>
|
165 |
|
166 |
+
<?php wp_nonce_field('bulk-delete-posts'); ?>
|
167 |
|
168 |
+
<input type="hidden" name="smbd_action" value="bulk-delete-special" />
|
169 |
+
</form>
|
170 |
|
171 |
<h3><?php _e("By Category"); ?></h3>
|
172 |
<h4><?php _e("Select the categories whose post you want to delete") ?></h4>
|
176 |
onsubmit="return bd_validateForm(this);">
|
177 |
|
178 |
<fieldset class="options">
|
179 |
+
<table class="optiontable">
|
180 |
<?php
|
181 |
$categories = get_categories(array('hide_empty' => false));
|
182 |
foreach ($categories as $category) {
|
200 |
<label for="smbd_cats_all"><?php _e("All Categories") ?></label>
|
201 |
</td>
|
202 |
</tr>
|
203 |
+
<tr>
|
204 |
+
<td colspan="2"></td>
|
205 |
+
</tr>
|
206 |
+
|
207 |
+
<tr>
|
208 |
+
<td scope="row">
|
209 |
+
<input name="smbd_cats_restrict" id="smbd_cats_restrict" value = "true" type = "checkbox" onclick="toggle_date_restrict('cats');" />
|
210 |
+
</td>
|
211 |
+
<td>
|
212 |
+
<?php _e("Only restrict to posts which are ");?>
|
213 |
+
<select name="smbd_cats_op" id="smbd_cats_op" disabled>
|
214 |
+
<option value ="<"><?php _e("older than");?></option>
|
215 |
+
<option value =">"><?php _e("posted within last");?></option>
|
216 |
+
</select>
|
217 |
+
<input type ="textbox" name="smbd_cats_days" id="smbd_cats_days" disabled value ="0" maxlength="4" size="4" /><?php _e("days");?>
|
218 |
+
</td>
|
219 |
+
</tr>
|
220 |
|
221 |
+
</table>
|
222 |
+
</fieldset>
|
223 |
<p class="submit">
|
224 |
<input type="submit" name="submit" value="<?php _e("Bulk Delete ") ?>»">
|
225 |
</p>
|
264 |
</td>
|
265 |
</tr>
|
266 |
|
267 |
+
<tr>
|
268 |
+
<td colspan="2"></td>
|
269 |
+
</tr>
|
270 |
+
|
271 |
+
<tr>
|
272 |
+
<td scope="row">
|
273 |
+
<input name="smbd_tags_restrict" id ="smbd_tags_restrict" value = "true" type = "checkbox" onclick="toggle_date_restrict('tags');" />
|
274 |
+
</td>
|
275 |
+
<td>
|
276 |
+
<?php _e("Only restrict to posts which are ");?>
|
277 |
+
<select name="smbd_tags_op" id="smbd_tags_op" disabled>
|
278 |
+
<option value ="<"><?php _e("older than");?></option>
|
279 |
+
<option value =">"><?php _e("posted within last");?></option>
|
280 |
+
</select>
|
281 |
+
<input type ="textbox" name="smbd_tags_days" id ="smbd_tags_days" value ="0" maxlength="4" size="4" disabled /><?php _e("days");?>
|
282 |
+
</td>
|
283 |
+
</tr>
|
284 |
+
|
285 |
</table>
|
286 |
</fieldset>
|
287 |
<p class="submit">
|
325 |
}
|
326 |
}
|
327 |
|
328 |
+
function toggle_date_restrict(el) {
|
329 |
+
if (jQuery("#smbd_" + el + "_restrict").is(":checked")) {
|
330 |
+
jQuery("#smbd_" + el + "_op").removeAttr('disabled');
|
331 |
+
jQuery("#smbd_" + el + "_days").removeAttr('disabled');
|
332 |
+
} else {
|
333 |
+
jQuery("#smbd_" + el + "_op").attr('disabled', 'true');
|
334 |
+
jQuery("#smbd_" + el + "_days").attr('disabled', 'true');
|
335 |
+
}
|
336 |
+
}
|
337 |
/**
|
338 |
* Validate Form
|
339 |
*/
|
359 |
<?php
|
360 |
}
|
361 |
|
362 |
+
/**
|
363 |
+
* function to filter posts by days
|
364 |
+
* @param <type> $where
|
365 |
+
* @return <type>
|
366 |
+
*/
|
367 |
+
function cats_by_days ($where = '') {
|
368 |
+
$cats_op = get_option('cats_op');
|
369 |
+
$cats_days = get_option('cats_days');
|
370 |
+
remove_filter('posts_where', 'cats_by_days');
|
371 |
+
|
372 |
+
$where .= " AND post_date $cats_op '" . date('y-m-d', strtotime("-$cats_days days")) . "'";
|
373 |
+
return $where;
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* function to filter posts by days
|
378 |
+
* @param <type> $where
|
379 |
+
* @return <type>
|
380 |
+
*/
|
381 |
+
function tags_by_days ($where = '') {
|
382 |
+
$tags_op = get_option('tags_op');
|
383 |
+
$tags_days = get_option('tags_days');
|
384 |
+
|
385 |
+
remove_filter('posts_where', 'tags_by_days');
|
386 |
+
$where .= " AND post_date $tags_op '" . date('y-m-d', strtotime("-$tags_days days")) . "'";
|
387 |
+
return $where;
|
388 |
+
}
|
389 |
+
|
390 |
/**
|
391 |
* Add navigation menu
|
392 |
*/
|
418 |
* Adds Footer links. Based on http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/
|
419 |
*/
|
420 |
function smbd_admin_footer() {
|
421 |
+
$plugin_data = get_plugin_data( __FILE__ );
|
422 |
printf('%1$s ' . __("plugin") .' | ' . __("Version") . ' %2$s | '. __('by') . ' %3$s<br />', $plugin_data['Title'], $plugin_data['Version'], $plugin_data['Author']);
|
423 |
}
|
424 |
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== Bulk Delete ===
|
2 |
Contributors: sudar
|
3 |
Tags: post, comment, delete, bulk, draft, revision, page
|
4 |
-
Requires at least: 2.
|
5 |
-
Tested up to: 2.
|
6 |
-
Stable tag: 0.
|
7 |
|
8 |
Bulk delete posts from selected categories or tags
|
9 |
|
@@ -22,6 +22,24 @@ If you looking for just moving posts, instead of deleting, then use [Bulk Move P
|
|
22 |
|
23 |
Extract the zip file and just drop the contents in the wp-content/plugins/ directory of your WordPress installation and then activate the Plugin from Plugins page.
|
24 |
|
25 |
-
|
26 |
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
=== Bulk Delete ===
|
2 |
Contributors: sudar
|
3 |
Tags: post, comment, delete, bulk, draft, revision, page
|
4 |
+
Requires at least: 2.0
|
5 |
+
Tested up to: 2.8.1
|
6 |
+
Stable tag: 0.4
|
7 |
|
8 |
Bulk delete posts from selected categories or tags
|
9 |
|
22 |
|
23 |
Extract the zip file and just drop the contents in the wp-content/plugins/ directory of your WordPress installation and then activate the Plugin from Plugins page.
|
24 |
|
25 |
+
== Changelog ==
|
26 |
|
27 |
+
**v0.1 (2009-02-02)**
|
28 |
+
|
29 |
+
* first version
|
30 |
+
|
31 |
+
**v0.2 (2009-02-03)**
|
32 |
+
|
33 |
+
* Fixed issues with pagging
|
34 |
+
|
35 |
+
**v0.3 (2009-04-05)**
|
36 |
+
|
37 |
+
* Prevented drafts from deleted when only posts are selected
|
38 |
+
|
39 |
+
**v0.4 (2009-07-05)**
|
40 |
+
|
41 |
+
* Added option to delete by date.
|
42 |
+
|
43 |
+
==Readme Generator==
|
44 |
+
|
45 |
+
This Readme file was generated using <a href = 'http://sudarmuthu.com/projects/wp-readme.php'>wp-readme</a>, which generates readme files for WordPress Plugins.
|