From 6288b2b867bf55f73baefb9079c134438b91afce Mon Sep 17 00:00:00 2001 From: azaozz Date: Wed, 8 Oct 2008 01:18:16 +0000 Subject: [PATCH] Convert the comment reply popup to a temp table row for consistency, add Quick Edit for comments, see #7435 git-svn-id: http://svn.automattic.com/wordpress/trunk@9098 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-ajax.php | 39 ++- wp-admin/css/colors-classic.css | 13 +- wp-admin/css/colors-fresh.css | 13 +- wp-admin/includes/template.php | 119 +++++---- wp-admin/js/edit-comments.js | 237 +++++++++++------- wp-admin/js/inline-edit-post.js | 4 +- wp-admin/js/inline-edit-tax.js | 3 +- wp-admin/wp-admin.css | 122 +++++---- wp-includes/js/jquery/jquery.table-hotkeys.js | 4 +- wp-includes/script-loader.php | 9 +- 10 files changed, 357 insertions(+), 206 deletions(-) diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 950ec1361..89b4fd510 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -444,7 +444,7 @@ case 'replyto-comment' : $comment_author = $wpdb->escape($user->display_name); $comment_author_email = $wpdb->escape($user->user_email); $comment_author_url = $wpdb->escape($user->user_url); - $comment_content = trim($_POST['comment']); + $comment_content = trim($_POST['content']); if ( current_user_can('unfiltered_html') ) { if ( wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment'] ) { kses_remove_filters(); // start with a clean slate @@ -486,6 +486,43 @@ case 'replyto-comment' : 'position' => $position )); + $x->send(); + break; +case 'edit-comment' : + check_ajax_referer( 'replyto-comment' ); + + $comment_post_ID = (int) $_POST['comment_post_ID']; + if ( ! current_user_can( 'edit_post', $comment_post_ID ) ) + die('-1'); + + if ( '' == $_POST['content'] ) + die( __('Error: please type a comment.') ); + + $comment_id = (int) $_POST['comment_ID']; + $_POST['comment_status'] = $_POST['status']; + edit_comment(); + + $mode = ( isset($_POST['mode']) && 'single' == $_POST['mode'] ) ? 'single' : 'detail'; + $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1'; + $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0; + + if ( get_option('show_avatars') && 'single' != $mode ) + add_filter( 'comment_author', 'floated_admin_avatar' ); + + $x = new WP_Ajax_Response(); + + ob_start(); + _wp_comment_row( $comment_id, $mode, false, $checkbox ); + $comment_list_item = ob_get_contents(); + ob_end_clean(); + + $x->add( array( + 'what' => 'edit_comment', + 'id' => $comment->comment_ID, + 'data' => $comment_list_item, + 'position' => $position + )); + $x->send(); break; case 'add-meta' : diff --git a/wp-admin/css/colors-classic.css b/wp-admin/css/colors-classic.css index 40b89fa33..278dac472 100644 --- a/wp-admin/css/colors-classic.css +++ b/wp-admin/css/colors-classic.css @@ -26,7 +26,8 @@ body > #upload-menu { div#current-widgets, #postcustomstuff table, #your-profile fieldset, a.page-numbers, #rightnow, div.dashboard-widget, -#dashboard-widgets p.dashboard-widget-links, .widefat { +#dashboard-widgets p.dashboard-widget-links, .widefat, +#replyrow #ed_reply_toolbar input { border-color: #ccc; } @@ -63,7 +64,7 @@ li.widget-list-control-item h4.widget-title a, li.widget-list-control-item, div.nav, .tablenav, #dashboard-widgets p.dashboard-widget-links, .form-table tr, #poststuff h3, #replyhandle, .login form, h3.info-box-title, #post-status-info, #edit-settings-wrap, -#wpbody-content .describe tr { +#wpbody-content .describe tr, #edithead, #replyhead { background-color: #cfebf7; } @@ -860,7 +861,8 @@ div.star.select:hover { /* inline editor */ .inline-editor input, -.inline-editor textarea { +.inline-editor textarea, +#replyrow input { border-color: #ddd; } @@ -880,3 +882,8 @@ div.star.select:hover { .inline-editor .quick-edit-save { background-color: #CFEBF7; } + +#replyrow #ed_reply_toolbar input:hover { + border-color: #aaa; + background: #ddd; +} diff --git a/wp-admin/css/colors-fresh.css b/wp-admin/css/colors-fresh.css index 5b0dcfb28..0d5cddfee 100644 --- a/wp-admin/css/colors-fresh.css +++ b/wp-admin/css/colors-fresh.css @@ -26,7 +26,8 @@ body > #upload-menu { div#current-widgets, #postcustomstuff table, #your-profile fieldset, a.page-numbers, #rightnow, div.dashboard-widget, -#dashboard-widgets p.dashboard-widget-links, .widefat { +#dashboard-widgets p.dashboard-widget-links, .widefat, +#replyrow #ed_reply_toolbar input { border-color: #ccc; } @@ -63,7 +64,7 @@ li.widget-list-control-item h4.widget-title a, li.widget-list-control-item, div.nav, .tablenav, #dashboard-widgets p.dashboard-widget-links, .form-table tr, #poststuff h3, #replyhandle, .login form, h3.info-box-title, #post-status-info, #edit-settings-wrap, -#wpbody-content .describe tr { +#wpbody-content .describe tr, #edithead, #replyhead { background-color: #eaf3fa; } @@ -839,7 +840,8 @@ div.star.select:hover { /* inline editor */ .inline-editor input, -.inline-editor textarea { +.inline-editor textarea, +#replyrow input { border-color: #ddd; } @@ -859,3 +861,8 @@ div.star.select:hover { .inline-editor .quick-edit-save { background-color: #EAF3FA; } + +#replyrow #ed_reply_toolbar input:hover { + border-color: #aaa; + background: #ddd; +} diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 7ba76e84b..a2de3148a 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -191,11 +191,11 @@ function _cat_row( $category, $level, $name_override = false ) { * {@internal Missing Short Description}} * * @since 2.7 - * + * * Outputs the HTML for the hidden table rows used in Categories, Link Caregories and Tags quick edit. * * @param string $type "tag", "category" or "link-category" - * @return + * @return */ function inline_edit_term_row($type) { @@ -259,7 +259,8 @@ function inline_edit_term_row($type) {
- + +
@@ -892,8 +893,8 @@ function print_column_headers( $type, $id = true ) { /** * {@internal Missing Short Description}} * - * Outputs the quick edit and bulk edit table rows - * + * Outputs the quick edit and bulk edit table rows for posts and pages + * * @since 2.7 * * @param string $type 'post' or 'page' @@ -1129,7 +1130,10 @@ function inline_edit_row( $type ) {
- + + +
@@ -1140,7 +1144,7 @@ function inline_edit_row( $type ) { "; - if ( 'detail' == $mode || 'single' == $mode ) comment_text(); - + if ( 'detail' == $mode || 'single' == $mode ) comment_text(); ?> + + comment_post_ID) ) { @@ -1989,24 +2000,22 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true $actions['spam'] = "" . __( 'Spam' ) . ''; $actions['delete'] = "" . __('Delete') . ''; $actions['edit'] = "". __('Edit') . ''; + $actions['quickedit'] = '' . __('Quick Edit') . ''; if ( 'spam' != $the_comment_status ) - $actions['reply'] = '' . __('Reply') . ''; + $actions['reply'] = '' . __('Reply') . ''; $actions = apply_filters( 'comment_row_actions', $actions, $comment ); - $action_count = count($actions); $i = 0; foreach ( $actions as $action => $link ) { ++$i; - ( $i == $action_count ) ? $sep = '' : $sep = ' | '; - // The action before reply shouldn't output a sep - if ( 'edit' == $action ) - $sep = ''; - // Reply needs a hide-if-no-js span - if ( 'reply' == $action ) - echo " | $link$sep"; - else - echo "$link$sep"; + ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; + + // Reply and quickedit need a hide-if-no-js span + if ( 'reply' == $action || 'quickedit' == $action ) + $action .= ' hide-if-no-js'; + + echo "$sep$link"; } } @@ -2053,42 +2062,60 @@ function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single') global $current_user; // allow plugin to replace the popup content - $content = apply_filters( 'wp_comment_reply', '', array('position'=>$position, 'checkbox'=>$checkbox, 'mode'=>$mode) ); + $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) ); if ( ! empty($content) ) { echo $content; return; } ?> -