PluginProbe
Welcart e-Commerce / 1.3.8
Welcart e-Commerce v1.3.8
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
usc-e-shop / includes / usces_item_master_edit.php

usces_item_master_edit.php in Welcart e-Commerce 1.3.8, at includes/usces_item_master_edit.php

389 lines 13.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 */
12 //require_once('admin.php');
13 /* 30 **************************************/
14 global $wp_version;
15 /***************************************/
16
17 //$parent_file = 'admin.php?page=usces_itemedit';
18 //$submenu_file = 'admin.php?page=usces_itemedit';
19 wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder'));
20
21 /**
22 * Redirect to previous page.
23 *
24 * @param int $post_ID Optional. Post ID.
25 */
26 function redirect_post($post_ID = '') {
27 global $action;
28
29 $referredby = '';
30 if ( !empty($_POST['referredby']) ) {
31 $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']);
32 $referredby = remove_query_arg('_wp_original_http_referer', $referredby);
33 }
34 $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer());
35
36 if ( !empty($_POST['mode']) && 'bookmarklet' == $_POST['mode'] ) {
37 $location = $_POST['referredby'];
38 } elseif ( !empty($_POST['mode']) && 'sidebar' == $_POST['mode'] ) {
39 if ( isset($_POST['saveasdraft']) )
40 $location = 'sidebar.php?a=c';
41 elseif ( isset($_POST['publish']) )
42 $location = 'sidebar.php?a=b';
43 } elseif ( ( isset($_POST['save']) || isset($_POST['publish']) ) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) {
44 if ( isset($_POST['_wp_original_http_referer']) && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post.php') === false && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post-new.php') === false ) {
45 $location = add_query_arg( array(
46 '_wp_original_http_referer' => urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ),
47 'message' => 1
48 ), usces_link_replace( get_edit_post_link( $post_ID, 'url' ) ) );
49 } else {
50 if ( isset( $_POST['publish'] ) ) {
51 if ( 'pending' == get_post_status( $post_ID ) )
52 $location = add_query_arg( 'message', 8, usces_link_replace( get_edit_post_link( $post_ID, 'url' ) ) );
53 else
54 $location = add_query_arg( 'message', 6, usces_link_replace( get_edit_post_link( $post_ID, 'url' ) ) );
55 } else {
56 $location = add_query_arg( 'message', 7, usces_link_replace( get_edit_post_link( $post_ID, 'url' ) ) );
57 }
58 //$dd=usces_link_replace( get_edit_post_link( $post_ID, 'url' ) );
59 // var_dump($referer);echo "<br>\n";
60 // var_dump($dd);echo "<br>\n";
61 // var_dump($location);echo "\n";
62 // exit;
63 }
64 } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) {
65 $location = add_query_arg( 'message', 2, wp_get_referer() );
66 $location = explode('#', $location);
67 $location = $location[0] . '#postcustom';
68 } elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) {
69 $location = add_query_arg( 'message', 3, wp_get_referer() );
70 $location = explode('#', $location);
71 $location = $location[0] . '#postcustom';
72 } elseif (!empty($referredby) && $referredby != $referer) {
73 $location = $_POST['referredby'];
74 $location = remove_query_arg('_wp_original_http_referer', $location);
75 if ( false !== strpos($location, 'edit.php') || false !== strpos($location, 'edit-post-drafts.php') )
76 $location = add_query_arg('posted', $post_ID, $location);
77 elseif ( false !== strpos($location, 'wp-admin') )
78 $location = "post-new.php?posted=$post_ID";
79 } elseif ( isset($_POST['publish']) ) {
80 $location = "post-new.php?posted=$post_ID";
81 } elseif ($action == 'editattachment') {
82 $location = 'attachments.php';
83 } elseif ( 'post-quickpress-save-cont' == $_POST['action'] ) {
84 $location = "post.php?action=edit&post=$post_ID&message=7";
85 } else {
86 $location = add_query_arg( 'message', 4, usces_link_replace( get_edit_post_link( $post_ID, 'url' ) ) );
87 }
88 //var_dump($location);echo "<br>\n";
89 wp_redirect( $location );
90 }
91
92 function usces_get_message($post_ID) {
93
94 if ( ( isset($_POST['save']) || isset($_POST['publish']) ) ) {
95 if ( isset($_POST['_wp_original_http_referer']) && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post.php') === false && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post-new.php') === false ) {
96 $this->action_message = sprintf(__('Post updated. <a href="%s">View post</a>'), get_permalink($post_ID));
97 } else {
98 if ( isset( $_POST['publish'] ) ) {
99 if ( 'pending' == get_post_status( $post_ID ) )
100 $this->action_message = sprintf(__('Post submitted. <a href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) );
101 else
102 $this->action_message = sprintf(__('Post published. <a href="%s">View post</a>'), get_permalink($post_ID));
103 } else {
104 $this->action_message = __('Post saved.');
105 }
106 }
107 } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) {
108 $this->action_message = __('Custom field updated.');
109 } elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) {
110 $this->action_message = __('Custom field deleted.');
111 } elseif ( 'post-quickpress-save-cont' == $_POST['action'] ) {
112 $this->action_message = __('Post saved.');
113 } else {
114 $this->action_message = __('Post updated.');
115 }
116
117 $this->action_status = 'none';
118 }
119
120 if ( isset( $_POST['deletepost'] ) )
121 $action = 'delete';
122 //elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] )
123 // $action = 'preview';
124
125 switch($action) {
126 //case 'postajaxpost':
127 //case 'post-quickpress-publish':
128 //case 'post-quickpress-save':
129 // check_admin_referer('add-post');
130 //
131 // if ( 'post-quickpress-publish' == $action )
132 // $_POST['publish'] = 'publish'; // tell write_post() to publish
133 //
134 // if ( 'post-quickpress-publish' == $action || 'post-quickpress-save' == $action ) {
135 // $_POST['comment_status'] = get_option('default_comment_status');
136 // $_POST['ping_status'] = get_option('default_ping_status');
137 // }
138 //
139 // if ( !empty( $_POST['quickpress_post_ID'] ) ) {
140 // $_POST['post_ID'] = (int) $_POST['quickpress_post_ID'];
141 // $post_ID = edit_post();
142 // } else {
143 // $post_ID = 'postajaxpost' == $action ? item_option_edit_post() : write_post();
144 // }
145 //
146 // if ( 0 === strpos( $action, 'post-quickpress' ) ) {
147 // $_POST['post_ID'] = $post_ID;
148 // // output the quickpress dashboard widget
149 // require_once(ABSPATH . 'wp-admin/includes/dashboard.php');
150 // wp_dashboard_quick_press();
151 // exit;
152 // }
153 //
154 // redirect_post($post_ID);
155 // exit();
156 // break;
157
158 case 'post':
159 case 'edit':
160 $editing = true;
161
162 if ( empty( $_GET['post'] ) ) {
163 wp_redirect("post.php");
164 exit();
165 }
166
167 $title = 'Welcart Shop '.__('Edit item', 'usces');
168
169 $this->action_status = 'none';
170
171 if ( version_compare($wp_version, '3.0-beta', '>') ){
172 global $post;
173 if ( $post ) {
174 $post_type_object = get_post_type_object($post->post_type);
175 if ( $post_type_object ) {
176 $post_type = $post->post_type;
177 $current_screen->post_type = $post->post_type;
178 $current_screen->id = $current_screen->post_type;
179 }
180 $post_id = $post->ID;
181 $post_ID = $post->ID;
182 }
183
184 $p = $post_id;
185
186 if ( empty($post->ID) )
187 wp_die( __('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?') );
188
189 if ( !current_user_can($post_type_object->cap->edit_post, $post_id) )
190 wp_die( __('You are not allowed to edit this item.') );
191
192 if ( 'trash' == $post->post_status )
193 wp_die( __('You can&#8217;t edit this item because it is in the Trash. Please restore it and try again.') );
194
195 if ( null == $post_type_object )
196 wp_die( __('Unknown post type.') );
197
198 $post_type = $post->post_type;
199 //$title = sprintf(__('Edit %s'), $post_type_object->singular_label);
200 if ( version_compare($wp_version, '3.4-beta', '>') ){
201 include(USCES_PLUGIN_DIR."/includes/edit-form-advanced34.php");
202 }else{
203 include(USCES_PLUGIN_DIR."/includes/edit-form-advanced30.php");
204 }
205
206 }else{
207
208 $post_ID = $p = (int) $_GET['post'];
209 $post = get_post($post_ID);
210
211 if ( empty($post->ID) ) wp_die( __("You attempted to edit a post that doesn't exist. Perhaps it was deleted?") );
212
213 if ( 'post' != $post->post_type ) {
214 wp_redirect( get_edit_post_link( $post->ID, 'url' ) );
215 exit();
216 }
217 if ( !current_user_can('edit_post', $post_ID) )
218 die ( __('You are not allowed to edit this post.') );
219
220 $post = get_post_to_edit($post_ID);
221 include(USCES_PLUGIN_DIR."/includes/edit-form-advanced.php");
222 }
223
224 break;
225
226 //case 'editattachment':
227 // $post_id = (int) $_POST['post_ID'];
228 //
229 // check_admin_referer('update-attachment_' . $post_id);
230 //
231 // // Don't let these be changed
232 // unset($_POST['guid']);
233 // $_POST['post_type'] = 'attachment';
234 //
235 // // Update the thumbnail filename
236 // $newmeta = wp_get_attachment_metadata( $post_id, true );
237 // $newmeta['thumb'] = $_POST['thumb'];
238 //
239 // wp_update_attachment_metadata( $post_id, $newmeta );
240 //
241 case 'editpost':
242
243 global $post;
244 $title = 'Welcart Shop '.__('Edit item', 'usces');
245 // if ( !current_user_can('edit_post', $post->ID) )
246 // die ( __('You are not allowed to edit this post.') );
247
248 if ( version_compare($wp_version, '3.0-beta', '>') ){
249 if ( $post ) {
250 $post_type_object = get_post_type_object($post->post_type);
251 if ( $post_type_object ) {
252 $post_type = $post->post_type;
253 $current_screen->post_type = $post->post_type;
254 $current_screen->id = $current_screen->post_type;
255 }
256 $post_id = $post->ID;
257 $post_ID = $post->ID;
258 }
259 add_action('check_admin_referer', 'usces_update_check_admin');
260
261 check_admin_referer('update-' . $post_type . '_' . $post_id);
262 $post_id = edit_post();
263 $post_ID = $post_id;
264
265 if ( version_compare($wp_version, '3.5-beta', '>') ){
266 $post = get_post($post_id, OBJECT, 'edit');
267 }else{
268 $post = get_post_to_edit($post_ID);
269 }
270
271 //redirect_post($post_id); // Send user on their way while we keep working
272 if ( version_compare($wp_version, '3.4-beta', '>') ){
273 include(USCES_PLUGIN_DIR."/includes/edit-form-advanced34.php");
274 }else{
275 include(USCES_PLUGIN_DIR."/includes/edit-form-advanced30.php");
276 }
277 }else{
278
279 $post_ID = edit_post();
280 $post = get_post_to_edit($post_ID);
281
282 include(USCES_PLUGIN_DIR."/includes/edit-form-advanced.php");
283 }
284
285
286 if ( ( isset($_POST['save']) || isset($_POST['publish']) ) ) {
287 if ( isset($_POST['_wp_original_http_referer']) && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post.php') === false && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post-new.php') === false ) {
288 $this->action_message = sprintf(__('Post updated. <a href="%s">View post</a>'), get_permalink($post_ID));
289 } else {
290 if ( isset( $_POST['publish'] ) ) {
291 if ( 'pending' == get_post_status( $post_ID ) )
292 $this->action_message = sprintf(__('Post submitted. <a href="%s">Preview post</a>'), add_query_arg( 'preview', 'true', get_permalink($post_ID) ) );
293 else
294 $this->action_message = sprintf(__('Post published. <a href="%s">View post</a>'), get_permalink($post_ID));
295 } else {
296 $this->action_message = __('Post saved.');
297 }
298 }
299 } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) {
300 $this->action_message = __('Custom field updated.');
301 } elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) {
302 $this->action_message = __('Custom field deleted.');
303 } elseif ( 'post-quickpress-save-cont' == $_POST['action'] ) {
304 $this->action_message = __('Post saved.');
305 } else {
306 $this->action_message = __('Post updated.');
307 }
308 $this->action_status = 'success';
309 // redirect_post($post_ID); // Send user on their way while we keep working
310 // exit();
311 break;
312
313 case 'new':
314
315 $title = 'Welcart Shop ' . __('Add New Item', 'usces');
316 global $post;
317
318 if ( version_compare($wp_version, '3.0-beta', '>') ){
319 global $post_ID, $current_screen;
320 if ( !isset($_GET['post_type']) )
321 $post_type = 'post';
322 elseif ( in_array( $_GET['post_type'], get_post_types( array('public' => true ) ) ) )
323 $post_type = $_GET['post_type'];
324 else
325 wp_die( __('Invalid post type') );
326
327 $action = 'post';
328 $post = get_default_post_to_edit( $post_type, true );
329 $post_ID = $post->ID;
330
331 if ( version_compare($wp_version, '3.4-beta', '>') ){
332 include(USCES_PLUGIN_DIR."/includes/edit-form-advanced34.php");
333 }else{
334 include(USCES_PLUGIN_DIR."/includes/edit-form-advanced30.php");
335 }
336 }else{
337 if ( current_user_can('edit_pages') ) {
338 $action = 'post';
339 $post = get_default_post_to_edit();
340 include(USCES_PLUGIN_DIR."/includes/edit-form-advanced.php");
341 }
342 }
343
344
345 break;
346
347 case 'delete':
348 $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
349 check_admin_referer('delete-post_' . $post_id);
350
351 $post = & get_post($post_id);
352
353 if ( !current_user_can('delete_post', $post_id) )
354 wp_die( __('You are not allowed to delete this post.') );
355
356 if ( $post->post_type == 'attachment' ) {
357 if ( ! wp_delete_attachment($post_id) )
358 wp_die( __('Error in deleting...') );
359 } else {
360 if ( !wp_delete_post($post_id) )
361 wp_die( __('Error in deleting...') );
362 }
363
364 $sendback = wp_get_referer();
365 if (strpos($sendback, 'admin.php') !== false) $sendback = admin_url('admin.php?page=usces_itemedit&deleted=1');
366 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
367 //else $sendback = add_query_arg('deleted', 1, $sendback);
368 else $sendback = admin_url('admin.php?page=usces_itemedit&deleted=1');
369 //wp_redirect($sendback);
370 exit();
371 break;
372
373 //case 'preview':
374 // check_admin_referer( 'autosave', 'autosavenonce' );
375 //
376 // $url = post_preview();
377 //var_dump($url);
378 //// wp_redirect($url);
379 // exit();
380 // break;
381
382 default:
383 //wp_redirect('admin.php?page=usces_itemedit');
384 exit();
385 break;
386 } // end switch
387 //include('admin-footer.php');
388 ?>
389