Sytling and improvements to inline editing, see #6815

git-svn-id: http://svn.automattic.com/wordpress/trunk@8943 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2008-09-21 19:45:45 +00:00
parent c57cfbaefc
commit 2e11a3bf66
10 changed files with 590 additions and 493 deletions

View File

@ -715,6 +715,7 @@ case 'hidden-columns' :
$current_user = wp_get_current_user();
if ( is_array($hidden) )
update_usermeta($current_user->ID, "manage-$page-columns-hidden", $hidden);
break;
case 'get-permalink':
check_ajax_referer( 'getpermalink', 'getpermalinknonce' );
$post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
@ -727,16 +728,8 @@ case 'sample-permalink':
$slug = isset($_POST['new_slug'])? $_POST['new_slug'] : '';
die(get_sample_permalink_html($post_id, $title, $slug));
break;
case 'inline-data':
check_ajax_referer( 'inlineeditnonce', 'inline_edit_nonce' );
if ( isset($_POST['posts']) )
get_inline_data( explode(',', $_POST['posts']) );
die();
break;
case 'inline-save':
check_ajax_referer( 'inlineeditnonce', 'inline_edit_nonce' );
check_ajax_referer( 'inlineeditnonce', '_inline_edit' );
if ( ! isset($_POST['post_ID']) )
exit;
@ -753,7 +746,7 @@ case 'inline-save':
post_rows($post);
}
die();
break;
break;
case 'meta-box-order':
check_ajax_referer( 'meta-box-order' );
update_user_option( $GLOBALS['current_user']->ID, "meta-box-order_$_POST[page]", $_POST['order'] );

View File

@ -806,7 +806,8 @@ table.diff .diff-addedline ins {
border-bottom-color: #14568A;
}
#replydiv {
#replydiv,
.inline-editor .quick-edit-div {
border-color: #EBEBEB #CCC #CCC #EBEBEB;
background-color: #fff;
}
@ -821,7 +822,7 @@ table.diff .diff-addedline ins {
background-color: #f8f8f8;
}
/* table vim shorcuts */
/* table vim shortcuts */
.vim-current {
background-color: #CFEBF7 !important;
}
@ -843,3 +844,26 @@ div.star.select:hover {
#plugin-information .fyi h2.mainheader {
background-color: #cee1ef;
}
/* inline editor */
.inline-editor input,
.inline-editor textarea {
border-color: #ddd;
}
.inline-editor div.title {
background-color: #CFEBF7;
}
.inline-editor ul.cat-checklist {
background-color: #FFFFFF;
}
.inline-editor .categories .catshow,
.inline-editor .categories .cathide {
color: #2583AD;
}
.inline-editor .quick-edit-save {
background-color: #CFEBF7;
}

View File

@ -789,7 +789,8 @@ table.diff .diff-addedline ins {
border-bottom-color: #E4F2FD;
}
#replydiv {
#replydiv,
.inline-editor .quick-edit-div {
border-color: #EBEBEB #CCC #CCC #EBEBEB;
background-color: #fff;
}
@ -804,7 +805,7 @@ table.diff .diff-addedline ins {
background-color: #f8f8f8;
}
/* table vim shorcuts */
/* table vim shortcuts */
.vim-current {
background-color: #E4F2FD !important;
}
@ -826,3 +827,26 @@ div.star.select:hover {
#plugin-information .fyi h2.mainheader {
background-color: #cee1ef;
}
/* inline editor */
.inline-editor input,
.inline-editor textarea {
border-color: #ddd;
}
.inline-editor div.title {
background-color: #EAF3FA;
}
.inline-editor ul.cat-checklist {
background-color: #FFFFFF;
}
.inline-editor .categories .catshow,
.inline-editor .categories .cathide {
color: #2583AD;
}
.inline-editor .quick-edit-save {
background-color: #EAF3FA;
}

View File

@ -189,7 +189,7 @@ $all = !( $h2_search || $post_status_q );
if ($posts) {
?>
<table class="widefat">
<table class="widefat page">
<thead>
<tr>
<?php print_column_headers('page'); ?>

View File

@ -8,7 +8,7 @@
if ( ! defined('ABSPATH') ) die();
?>
<table class="widefat">
<table class="widefat post">
<thead>
<tr>
<?php print_column_headers('post'); ?>

View File

@ -185,7 +185,7 @@ if ( $page_links )
<div class="alignleft">
<select name="action">
<option value="" selected><?php _e('Actions'); ?></option>
<option value="" selected="selected"><?php _e('Actions'); ?></option>
<option value="edit"><?php _e('Edit'); ?></option>
<option value="delete"><?php _e('Delete'); ?></option>
</select>

View File

@ -249,7 +249,7 @@ class Walker_Category_Checklist extends Walker {
extract($args);
$class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
$output .= "\n<li id='category-$category->term_id'$class>" . '<label for="in-category-' . $category->term_id . '" class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . wp_specialchars( apply_filters('the_category', $category->name )) . '</label>';
$output .= "\n<li id='category-$category->term_id'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . wp_specialchars( apply_filters('the_category', $category->name )) . '</label>';
}
function end_el(&$output, $category, $depth, $args) {
@ -315,7 +315,7 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $ech
?>
<li id="<?php echo $id; ?>" class="popular-category">
<label class="selectit" for="in-<?php echo $id; ?>">
<label class="selectit">
<input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" />
<?php echo wp_specialchars( apply_filters( 'the_category', $category->name ) ); ?>
</label>
@ -602,23 +602,29 @@ function print_column_headers( $type ) {
$style .= ' ' . $styles[$type][$column_key];
$style = ' style="' . $style . '"';
?>
<th scope="col"<?php echo "id=\"$column_key\""; echo $class; echo $style?>><?php echo $column_display_name; ?></th>
<th scope="col" <?php echo "id=\"$column_key\""; echo $class; echo $style?>><?php echo $column_display_name; ?></th>
<?php }
}
function inline_edit_row( $type ) {
global $current_user;
global $current_user, $mode;
if ( 'post' == $type )
$post = get_default_post_to_edit();
else
$is_page = 'page' == $type;
if ( $is_page )
$post = get_default_page_to_edit();
else
$post = get_default_post_to_edit();
echo '<tr id="inline-edit" style="display: none">';
$columns = $type == 'post' ? wp_manage_posts_columns() : wp_manage_pages_columns();
$columns = $is_page ? wp_manage_pages_columns() : wp_manage_posts_columns();
$hidden = (array) get_user_option( "manage-$type-columns-hidden" );
$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; ?>">
<?php
foreach($columns as $column_name=>$column_display_name) {
$class = "class=\"$column_name column-$column_name\"";
$class = "class=\"$column_name column-$column_name quick-edit-div\"";
$style = '';
if ( in_array($column_name, $hidden) )
@ -627,152 +633,175 @@ function inline_edit_row( $type ) {
$attributes = "$class$style";
switch($column_name) {
case 'cb': ?>
<th class="check-column"></th>
<?php
case 'cb':
break;
case 'modified':
case 'date':
$attributes = 'class="date column-date"' . $style;
?>
<td class="date"<?php echo $style ?>>
<div <?php echo $attributes; ?> title="<?php _e('Timestamp'); ?>">
<div class="title"><?php _e('Timestamp'); ?></div>
<div class="in">
<?php touch_time(1, 1, 4, 1); ?>
</td>
</div>
</div>
<?php
break;
case 'title':
$attributes = "class=\"$type-title column-title\"" . $style;
?>
<td <?php echo $attributes ?>>
<?php wp_nonce_field( 'inlineeditnonce', 'inline_edit_nonce', false ) ?>
<div class="title">
<input type="text" name="post_title" class="title" value="" /><br />
<label><?php _e('Slug'); ?></label><input type="text" name="post_name" value="" class="slug" />
$attributes = "class=\"$type-title column-title quick-edit-div\"" . $style; ?>
<div <?php echo $attributes ?>>
<div class="title"><?php _e('Title'); ?></div>
<div class="in">
<label title="<?php _e('Title'); ?>"><input type="text" name="post_title" class="ptitle" value="" /></label><br />
<div class="slug">
<label title="<?php _e('Slug'); ?>"><?php _e('Slug'); ?><input type="text" name="post_name" value="" /></label></div>
</div>
<?php if ($type == 'page'): ?>
<div class="other">
<label><?php _e('Parent'); ?></label>
</div>
<?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">
<option value="0"><?php _e('Main Page (no parent)'); ?></option>
<?php parent_dropdown(); ?>
</select><br />
<label><?php _e('Template'); ?></label>
</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 page_template_dropdown() ?>
</select>
</div>
<div class="more">
<label><?php _e('Order'); ?></label><input type="text" name="menu_order" value="<?php echo $post->menu_order ?>" />
<label><?php _e('Password'); ?></label><input type="text" name="post_password" value="<?php echo $post->post_password ?>" />
</div>
<?php endif; ?>
<div class="clear"></div>
<div class="save">
<?php
$actions = array();
$actions['save'] = '<a href="#">' . __('Save') . '</a>';
$actions['cancel'] = '<a href="#">' . __('Cancel') . '</a>';
$action_count = count($actions);
$i = 0;
foreach ( $actions as $action => $link ) {
++$i;
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
echo "<span class='$action'>$link$sep</span>";
}
?>
<div class="order quick-edit-div" title="<?php _e('Page Order'); ?>">
<div class="title"><?php _e('Page Order'); ?></div>
<div class="in">
<input type="text" name="menu_order" value="<?php echo $post->menu_order ?>" />
</div>
</td>
<?php
</div>
<?php }
break;
case 'categories': ?>
<td <?php echo $attributes ?>>
<ul class="categories">
<?php wp_category_checklist() ?>
<div <?php echo $attributes ?> title="<?php _e('Categories'); ?>">
<div class="title"><?php _e('Categories'); ?>
<span class="catshow"><?php _e('(expand)'); ?></span>
<span class="cathide" style="display:none;"><?php _e('(fold)'); ?></span></div>
<ul class="cat-checklist">
<?php wp_category_checklist(); ?>
</ul>
</td>
</div>
<?php
break;
case 'tags': ?>
<td <?php echo $attributes ?>>
<textarea name="tags_input"></textarea>
</td>
<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
break;
case 'comments':
$attributes = 'class="comments column-comments num"' . $style;
?>
<td <?php echo $attributes ?>>
<input title="Allow Comments" type="checkbox" name="comment_status" value="open" /><br />
<input title="Allow Pings" type="checkbox" name="ping_status" value="open" />
</td>
$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">
<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>
</div>
</div>
<?php
break;
case 'author': ?>
<td <?php echo $attributes ?>>
<?php
case 'author':
$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
if ( $authors && count( $authors ) > 1 ) {
wp_dropdown_users( array('include' => $authors, 'name' => 'post_author', 'class'=> 'author', 'selected' => $post->post_author) );
} else {
echo $current_user->user_nicename.'<input type="hidden" value="'.$post->post_author.'" class="author" />';
}
?>
</td>
if ( $authors && count( $authors ) > 1 ) { ?>
<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) ); ?>
</div>
</div>
<?php } ?>
<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 echo $post->post_password ?>" />
<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
break;
case 'status': ?>
<td <?php echo $attributes ?>>
<div <?php echo $attributes ?> title="<?php _e('Status'); ?>">
<div class="title"><?php _e('Status'); ?></div>
<div class="in">
<select name="post_status">
<?php if ( current_user_can('publish_posts') ) : // Contributors only get "Unpublished" and "Pending Review" ?>
<?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 endif; ?>
<?php } ?>
<option value='pending'><?php _e('Pending Review') ?></option>
<option value='draft'><?php _e('Unpublished') ?></option>
</select>
<?php if($type == 'page'): ?>
<br /><label><input type="checkbox" name="page_private" value="private" <?php checked($post->post_status, 'private'); ?> /> <?php _e('Private') ?></label></p>
<?php else: ?>
<?php if ( current_user_can( 'edit_others_posts' ) ) : ?>
<br /><label><input type="checkbox" name="sticky" value="sticky" /> <?php _e('Sticky') ?></label></p>
<?php endif; ?>
<?php endif; ?>
</td>
<?php
</div>
</div>
<?php if ( current_user_can( 'edit_others_posts' ) && ! $is_page ) { ?>
<div class="sticky quick-edit-div" <?php echo $style; ?> title="<?php _e('Sticky') ?>">
<div class="title"><?php _e('Sticky'); ?></div>
<div class="in">
<label title="<?php _e('Sticky') ?>">
<input type="checkbox" name="sticky" value="sticky" /> <?php _e('Stick this post to the front page') ?></label>
</div>
</div>
<?php }
break;
case 'control_view': ?>
<td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
<div><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></div>
<?php
break;
case 'control_edit': ?>
<td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
<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': ?>
<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>
<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: ?>
<td><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></td>
<div><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></div>
<?php
break;
}
}
} ?>
echo '</tr>';
<div class="clear"></div>
<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 ) ?>
<input type="hidden" name="post_view" value="<?php echo $m; ?>" />
</div>
</td></tr>
<?php
}
function inline_save_row( $data ) {
@ -781,7 +810,7 @@ function inline_save_row( $data ) {
$data['content'] = $post['post_content'];
// statuses
if ( 'page' == $data['post_type'] && 'private' == $data['page_private'] )
if ( 'private' == $data['keep_private'] )
$data['post_status'] = 'private';
if ( empty($data['comment_status']) )
$data['comment_status'] = 'closed';
@ -799,51 +828,44 @@ function inline_save_row( $data ) {
edit_post();
}
// outputs XML of the post/page data ready for use in the inline editor
// accepts array of post IDs
function get_inline_data($posts) {
global $post;
// adds hidden fields with the data for use in the inline editor
function get_inline_data($post) {
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
echo "<?xml version='1.0' ?>\n";
echo "<posts>\n";
if ( ! current_user_can('edit_' . $post->post_type, $post->ID) )
return;
foreach ($posts as $ID) {
$GLOBALS['post'] = get_post($ID);
$GLOBALS['post_ID'] = $ID;
$title = apply_filters( 'the_title', $post->post_title );
if ( empty($title) )
$title = __('(no title)');
if ( ($post->post_type == 'post' && !current_user_can('edit_post', $ID)) ||
($post->post_type == 'page' && !current_user_can('edit_page', $ID)) ||
($post->post_type != 'post' && $post->post_type != 'page'))
continue;
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="post_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) . '" />';
echo " <post id='$ID'>\n";
echo " <post_title>" . wp_specialchars($post->post_title, 1) . "</post_title>\n";
echo " <post_name>$post->post_name</post_name>\n";
echo " <post_author>$post->post_author</post_author>\n";
echo " <comment_status>$post->comment_status</comment_status>\n";
echo " <ping_status>$post->ping_status</ping_status>\n";
echo " <post_status>$post->post_status</post_status>\n";
echo " <jj>" . mysql2date( 'd', $post->post_date ) . "</jj>\n";
echo " <mm>" . mysql2date( 'm', $post->post_date ) . "</mm>\n";
echo " <aa>" . mysql2date( 'Y', $post->post_date ) . "</aa>\n";
echo " <hh>" . mysql2date( 'H', $post->post_date ) . "</hh>\n";
echo " <mn>" . mysql2date( 'i', $post->post_date ) . "</mn>\n";
if( $post->post_type == 'post' ) {
echo ' <tags_input>' . wp_specialchars(get_tags_to_edit( $post->ID ), 1) . "</tags_input>\n";
echo ' <post_category>' . implode( ',', wp_get_post_categories( $post->ID ) ) . "</post_category>\n";
echo ' <sticky>' . (is_sticky($post->ID) ? 'sticky' : '') . "</sticky>\n";
}
if( $post->post_type == 'page' ) {
echo " <post_parent>$post->post_parent</post_parent>\n";
echo ' <page_template>' . wp_specialchars(get_post_meta( $post->ID, '_wp_page_template', true ), 1) . "</page_template>\n";
echo " <post_password>" . wp_specialchars($post->post_password, 1) . "</post_password>\n";
echo " <menu_order>$post->menu_order</menu_order>\n";
}
echo " </post>\n";
}
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 . '" />';
echo '</posts>';
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' : '') . '" />';
echo '</div>';
}
function post_rows( $posts = array() ) {
@ -874,13 +896,13 @@ function post_rows( $posts = array() ) {
function _post_row($a_post, $pending_comments, $mode) {
global $post;
static $class;
static $rowclass;
$global_post = $post;
$post = $a_post;
setup_postdata($post);
$class = 'alternate' == $class ? '' : 'alternate';
$rowclass = 'alternate' == $rowclass ? '' : 'alternate';
global $current_user;
$post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
$edit_link = get_edit_post_link( $post->ID );
@ -888,7 +910,7 @@ function _post_row($a_post, $pending_comments, $mode) {
if ( empty($title) )
$title = __('(no title)');
?>
<tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $class . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
<tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top">
<?php
$posts_columns = wp_manage_posts_columns();
$hidden = (array) get_user_option( 'manage-post-columns-hidden' );
@ -934,11 +956,13 @@ function _post_row($a_post, $pending_comments, $mode) {
}
}
if ( 'excerpt' == $mode ) { ?>
<td <?php echo $attributes ?>><?php echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode) ?></td>
<?php } else { ?>
<td <?php echo $attributes ?>><abbr title="<?php echo $t_time ?>"><?php echo apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) ?></abbr></td>
<?php }
echo '<td ' . $attributes . '>';
if ( 'excerpt' == $mode )
echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
else
echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
echo '</td>';
break;
case 'title':
@ -966,6 +990,8 @@ function _post_row($a_post, $pending_comments, $mode) {
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
echo "<span class='$action'>$link$sep</span>";
}
get_inline_data($post);
?>
</td>
<?php
@ -1088,7 +1114,7 @@ function _post_row($a_post, $pending_comments, $mode) {
*/
function display_page_row( $page, $level = 0 ) {
global $post;
static $class;
static $rowclass;
$post = $page;
setup_postdata($page);
@ -1096,17 +1122,15 @@ function display_page_row( $page, $level = 0 ) {
$page->post_title = wp_specialchars( $page->post_title );
$pad = str_repeat( '&#8212; ', $level );
$id = (int) $page->ID;
$class = ('alternate' == $class ) ? '' : 'alternate';
$rowclass = 'alternate' == $rowclass ? '' : 'alternate';
$posts_columns = wp_manage_pages_columns();
$hidden = (array) get_user_option( 'manage-page-columns-hidden' );
$title = get_the_title();
if ( empty($title) )
$title = __('(no title)');
?>
<tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>
<?php
<tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit">
<?php
foreach ($posts_columns as $column_name=>$column_display_name) {
$class = "class=\"$column_name column-$column_name\"";
@ -1175,9 +1199,9 @@ foreach ($posts_columns as $column_name=>$column_display_name) {
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
echo "<span class='$action'>$link$sep</span>";
}
?>
</td>
<?php
get_inline_data($post);
echo '</td>';
break;
case 'comments':
@ -1236,9 +1260,9 @@ foreach ($posts_columns as $column_name=>$column_display_name) {
break;
}
}
?>
?>
</tr>
</tr>
<?php
}
@ -1517,7 +1541,7 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true
$spam_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
?>
<tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $the_comment_status; ?>'>
<tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $the_comment_status; ?>'>
<?php if ( $checkbox ) : ?>
<td class="check-column"><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
<?php endif; ?>
@ -1584,7 +1608,7 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true
<?php echo get_the_time(__('Y/m/d \a\t g:ia')); ?>
</td>
<?php endif; ?>
</tr>
</tr>
<?php
}

View File

@ -1,130 +1,97 @@
var postType = null;
var postView = null;
var postsXml = null;
var inlineRows = null;
jQuery(document).ready(function() {
postType = window.location.href.indexOf('edit.php') == -1 ? 'page' : 'post';
postView = window.location.href.indexOf('mode=excerpt') == -1 ? 'list' : 'excerpt';
(function($) {
inlineEdit = {
type : '',
rows : '',
// get IDs of all editable rows
inlineRows = jQuery('table.widefat .check-column :checkbox[name="post[]"]').parents('tr');
init : function() {
var t = this, blankRow = $('#inline-edit');
t.type = $('table.widefat').hasClass('page') ? 'page' : 'post';
// get all editable rows
t.rows = $('tr.iedit');
// prepare the edit row
var blankRow = jQuery('#inline-edit');
jQuery('ul.categories *', blankRow).removeAttr('id');
jQuery('ul.categories label', blankRow).removeAttr('for');
blankRow.attr('title', 'Double-click to cancel')
.dblclick(function() { toggleRow(this); })
.keypress(function(event) { if(event.which == 13) return saveRow(this); });
jQuery('span.cancel a', blankRow).click(function() { return revertRow(this); });
jQuery('span.save a', blankRow).click(function() { return saveRow(this); });
blankRow.dblclick(function() { inlineEdit.toggle(this); })
.keyup(function(e) { if(e.which == 27) return inlineEdit.revert(this); });
// add events and get data
inlineRows.dblclick(function() { toggleRow(this); });
addEvents(inlineRows);
$('a.cancel', blankRow).click(function() { return inlineEdit.revert(this); });
$('a.save', blankRow).click(function() { return inlineEdit.save(this); });
// get data
getInlineData('all');
});
function toggleRow(el) {
jQuery('#'+postType+'-'+getRowId(el)).css('display') == 'none' ? revertRow(el) : editRow(el);
}
// add events to links and make rows double-clickable
function addEvents(rows) {
rows.each(function() {
var row = jQuery(this);
jQuery('a.editinline', row).click(function() { editRow(this); return false; });
row.attr('title', 'Double-click to edit');
});
}
function getInlineData(id) {
if(id == 'all') {
var editable = [];
inlineRows.each(function(i) { editable[i] = getRowId(this); });
id = editable.join(',');
}
if(id == '')
return false;
jQuery.post('admin-ajax.php', {
'inline_edit_nonce': jQuery('#inline_edit_nonce').val(),
action: 'inline-data',
posts: id
// add events
t.rows.dblclick(function() { inlineEdit.toggle(this); });
t.addEvents(t.rows);
},
function(xml) {
if(id.indexOf(',') == -1) {
var newData = jQuery(xml).find('post[id="'+id+'"]');
jQuery(postsXml).find('post[id="'+id+'"]').replaceWith(newData);
} else {
postsXml = xml;
toggle : function(el) {
var t = this;
$('#'+t.type+'-'+t.getId(el)).css('display') == 'none' ? t.revert(el) : t.edit(el);
},
addEvents : function(r) {
r.each(function() {
var row = $(this);
$('a.editinline', row).click(function() { inlineEdit.edit(this); return false; });
row.attr('title', inlineEditL10n.edit);
});
},
edit : function(id) {
var t = this, type = t.type, old = $('tr.inline-editor').attr('id');
if( typeof(id) == 'object' )
id = t.getId(id);
if ( old ) {
old = old.split('-')[1];
t.revert(old);
}
}, 'xml'
);
}
function editRow(id) {
if(typeof(id) == 'object')
id = getRowId(id);
var blankRow = jQuery('#inline-edit');
var fields = ['post_title', 'post_name', 'post_author', 'post_status', 'jj', 'mm', 'aa', 'hh', 'mn'];
if(postType == 'page') fields.push('post_parent', 'menu_order', 'page_template', 'post_password');
if(postType == 'post') fields.push('tags_input');
var fields = ['post_title', 'post_name', 'post_author', 'post_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');
// add the new blank row
var editRow = blankRow.clone(true);
jQuery(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
if(jQuery('#'+postType+'-'+id).hasClass('alternate'))
jQuery(editRow).addClass('alternate');
jQuery('#'+postType+'-'+id).hide().after(editRow);
var editRow = $('#inline-edit').clone(true);
if ( $('#'+type+'-'+id).hasClass('alternate') )
$(editRow).addClass('alternate');
$('#'+type+'-'+id).hide().after(editRow);
// populate the data
var rowData = jQuery(postsXml).find('post[id="'+id+'"]');
for(var f = 0; f < fields.length; f++) {
jQuery(':input[name="'+fields[f]+'"]', editRow).val(jQuery(fields[f], rowData).text());
var rowData = $('#inline_'+id);
for ( var f = 0; f < fields.length; f++ ) {
$(':input[name="'+fields[f]+'"]', editRow).val( $('.'+fields[f], rowData).val() );
}
// ping, comments, and privacy
if(jQuery('comment_status', rowData).text() == 'open')
jQuery('input[name="comment_status"]', editRow).select();
if(jQuery('ping_status', rowData).text() == 'open')
jQuery('input[name="ping_status"]', editRow).select();
if(jQuery('sticky', rowData).text() == 'sticky')
jQuery('input[name="sticky"]', editRow).select();
if ( $('.comment_status', rowData).val() == 'open' )
$('input[name="comment_status"]', editRow).attr("checked", "checked");
if ( $('.ping_status', rowData).val() == 'open' )
$('input[name="ping_status"]', editRow).attr("checked", "checked");
if ( $('.sticky', rowData).val() == 'sticky' )
$('input[name="sticky"]', editRow).attr("checked", "checked");
// categories
var categories = jQuery('post_category', rowData).text().split(',');
jQuery(categories).each(function() {
jQuery('ul.categories :checkbox[value="'+this+'"]', editRow).select();
});
var cats;
if ( cats = $('.post_category', rowData).val() )
$('ul.cat-checklist :checkbox').val(cats.split(','));
// handle the post status
var status = jQuery('post_status', rowData).text();
if(status != 'future') jQuery('select[name="post_status"] option[value="future"]', editRow).remove();
if(status == 'private') jQuery('input[name="page_private"]', editRow).select();
// enable autocomplete for tags
if(postType == 'post') {
jQuery('tr.inline textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
}
var status = $('.post_status', rowData).val();
if ( status != 'future' ) $('select[name="post_status"] option[value="future"]', editRow).remove();
if ( status == 'private' ) $('input[name="keep_private"]', editRow).attr("checked", "checked");
// remove the current page and children from the parent dropdown
var pageOpt = jQuery('select[name="post_parent"] option[value="'+id+'"]', editRow);
if(pageOpt.length > 0) {
var pageLevel = pageOpt[0].className.split('-')[1];
var nextPage = pageOpt; var pageLoop = true;
while(pageLoop) {
var nextPage = nextPage.next('option');
var nextLevel = nextPage[0].className.split('-')[1];
if(nextLevel <= pageLevel)
var pageOpt = $('select[name="post_parent"] option[value="'+id+'"]', editRow);
if ( pageOpt.length > 0 ) {
var pageLevel = pageOpt[0].className.split('-')[1], nextPage = pageOpt, pageLoop = true;
while ( pageLoop ) {
var nextPage = nextPage.next('option'), nextLevel = nextPage[0].className.split('-')[1];
if ( nextLevel <= pageLevel ) {
pageLoop = false;
else {
} else {
nextPage.remove();
nextPage = pageOpt;
}
@ -132,56 +99,76 @@ function editRow(id) {
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' )
$('tr.inline-editor textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
return false;
}
},
function saveRow(id) {
if(typeof(id) == 'object')
id = getRowId(id);
save : function(id) {
if( typeof(id) == 'object' )
id = this.getId(id);
jQuery('#edit-'+id+' .check-column').html('<img src="images/loading.gif" alt="" />');
$('#edit-'+id+' .check-column').html('<img src="images/loading.gif" alt="" />');
var params = {
'inline_edit_nonce': jQuery('#inline_edit_nonce').val(),
action: 'inline-save',
post_type: postType,
post_type: this.type,
post_ID: id,
edit_date: 'true',
post_view: postView
edit_date: 'true'
};
var fields = jQuery('#edit-'+id+' :input').fieldSerialize();
params = fields + '&' + jQuery.param(params);
var fields = $('#edit-'+id+' :input').fieldSerialize();
params = fields + '&' + $.param(params);
// make ajax request
jQuery.post('admin-ajax.php', params,
$.post('admin-ajax.php', params,
function(html) {
var row = jQuery('#'+postType+'-'+id);
jQuery('#edit-'+id).hide();
html = jQuery(html).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);
getInlineData(id);
addEvents(row);
inlineEdit.addEvents(row);
}
);
return false;
},
revert : function(id) {
if ( typeof(id) == 'object' )
id = this.getId(id);
$('#edit-'+id).remove();
$('#'+this.type+'-'+id).show();
return false;
}
},
function revertRow(id) {
if(typeof(id) == 'object')
id = getRowId(id);
jQuery('#edit-'+id).remove();
jQuery('#'+postType+'-'+id).show();
return false;
}
function getRowId(obj) {
var id = obj.tagName == 'TR' ? obj.id : jQuery(obj).parents('tr').attr('id');
getId : function(o) {
var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id');
var parts = id.split('-');
return parts[parts.length - 1];
}
}
};
$(document).ready(function(){inlineEdit.init();});
})(jQuery);

View File

@ -2159,120 +2159,162 @@ a.togbox {
font-size: 11px;
}
.inline-editor .save {
padding-top: 5px;
}
.inline-editor td {
padding-right: 4px;
padding-left: 7px;
padding: 3px;
}
.inline-editor input, .inline-editor select, .inline-editor textarea {
font-size: 10px !important;
.inline-editor .save,
.inline-editor .cancel {
margin-right: 5px;
}
.inline-editor .quick-edit-div {
float: left;
height: 85px;
margin: 0 5px 3px 0;
width: 130px;
border-style: solid;
border-width: 1px;
padding: 2px;
border: 1px solid #ddd;
}
.inline-editor td.date {
width: 87px;
.inline-editor .in {
padding: 4px;
margin: 2px 0 0;
line-height: 15px;
}
.inline-editor td.page-title {
width: 495px;
.inline-editor input {
font-size: 11px !important;
padding: 2px;
border-width: 1px;
border-style: solid;
}
.inline-editor td.post-title input.title {
width: 250px;
}
.inline-editor td.post-title input.slug {
width: 222px;
float: right;
#wpbody-content .inline-editor select {
padding: 0;
height: auto;
width: 120px;
font-size: 11px !important;
}
.inline-editor div.title {
float: left;
padding: 2px 5px;
cursor: default;
}
.inline-editor div.title input.title {
.inline-editor .post-title,
.inline-editor .page-title {
width: 260px;
}
.inline-editor .post-title .ptitle,
.inline-editor .page-title .ptitle {
width: 245px;
margin-bottom: 5px;
font-size: 12px !important;
}
.inline-editor div.title label {
float: left;
margin-top: 4px;
.inline-editor .post-title .slug,
.inline-editor .page-title .slug {
text-align: right;
}
.inline-editor td.page-title input.slug {
width: 123px;
float: right;
.inline-editor .slug input {
width: 170px;
margin: 0 2px 0 4px;
}
.inline-editor div.other, .inline-editor div.more {
width: 190px;
float: left;
padding-left: 5px;
.inline-editor .password input,
.inline-editor .order input {
width: 112px;
}
.inline-editor div.other label, .inline-editor div.more label {
display: block; float: left;
width: 54px;
margin-top: 4px;
.inline-editor .password label input {
width: auto;
margin: 3px 0 0;
}
.inline-editor div.other select {
width: 133px;
.inline-editor .date {
width: 160px;
}
.inline-editor div.more {
width: 125px;
.inline-editor .date input {
padding: 2px 1px;
margin: 1px;
width: 18px;
}
.inline-editor div.more input {
width: 60px;
.inline-editor .date input[name="aa"] {
width: 30px;
}
.inline-editor td.author select {
width: 110px;
#wpbody-content .inline-editor .date select {
width: 80px;
}
.inline-editor ul.categories {
.inline-editor .categories {
width: 180px;
}
.inline-editor .categories ul.cat-checklist {
list-style: none;
padding: 0; margin: 0;
padding: 0 0 0 4px;
margin: 0;
height: 65px;
overflow: auto;
font-size: 10px;
font-size: 11px;
z-index: 5;
position: relative;
overflow-x: hidden;
}
.inline-editor ul.categories ul.children {
.inline-editor .categories ul.cat-hover {
height: 200px;
overflow: auto;
}
.inline-editor .categories ul.children {
list-style: none;
padding-left: 15px;
}
.inline-editor ul.categories li {
margin-bottom: 2px;
.inline-editor .categories li {
margin-bottom: 3px;
line-height: auto;
}
.inline-editor ul.categories input {
.inline-editor .categories input {
vertical-align: middle;
padding: 0; border: 0;
padding: 0;
border: 0;
}
.inline-editor td.tags textarea {
height: 58px; width: 100%;
.inline-editor .categories .catshow,
.inline-editor .categories .cathide {
font-size: 9px;
cursor: pointer;
}
.inline-editor td.comments {
padding-left: 0;
.inline-editor .tags {
width: 220px;
}
.inline-editor td.status select {
width: 98px;
.inline-editor textarea {
border-width: 1px;
border-style: solid;
height: 45px;
width: 200px;
font-size: 11px;
}
.inline-editor td.status input {
vertical-align: middle;
.inline-editor .comments {
text-align: left;
width: 160px;
}
.inline-editor .quick-edit-save {
padding: 8px 10px;
}
/* Media library */

View File

@ -244,7 +244,10 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'theme-preview', '/wp-admin/js/theme-preview.js', array( 'thickbox', 'jquery' ), '20080625' );
$scripts->add( 'inline-edit', '/wp-admin/js/inline-edit.js', array( 'jquery', 'jquery-form', 'suggest' ), '20080812' );
$scripts->add( 'inline-edit', '/wp-admin/js/inline-edit.js', array( 'jquery', 'jquery-form', 'suggest' ), '20080920' );
$scripts->localize( 'inline-edit', 'inlineEditL10n', array(
'edit' => __('Double-click to edit')
) );
$scripts->add( 'plugin-install', '/wp-admin/js/plugin-install.js', array( 'thickbox', 'jquery' ), '20080803' );
$scripts->localize( 'plugin-install', 'plugininstallL10n', array(