29 $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']); |
29 $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']); |
30 $referredby = remove_query_arg('_wp_original_http_referer', $referredby); |
30 $referredby = remove_query_arg('_wp_original_http_referer', $referredby); |
31 } |
31 } |
32 $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer()); |
32 $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer()); |
33 |
33 |
34 if ( 'post' == $_POST['originalaction'] && !empty($_POST['mode']) && 'bookmarklet' == $_POST['mode'] ) { |
34 if ( 'post' == $_POST['originalaction'] && !empty($_POST['mode']) && 'sidebar' == $_POST['mode'] ) { |
35 $location = $_POST['referredby']; |
|
36 } elseif ( 'post' == $_POST['originalaction'] && !empty($_POST['mode']) && 'sidebar' == $_POST['mode'] ) { |
|
37 $location = 'sidebar.php?a=b'; |
35 $location = 'sidebar.php?a=b'; |
38 } elseif ( ( isset($_POST['save']) || isset($_POST['publish']) ) ) { |
36 } elseif ( isset($_POST['save']) || isset($_POST['publish']) ) { |
|
37 $status = get_post_status( $page_ID ); |
|
38 |
39 if ( isset( $_POST['publish'] ) ) { |
39 if ( isset( $_POST['publish'] ) ) { |
40 if ( 'pending' == get_post_status( $page_ID ) ) |
40 switch ( $status ) { |
41 $location = add_query_arg( 'message', 6, get_edit_post_link( $page_ID, 'url' ) ); |
41 case 'pending': |
42 else |
42 $message = 6; |
43 $location = add_query_arg( 'message', 5, get_edit_post_link( $page_ID, 'url' ) ); |
43 break; |
|
44 case 'future': |
|
45 $message = 7; |
|
46 break; |
|
47 default: |
|
48 $message = 4; |
|
49 } |
44 } else { |
50 } else { |
45 $location = add_query_arg( 'message', 1, get_edit_post_link( $page_ID, 'url' ) ); |
51 $message = 'draft' == $status ? 8 : 1; |
46 } |
52 } |
|
53 |
|
54 $location = add_query_arg( 'message', $message, get_edit_post_link( $page_ID, 'url' ) ); |
47 } elseif ( isset($_POST['addmeta']) ) { |
55 } elseif ( isset($_POST['addmeta']) ) { |
48 $location = add_query_arg( 'message', 2, wp_get_referer() ); |
56 $location = add_query_arg( 'message', 2, wp_get_referer() ); |
49 $location = explode('#', $location); |
57 $location = explode('#', $location); |
50 $location = $location[0] . '#postcustom'; |
58 $location = $location[0] . '#postcustom'; |
51 } elseif ( isset($_POST['deletemeta']) ) { |
59 } elseif ( isset($_POST['deletemeta']) ) { |
52 $location = add_query_arg( 'message', 3, wp_get_referer() ); |
60 $location = add_query_arg( 'message', 3, wp_get_referer() ); |
53 $location = explode('#', $location); |
61 $location = explode('#', $location); |
54 $location = $location[0] . '#postcustom'; |
62 $location = $location[0] . '#postcustom'; |
55 } elseif ($action == 'editattachment') { |
|
56 $location = 'attachments.php'; |
|
57 } else { |
63 } else { |
58 $location = add_query_arg( 'message', 1, get_edit_post_link( $page_ID, 'url' ) ); |
64 $location = add_query_arg( 'message', 1, get_edit_post_link( $page_ID, 'url' ) ); |
59 } |
65 } |
60 |
66 |
61 wp_redirect($location); |
67 wp_redirect( apply_filters( 'redirect_page_location', $location, $page_ID ) ); |
62 } |
68 } |
63 |
69 |
64 if (isset($_POST['deletepost'])) |
70 if (isset($_POST['deletepost'])) |
65 $action = "delete"; |
71 $action = "delete"; |
66 elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] ) |
72 elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] ) |
67 $action = 'preview'; |
73 $action = 'preview'; |
|
74 |
|
75 $sendback = wp_get_referer(); |
|
76 if ( strpos($sendback, 'page.php') !== false || strpos($sendback, 'page-new.php') !== false ) |
|
77 $sendback = admin_url('edit-pages.php'); |
|
78 else |
|
79 $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $sendback ); |
68 |
80 |
69 switch($action) { |
81 switch($action) { |
70 case 'post': |
82 case 'post': |
71 check_admin_referer('add-page'); |
83 check_admin_referer('add-page'); |
72 $page_ID = write_post(); |
84 $page_ID = write_post(); |
80 $title = __('Edit Page'); |
92 $title = __('Edit Page'); |
81 $editing = true; |
93 $editing = true; |
82 $page_ID = $post_ID = $p = (int) $_GET['post']; |
94 $page_ID = $post_ID = $p = (int) $_GET['post']; |
83 $post = get_post_to_edit($page_ID); |
95 $post = get_post_to_edit($page_ID); |
84 |
96 |
85 if ( empty($post->ID) ) wp_die( __('You attempted to edit a page that doesn’t exist. Perhaps it was deleted?') ); |
97 if ( empty($post->ID) ) |
|
98 wp_die( __('You attempted to edit a page that doesn’t exist. Perhaps it was deleted?') ); |
|
99 |
|
100 if ( !current_user_can('edit_page', $page_ID) ) |
|
101 wp_die( __('You are not allowed to edit this page.') ); |
|
102 |
|
103 if ( 'trash' == $post->post_status ) |
|
104 wp_die( __('You can’t edit this page because it is in the Trash. Please move it out of the Trash and try again.') ); |
86 |
105 |
87 if ( 'page' != $post->post_type ) { |
106 if ( 'page' != $post->post_type ) { |
88 wp_redirect( get_edit_post_link( $post_ID, 'url' ) ); |
107 wp_redirect( get_edit_post_link( $post_ID, 'url' ) ); |
89 exit(); |
108 exit(); |
90 } |
109 } |
91 |
110 |
92 wp_enqueue_script('page'); |
111 wp_enqueue_script('post'); |
93 if ( user_can_richedit() ) |
112 if ( user_can_richedit() ) |
94 wp_enqueue_script('editor'); |
113 wp_enqueue_script('editor'); |
95 add_thickbox(); |
114 add_thickbox(); |
96 wp_enqueue_script('media-upload'); |
115 wp_enqueue_script('media-upload'); |
97 wp_enqueue_script('word-count'); |
116 wp_enqueue_script('word-count'); |
98 |
117 |
99 if ( current_user_can('edit_page', $page_ID) ) { |
118 if ( $last = wp_check_post_lock( $post->ID ) ) { |
100 if ( $last = wp_check_post_lock( $post->ID ) ) { |
119 add_action('admin_notices', '_admin_notice_post_locked' ); |
101 add_action('admin_notices', '_admin_notice_post_locked' ); |
120 } else { |
102 } else { |
121 wp_set_post_lock( $post->ID ); |
103 wp_set_post_lock( $post->ID ); |
122 wp_enqueue_script('autosave'); |
104 wp_enqueue_script('autosave'); |
123 } |
105 } |
|
106 } |
|
107 |
|
108 if ( !current_user_can('edit_page', $page_ID) ) |
|
109 die ( __('You are not allowed to edit this page.') ); |
|
110 |
124 |
111 include('edit-page-form.php'); |
125 include('edit-page-form.php'); |
112 break; |
126 break; |
113 |
127 |
114 case 'editattachment': |
128 case 'editattachment': |
134 redirect_page($page_ID); |
148 redirect_page($page_ID); |
135 |
149 |
136 exit(); |
150 exit(); |
137 break; |
151 break; |
138 |
152 |
|
153 case 'trash': |
|
154 $post_id = isset($_GET['post']) ? intval($_GET['post']) : intval($_POST['post_ID']); |
|
155 check_admin_referer('trash-page_' . $post_id); |
|
156 |
|
157 $post = & get_post($post_id); |
|
158 |
|
159 if ( !current_user_can('delete_page', $post_id) ) |
|
160 wp_die( __('You are not allowed to move this page to the trash.') ); |
|
161 |
|
162 if ( !wp_trash_post($post_id) ) |
|
163 wp_die( __('Error in moving to trash...') ); |
|
164 |
|
165 wp_redirect( add_query_arg( array('trashed' => 1, 'ids' => $post_id), $sendback ) ); |
|
166 exit(); |
|
167 break; |
|
168 |
|
169 case 'untrash': |
|
170 $post_id = isset($_GET['post']) ? intval($_GET['post']) : intval($_POST['post_ID']); |
|
171 check_admin_referer('untrash-page_' . $post_id); |
|
172 |
|
173 $post = & get_post($post_id); |
|
174 |
|
175 if ( !current_user_can('delete_page', $post_id) ) |
|
176 wp_die( __('You are not allowed to move this page out of the trash.') ); |
|
177 |
|
178 if ( !wp_untrash_post($post_id) ) |
|
179 wp_die( __('Error in restoring from trash...') ); |
|
180 |
|
181 wp_redirect( add_query_arg('untrashed', 1, $sendback) ); |
|
182 exit(); |
|
183 break; |
|
184 |
139 case 'delete': |
185 case 'delete': |
140 $page_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); |
186 $page_id = isset($_GET['post']) ? intval($_GET['post']) : intval($_POST['post_ID']); |
141 check_admin_referer('delete-page_' . $page_id); |
187 check_admin_referer('delete-page_' . $page_id); |
142 |
188 |
143 $page = & get_post($page_id); |
189 $page = & get_post($page_id); |
144 |
190 |
145 if ( !current_user_can('delete_page', $page_id) ) |
191 if ( !current_user_can('delete_page', $page_id) ) |