From 7ce1968d15c2eb8c42b7aad0e0fe66c70ffc1400 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 26 Nov 2012 22:03:37 +0000 Subject: [PATCH] In media_buttons(), consult global post_ID if get_post() comes up with nothing. Default postID to 0 in wp_enqueue_media(). Props nacin fixes #22085 git-svn-id: https://develop.svn.wordpress.org/trunk@22846 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/media.php | 6 +++++- wp-includes/media.php | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index c81d495248..21b5522768 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -383,8 +383,12 @@ document.body.className = document.body.className.replace('no-js', 'js'); * @param string $editor_id */ function media_buttons($editor_id = 'content') { + $post = get_post(); + if ( ! $post && ! empty( $GLOBALS['post_ID'] ) ) + $post = $GLOBALS['post_ID']; + wp_enqueue_media( array( - 'post' => get_post() + 'post' => $post ) ); // $context = apply_filters('media_buttons_context', __('Upload/Insert %s')); diff --git a/wp-includes/media.php b/wp-includes/media.php index b91fab5d0c..005f863e51 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1393,6 +1393,7 @@ function wp_enqueue_media( $args = array() ) { 'nonce' => array( 'sendToEditor' => wp_create_nonce( 'media-send-to-editor' ), ), + 'postId' => 0, ); $post = null;