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
This commit is contained in:
parent
1c25af8cb6
commit
340acf8263
|
@ -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
|
||||
|
|
|
@ -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'); ?>
|
||||
<div class="wrap">
|
||||
<p><?php printf(__('Since you’re a newcomer, you’ll have to wait for an admin to add the <code>edit_posts</code> capability to your user, in order to be authorized to post.<br />
|
||||
You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br />
|
||||
|
@ -46,10 +39,12 @@ When you’re promoted, just reload this page and you’ll be able to bl
|
|||
</p>
|
||||
</div>
|
||||
<?php
|
||||
include('admin-footer.php');
|
||||
include('./admin-footer.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
wp_enqueue_script('autosave');
|
||||
|
||||
// Show post form.
|
||||
if ( current_user_can($post_type_object->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');
|
||||
?>
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue