Changeset 11807 for trunk/wp-admin/page.php
- Timestamp:
- 08/12/2009 10:57:15 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/page.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/page.php
r11749 r11807 53 53 $location = explode('#', $location); 54 54 $location = $location[0] . '#postcustom'; 55 } elseif ($action == 'editattachment') {56 $location = 'attachments.php';57 55 } else { 58 56 $location = add_query_arg( 'message', 1, get_edit_post_link( $page_ID, 'url' ) ); … … 83 81 $post = get_post_to_edit($page_ID); 84 82 85 if ( empty($post->ID) ) wp_die( __('You attempted to edit a page that doesn’t exist. Perhaps it was deleted?') ); 86 if ( $post->post_status == 'trash' ) wp_die( __('You can’t edit this page because it is in the Trash. Please move it out of the Trash and try again.') ); 83 if ( empty($post->ID) ) 84 wp_die( __('You attempted to edit a page that doesn’t exist. Perhaps it was deleted?') ); 85 86 if ( !current_user_can('edit_page', $page_ID) ) 87 wp_die( __('You are not allowed to edit this page.') ); 88 89 if ( 'trash' == $post->post_status ) 90 wp_die( __('You can’t edit this page because it is in the Trash. Please move it out of the Trash and try again.') ); 87 91 88 92 if ( 'page' != $post->post_type ) { … … 98 102 wp_enqueue_script('word-count'); 99 103 100 if ( current_user_can('edit_page', $page_ID) ) { 101 if ( $last = wp_check_post_lock( $post->ID ) ) { 102 $last_user = get_userdata( $last ); 103 $last_user_name = $last_user ? $last_user->display_name : __('Somebody'); 104 $message = sprintf( __( 'Warning: %s is currently editing this page' ), esc_html( $last_user_name ) ); 105 $message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" ); 106 add_action('admin_notices', create_function( '', "echo '$message';" ) ); 107 } else { 108 wp_set_post_lock( $post->ID ); 109 wp_enqueue_script('autosave'); 110 } 111 } 112 113 if ( !current_user_can('edit_page', $page_ID) ) 114 die ( __('You are not allowed to edit this page.') ); 104 if ( $last = wp_check_post_lock( $post->ID ) ) { 105 $last_user = get_userdata( $last ); 106 $last_user_name = $last_user ? $last_user->display_name : __('Somebody'); 107 $message = sprintf( __( 'Warning: %s is currently editing this page' ), esc_html( $last_user_name ) ); 108 $message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" ); 109 add_action('admin_notices', create_function( '', "echo '$message';" ) ); 110 } else { 111 wp_set_post_lock( $post->ID ); 112 wp_enqueue_script('autosave'); 113 } 115 114 116 115 include('edit-page-form.php'); … … 143 142 144 143 case 'trash': 145 $post_id = (isset($_GET['post']))? intval($_GET['post']) : intval($_POST['post_ID']);144 $post_id = isset($_GET['post']) ? intval($_GET['post']) : intval($_POST['post_ID']); 146 145 check_admin_referer('trash-page_' . $post_id); 147 146 … … 152 151 153 152 if ( !wp_trash_post($post_id) ) 154 wp_die( __('Error in removing fromtrash...') );153 wp_die( __('Error in moving to trash...') ); 155 154 156 155 $sendback = wp_get_referer(); 157 if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit-pages.php?trashed=1'); 158 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); 159 else $sendback = add_query_arg('trashed', 1, $sendback); 156 if ( strpos($sendback, 'page.php') !== false ) 157 $sendback = admin_url('edit-pages.php?trashed=1'); 158 else 159 $sendback = add_query_arg('trashed', 1, $sendback); 160 160 161 wp_redirect($sendback); 161 162 exit(); … … 163 164 164 165 case 'untrash': 165 $post_id = (isset($_GET['post']))? intval($_GET['post']) : intval($_POST['post_ID']);166 $post_id = isset($_GET['post']) ? intval($_GET['post']) : intval($_POST['post_ID']); 166 167 check_admin_referer('untrash-page_' . $post_id); 167 168 … … 169 170 170 171 if ( !current_user_can('delete_page', $page_id) ) 171 wp_die( __('You are not allowed to remove this page formthe trash.') );172 wp_die( __('You are not allowed to move this page out of the trash.') ); 172 173 173 174 if ( !wp_untrash_post($post_id) ) 174 wp_die( __('Error in re moving from trash...') );175 wp_die( __('Error in restoring from trash...') ); 175 176 176 177 $sendback = wp_get_referer(); 177 if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit-pages.php?untrashed=1'); 178 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); 179 else $sendback = add_query_arg('untrashed', 1, $sendback); 178 if ( strpos($sendback, 'page.php') !== false ) 179 $sendback = admin_url('edit-pages.php?untrashed=1'); 180 else 181 $sendback = add_query_arg('untrashed', 1, $sendback); 182 180 183 wp_redirect($sendback); 181 184 exit(); … … 183 186 184 187 case 'delete': 185 $page_id = (isset($_GET['post']))? intval($_GET['post']) : intval($_POST['post_ID']);188 $page_id = isset($_GET['post']) ? intval($_GET['post']) : intval($_POST['post_ID']); 186 189 check_admin_referer('delete-page_' . $page_id); 187 190 … … 200 203 201 204 $sendback = wp_get_referer(); 202 if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit-pages.php?deleted=1'); 203 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); 204 else $sendback = add_query_arg('deleted', 1, $sendback); 205 if ( strpos($sendback, 'page.php') !== false ) 206 $sendback = admin_url('edit-pages.php?deleted=1'); 207 else 208 $sendback = add_query_arg('deleted', 1, $sendback); 209 205 210 wp_redirect($sendback); 206 211 exit();
Note: See TracChangeset
for help on using the changeset viewer.