diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php
index 8e55f4b29..137937cee 100644
--- a/wp-admin/admin-functions.php
+++ b/wp-admin/admin-functions.php
@@ -1,6 +1,6 @@
post_content = format_to_edit($post->post_content);
+ $post->post_content = apply_filters('content_edit_pre', $post->post_content);
+
+ $post->post_excerpt = format_to_edit($post->post_excerpt);
+ $post->post_excerpt = apply_filters('excerpt_edit_pre', $post->post_excerpt);
+
+ $post->post_title = format_to_edit($post->post_title);
+ $post->post_title = apply_filters('title_edit_pre', $post->post_title);
+
+ if ($post->post_status == 'static')
+ $post->page_template = get_post_meta($id, '_wp_page_template', true);
+
+ return $post;
+}
+
+// Default post information to use when populating the "Write Post" form.
+function get_default_post_to_edit() {
+ global $content, $excerpt, $edited_post_title;
+
+ $post->post_status = 'draft';
+ $post->comment_status = get_settings('default_comment_status');
+ $post->ping_status = get_settings('default_ping_status');
+ $post->post_pingback = get_settings('default_pingback_flag');
+ $post->post_category = get_settings('default_category');
+ $content = wp_specialchars($content);
+ $post->post_content = apply_filters('default_content', $content);
+ $post->post_title = apply_filters('default_title', $edited_post_title);
+ $post->post_excerpt = apply_filters('default_excerpt', $excerpt);
+
+ return $post;
+}
+
function url_shorten ($url) {
$short_url = str_replace('http://', '', stripslashes($url));
$short_url = str_replace('www.', '', $short_url);
@@ -672,26 +709,6 @@ function save_mod_rewrite_rules() {
insert_with_markers($home_path.'.htaccess', 'WordPress', $rules);
}
-function generate_page_rewrite_rules() {
- global $wpdb;
- $posts = $wpdb->get_results("SELECT ID, post_name FROM $wpdb->posts WHERE post_status = 'static' ORDER BY post_parent DESC");
-
- $page_rewrite_rules = array();
-
- if ($posts) {
- foreach ($posts as $post) {
- // URI => page name
- $uri = get_page_uri($post->ID);
-
- $page_rewrite_rules[$uri] = $post->post_name;
- }
-
- update_option('page_uris', $page_rewrite_rules);
-
- save_mod_rewrite_rules();
- }
-}
-
function the_quicktags () {
// Browser detection sucks, but until Safari supports the JS needed for this to work people just assume it's a bug in WP
if ( !strstr($_SERVER['HTTP_USER_AGENT'], 'Safari') ) :
diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php
index a4145cc24..a7970a635 100644
--- a/wp-admin/edit-form-advanced.php
+++ b/wp-admin/edit-form-advanced.php
@@ -22,9 +22,9 @@ if (0 == $post_ID) {
$form_pingback = '';
-$form_prevstatus = '';
+$form_prevstatus = '';
-$form_trackback = '';
+$form_trackback = 'to_ping) .'" />';
if ('' != $pinged) {
$pings .= '
'. __('Already pinged:') . '
';
@@ -37,13 +37,13 @@ if ('' != $pinged) {
$saveasdraft = '';
-if (empty($post_status)) $post_status = 'draft';
+if (empty($post->post_status)) $post->post_status = 'draft';
?>
-
+
$_GET['message']) : ?>
@@ -67,20 +67,20 @@ window.onload = focusit;
-
+
@@ -97,7 +97,7 @@ edCanvas = document.getElementById('content');
|
@@ -106,7 +106,7 @@ edCanvas = document.getElementById('content');
|
: |
- |
+ |
7 && $users = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users WHERE user_level <= $user_level AND user_level > 0") ) : ?>
@@ -116,7 +116,7 @@ edCanvas = document.getElementById('content');
ID );
- if ( $post_author == $o->ID ) $selected = 'selected="selected"';
+ if ( $post->post_author == $o->ID ) $selected = 'selected="selected"';
else $selected = '';
echo "";
endforeach;
@@ -127,12 +127,12 @@ edCanvas = document.getElementById('content');
: |
- |
+ |
: |
- />
+ post_title) ) . "')\""; ?> />
|
diff --git a/wp-admin/post.php b/wp-admin/post.php
index 93b6f431b..5771bcaa5 100644
--- a/wp-admin/post.php
+++ b/wp-admin/post.php
@@ -64,42 +64,21 @@ case 'edit':
require_once('admin-header.php');
- $post = $post_ID = $p = (int) $_GET['post'];
+ $post_ID = $p = (int) $_GET['post'];
if ( !user_can_edit_post($user_ID, $post_ID) )
die ( __('You are not allowed to edit this post.') );
-
- $postdata = &get_post($post_ID);
- $content = $postdata->post_content;
- $content = format_to_edit($content);
- $content = apply_filters('content_edit_pre', $content);
- $excerpt = $postdata->post_excerpt;
- $excerpt = format_to_edit($excerpt);
- $excerpt = apply_filters('excerpt_edit_pre', $excerpt);
- $edited_post_title = format_to_edit($postdata->post_title);
- $edited_post_title = apply_filters('title_edit_pre', $edited_post_title);
- $post_status = $postdata->post_status;
- $comment_status = $postdata->comment_status;
- $ping_status = $postdata->ping_status;
- $post_password = $postdata->post_password;
- $to_ping = $postdata->to_ping;
- $pinged = $postdata->pinged;
- $post_name = $postdata->post_name;
- $post_parent = $postdata->post_parent;
- $post_author = $postdata->post_author;
- $menu_order = $postdata->menu_order;
- if( 'private' == $postdata->post_status && $postdata->post_author != $user_ID )
- die ( __('You are not allowed to view other users\' private posts.') );
+ if ( !user_can_edit_post($user_ID, $post_ID) )
+ die ( __('You are not allowed to view other users\' private posts.') );
- if ($post_status == 'static') {
- $page_template = get_post_meta($post_ID, '_wp_page_template', true);
+ $post = get_post_to_edit($post_ID);
+
+ if ($post->post_status == 'static')
include('edit-page-form.php');
- } else {
+ else
include('edit-form-advanced.php');
- }
- $post = &$postdata;
?>
@@ -108,8 +87,7 @@ case 'edit':
post_content);
- echo $content;
+ echo apply_filters('the_content', $post->post_content);
?>
@@ -153,8 +131,6 @@ case 'delete':
if (strstr($sendback, 'post.php')) $sendback = get_settings('siteurl') .'/wp-admin/post.php';
$sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
header ('Location: ' . $sendback);
- generate_page_rewrite_rules();
- do_action('delete_post', $post_id);
break;
case 'editcomment':
@@ -405,17 +381,8 @@ default:
diff --git a/wp-includes/functions-post.php b/wp-includes/functions-post.php
index 99be3ac2b..7948d26aa 100644
--- a/wp-includes/functions-post.php
+++ b/wp-includes/functions-post.php
@@ -303,6 +303,11 @@ function wp_delete_post($postid = 0) {
$wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id = $postid");
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $postid");
+
+ if ( 'static' == $post->post_status )
+ generate_page_rewrite_rules();
+
+ do_action('delete_post', $postid);
return $post;
}
@@ -654,4 +659,24 @@ function add_ping($post_id, $uri) { // Add a URI to those already pung
return $wpdb->query("UPDATE $wpdb->posts SET pinged = '$new' WHERE ID = $post_id");
}
+function generate_page_rewrite_rules() {
+ global $wpdb;
+ $posts = $wpdb->get_results("SELECT ID, post_name FROM $wpdb->posts WHERE post_status = 'static' ORDER BY post_parent DESC");
+
+ $page_rewrite_rules = array();
+
+ if ($posts) {
+ foreach ($posts as $post) {
+ // URI => page name
+ $uri = get_page_uri($post->ID);
+
+ $page_rewrite_rules[$uri] = $post->post_name;
+ }
+
+ update_option('page_uris', $page_rewrite_rules);
+
+ save_mod_rewrite_rules();
+ }
+}
+
?>