Ajax post meta fixes from mdawaffe. fixes #3098

git-svn-id: http://svn.automattic.com/wordpress/trunk@4157 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-09-02 17:03:57 +00:00
parent 02ad124b46
commit e41db03b26

View File

@ -158,22 +158,19 @@ case 'add-meta' :
if ( !current_user_can( 'edit_post', $id ) ) if ( !current_user_can( 'edit_post', $id ) )
die('-1'); die('-1');
if ( $id < 0 ) { if ( $id < 0 ) {
if ( $pid = write_post() ) if ( $pid = wp_insert_post() )
$meta = has_meta( $pid ); $mid = add_meta( $pid );
else else
die('0'); die('0');
$key = $meta[0]['meta_key']; } else if ( !$mid = add_meta( $id ) ) {
$value = $meta[0]['meta_value']; die('0');
$mid = (int) $meta[0]['meta_id'];
} else {
if ( $mid = add_meta( $id ) )
$meta = get_post_meta_by_id( $mid );
else
die('0');
$key = $meta->meta_key;
$value = $meta->meta_value;
$pid = (int) $meta->post_id;
} }
$meta = get_post_meta_by_id( $mid );
$key = $meta->meta_key;
$value = $meta->meta_value;
$pid = (int) $meta->post_id;
$r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>"; $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>";
$r .= wp_ajax_echo_meta( $pid, $mid, $key, $value ); $r .= wp_ajax_echo_meta( $pid, $mid, $key, $value );
$r .= '</ajaxresponse>'; $r .= '</ajaxresponse>';