From 687642feadd6d54440416cba8b05908036be6b63 Mon Sep 17 00:00:00 2001 From: nacin Date: Tue, 1 Nov 2011 21:23:05 +0000 Subject: [PATCH] Simplify logic in wp-fullscreen-save-post. Most of this came from post.php but that's been cut down as well. see #18785. git-svn-id: http://svn.automattic.com/wordpress/trunk@19107 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-ajax.php | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 0ea02a98a..78cf705c6 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -1506,26 +1506,17 @@ case 'time_format' : die( date_i18n( sanitize_option( 'time_format', $_POST['date'] ) ) ); break; case 'wp-fullscreen-save-post' : - if ( isset($_POST['post_ID']) ) - $post_id = (int) $_POST['post_ID']; - else - $post_id = 0; + $post_id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0; - $post = null; - $post_type_object = null; - $post_type = null; - if ( $post_id ) { - $post = get_post($post_id); - if ( $post ) { - $post_type_object = get_post_type_object($post->post_type); - if ( $post_type_object ) - $post_type = $post->post_type; - } - } elseif ( isset($_POST['post_type']) ) { - $post_type_object = get_post_type_object($_POST['post_type']); - if ( $post_type_object ) - $post_type = $post_type_object->name; - } + $post = $post_type = null; + + if ( $post_id ) + $post = get_post( $post_id ); + + if ( $post ) + $post_type = $post->post_type; + elseif ( isset( $_POST['post_type'] ) && post_type_exists( $_POST['post_type'] ) ) + $post_type = $_POST['post_type']; check_ajax_referer('update-' . $post_type . '_' . $post_id, '_wpnonce');