From 0c42e6121a8dbd24c87cb40f1b0f828f8197b3c5 Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Thu, 27 Sep 2012 20:04:34 +0000 Subject: [PATCH] Add QuickPress support for new media workflow. * Adds the code required to include the new media scripts, styles, and settings to `media_button()`. * Improves script dependencies, namely making `media-upload` require `media-views`. * Some CSS tweaks for the making the new button work well with QuickPress. see #21390, fixes #22021. git-svn-id: http://core.svn.wordpress.org/trunk@22072 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/css/wp-admin.css | 2 +- wp-admin/edit-form-advanced.php | 6 ++---- wp-admin/includes/media.php | 5 +++++ wp-admin/js/media-upload.js | 2 +- wp-includes/script-loader.php | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/wp-admin/css/wp-admin.css b/wp-admin/css/wp-admin.css index d9f4ba2951..5358027920 100644 --- a/wp-admin/css/wp-admin.css +++ b/wp-admin/css/wp-admin.css @@ -6216,7 +6216,7 @@ h3:hover .edit-box { } #dashboard_quick_press .wp-media-buttons { - margin: 0 0 .2em 8px; + margin: 0 0 .2em 1px; padding: 0; } diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index ad831555a1..1c9921a78e 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -17,13 +17,11 @@ 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_script( 'media-views' ); + + wp_enqueue_script( 'media-upload' ); wp_enqueue_style( 'media-views' ); wp_plupload_default_settings(); add_action( 'admin_footer', 'wp_print_media_templates' ); - - wp_enqueue_script( 'mce-view' ); } /** diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 594cfe0d19..1d12d33237 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -377,6 +377,11 @@ 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' ); + $context = apply_filters('media_buttons_context', __('Upload/Insert %s')); $img = ''; diff --git a/wp-admin/js/media-upload.js b/wp-admin/js/media-upload.js index bb1815505c..aec6412131 100644 --- a/wp-admin/js/media-upload.js +++ b/wp-admin/js/media-upload.js @@ -148,5 +148,5 @@ var tb_position; } }; - $( wp.mce.media.init ) + $( wp.mce.media.init ); }(jQuery)); \ No newline at end of file diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 451ea2cb34..67626f8d2a 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -297,7 +297,7 @@ function wp_default_scripts( &$scripts ) { 'type' => 'characters' == _x( 'words', 'word count: words or characters?' ) ? 'c' : 'w', ) ); - $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'mce-view' ), false, 1 ); + $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'mce-view', 'media-views' ), false, 1 ); $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), 'r6', 1 );