WordPress.org

Make WordPress Core

Ticket #12590: scripts.diff

File scripts.diff, 2.3 KB (added by scribu, 8 years ago)

load scripts only when needed

  • wp-admin/post-new.php

     
    2929$title = sprintf(__('Add New %s'), $post_type_object->singular_label);
    3030
    3131$editing = true;
    32 wp_enqueue_script('autosave');
    33 wp_enqueue_script('post');
    34 if ( user_can_richedit() )
    35         wp_enqueue_script('editor');
    36 add_thickbox();
    37 wp_enqueue_script('media-upload');
    38 wp_enqueue_script('word-count');
    3932
    4033if ( 'post' == $post_type && !current_user_can('edit_posts') ) {
    41         require_once ('./admin-header.php'); ?>
     34        include('admin-header.php'); ?>
    4235<div class="wrap">
    4336<p><?php printf(__('Since you&#8217;re a newcomer, you&#8217;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 />
    4437You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br />
     
    5851}
    5952
    6053include('admin-footer.php');
    61 ?>
     54
  • wp-admin/post.php

     
    170170                $submenu_file = "edit.php?post_type=$post_type";
    171171        }
    172172
    173         wp_enqueue_script('post');
    174         if ( user_can_richedit() )
    175                 wp_enqueue_script('editor');
    176         add_thickbox();
    177         wp_enqueue_script('media-upload');
    178         wp_enqueue_script('word-count');
    179         wp_enqueue_script( 'admin-comments' );
    180         enqueue_comment_hotkeys_js();
    181 
    182173        if ( $last = wp_check_post_lock( $post->ID ) ) {
    183174                add_action('admin_notices', '_admin_notice_post_locked' );
    184175        } else {
  • wp-admin/edit-form-advanced.php

     
    1010if ( !defined('ABSPATH') )
    1111        die('-1');
    1212
     13// load required scripts
     14wp_enqueue_script('post');
     15if ( post_type_supports($post_type, 'editor') ) {
     16        if ( user_can_richedit() )
     17                wp_enqueue_script('editor');
     18        add_thickbox();
     19        wp_enqueue_script('media-upload');
     20        wp_enqueue_script('word-count');
     21}
     22
     23if ( post_type_supports($post_type, 'comments') ) {
     24        wp_enqueue_script( 'admin-comments' );
     25        enqueue_comment_hotkeys_js();
     26}
     27
    1328/**
    1429 * Post ID global
    1530 * @name $post_ID