Batch editing, first cut, see #6815

git-svn-id: http://svn.automattic.com/wordpress/trunk@8973 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2008-09-25 13:42:34 +00:00
parent 78f973ad2c
commit 339e87dc5c
18 changed files with 422 additions and 167 deletions

View File

@ -731,9 +731,16 @@ break;
case 'inline-save':
check_ajax_referer( 'inlineeditnonce', '_inline_edit' );
if ( ! isset($_POST['post_ID']) )
if ( ! isset($_POST['post_ID']) || ! ( $id = (int) $_POST['post_ID'] ) )
exit;
if ( $last = wp_check_post_lock( $id ) ) {
$last_user = get_userdata( $last );
$last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );
echo '<tr><td colspan="8"><div class="error"><p>' . sprintf( $_POST['post_type'] == 'page' ? __( 'Saving is disabled: %s is currently editing this page.' ) : __( 'Saving is disabled: %s is currently editing this post.' ), wp_specialchars( $last_user_name ) ) . '</p></div></td></tr>';
exit;
}
inline_save_row( $_POST );
$post = array();

View File

@ -178,7 +178,7 @@ if ( $page_links )
<option value="" selected><?php _e('Actions'); ?></option>
<option value="delete"><?php _e('Delete'); ?></option>
</select>
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" />
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
<?php wp_nonce_field('bulk-categories'); ?>
</div>

View File

@ -204,7 +204,8 @@ th.check-column + th, th.check-column + td {
padding-left: 5px;
}
*/
.widefat .num {
.widefat .num,
.widefat .column-comments {
text-align: center;
}

View File

@ -195,7 +195,7 @@ if ( $page_links )
<?php endif; ?>
<option value="delete"><?php _e('Delete'); ?></option>
</select>
<input type="submit" name="doaction" value="<?php _e('Apply'); ?>" class="button-secondary apply" />
<input type="submit" name="doaction" id="doaction" value="<?php _e('Apply'); ?>" class="button-secondary apply" />
<?php wp_nonce_field('bulk-comments'); ?>
<?php if ( isset($_GET['apage']) ) { ?>
<input type="hidden" name="apage" value="<?php echo absint( $_GET['apage'] ); ?>" />

View File

@ -118,7 +118,7 @@ if ( $page_links )
<option value="" selected><?php _e('Actions'); ?></option>
<option value="delete"><?php _e('Delete'); ?></option>
</select>
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" />
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
<?php wp_nonce_field('bulk-link-categories'); ?>
</div>

View File

@ -9,10 +9,12 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');
// Handle bulk deletes
if ( isset($_GET['action']) && isset($_GET['post']) && isset($_GET['doaction']) ) {
// Handle bulk actions
if ( isset($_GET['action']) && $_GET['action'] != -1 ) {
switch ( $_GET['action'] ) {
case 'delete':
if ( isset($_GET['post']) && isset($_GET['doaction']) ) {
check_admin_referer('bulk-pages');
if ( $_GET['action'] == 'delete' ) {
foreach( (array) $_GET['post'] as $post_id_del ) {
$post_del = & get_post($post_id_del);
@ -27,15 +29,32 @@ if ( isset($_GET['action']) && isset($_GET['post']) && isset($_GET['doaction'])
wp_die( __('Error in deleting...') );
}
}
}
break;
case 'edit':
if ( isset($_GET['post']) ) {
check_admin_referer('bulk-pages');
$_GET['post_status'] = $_GET['_status'];
if ( -1 == $_GET['post_author'] )
unset($_GET['post_author']);
$done = bulk_edit_posts($_GET);
}
break;
}
$sendback = wp_get_referer();
if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('page-new.php');
elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
$sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
if ( isset($done) ) {
$done['upd'] = count( $done['upd'] );
$done['skip'] = count( $done['skip'] );
$sendback = add_query_arg( $done, $sendback );
unset($done);
}
wp_redirect($sendback);
exit();
}
} elseif ( !empty($_GET['_wp_http_referer']) ) {
wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
exit;
@ -85,6 +104,18 @@ require_once('admin-header.php');
</p>
</form>
<?php if ( isset($_GET['upd']) && (int) $_GET['upd'] ) { ?>
<div id="message" class="updated fade"><p>
<?php printf( __ngettext( '%d page updated.', '%d pages updated.', $_GET['upd'] ), number_format_i18n( $_GET['upd'] ) );
unset($_GET['upd']);
if ( isset($_GET['skip']) && (int) $_GET['skip'] ) {
printf( __ngettext( ' %d page not updated. Somebody is editing it.', ' %d pages not updated. Somebody is editing them.', $_GET['skip'] ), number_format_i18n( $_GET['skip'] ) );
unset($_GET['skip']);
} ?>
</p></div>
<?php } ?>
<div class="wrap">
<form id="adv-settings" action="" method="get">
<div id="show-settings"><a href="#edit_settings" id="show-settings-link" class="hide-if-no-js"><?php _e('Advanced Options') ?></a>
@ -175,7 +206,7 @@ if ( $page_links )
<option value="edit"><?php _e('Edit'); ?></option>
<option value="delete"><?php _e('Delete'); ?></option>
</select>
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" />
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
<?php wp_nonce_field('bulk-pages'); ?>
</div>
@ -197,12 +228,13 @@ if ($posts) {
</tr>
</thead>
<tbody>
<?php inline_edit_row( 'page' ) ?>
<?php page_rows($posts, $pagenum, $per_page); ?>
</tbody>
</table>
</form>
<?php inline_edit_row( 'page' ) ?>
<div id="ajax-response"></div>
<?php

View File

@ -16,8 +16,6 @@ if ( ! defined('ABSPATH') ) die();
</thead>
<tbody>
<?php inline_edit_row( 'post' ) ?>
<?php
if ( have_posts() ) {
post_rows();

View File

@ -184,7 +184,7 @@ if ( $page_links )
<option value="" selected><?php _e('Actions'); ?></option>
<option value="delete"><?php _e('Delete'); ?></option>
</select>
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" />
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
<?php wp_nonce_field('bulk-tags'); ?>
</div>

View File

@ -10,10 +10,10 @@
require_once('admin.php');
// Handle bulk actions
if ( isset($_GET['action']) && $_GET['action'] != -1 && isset($_GET['doaction']) ) {
if ( isset($_GET['action']) && $_GET['action'] != -1 ) {
switch ( $_GET['action'] ) {
case 'delete':
if ( isset($_GET['post']) ) {
if ( isset($_GET['post']) && isset($_GET['doaction']) ) {
check_admin_referer('bulk-posts');
foreach( (array) $_GET['post'] as $post_id_del ) {
$post_del = & get_post($post_id_del);
@ -32,14 +32,28 @@ if ( isset($_GET['action']) && $_GET['action'] != -1 && isset($_GET['doaction'])
}
break;
case 'edit':
// TODO: Decide what to do here - add bulk edit feature, or just disallow if >1 post selected
if ( isset($_GET['post']) ) {
check_admin_referer('bulk-posts');
$_GET['post_status'] = $_GET['_status'];
if ( -1 == $_GET['post_author'] )
unset($_GET['post_author']);
$done = bulk_edit_posts($_GET);
}
break;
}
$sendback = wp_get_referer();
if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('post-new.php');
elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
$sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
if ( isset($done) ) {
$done['upd'] = count( $done['upd'] );
$done['skip'] = count( $done['skip'] );
$sendback = add_query_arg( $done, $sendback );
unset($done);
}
wp_redirect($sendback);
exit();
} elseif ( !empty($_GET['_wp_http_referer']) ) {
@ -79,6 +93,23 @@ else
</p>
</form>
<?php if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
<div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $_GET['posted'] ); ?>"><?php _e('Edit post'); ?></a></p></div>
<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
endif; ?>
<?php if ( isset($_GET['upd']) && (int) $_GET['upd'] ) { ?>
<div id="message" class="updated fade"><p>
<?php printf( __ngettext( '%d post updated.', '%d posts updated.', $_GET['upd'] ), number_format_i18n( $_GET['upd'] ) );
unset($_GET['upd']);
if ( isset($_GET['skip']) && (int) $_GET['skip'] ) {
printf( __ngettext( ' %d post not updated. Somebody is editing it.', ' %d posts not updated. Somebody is editing them.', $_GET['skip'] ), number_format_i18n( $_GET['skip'] ) );
unset($_GET['skip']);
} ?>
</p></div>
<?php } ?>
<div class="wrap">
<form id="adv-settings" action="" method="get">
@ -154,14 +185,7 @@ unset( $status_links );
<?php if ( isset($_GET['post_status'] ) ) : ?>
<input type="hidden" name="post_status" value="<?php echo attribute_escape($_GET['post_status']) ?>" />
<?php endif;
if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
<div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $_GET['posted'] ); ?>"><?php _e('Edit post'); ?></a></p></div>
<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
endif;
?>
<?php endif; ?>
<input type="hidden" name="mode" value="<?php echo $mode; ?>" />
<ul class="view-switch">
@ -189,7 +213,7 @@ if ( $page_links )
<option value="edit"><?php _e('Edit'); ?></option>
<option value="delete"><?php _e('Delete'); ?></option>
</select>
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" />
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
<?php wp_nonce_field('bulk-posts'); ?>
<?php
if ( !is_singular() ) {
@ -243,6 +267,8 @@ do_action('restrict_manage_posts');
</form>
<?php inline_edit_row( 'post' ); ?>
<div id="ajax-response"></div>
<div class="tablenav">

View File

@ -31,7 +31,7 @@ endif;
<option value="" selected><?php _e('Actions'); ?></option>
<option value="archive"><?php _e('Archive'); ?></option>
</select>
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" />
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
</div>
<br class="clear" />
</div>

View File

@ -177,6 +177,68 @@ function edit_post( $post_data = null ) {
return $post_ID;
}
function bulk_edit_posts( $post_data = null ) {
if ( empty($post_data) )
$post_data = &$_POST;
if ( 'page' == $post_data['post_type'] ) {
if ( ! current_user_can( 'edit_pages' ) )
wp_die( __('You are not allowed to edit pages.') );
} else {
if ( ! current_user_can( 'edit_posts' ) )
wp_die( __('You are not allowed to edit posts.') );
}
$post_IDs = array_map( intval, (array) $post_data['post'] );
if ( isset($post_data['post_category']) ) {
if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) )
$new_cats = array_map( absint, $post_data['post_category'] );
else
unset($post_data['post_category']);
}
if ( isset($post_data['tags_input']) ) {
if ( ! empty($post_data['tags_input']) ) {
$new_tags = preg_replace( '/\s*,\s*/', ',', rtrim($post_data['tags_input'], ' ,') );
$new_tags = explode(',', $new_tags);
} else {
unset($post_data['tags_input']);
}
}
$reset = array( 'post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private' );
foreach ( $reset as $field ) {
if ( isset($post_data[$field]) && '' == $post_data[$field] )
unset($post_data[$field]);
}
$updated = $skipped = array();
foreach ( $post_IDs as $post_ID ) {
if ( wp_check_post_lock( $post_ID ) ) {
$skipped[] = $post_ID;
continue;
}
if ( isset($new_cats) ) {
$cats = (array) wp_get_post_categories($post_ID);
$post_data['post_category'] = array_unique( array_merge($cats, $new_cats) );
}
if ( isset($new_tags) ) {
$tags = wp_get_post_tags($post_ID, array('fields' => 'names'));
$post_data['tags_input'] = array_unique( array_merge($tags, $new_tags) );
}
$post_data['ID'] = $post_ID;
$updated[] = wp_update_post( $post_data );
}
return array( 'upd' => $updated, 'skip' => $skipped );
}
// Default post information to use when populating the "Write Post" form.
function get_default_post_to_edit() {
if ( !empty( $_REQUEST['post_title'] ) )

View File

@ -622,8 +622,14 @@ function inline_edit_row( $type ) {
$hidden_count = empty($hidden[0]) ? 0 : count($hidden);
$col_count = count($columns) - $hidden_count;
$m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
?>
<tr title="<?php _e('Double-click to cancel'); ?>" id="inline-edit" style="display: none"><td colspan="<?php echo $col_count; ?>">
$can_publish = current_user_can('publish_posts'); ?>
<form method="get" action=""><table style="display: none"><tbody id="inlineedit">
<?php
$bulk = 0;
while ( $bulk < 2 ) { ?>
<tr title="<?php _e('Double-click to cancel'); ?>" id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" style="display: none"><td colspan="<?php echo $col_count; ?>">
<?php
foreach($columns as $column_name=>$column_display_name) {
$class = "class=\"$column_name column-$column_name quick-edit-div\"";
@ -640,7 +646,7 @@ function inline_edit_row( $type ) {
case 'modified':
case 'date':
?>
if ( ! $bulk ) { ?>
<div <?php echo $attributes; ?> title="<?php _e('Timestamp'); ?>">
<div class="title"><?php _e('Timestamp'); ?></div>
<div class="in">
@ -648,10 +654,19 @@ function inline_edit_row( $type ) {
</div>
</div>
<?php
}
break;
case 'title':
$attributes = "class=\"$type-title column-title quick-edit-div\"" . $style; ?>
<?php if ( $bulk ) { ?>
<div <?php echo $attributes; ?> id="bulk-title-div" title="<?php $is_page ? _e('Selected pages') : _e('Selected posts'); ?>">
<div class="title"><?php $is_page ? _e('Selected pages') : _e('Selected posts'); ?></div>
<div class="in">
<div id="bulk-titles"></div>
</div>
</div>
<?php } else { ?>
<div <?php echo $attributes ?>>
<div class="title"><?php _e('Title'); ?></div>
<div class="in">
@ -660,25 +675,36 @@ function inline_edit_row( $type ) {
<label title="<?php _e('Slug'); ?>"><?php _e('Slug'); ?><input type="text" name="post_name" value="" /></label></div>
</div>
</div>
<?php } ?>
<?php if ( $is_page ) { ?>
<div class="parent quick-edit-div" title="<?php _e('Page Parent'); ?>">
<div class="title"><?php _e('Page Parent'); ?></div>
<div class="in">
<select name="post_parent">
<?php if ( $bulk ) { ?>
<option value=""><?php _e('- No Change -'); ?></option>
<?php } ?>
<option value="0"><?php _e('Main Page (no parent)'); ?></option>
<?php parent_dropdown(); ?>
</select>
</div>
</div>
<div class="template quick-edit-div" title="<?php _e('Page Template'); ?>">
<div class="title"><?php _e('Page Template'); ?></div>
<div class="in">
<select name="page_template">
<option value='default'><?php _e('Default Template'); ?></option>
<?php if ( $bulk ) { ?>
<option value=""><?php _e('- No Change -'); ?></option>
<?php } ?>
<option value="default"><?php _e('Default Template'); ?></option>
<?php page_template_dropdown() ?>
</select>
</div>
</div>
<?php if ( ! $bulk ) { ?>
<div class="order quick-edit-div" title="<?php _e('Page Order'); ?>">
<div class="title"><?php _e('Page Order'); ?></div>
<div class="in">
@ -686,10 +712,12 @@ function inline_edit_row( $type ) {
</div>
</div>
<?php }
}
break;
case 'categories': ?>
<?php if ( ! $bulk ) { ?>
<div <?php echo $attributes ?> title="<?php _e('Categories'); ?>">
<div class="title"><?php _e('Categories'); ?>
<span class="catshow"><?php _e('(expand)'); ?></span>
@ -698,28 +726,42 @@ function inline_edit_row( $type ) {
<?php wp_category_checklist(); ?>
</ul>
</div>
<?php
<?php }
break;
case 'tags': ?>
<?php if ( ! $bulk ) { ?>
<div <?php echo $attributes ?> title="<?php _e('Tags'); ?>">
<div class="title"><?php _e('Tags'); ?></div>
<div class="in">
<textarea cols="22" rows="1" type="text" name="tags_input" class="tags_input"></textarea>
</div>
</div>
<?php
<?php }
break;
case 'comments':
$attributes = 'class="comments column-comments num quick-edit-div"' . $style; ?>
?>
<div <?php echo $attributes ?> title="<?php _e('Comments and Pings'); ?>">
<div class="title"><?php _e('Comments and Pings'); ?></div>
<div class="in">
<?php if ( $bulk ) { ?>
<select name="comment_status">
<option value=""><?php _e('- No Change -'); ?></option>
<option value="open"><?php _e('Allow Comments'); ?></option>
<option value="closed"><?php _e('Disallow Comments'); ?></option>
</select>
<select name="ping_status">
<option value=""><?php _e('- No Change -'); ?></option>
<option value="open"><?php _e('Allow Pings'); ?></option>
<option value="closed"><?php _e('Disallow Pings'); ?></option>
</select>
<?php } else { ?>
<label><input type="checkbox" name="comment_status" value="open" />
<?php _e('Allow Comments'); ?></label><br />
<label><input type="checkbox" name="ping_status" value="open" />
<?php _e('Allow Pings'); ?></label>
<?php } ?>
</div>
</div>
<?php
@ -731,20 +773,24 @@ function inline_edit_row( $type ) {
<div <?php echo $attributes ?> title="<?php _e('Author'); ?>">
<div class="title"><?php _e('Author'); ?></div>
<div class="in">
<?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'selected' => $post->post_author) ); ?>
<?php
$users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors');
if ( $bulk ) $users_opt['show_option_none'] = __('- No Change -');
wp_dropdown_users( $users_opt ); ?>
</div>
</div>
<?php } ?>
<?php if ( ! $bulk ) { ?>
<div class="password quick-edit-div" title="<?php _e('Password'); ?>">
<div class="title"><?php _e('Password'); ?></div>
<div class="in">
<input type="text" name="post_password" value="<?php the_post_password(); ?>" />
<input type="text" name="post_password" value="" />
<label title="<?php _e('Privacy'); ?>">
<input type="checkbox" name="keep_private" value="private" <?php checked($post->post_status, 'private'); ?> /> <?php echo $is_page ? __('Keep this page private') : __('Keep this post private'); ?></label>
</div>
</div>
<?php
<?php }
break;
case 'status': ?>
@ -752,17 +798,23 @@ function inline_edit_row( $type ) {
<div class="title"><?php _e('Status'); ?></div>
<div class="in">
<select name="_status">
<?php if ( current_user_can('publish_posts') ) { // Contributors only get "Unpublished" and "Pending Review" ?>
<option value='publish'><?php _e('Published') ?></option>
<option value='future'><?php _e('Scheduled') ?></option>
<?php if ( $bulk ) { ?>
<option value=""><?php _e('- No Change -'); ?></option>
<?php if ( $can_publish ) { ?>
<option value="private"><?php _e('Private') ?></option>
<?php } ?>
<option value='pending'><?php _e('Pending Review') ?></option>
<option value='draft'><?php _e('Unpublished') ?></option>
<?php } ?>
<?php if ( $can_publish ) { // Contributors only get "Unpublished" and "Pending Review" ?>
<option value="publish"><?php _e('Published') ?></option>
<option value="future"><?php _e('Scheduled') ?></option>
<?php } ?>
<option value="pending"><?php _e('Pending Review') ?></option>
<option value="draft"><?php _e('Unpublished') ?></option>
</select>
</div>
</div>
<?php if ( current_user_can( 'edit_others_posts' ) && ! $is_page ) { ?>
<?php if ( ! $is_page && ! $bulk && current_user_can( 'edit_others_posts' ) ) { ?>
<div class="sticky quick-edit-div" <?php echo $style; ?> title="<?php _e('Sticky') ?>">
<div class="title"><?php _e('Sticky'); ?></div>
<div class="in">
@ -773,24 +825,12 @@ function inline_edit_row( $type ) {
<?php }
break;
case 'control_view': ?>
<div><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></div>
<?php
break;
default:
if ( $bulk )
do_action('bulk_edit_custom_box', $column_name, $type);
else
do_action('quick_edit_custom_box', $column_name, $type);
case 'control_edit': ?>
<div><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></div>
<?php
break;
case 'control_delete': ?>
<div><?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>"; } ?></div>
<?php
break;
default: ?>
<div><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></div>
<?php
break;
}
} ?>
@ -799,10 +839,14 @@ function inline_edit_row( $type ) {
<div class="quick-edit-save">
<a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel"><?php _e('Cancel'); ?></a>
<a accesskey="s" href="#inline-edit" title="<?php _e('Save'); ?>" class="button-secondary save"><?php _e('Save'); ?></a>
<?php wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ) ?>
<?php if ( ! $bulk ) wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); ?>
<input type="hidden" name="post_view" value="<?php echo $m; ?>" />
</div>
</td></tr>
<?php
$bulk++;
} ?>
</tbody></table></form>
<?php
}
@ -844,31 +888,31 @@ function get_inline_data($post) {
$title = __('(no title)');
echo '
<div id="inline_' . $post->ID . '">
<input type="hidden" name="" class="post_title" value="' . $title . '" />
<input type="hidden" name="" class="post_name" value="' . $post->post_name . '" />
<input type="hidden" name="" class="post_author" value="' . $post->post_author . '" />
<input type="hidden" name="" class="comment_status" value="' . $post->comment_status . '" />
<input type="hidden" name="" class="ping_status" value="' . $post->ping_status . '" />
<input type="hidden" name="" class="_status" value="' . $post->post_status . '" />
<input type="hidden" name="" class="jj" value="' . mysql2date( 'd', $post->post_date ) . '" />
<input type="hidden" name="" class="mm" value="' . mysql2date( 'm', $post->post_date ) . '" />
<input type="hidden" name="" class="aa" value="' . mysql2date( 'Y', $post->post_date ) . '" />
<input type="hidden" name="" class="hh" value="' . mysql2date( 'H', $post->post_date ) . '" />
<input type="hidden" name="" class="mn" value="' . mysql2date( 'i', $post->post_date ) . '" />
<input type="hidden" name="" class="post_password" value="' . wp_specialchars($post->post_password, 1) . '" />';
<div class="hidden" id="inline_' . $post->ID . '">
<div class="post_title">' . $title . '</div>
<div class="post_name">' . $post->post_name . '</div>
<div class="post_author">' . $post->post_author . '</div>
<div class="comment_status">' . $post->comment_status . '</div>
<div class="ping_status">' . $post->ping_status . '</div>
<div class="_status">' . $post->post_status . '</div>
<div class="jj">' . mysql2date( 'd', $post->post_date ) . '</div>
<div class="mm">' . mysql2date( 'm', $post->post_date ) . '</div>
<div class="aa">' . mysql2date( 'Y', $post->post_date ) . '</div>
<div class="hh">' . mysql2date( 'H', $post->post_date ) . '</div>
<div class="mn">' . mysql2date( 'i', $post->post_date ) . '</div>
<div class="post_password">' . wp_specialchars($post->post_password, 1) . '</div>';
if( $post->post_type == 'page' )
echo '
<input type="hidden" name="" class="post_parent" value="' . $post->post_parent . '" />
<input type="hidden" name="" class="page_template" value="' . wp_specialchars(get_post_meta( $post->ID, '_wp_page_template', true ), 1) . '" />
<input type="hidden" name="" class="menu_order" value="' . $post->menu_order . '" />';
<div class="post_parent">' . $post->post_parent . '</div>
<div class="page_template">' . wp_specialchars(get_post_meta( $post->ID, '_wp_page_template', true ), 1) . '</div>
<div class="menu_order">' . $post->menu_order . '</div>';
if( $post->post_type == 'post' )
echo '
<input type="hidden" name="" class="tags_input" value="' . wp_specialchars( str_replace( ',', ', ', get_tags_to_edit($post->ID) ), 1) . '" />
<input type="hidden" name="" class="post_category" value="' . implode( ',', wp_get_post_categories( $post->ID ) ) . '" />
<input type="hidden" name="" class="sticky" value="' . (is_sticky($post->ID) ? 'sticky' : '') . '" />';
<div class="tags_input">' . wp_specialchars( str_replace( ',', ', ', get_tags_to_edit($post->ID) ), 1) . '</div>
<div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div>
<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
echo '</div>';
}
@ -1035,7 +1079,6 @@ function _post_row($a_post, $pending_comments, $mode) {
break;
case 'comments':
$attributes = 'class="comments column-comments num"' . $style;
?>
<td <?php echo $attributes ?>><div class="post-com-count-wrapper">
<?php
@ -1210,7 +1253,6 @@ foreach ($posts_columns as $column_name=>$column_display_name) {
break;
case 'comments':
$attributes = 'class="comments column-comments num"' . $style;
?>
<td <?php echo $attributes ?>><div class="post-com-count-wrapper">
<?php

View File

@ -1,33 +1,73 @@
(function($) {
inlineEdit = {
type : '',
rows : '',
init : function() {
var t = this, blankRow = $('#inline-edit');
var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit');
t.type = $('table.widefat').hasClass('page') ? 'page' : 'post';
t.what = '#'+t.type+'-';
// get all editable rows
t.rows = $('tr.iedit');
// prepare the edit row
blankRow.dblclick(function() { inlineEdit.toggle(this); })
.keyup(function(e) { if(e.which == 27) return inlineEdit.revert(this); });
qeRow.dblclick(function() { inlineEdit.toggle(this); })
.keyup(function(e) { if(e.which == 27) return inlineEdit.revert(); });
$('a.cancel', blankRow).click(function() { return inlineEdit.revert(this); });
$('a.save', blankRow).click(function() { return inlineEdit.save(this); });
bulkRow.dblclick(function() { inlineEdit.revert(); })
.keyup(function(e) { if (e.which == 27) return inlineEdit.revert(); });
$('a.cancel', qeRow).click(function() { return inlineEdit.revert(); });
$('a.save', qeRow).click(function() { return inlineEdit.save(this); });
$('a.cancel', bulkRow).click(function() { return inlineEdit.revert(); });
$('a.save', bulkRow).click(function() { return inlineEdit.saveBulk(); });
// add events
t.rows.dblclick(function() { inlineEdit.toggle(this); });
t.addEvents(t.rows);
$('#bulk-title-div').after(
$('#inline-edit div.categories').clone(),
$('#inline-edit div.tags').clone()
);
// categories expandable?
$('span.catshow').click(function() {
$('.inline-editor ul.cat-checklist').addClass("cat-hover");
$('.inline-editor span.cathide').show();
$(this).hide();
});
$('span.cathide').click(function() {
$('.inline-editor ul.cat-checklist').removeClass("cat-hover");
$('.inline-editor span.catshow').show();
$(this).hide();
});
$('select[name="_status"] option[value="future"]', bulkRow).remove();
$('#doaction').click(function(e){
if ( $('select[name="action"]').val() == 'edit' ) {
e.preventDefault();
t.setBulk();
} else if ( $('form#posts-filter tr.inline-editor').length > 0 ) {
t.revert();
}
});
$('#post-query-submit').click(function(e){
if ( $('form#posts-filter tr.inline-editor').length > 0 )
t.revert();
});
},
toggle : function(el) {
var t = this;
$('#'+t.type+'-'+t.getId(el)).css('display') == 'none' ? t.revert(el) : t.edit(el);
$(t.what+t.getId(el)).css('display') == 'none' ? t.revert() : t.edit(el);
},
addEvents : function(r) {
@ -38,48 +78,66 @@ inlineEdit = {
});
},
edit : function(id) {
var t = this, type = t.type, old = $('tr.inline-editor').attr('id');
setBulk : function() {
var te = '', c = '';
this.revert();
if( typeof(id) == 'object' )
$('table.widefat tbody').prepend( $('#bulk-edit') );
$('#bulk-edit').addClass('inline-editor').show();
$('tbody th.check-column input[type="checkbox"]').each(function(i){
if ( $(this).attr('checked') ) {
var id = $(this).val();
c = c == '' ? ' class="alternate"' : '';
te += '<div'+c+'>'+$('#inline_'+id+' .post_title').text()+'</div>';
}
});
$('#bulk-titles').html(te);
// enable autocomplete for tags
if ( this.type == 'post' )
$('tr.inline-editor textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
},
edit : function(id) {
var t = this;
t.revert();
if ( typeof(id) == 'object' )
id = t.getId(id);
if ( old ) {
old = old.split('-')[1];
t.revert(old);
}
var fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'post_password'];
if ( type == 'page' ) fields.push('post_parent', 'menu_order', 'page_template');
if ( type == 'post' ) fields.push('tags_input');
if ( t.type == 'page' ) fields.push('post_parent', 'menu_order', 'page_template');
if ( t.type == 'post' ) fields.push('tags_input');
// add the new blank row
var editRow = $('#inline-edit').clone(true);
if ( $('#'+type+'-'+id).hasClass('alternate') )
if ( $(t.what+id).hasClass('alternate') )
$(editRow).addClass('alternate');
$('#'+type+'-'+id).hide().after(editRow);
$(t.what+id).hide().after(editRow);
// populate the data
var rowData = $('#inline_'+id);
for ( var f = 0; f < fields.length; f++ ) {
$(':input[name="'+fields[f]+'"]', editRow).val( $('.'+fields[f], rowData).val() );
$(':input[name="'+fields[f]+'"]', editRow).val( $('.'+fields[f], rowData).text() );
}
if ( $('.comment_status', rowData).val() == 'open' )
if ( $('.comment_status', rowData).text() == 'open' )
$('input[name="comment_status"]', editRow).attr("checked", "checked");
if ( $('.ping_status', rowData).val() == 'open' )
if ( $('.ping_status', rowData).text() == 'open' )
$('input[name="ping_status"]', editRow).attr("checked", "checked");
if ( $('.sticky', rowData).val() == 'sticky' )
if ( $('.sticky', rowData).text() == 'sticky' )
$('input[name="sticky"]', editRow).attr("checked", "checked");
// categories
var cats;
if ( cats = $('.post_category', rowData).val() )
$('ul.cat-checklist :checkbox').val(cats.split(','));
if ( cats = $('.post_category', rowData).text() )
$('ul.cat-checklist :checkbox', editRow).val(cats.split(','));
// handle the post status
var status = $('._status', rowData).val();
var status = $('._status', rowData).text();
if ( status != 'future' ) $('select[name="_status"] option[value="future"]', editRow).remove();
if ( status == 'private' ) $('input[name="keep_private"]', editRow).attr("checked", "checked");
@ -99,24 +157,11 @@ inlineEdit = {
pageOpt.remove();
}
// categories expandable?
$('span.catshow', editRow).click(function() {
$('ul.cat-checklist', editRow).addClass("cat-hover");
$('span.cathide', editRow).show();
$(this).hide();
});
$('span.cathide', editRow).click(function() {
$('ul.cat-checklist', editRow).removeClass("cat-hover");
$('span.catshow', editRow).show();
$(this).hide();
});
$(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
$('.ptitle', editRow).focus();
// enable autocomplete for tags
if ( type == 'post' )
if ( t.type == 'post' )
$('tr.inline-editor textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
return false;
@ -140,25 +185,36 @@ inlineEdit = {
// make ajax request
$.post('admin-ajax.php', params,
function(html) {
var row = $('#'+inlineEdit.type+'-'+id);
$('#edit-'+id).hide();
html = $(html).html();
row.html(html).show();
row.animate( { backgroundColor: '#FFFBCC' }, 200)
.animate( { backgroundColor: row.css('background-color') }, 500);
function(r) {
var row = $(inlineEdit.what+id);
$('#edit-'+id).remove();
row.html($(r).html()).show()
.animate( { backgroundColor: '#CCEEBB' }, 500)
.animate( { backgroundColor: '#eefee7' }, 500);
inlineEdit.addEvents(row);
}
);
return false;
},
revert : function(id) {
if ( typeof(id) == 'object' )
id = this.getId(id);
saveBulk : function() {
$('form#posts-filter').submit();
},
$('#edit-'+id).remove();
$('#'+this.type+'-'+id).show();
revert : function() {
var id;
if ( id = $('table.widefat tr.inline-editor').attr('id') ) {
if ( 'bulk-edit' == id ) {
$('table.widefat #bulk-edit').removeClass('inline-editor').hide();
$('#bulk-titles').html('');
$('#inlineedit').append( $('#bulk-edit') );
} else {
$('#'+id).remove();
id = id.substr( id.lastIndexOf('-') + 1 );
$(this.what+id).show();
}
}
return false;
},

View File

@ -120,7 +120,7 @@ if ( isset($_GET['deleted']) ) {
<option value="" selected><?php _e('Actions'); ?></option>
<option value="delete"><?php _e('Delete'); ?></option>
</select>
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" />
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
<?php
$categories = get_terms('link_category', "hide_empty=1");
$select_cat = "<select name=\"cat_id\">\n";

View File

@ -331,7 +331,7 @@ function print_plugins_table($plugins, $context = '') {
<option value="" selected><?php _e('Actions'); ?></option>
<option value="deactivate-selected"><?php _e('Deactivate'); ?></option>
</select>
<input type="submit" name="doaction" value="<?php _e('Apply'); ?>" class="button-secondary action" />
<input type="submit" name="doaction_active" value="<?php _e('Apply'); ?>" class="button-secondary action" />
</div>
</div>
<br class="clear" />
@ -356,7 +356,7 @@ function print_plugins_table($plugins, $context = '') {
<option value="delete-selected"><?php _e('Delete'); ?></option>
<?php endif; ?>
</select>
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" />
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction_recent" class="button-secondary action" />
<input type="submit" name="clear-recent-list" value="<?php _e('Clear List') ?>" class="button-secondary" />
</div>
</div>

View File

@ -271,7 +271,7 @@ if ( $page_links )
<option value="attach"><?php _e('Attach to a post'); ?></option>
<?php } ?>
</select>
<input type="submit" id="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" />
<input type="submit" id="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
<?php wp_nonce_field('bulk-media'); ?>
<?php

View File

@ -332,7 +332,7 @@ unset($role_links);
<option value="" selected><?php _e('Actions'); ?></option>
<option value="delete"><?php _e('Delete'); ?></option>
</select>
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" />
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
<label class="hidden" for="new_role"><?php _e('Change role to&hellip;') ?></label><select name="new_role" id="new_role"><option value=''><?php _e('Change role to&hellip;') ?></option><?php wp_dropdown_roles(); ?></select>
<input type="submit" value="<?php _e('Change'); ?>" name="changeit" class="button-secondary" />
<?php wp_nonce_field('bulk-users'); ?>

View File

@ -2203,7 +2203,9 @@ a.togbox {
}
.inline-editor div.title {
padding: 2px 5px;
height: 18px;
line-height: 16px;
padding: 1px 5px;
cursor: default;
}
@ -2212,6 +2214,12 @@ a.togbox {
width: 260px;
}
#bulk-edit .post-title,
#bulk-edit .page-title {
width: 200px;
height: 179px;
}
.inline-editor .post-title .ptitle,
.inline-editor .page-title .ptitle {
width: 245px;
@ -2258,7 +2266,7 @@ a.togbox {
}
.inline-editor .categories {
width: 180px;
width: 200px;
}
.inline-editor .categories ul.cat-checklist {
@ -2275,7 +2283,7 @@ a.togbox {
.inline-editor .categories ul.cat-hover {
height: 200px;
overflow: auto;
overflow-x: auto;
}
.inline-editor .categories ul.children {
@ -2301,14 +2309,14 @@ a.togbox {
}
.inline-editor .tags {
width: 220px;
width: 200px;
}
.inline-editor textarea {
border-width: 1px;
border-style: solid;
height: 45px;
width: 200px;
width: 180px;
font-size: 11px;
}
@ -2317,10 +2325,33 @@ a.togbox {
width: 160px;
}
#wpbody-content .inline-editor .comments select {
margin-bottom: 3px;
width: 150px;
}
.inline-editor .parent {
width: 180px;
}
#wpbody-content .inline-editor .parent select {
width: 170px;
}
.inline-editor .quick-edit-save {
padding: 8px 10px;
}
#bulk-titles {
height: 150px;
overflow: auto;
cursor: default;
}
#bulk-titles div {
padding: 1px 2px;
}
/* Media library */
#wpbody-content .media-item-info tr {
background-color: transparent;