From 69861a276dcafeba093a998785cfb6564b7104ea Mon Sep 17 00:00:00 2001 From: Biser Perchinkov Date: Wed, 18 Oct 2017 18:52:34 +0300 Subject: [PATCH] Remove post_ID requirement from parse_embed ajax call --- src/wp-admin/includes/ajax-actions.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 5c53f6805ca57..85ec029d28845 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -3005,11 +3005,7 @@ function wp_ajax_query_themes() { function wp_ajax_parse_embed() { global $post, $wp_embed; - if ( ! $post = get_post( (int) $_POST['post_ID'] ) ) { - wp_send_json_error(); - } - - if ( empty( $_POST['shortcode'] ) || ! current_user_can( 'edit_post', $post->ID ) ) { + if ( empty( $_POST['shortcode'] ) || ! current_user_can( 'edit_posts' ) ) { wp_send_json_error(); } @@ -3026,7 +3022,10 @@ function wp_ajax_parse_embed() { } $parsed = false; - setup_postdata( $post ); + + if ( (int) $_POST['post_ID'] && $post = get_post( (int) $_POST['post_ID'] ) ) { + setup_postdata( $post ); + } $wp_embed->return_false_on_fail = true;