Don't hard code post type in edit forms. Props filosofo and DD32. fixes #4991

git-svn-id: http://svn.automattic.com/wordpress/trunk@6712 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-02-02 19:22:14 +00:00
parent 8263948a96
commit d42b1a8256
5 changed files with 17 additions and 8 deletions

View File

@ -46,15 +46,13 @@ if ('' != $post->pinged) {
$saveasdraft = '<input name="save" type="submit" id="save" tabindex="3" value="' . attribute_escape( __('Save and Continue Editing') ) . '" />';
if (empty($post->post_status)) $post->post_status = 'draft';
?>
<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
<input type="hidden" id="hiddenaction" name="action" value="<?php echo $form_action ?>" />
<input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
<input type="hidden" name="post_author" value="<?php echo attribute_escape( $post->post_author ); ?>" />
<input type="hidden" id="post_type" name="post_type" value="post" />
<input type="hidden" id="post_type" name="post_type" value="<?php echo $post->post_type ?>" />
<?php echo $form_extra ?>
<?php if ((isset($post->post_title) && '' == $post->post_title) || (isset($_GET['message']) && 2 > $_GET['message'])) : ?>

View File

@ -27,15 +27,14 @@ if ( 0 != $post_ID && $sendto == get_permalink($post_ID) )
<?php
wp_nonce_field($nonce_action);
if (isset($mode) && 'bookmarklet' == $mode) {
if (isset($mode) && 'bookmarklet' == $mode)
echo '<input type="hidden" name="mode" value="bookmarklet" />';
}
?>
<input type="hidden" id="user-id" name="user_ID" value="<?php echo $user_ID ?>" />
<input type="hidden" id="hiddenaction" name="action" value='<?php echo $form_action ?>' />
<input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
<?php echo $form_extra ?>
<input type="hidden" id="post_type" name="post_type" value="page" />
<input type="hidden" id="post_type" name="post_type" value="<?php echo $post->post_type ?>" />
<script type="text/javascript">
// <![CDATA[

View File

@ -143,6 +143,7 @@ function get_default_post_to_edit() {
$post_excerpt = '';
$post->post_status = 'draft';
$post->post_type = 'post';
$post->comment_status = get_option( 'default_comment_status' );
$post->ping_status = get_option( 'default_ping_status' );
$post->post_pingback = get_option( 'default_pingback_flag' );
@ -157,6 +158,12 @@ function get_default_post_to_edit() {
return $post;
}
function get_default_page_to_edit() {
$page = get_default_post_to_edit();
$page->post_type = 'page';
return $page;
}
// Get an existing post and format it for editing.
function get_post_to_edit( $id ) {

View File

@ -18,8 +18,7 @@ require_once('admin-header.php');
<?php
if ( current_user_can('edit_pages') ) {
$action = 'post';
$post = get_default_post_to_edit();
$post->post_type = 'page';
$post = get_default_page_to_edit();
include('edit-page-form.php');
}

View File

@ -62,6 +62,12 @@ foreach ( $filters as $filter ) {
add_filter($filter, 'sanitize_title');
}
// Keys
$filters = array('pre_post_type');
foreach ( $filters as $filter ) {
add_filter($filter, 'sanitize_user');
}
// Places to balance tags on input
$filters = array('content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content');
foreach ( $filters as $filter ) {