<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[14107] trunk/wp-admin: Don'
 t enqueue unnecessary scripts when the post type doesn't support the editor
 .</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/14107">14107</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-04-16 14:03:48 +0000 (Fri, 16 Apr 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Don't enqueue unnecessary scripts when the post type doesn't support the editor. fixes <a href="http://trac.wordpress.org/ticket/12590">#12590</a>, props scribu, _duck.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmineditformadvancedphp">trunk/wp-admin/edit-form-advanced.php</a></li>
<li><a href="#trunkwpadminpostnewphp">trunk/wp-admin/post-new.php</a></li>
<li><a href="#trunkwpadminpostphp">trunk/wp-admin/post.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmineditformadvancedphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-form-advanced.php (14106 => 14107)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-form-advanced.php        2010-04-16 13:57:57 UTC (rev 14106)
+++ trunk/wp-admin/edit-form-advanced.php        2010-04-16 14:03:48 UTC (rev 14107)
</span><span class="lines">@@ -10,6 +10,19 @@
</span><span class="cx"> if ( !defined('ABSPATH') )
</span><span class="cx">         die('-1');
</span><span class="cx"> 
</span><ins>+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');
+}
+
</ins><span class="cx"> /**
</span><span class="cx">  * Post ID global
</span><span class="cx">  * @name $post_ID
</span></span></pre></div>
<a id="trunkwpadminpostnewphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/post-new.php (14106 => 14107)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/post-new.php        2010-04-16 13:57:57 UTC (rev 14106)
+++ trunk/wp-admin/post-new.php        2010-04-16 14:03:48 UTC (rev 14107)
</span><span class="lines">@@ -7,7 +7,7 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /** Load WordPress Administration Bootstrap */
</span><del>-require_once('admin.php');
</del><ins>+require_once('./admin.php');
</ins><span class="cx"> 
</span><span class="cx"> if ( !isset($_GET['post_type']) )
</span><span class="cx">         $post_type = 'post';
</span><span class="lines">@@ -29,16 +29,9 @@
</span><span class="cx"> $title = sprintf(__('Add New %s'), $post_type_object-&gt;singular_label);
</span><span class="cx"> 
</span><span class="cx"> $editing = true;
</span><del>-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');
</del><span class="cx"> 
</span><span class="cx"> if ( 'post' == $post_type &amp;&amp; !current_user_can('edit_posts') ) {
</span><del>-        require_once ('./admin-header.php'); ?&gt;
</del><ins>+        include('./admin-header.php'); ?&gt;
</ins><span class="cx"> &lt;div class=&quot;wrap&quot;&gt;
</span><span class="cx"> &lt;p&gt;&lt;?php printf(__('Since you&amp;#8217;re a newcomer, you&amp;#8217;ll have to wait for an admin to add the &lt;code&gt;edit_posts&lt;/code&gt; capability to your user, in order to be authorized to post.&lt;br /&gt;
</span><span class="cx"> You can also &lt;a href=&quot;mailto:%s?subject=Promotion?&quot;&gt;e-mail the admin&lt;/a&gt; to ask for a promotion.&lt;br /&gt;
</span><span class="lines">@@ -46,10 +39,12 @@
</span><span class="cx"> &lt;/p&gt;
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> &lt;?php
</span><del>-        include('admin-footer.php');
</del><ins>+        include('./admin-footer.php');
</ins><span class="cx">         exit();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+wp_enqueue_script('autosave');
+
</ins><span class="cx"> // Show post form.
</span><span class="cx"> if ( current_user_can($post_type_object-&gt;edit_type_cap) ) {
</span><span class="cx">         $post = get_default_post_to_edit( $post_type, true );
</span><span class="lines">@@ -57,5 +52,5 @@
</span><span class="cx">         include('edit-form-advanced.php');
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-include('admin-footer.php');
-?&gt;
</del><ins>+include('./admin-footer.php');
+?&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadminpostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/post.php (14106 => 14107)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/post.php        2010-04-16 13:57:57 UTC (rev 14106)
+++ trunk/wp-admin/post.php        2010-04-16 14:03:48 UTC (rev 14107)
</span><span class="lines">@@ -170,15 +170,6 @@
</span><span class="cx">                 $submenu_file = &quot;edit.php?post_type=$post_type&quot;;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        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();
-
</del><span class="cx">         if ( $last = wp_check_post_lock( $post-&gt;ID ) ) {
</span><span class="cx">                 add_action('admin_notices', '_admin_notice_post_locked' );
</span><span class="cx">         } else {
</span><span class="lines">@@ -189,6 +180,11 @@
</span><span class="cx">         $title = sprintf(__('Edit %s'), $post_type_object-&gt;singular_label);
</span><span class="cx">         $post = get_post_to_edit($post_id);
</span><span class="cx"> 
</span><ins>+        if ( post_type_supports($post_type, 'comments') ) {
+                wp_enqueue_script('admin-comments');
+                enqueue_comment_hotkeys_js();
+        }
+
</ins><span class="cx">         include('edit-form-advanced.php');
</span><span class="cx"> 
</span><span class="cx">         break;
</span></span></pre>
</div>
</div>

</body>
</html>