Don't load wp-lists on pages that don't need it. Props mdawaffe. fixes #6011

git-svn-id: http://svn.automattic.com/wordpress/trunk@7057 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-02-27 00:46:27 +00:00
parent 83df1eb992
commit 354edc9544
11 changed files with 16 additions and 90 deletions

View File

@ -179,8 +179,7 @@ if ($comments) {
$post = get_post($comment->comment_post_ID);
$authordata = get_userdata($post->post_author);
$the_comment_status = wp_get_comment_status($comment->comment_ID);
$class = ('alternate' == $class) ? '' : '';
$class .= ('unapproved' == $the_comment_status) ? ' unapproved' : '';
$class = ('unapproved' == $the_comment_status) ? 'unapproved' : '';
$post_link = '<a href="' . get_comment_link() . '">' . get_the_title($comment->comment_post_ID) . '</a>';
$author_url = get_comment_author_url();
if ( 'http://' == $author_url )

View File

@ -33,7 +33,6 @@ if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) {
$title = __('Pages');
$parent_file = 'edit.php';
wp_enqueue_script( 'wp-lists' );
wp_enqueue_script('admin-forms');
require_once('admin-header.php');
@ -139,7 +138,7 @@ if ($posts) {
<?php } ?>
</tr>
</thead>
<tbody id="the-list" class="list:page">
<tbody>
<?php page_rows($posts); ?>
</tbody>
</table>

View File

@ -10,15 +10,13 @@
</tr>
</thead>
<tbody id="the-list" class="list:post">
<tbody>
<?php
$i_post = 0;
if ( have_posts() ) {
$bgcolor = '';
add_filter('the_title','wp_specialchars');
while (have_posts()) : the_post(); $i_post++;
if ( 16 == $i_post )
echo "\t</tbody>\n\t<tbody id='the-extra-list' class='list:post' style='display: none'>\n"; // Hack!
$class = ( $i_post > 15 || 'alternate' == $class) ? '' : 'alternate';
global $current_user;
$post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
@ -165,7 +163,7 @@ foreach($posts_columns as $column_name=>$column_display_name) {
case 'control_delete':
?>
<td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete:the-list:post-$post->ID delete'>" . __('Delete') . "</a>"; } ?></td>
<td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
<?php
break;

View File

@ -33,15 +33,12 @@ if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) {
$title = __('Posts');
$parent_file = 'edit.php';
wp_enqueue_script( 'admin-posts' );
wp_enqueue_script('admin-forms');
if ( 1 == $_GET['c'] )
wp_enqueue_script( 'admin-comments' );
require_once('admin-header.php');
add_filter( 'post_limits', $limit_filter = create_function( '$a', '$b = split(" ",$a); if ( !isset($b[2]) ) return $a; $start = intval(trim($b[1])) / 20 * 15; if ( !is_int($start) ) return $a; return "LIMIT $start, 20";' ) );
list($post_stati, $avail_post_stati) = wp_edit_posts_query();
$wp_query->max_num_pages = ceil( $wp_query->found_posts / 15 ); // We grab 20 but only show 15 ( 5 more for ajax extra )
if ( !isset( $_GET['paged'] ) )
$_GET['paged'] = 1;
@ -179,10 +176,6 @@ foreach ($arc_result as $arc_row) {
</form>
<form action="" method="post" id="get-extra-posts" class="add:the-extra-list:" style="display:none">
<?php wp_nonce_field( 'add-post', '_ajax_nonce', false ); ?>
</form>
<div id="ajax-response"></div>
<div class="tablenav">

View File

@ -263,20 +263,9 @@ function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) {
// convert it to table rows
$out = '';
$class = '';
$i = 0;
$count = 0;
foreach( $tags as $tag ) {
if( $i ) {
$i = 0;
$class = ' class="alternate"';
} else {
$i = 1;
$class = '';
}
$out .= _tag_row( $tag, $class );
$count++;
}
foreach( $tags as $tag )
$out .= _tag_row( $tag, ++$count % 2 ? ' class="alternate"' : '' );
// filter and send to screen
$out = apply_filters('tag_rows', $out);

View File

@ -1,22 +0,0 @@
jQuery(function($) {
var delAfter; var extra; var list;
if ( document.location.href.match(/(\?|&)c=/) )
delAfter = function() { $('#comments, #the-comment-list').remove(); }
else
delAfter = function() {
list[0].wpList.add( extra.children(':eq(0)').remove().clone() );
$('#get-extra-posts').submit();
}
var addBefore = function ( settings ) {
var q = document.location.href.split('?');
if ( q[1] )
settings.data += '&' + q[1];
return settings;
}
extra = $('#the-extra-list').wpList( { alt: '', addBefore: addBefore, addColor: 'none', delColor: 'none' } );
list = $('#the-list').wpList( { delAfter: delAfter, addColor: 'none' } );
} );

View File

@ -1,22 +1 @@
jQuery( function($) {
var userLists; var list; var addBefore; var addAfter;
addBefore = function( s ) {
if ( $( '#role-' + $('#role').val() ).size() )
return s;
return false;
};
addAfter = function( r, s ) {
var roleTable = $( '#role-' + $('role', r).text() );
var e = $('#user-' + $('user', r).attr('id') );
if ( !roleTable.size() ) { return; }
if ( !e.size() ) { return; }
roleTable[0].wpList.add(e.remove().clone());
};
userLists = $('.user-list').wpList();
list = $('#user-list').wpList( { addBefore: addBefore, addAfter: addAfter } );
} );
jQuery( function($) { $('#users').wpList(); } );

View File

@ -24,7 +24,6 @@ if ( isset($_GET['deleteit']) && isset($_GET['linkcheck']) ) {
exit;
}
wp_enqueue_script( 'wp-lists' );
wp_enqueue_script('admin-forms');
wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
@ -150,7 +149,7 @@ if ( $links ) {
} ?>
</tr>
</thead>
<tbody id="the-list" class="list:link">
<tbody>
<?php
foreach ($links as $link) {
$link = sanitize_bookmark($link);

View File

@ -31,7 +31,6 @@ if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) {
$title = __('Media Library');
$parent_file = 'edit.php';
wp_enqueue_script( 'admin-posts' );
wp_enqueue_script( 'admin-forms' );
if ( 1 == $_GET['c'] )
wp_enqueue_script( 'admin-comments' );
@ -181,10 +180,6 @@ foreach ($arc_result as $arc_row) {
</form>
<form action="" method="post" id="get-extra-posts" class="add:the-extra-list:" style="display:none">
<?php wp_nonce_field( 'add-post', '_ajax_nonce', false ); ?>
</form>
<div id="ajax-response"></div>
<div class="tablenav">

View File

@ -264,14 +264,17 @@ foreach ( (array) $users_of_blog as $b_user ) {
}
unset($users_of_blog);
$current_role = false;
foreach ( $wp_roles->get_names() as $role => $name ) {
if ( !isset($avail_roles[$role]) )
continue;
$class = '';
if ( $role == $_GET['role'] )
if ( $role == $_GET['role'] ) {
$current_role = $_GET['role'];
$class = ' class="current"';
}
$name = translate_with_context($name);
$name = sprintf(_c('%1$s (%2$s)|user role with count'), $name, $avail_roles[$role]);
@ -339,12 +342,12 @@ unset($role_links);
</tbody>
<tbody id="users" class="list:user user-list">
<?php
$style = '';
foreach ( $wp_user_search->get_results() as $userid ) {
$user_object = new WP_User($userid);
$roles = $user_object->roles;
$role = array_shift($roles);
$style = '';
$style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
echo "\n\t" . user_row($user_object, $style, $role);
}
@ -399,7 +402,7 @@ foreach ( $wp_user_search->get_results() as $userid ) {
else
echo '<p>' . sprintf(__('Users cannot currently <a href="%1$s">register themselves</a>, but you can manually create users here.'), get_option('siteurl').'/wp-admin/options-general.php#users_can_register') . '</p>';
?>
<form action="#add-new-user" method="post" name="adduser" id="adduser" class="add:user-list:">
<form action="#add-new-user" method="post" name="adduser" id="adduser" class="add:users:">
<?php wp_nonce_field('add-user') ?>
<table class="form-table">
<tr class="form-field form-required">
@ -437,7 +440,7 @@ foreach ( $wp_user_search->get_results() as $userid ) {
<td><select name="role" id="role">
<?php
if ( !$new_user_role )
$new_user_role = get_option('default_role');
$new_user_role = $current_role ? $current_role : get_option('default_role');
wp_dropdown_roles($new_user_role);
?>
</select>
@ -450,11 +453,6 @@ foreach ( $wp_user_search->get_results() as $userid ) {
</p>
</form>
<table style="color:red">
<tbody id="user-list" class="list:user">
</tbody>
</table>
</div>
<?php

View File

@ -126,9 +126,8 @@ class WP_Scripts {
'strong' => __('Strong')
) );
$this->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists'), '20071104' );
$this->add( 'admin-posts', '/wp-admin/js/edit-posts.js', array('wp-lists'), '20071023' );
$this->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists'), '20070823' );
$this->add( 'admin-forms', '/wp-admin/js/forms.js', array('wp-lists'), '20080108' );
$this->add( 'admin-forms', '/wp-admin/js/forms.js', false, '20080108' );
$this->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' );
$this->add( 'upload', '/wp-admin/js/upload.js', array('jquery'), '20070518' );
$this->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery'), '20080128' );