diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index e72881bc80..08c1fe8933 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -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' ); } /** diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index edc736c80b..8516fa56c2 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -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')); diff --git a/wp-includes/media.php b/wp-includes/media.php index 89254daea3..8a1bf41009 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -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. *