From 340acf8263f6b273539bc233ba060692d8b0202b Mon Sep 17 00:00:00 2001 From: nacin Date: Fri, 16 Apr 2010 14:03:48 +0000 Subject: [PATCH] Don't enqueue unnecessary scripts when the post type doesn't support the editor. fixes #12590, props scribu, _duck. git-svn-id: http://svn.automattic.com/wordpress/trunk@14107 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-form-advanced.php | 13 +++++++++++++ wp-admin/post-new.php | 19 +++++++------------ wp-admin/post.php | 14 +++++--------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 5d009fa5f..b0a71ca91 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -10,6 +10,19 @@ if ( !defined('ABSPATH') ) die('-1'); +wp_enqueue_script('post'); + +if ( post_type_supports($post_type, 'editor') ) { + if ( user_can_richedit() ) + wp_enqueue_script('editor'); + wp_enqueue_script('word-count'); +} + +if ( post_type_supports($post_type, 'editor') || post_type_supports($post_type, 'thumbnail') ) { + add_thickbox(); + wp_enqueue_script('media-upload'); +} + /** * Post ID global * @name $post_ID diff --git a/wp-admin/post-new.php b/wp-admin/post-new.php index ef9f7600a..7a84026aa 100644 --- a/wp-admin/post-new.php +++ b/wp-admin/post-new.php @@ -7,7 +7,7 @@ */ /** Load WordPress Administration Bootstrap */ -require_once('admin.php'); +require_once('./admin.php'); if ( !isset($_GET['post_type']) ) $post_type = 'post'; @@ -29,16 +29,9 @@ $post_type_object = get_post_type_object($post_type); $title = sprintf(__('Add New %s'), $post_type_object->singular_label); $editing = true; -wp_enqueue_script('autosave'); -wp_enqueue_script('post'); -if ( user_can_richedit() ) - wp_enqueue_script('editor'); -add_thickbox(); -wp_enqueue_script('media-upload'); -wp_enqueue_script('word-count'); if ( 'post' == $post_type && !current_user_can('edit_posts') ) { - require_once ('./admin-header.php'); ?> + include('./admin-header.php'); ?>

edit_posts capability to your user, in order to be authorized to post.
You can also e-mail the admin to ask for a promotion.
@@ -46,10 +39,12 @@ When you’re promoted, just reload this page and you’ll be able to bl

edit_type_cap) ) { $post = get_default_post_to_edit( $post_type, true ); @@ -57,5 +52,5 @@ if ( current_user_can($post_type_object->edit_type_cap) ) { include('edit-form-advanced.php'); } -include('admin-footer.php'); -?> +include('./admin-footer.php'); +?> \ No newline at end of file diff --git a/wp-admin/post.php b/wp-admin/post.php index e04118d7c..1fe1cad48 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -170,15 +170,6 @@ case 'edit': $submenu_file = "edit.php?post_type=$post_type"; } - wp_enqueue_script('post'); - if ( user_can_richedit() ) - wp_enqueue_script('editor'); - add_thickbox(); - wp_enqueue_script('media-upload'); - wp_enqueue_script('word-count'); - wp_enqueue_script( 'admin-comments' ); - enqueue_comment_hotkeys_js(); - if ( $last = wp_check_post_lock( $post->ID ) ) { add_action('admin_notices', '_admin_notice_post_locked' ); } else { @@ -189,6 +180,11 @@ case 'edit': $title = sprintf(__('Edit %s'), $post_type_object->singular_label); $post = get_post_to_edit($post_id); + if ( post_type_supports($post_type, 'comments') ) { + wp_enqueue_script('admin-comments'); + enqueue_comment_hotkeys_js(); + } + include('edit-form-advanced.php'); break;