2005-11-13 05:40:18 +01:00
|
|
|
<?php
|
|
|
|
require_once('../wp-config.php');
|
|
|
|
require_once('admin-functions.php');
|
|
|
|
require_once('admin-db.php');
|
|
|
|
|
2005-12-15 17:31:41 +01:00
|
|
|
if ( !is_user_logged_in() )
|
2005-11-13 05:40:18 +01:00
|
|
|
die('-1');
|
2006-04-21 23:18:32 +02:00
|
|
|
if ( !check_ajax_referer() )
|
|
|
|
die('-1');
|
2005-11-13 05:40:18 +01:00
|
|
|
|
|
|
|
function grab_results() {
|
|
|
|
global $ajax_results;
|
|
|
|
$ajax_results = func_get_arg(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_out_now() { exit; }
|
|
|
|
add_action('shutdown', 'get_out_now', -1);
|
|
|
|
|
|
|
|
switch ( $_POST['action'] ) :
|
|
|
|
case 'delete-link' :
|
|
|
|
$id = (int) $_POST['id'];
|
|
|
|
if ( !current_user_can('manage_links') )
|
|
|
|
die ('-1');
|
|
|
|
|
2006-03-06 19:49:49 +01:00
|
|
|
if ( wp_delete_link($id) )
|
2005-11-13 05:40:18 +01:00
|
|
|
die('1');
|
|
|
|
else die('0');
|
|
|
|
break;
|
|
|
|
case 'delete-post' :
|
|
|
|
case 'delete-page' :
|
|
|
|
$id = (int) $_POST['id'];
|
2005-12-29 22:16:53 +01:00
|
|
|
if ( !current_user_can('edit_post', $id) ) {
|
2005-11-13 05:40:18 +01:00
|
|
|
die('-1');
|
2005-12-29 22:16:53 +01:00
|
|
|
}
|
2005-11-13 05:40:18 +01:00
|
|
|
|
2005-12-29 22:16:53 +01:00
|
|
|
if ( wp_delete_post($id) ) {
|
2005-11-13 05:40:18 +01:00
|
|
|
die('1');
|
2005-12-29 22:16:53 +01:00
|
|
|
} else die('0');
|
2005-11-13 05:40:18 +01:00
|
|
|
break;
|
|
|
|
case 'delete-cat' :
|
|
|
|
if ( !current_user_can('manage_categories') )
|
|
|
|
die ('-1');
|
|
|
|
|
|
|
|
$id = (int) $_POST['id'];
|
|
|
|
$cat_name = get_catname($cat_ID);
|
|
|
|
|
|
|
|
if ( wp_delete_category($id) )
|
|
|
|
die('1');
|
|
|
|
else die('0');
|
|
|
|
break;
|
|
|
|
case 'delete-comment' :
|
|
|
|
$id = (int) $_POST['id'];
|
|
|
|
|
|
|
|
if ( !$comment = get_comment($id) )
|
|
|
|
die('0');
|
|
|
|
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
|
|
|
|
die('-1');
|
|
|
|
|
2005-11-16 07:29:36 +01:00
|
|
|
if ( wp_delete_comment($comment->comment_ID) ) {
|
2005-11-13 05:40:18 +01:00
|
|
|
die('1');
|
|
|
|
} else {
|
|
|
|
die('0');
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'delete-link-category' :
|
|
|
|
$id = (int) $_POST['id'];
|
|
|
|
if ( 1 == $id )
|
|
|
|
die('0');
|
|
|
|
if ( !current_user_can('manage_links') )
|
|
|
|
die('-1');
|
|
|
|
|
|
|
|
if ( $wpdb->query("DELETE FROM $wpdb->linkcategories WHERE cat_id='$id'") ) {
|
|
|
|
$wpdb->query("UPDATE $wpdb->links SET link_category=1 WHERE link_category='$id'");
|
|
|
|
die('1');
|
|
|
|
} else {
|
|
|
|
die('0');
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
endswitch;
|
|
|
|
?>
|