author | Anthony Ly <anthonyly.com@gmail.com> |
Wed, 19 Dec 2012 17:46:52 -0800 | |
changeset 204 | 09a1c134465b |
parent 194 | 32102edaa81b |
permissions | -rw-r--r-- |
136 | 1 |
<?php |
2 |
/** |
|
3 |
* Edit post administration panel. |
|
4 |
* |
|
5 |
* Manage Post actions: post, edit, delete, etc. |
|
6 |
* |
|
7 |
* @package WordPress |
|
8 |
* @subpackage Administration |
|
9 |
*/ |
|
10 |
||
11 |
/** WordPress Administration Bootstrap */ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
12 |
require_once('./admin.php'); |
136 | 13 |
|
14 |
$parent_file = 'edit.php'; |
|
15 |
$submenu_file = 'edit.php'; |
|
16 |
||
17 |
wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder')); |
|
18 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
19 |
if ( isset( $_GET['post'] ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
20 |
$post_id = $post_ID = (int) $_GET['post']; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
21 |
elseif ( isset( $_POST['post_ID'] ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
22 |
$post_id = $post_ID = (int) $_POST['post_ID']; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
23 |
else |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
24 |
$post_id = $post_ID = 0; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
25 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
26 |
$post = $post_type = $post_type_object = null; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
27 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
28 |
if ( $post_id ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
29 |
$post = get_post( $post_id ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
30 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
31 |
if ( $post ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
32 |
$post_type = $post->post_type; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
33 |
$post_type_object = get_post_type_object( $post_type ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
34 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
35 |
|
136 | 36 |
/** |
37 |
* Redirect to previous page. |
|
38 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
39 |
* @param int $post_id Optional. Post ID. |
136 | 40 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
41 |
function redirect_post($post_id = '') { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
42 |
if ( isset($_POST['save']) || isset($_POST['publish']) ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
43 |
$status = get_post_status( $post_id ); |
136 | 44 |
|
45 |
if ( isset( $_POST['publish'] ) ) { |
|
46 |
switch ( $status ) { |
|
47 |
case 'pending': |
|
48 |
$message = 8; |
|
49 |
break; |
|
50 |
case 'future': |
|
51 |
$message = 9; |
|
52 |
break; |
|
53 |
default: |
|
54 |
$message = 6; |
|
55 |
} |
|
56 |
} else { |
|
57 |
$message = 'draft' == $status ? 10 : 1; |
|
58 |
} |
|
59 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
60 |
$location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) ); |
136 | 61 |
} elseif ( isset($_POST['addmeta']) && $_POST['addmeta'] ) { |
62 |
$location = add_query_arg( 'message', 2, wp_get_referer() ); |
|
63 |
$location = explode('#', $location); |
|
64 |
$location = $location[0] . '#postcustom'; |
|
65 |
} elseif ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) { |
|
66 |
$location = add_query_arg( 'message', 3, wp_get_referer() ); |
|
67 |
$location = explode('#', $location); |
|
68 |
$location = $location[0] . '#postcustom'; |
|
69 |
} elseif ( 'post-quickpress-save-cont' == $_POST['action'] ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
70 |
$location = "post.php?action=edit&post=$post_id&message=7"; |
136 | 71 |
} else { |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
72 |
$location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) ); |
136 | 73 |
} |
74 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
75 |
wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
76 |
exit; |
136 | 77 |
} |
78 |
||
79 |
if ( isset( $_POST['deletepost'] ) ) |
|
80 |
$action = 'delete'; |
|
81 |
elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] ) |
|
82 |
$action = 'preview'; |
|
83 |
||
84 |
$sendback = wp_get_referer(); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
85 |
if ( ! $sendback || |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
86 |
strpos( $sendback, 'post.php' ) !== false || |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
87 |
strpos( $sendback, 'post-new.php' ) !== false ) { |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
88 |
if ( 'attachment' == $post_type ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
89 |
$sendback = admin_url( 'upload.php' ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
90 |
} else { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
91 |
$sendback = admin_url( 'edit.php' ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
92 |
$sendback .= ( ! empty( $post_type ) ) ? '?post_type=' . $post_type : ''; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
93 |
} |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
94 |
} else { |
136 | 95 |
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $sendback ); |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
96 |
} |
136 | 97 |
|
98 |
switch($action) { |
|
99 |
case 'postajaxpost': |
|
100 |
case 'post': |
|
101 |
case 'post-quickpress-publish': |
|
102 |
case 'post-quickpress-save': |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
103 |
check_admin_referer('add-' . $post_type); |
136 | 104 |
|
105 |
if ( 'post-quickpress-publish' == $action ) |
|
106 |
$_POST['publish'] = 'publish'; // tell write_post() to publish |
|
107 |
||
108 |
if ( 'post-quickpress-publish' == $action || 'post-quickpress-save' == $action ) { |
|
109 |
$_POST['comment_status'] = get_option('default_comment_status'); |
|
110 |
$_POST['ping_status'] = get_option('default_ping_status'); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
111 |
$post_id = edit_post(); |
136 | 112 |
} else { |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
113 |
$post_id = 'postajaxpost' == $action ? edit_post() : write_post(); |
136 | 114 |
} |
115 |
||
116 |
if ( 0 === strpos( $action, 'post-quickpress' ) ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
117 |
$_POST['post_ID'] = $post_id; |
136 | 118 |
// output the quickpress dashboard widget |
119 |
require_once(ABSPATH . 'wp-admin/includes/dashboard.php'); |
|
120 |
wp_dashboard_quick_press(); |
|
121 |
exit; |
|
122 |
} |
|
123 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
124 |
redirect_post($post_id); |
136 | 125 |
exit(); |
126 |
break; |
|
127 |
||
128 |
case 'edit': |
|
129 |
$editing = true; |
|
130 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
131 |
if ( empty( $post_id ) ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
132 |
wp_redirect( admin_url('post.php') ); |
136 | 133 |
exit(); |
134 |
} |
|
135 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
136 |
$p = $post_id; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
137 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
138 |
if ( empty($post->ID) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
139 |
wp_die( __('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?') ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
140 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
141 |
if ( null == $post_type_object ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
142 |
wp_die( __('Unknown post type.') ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
143 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
144 |
if ( !current_user_can($post_type_object->cap->edit_post, $post_id) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
145 |
wp_die( __('You are not allowed to edit this item.') ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
146 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
147 |
if ( 'trash' == $post->post_status ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
148 |
wp_die( __('You can’t edit this item because it is in the Trash. Please restore it and try again.') ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
149 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
150 |
$post_type = $post->post_type; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
151 |
if ( 'post' == $post_type ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
152 |
$parent_file = "edit.php"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
153 |
$submenu_file = "edit.php"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
154 |
$post_new_file = "post-new.php"; |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
155 |
} elseif ( 'attachment' == $post_type ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
156 |
$parent_file = 'upload.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
157 |
$submenu_file = 'upload.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
158 |
$post_new_file = 'media-new.php'; |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
159 |
} else { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
160 |
if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
161 |
$parent_file = $post_type_object->show_in_menu; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
162 |
else |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
163 |
$parent_file = "edit.php?post_type=$post_type"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
164 |
$submenu_file = "edit.php?post_type=$post_type"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
165 |
$post_new_file = "post-new.php?post_type=$post_type"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
166 |
} |
136 | 167 |
|
168 |
if ( $last = wp_check_post_lock( $post->ID ) ) { |
|
169 |
add_action('admin_notices', '_admin_notice_post_locked' ); |
|
170 |
} else { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
171 |
$active_post_lock = wp_set_post_lock( $post->ID ); |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
172 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
173 |
if ( 'attachment' !== $post_type ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
174 |
wp_enqueue_script('autosave'); |
136 | 175 |
} |
176 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
177 |
$title = $post_type_object->labels->edit_item; |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
178 |
$post = get_post($post_id, OBJECT, 'edit'); |
136 | 179 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
180 |
if ( post_type_supports($post_type, 'comments') ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
181 |
wp_enqueue_script('admin-comments'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
182 |
enqueue_comment_hotkeys_js(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
183 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
184 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
185 |
include('./edit-form-advanced.php'); |
136 | 186 |
|
187 |
break; |
|
188 |
||
189 |
case 'editattachment': |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
190 |
check_admin_referer('update-post_' . $post_id); |
136 | 191 |
|
192 |
// Don't let these be changed |
|
193 |
unset($_POST['guid']); |
|
194 |
$_POST['post_type'] = 'attachment'; |
|
195 |
||
196 |
// Update the thumbnail filename |
|
197 |
$newmeta = wp_get_attachment_metadata( $post_id, true ); |
|
198 |
$newmeta['thumb'] = $_POST['thumb']; |
|
199 |
||
200 |
wp_update_attachment_metadata( $post_id, $newmeta ); |
|
201 |
||
202 |
case 'editpost': |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
203 |
check_admin_referer('update-post_' . $post_id); |
136 | 204 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
205 |
$post_id = edit_post(); |
136 | 206 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
207 |
redirect_post($post_id); // Send user on their way while we keep working |
136 | 208 |
|
209 |
exit(); |
|
210 |
break; |
|
211 |
||
212 |
case 'trash': |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
213 |
check_admin_referer('trash-post_' . $post_id); |
136 | 214 |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
215 |
$post = get_post($post_id); |
136 | 216 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
217 |
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
218 |
wp_die( __('You are not allowed to move this item to the Trash.') ); |
136 | 219 |
|
220 |
if ( ! wp_trash_post($post_id) ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
221 |
wp_die( __('Error in moving to Trash.') ); |
136 | 222 |
|
223 |
wp_redirect( add_query_arg( array('trashed' => 1, 'ids' => $post_id), $sendback ) ); |
|
224 |
exit(); |
|
225 |
break; |
|
226 |
||
227 |
case 'untrash': |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
228 |
check_admin_referer('untrash-post_' . $post_id); |
136 | 229 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
230 |
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
231 |
wp_die( __('You are not allowed to move this item out of the Trash.') ); |
136 | 232 |
|
233 |
if ( ! wp_untrash_post($post_id) ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
234 |
wp_die( __('Error in restoring from Trash.') ); |
136 | 235 |
|
236 |
wp_redirect( add_query_arg('untrashed', 1, $sendback) ); |
|
237 |
exit(); |
|
238 |
break; |
|
239 |
||
240 |
case 'delete': |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
241 |
check_admin_referer('delete-post_' . $post_id); |
136 | 242 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
243 |
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
244 |
wp_die( __('You are not allowed to delete this item.') ); |
136 | 245 |
|
246 |
$force = !EMPTY_TRASH_DAYS; |
|
247 |
if ( $post->post_type == 'attachment' ) { |
|
248 |
$force = ( $force || !MEDIA_TRASH ); |
|
249 |
if ( ! wp_delete_attachment($post_id, $force) ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
250 |
wp_die( __('Error in deleting.') ); |
136 | 251 |
} else { |
252 |
if ( !wp_delete_post($post_id, $force) ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
253 |
wp_die( __('Error in deleting.') ); |
136 | 254 |
} |
255 |
||
256 |
wp_redirect( add_query_arg('deleted', 1, $sendback) ); |
|
257 |
exit(); |
|
258 |
break; |
|
259 |
||
260 |
case 'preview': |
|
261 |
check_admin_referer( 'autosave', 'autosavenonce' ); |
|
262 |
||
263 |
$url = post_preview(); |
|
264 |
||
265 |
wp_redirect($url); |
|
266 |
exit(); |
|
267 |
break; |
|
268 |
||
269 |
default: |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
270 |
wp_redirect( admin_url('edit.php') ); |
136 | 271 |
exit(); |
272 |
break; |
|
273 |
} // end switch |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
274 |
include('./admin-footer.php'); |