Media: Add wp_enqueue_media to easily include all media dependencies.

Also, media templates now print on `wp_footer`.

props sushkov. fixes #22060, see #21390.


git-svn-id: http://core.svn.wordpress.org/trunk@22489 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2012-11-09 04:57:25 +00:00
parent 57db888420
commit 0a67c025e5
3 changed files with 15 additions and 9 deletions

View File

@ -17,11 +17,6 @@ if ( wp_is_mobile() )
if ( post_type_supports($post_type, 'editor') || post_type_supports($post_type, 'thumbnail') ) {
add_thickbox();
wp_enqueue_script( 'media-upload' );
wp_enqueue_style( 'media-views' );
wp_plupload_default_settings();
add_action( 'admin_footer', 'wp_print_media_templates' );
}
/**

View File

@ -383,10 +383,7 @@ document.body.className = document.body.className.replace('no-js', 'js');
* @param string $editor_id
*/
function media_buttons($editor_id = 'content') {
wp_enqueue_script( 'media-upload' );
wp_enqueue_style( 'media-views' );
wp_plupload_default_settings();
add_action( 'admin_footer', 'wp_print_media_templates' );
wp_enqueue_media();
$context = apply_filters('media_buttons_context', __('Upload/Insert %s'));

View File

@ -1290,6 +1290,20 @@ function wp_prepare_attachment_for_js( $attachment ) {
return apply_filters( 'wp_prepare_attachment_for_js', $response, $attachment, $meta );
}
/**
* Enqueues all scripts, styles, settings, and templates necessary to use
* all media JS APIs.
*
* @since 3.5.0
*/
function wp_enqueue_media() {
wp_enqueue_script( 'media-upload' );
wp_enqueue_style( 'media-views' );
wp_plupload_default_settings();
add_action( 'admin_footer', 'wp_print_media_templates' );
add_action( 'wp_footer', 'wp_print_media_templates' );
}
/**
* Prints the templates used in the media manager.
*