From db7dc96921af133e7d6ea693047eb329c195dd74 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 20 Nov 2012 23:22:03 +0000 Subject: [PATCH] Media: For pages, use 'Insert into page' rather than 'Insert into post'. Custom post types can use the media_view_strings filter. No new post type "labels" for now. see #22712. see #21092 (and #19696). git-svn-id: https://develop.svn.wordpress.org/trunk@22735 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/edit-form-advanced.php | 10 +++++----- wp-includes/media.php | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 081a435258..e0461f2421 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -15,11 +15,6 @@ wp_enqueue_script('post'); if ( wp_is_mobile() ) wp_enqueue_script( 'jquery-touch-punch' ); -if ( post_type_supports($post_type, 'editor') || post_type_supports($post_type, 'thumbnail') ) { - add_thickbox(); - wp_enqueue_media(); -} - /** * Post ID global * @name $post_ID @@ -29,6 +24,11 @@ $post_ID = isset($post_ID) ? (int) $post_ID : 0; $user_ID = isset($user_ID) ? (int) $user_ID : 0; $action = isset($action) ? $action : ''; +if ( post_type_supports($post_type, 'editor') || post_type_supports($post_type, 'thumbnail') ) { + add_thickbox(); + wp_enqueue_media( array( 'post' => $post_id ) ); +} + $messages = array(); $messages['post'] = array( 0 => '', // Unused. Messages start at index 1. diff --git a/wp-includes/media.php b/wp-includes/media.php index 3ef3e5ddd4..8ea11a23fd 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1334,6 +1334,8 @@ function wp_enqueue_media( $args = array() ) { $settings['postId'] = $post->ID; } + $hier = $post && is_post_type_hierarchical( $post->post_type ); + $strings = array( // Generic 'url' => __( 'URL' ), @@ -1354,11 +1356,11 @@ function wp_enqueue_media( $args = array() ) { // Library 'mediaLibraryTitle' => __( 'Media Library' ), 'createNewGallery' => __( 'Create a new gallery' ), - 'insertIntoPost' => __( 'Insert into post' ), + 'insertIntoPost' => $hier ? __( 'Insert into page' ) : __( 'Insert into post' ), 'returnToLibrary' => __( '← Return to library' ), 'allMediaItems' => __( 'All media items' ), - 'uploadedToThisPost' => __( 'Uploaded to this post' ), + 'uploadedToThisPost' => $hier ? __( 'Uploaded to this page' ) : __( 'Uploaded to this post' ), 'images' => __( 'Images' ), 'audio' => __( 'Audio' ), 'videos' => __( 'Videos' ),