From ae2c4bc50cb7c24a2fbe0e8ca2cbf058747aaa37 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 16 Oct 2008 22:23:32 +0000 Subject: [PATCH] Add opt-in optioon for comment hotkeys. Props nbachiyski. fixes #7643 git-svn-id: http://svn.automattic.com/wordpress/trunk@9217 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-comments.php | 2 +- wp-admin/edit-pages.php | 2 +- wp-admin/edit.php | 2 +- wp-admin/includes/comment.php | 5 +++++ wp-admin/includes/user.php | 2 ++ wp-admin/js/edit-comments.js | 3 ++- wp-admin/post.php | 2 +- wp-admin/upload.php | 2 +- wp-admin/user-edit.php | 4 ++++ wp-includes/registration.php | 4 ++++ wp-includes/script-loader.php | 4 ++-- 11 files changed, 24 insertions(+), 8 deletions(-) diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index 7a37d0ca4..b47d860f0 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -12,7 +12,7 @@ require_once('admin.php'); $title = __('Edit Comments'); wp_enqueue_script( 'admin-comments' ); wp_enqueue_script( 'admin-forms' ); -wp_enqueue_script( 'jquery-table-hotkeys' ); +enqueue_comment_hotkeys_js(); if ( ( isset( $_POST['delete_all_spam'] ) || isset( $_POST['delete_all_spam2'] ) ) && !empty( $_POST['pagegen_timestamp'] ) ) { check_admin_referer('bulk-spam-delete'); diff --git a/wp-admin/edit-pages.php b/wp-admin/edit-pages.php index 2d2927ee5..b55c3035d 100644 --- a/wp-admin/edit-pages.php +++ b/wp-admin/edit-pages.php @@ -95,7 +95,7 @@ wp($query_str); if ( is_singular() ) { wp_enqueue_script( 'admin-comments' ); - wp_enqueue_script( 'jquery-table-hotkeys' ); + enqueue_comment_hotkeys_js(); } require_once('admin-header.php'); ?> diff --git a/wp-admin/edit.php b/wp-admin/edit.php index 2162e2f08..eeae905f4 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -77,7 +77,7 @@ list($post_stati, $avail_post_stati) = wp_edit_posts_query(); if ( 1 == count($posts) && is_singular() ) { wp_enqueue_script( 'admin-comments' ); - wp_enqueue_script( 'jquery-table-hotkeys' ); + enqueue_comment_hotkeys_js(); } require_once('admin-header.php'); diff --git a/wp-admin/includes/comment.php b/wp-admin/includes/comment.php index d823732ba..0fd1533d2 100644 --- a/wp-admin/includes/comment.php +++ b/wp-admin/includes/comment.php @@ -151,6 +151,11 @@ function floated_admin_avatar( $name ) { return "$avatar $name"; } +function enqueue_comment_hotkeys_js() { + if ( 'true' == get_user_option( 'comment_shortcuts' ) ) + wp_enqueue_script( 'jquery-table-hotkeys' ); +} + if ( is_admin() && ('edit-comments.php' == $pagenow || 'edit.php' == $pagenow) ) { if ( get_option('show_avatars') ) add_filter( 'comment_author', 'floated_admin_avatar' ); diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php index af35160a9..4b663e7bb 100644 --- a/wp-admin/includes/user.php +++ b/wp-admin/includes/user.php @@ -98,6 +98,8 @@ function edit_user( $user_id = 0 ) { else $user->rich_editing = 'true'; + $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] )? $_POST['comment_shortcuts'] : ''; + $user->use_ssl = 0; if ( !empty($_POST['use_ssl']) ) $user->use_ssl = 1; diff --git a/wp-admin/js/edit-comments.js b/wp-admin/js/edit-comments.js index 701d94290..b06e066cf 100644 --- a/wp-admin/js/edit-comments.js +++ b/wp-admin/js/edit-comments.js @@ -320,7 +320,8 @@ $(document).ready(function(){ }; $.table_hotkeys($('table.widefat'),['a', 'u', 's', 'd', 'r', ['e', edit_comment], ['shift+a', make_bulk('approve')], ['shift+s', make_bulk('markspam')], - ['shift+d', make_bulk('delete')], ['shift+x', toggle_all]], + ['shift+d', make_bulk('delete')], ['shift+x', toggle_all], + ['shift+u', make_bulk('unapprove')]], {highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last, prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next')} ); diff --git a/wp-admin/post.php b/wp-admin/post.php index 79824bf08..1ef464c91 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -140,7 +140,7 @@ case 'edit': wp_enqueue_script('media-upload'); wp_enqueue_script('word-count'); wp_enqueue_script( 'admin-comments' ); - wp_enqueue_script( 'jquery-table-hotkeys' ); + enqueue_comment_hotkeys_js(); if ( current_user_can('edit_post', $post_ID) ) { if ( $last = wp_check_post_lock( $post->ID ) ) { diff --git a/wp-admin/upload.php b/wp-admin/upload.php index 2ffc8239b..dff6d9649 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -140,7 +140,7 @@ if ( isset($_GET['detached']) ) { if ( is_singular() ) { wp_enqueue_script( 'admin-comments' ); - wp_enqueue_script( 'jquery-table-hotkeys' ); + enqueue_comment_hotkeys_js(); } require_once('admin-header.php'); ?> diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php index 3ec5fc669..efac07629 100644 --- a/wp-admin/user-edit.php +++ b/wp-admin/user-edit.php @@ -220,6 +220,10 @@ foreach ( $_wp_admin_css_colors as $color => $color_info ): ?> + + + + __('Medium'), 'strong' => __('Strong') ) ); - $scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags', 'columns', 'settings-box'), '20081014' ); + $scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags', 'columns', 'settings-box'), '20081016' ); $scripts->localize( 'admin-comments', 'adminCommentsL10n', array( 'pending' => __('%i% pending'), // must look like: "# blah blah" 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), @@ -435,4 +435,4 @@ add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); add_action( 'wp_default_styles', 'wp_default_styles' ); -add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 ); \ No newline at end of file +add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );