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
This commit is contained in:
ryan 2008-10-16 22:23:32 +00:00
parent 72577aacd8
commit ae2c4bc50c
11 changed files with 24 additions and 8 deletions

View File

@ -12,7 +12,7 @@ require_once('admin.php');
$title = __('Edit Comments'); $title = __('Edit Comments');
wp_enqueue_script( 'admin-comments' ); wp_enqueue_script( 'admin-comments' );
wp_enqueue_script( 'admin-forms' ); 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'] ) ) { if ( ( isset( $_POST['delete_all_spam'] ) || isset( $_POST['delete_all_spam2'] ) ) && !empty( $_POST['pagegen_timestamp'] ) ) {
check_admin_referer('bulk-spam-delete'); check_admin_referer('bulk-spam-delete');

View File

@ -95,7 +95,7 @@ wp($query_str);
if ( is_singular() ) { if ( is_singular() ) {
wp_enqueue_script( 'admin-comments' ); wp_enqueue_script( 'admin-comments' );
wp_enqueue_script( 'jquery-table-hotkeys' ); enqueue_comment_hotkeys_js();
} }
require_once('admin-header.php'); ?> require_once('admin-header.php'); ?>

View File

@ -77,7 +77,7 @@ list($post_stati, $avail_post_stati) = wp_edit_posts_query();
if ( 1 == count($posts) && is_singular() ) { if ( 1 == count($posts) && is_singular() ) {
wp_enqueue_script( 'admin-comments' ); wp_enqueue_script( 'admin-comments' );
wp_enqueue_script( 'jquery-table-hotkeys' ); enqueue_comment_hotkeys_js();
} }
require_once('admin-header.php'); require_once('admin-header.php');

View File

@ -151,6 +151,11 @@ function floated_admin_avatar( $name ) {
return "$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 ( is_admin() && ('edit-comments.php' == $pagenow || 'edit.php' == $pagenow) ) {
if ( get_option('show_avatars') ) if ( get_option('show_avatars') )
add_filter( 'comment_author', 'floated_admin_avatar' ); add_filter( 'comment_author', 'floated_admin_avatar' );

View File

@ -98,6 +98,8 @@ function edit_user( $user_id = 0 ) {
else else
$user->rich_editing = 'true'; $user->rich_editing = 'true';
$user->comment_shortcuts = isset( $_POST['comment_shortcuts'] )? $_POST['comment_shortcuts'] : '';
$user->use_ssl = 0; $user->use_ssl = 0;
if ( !empty($_POST['use_ssl']) ) if ( !empty($_POST['use_ssl']) )
$user->use_ssl = 1; $user->use_ssl = 1;

View File

@ -320,7 +320,8 @@ $(document).ready(function(){
}; };
$.table_hotkeys($('table.widefat'),['a', 'u', 's', 'd', 'r', ['e', edit_comment], $.table_hotkeys($('table.widefat'),['a', 'u', 's', 'd', 'r', ['e', edit_comment],
['shift+a', make_bulk('approve')], ['shift+s', make_bulk('markspam')], ['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, {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')} prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next')}
); );

View File

@ -140,7 +140,7 @@ case 'edit':
wp_enqueue_script('media-upload'); wp_enqueue_script('media-upload');
wp_enqueue_script('word-count'); wp_enqueue_script('word-count');
wp_enqueue_script( 'admin-comments' ); wp_enqueue_script( 'admin-comments' );
wp_enqueue_script( 'jquery-table-hotkeys' ); enqueue_comment_hotkeys_js();
if ( current_user_can('edit_post', $post_ID) ) { if ( current_user_can('edit_post', $post_ID) ) {
if ( $last = wp_check_post_lock( $post->ID ) ) { if ( $last = wp_check_post_lock( $post->ID ) ) {

View File

@ -140,7 +140,7 @@ if ( isset($_GET['detached']) ) {
if ( is_singular() ) { if ( is_singular() ) {
wp_enqueue_script( 'admin-comments' ); wp_enqueue_script( 'admin-comments' );
wp_enqueue_script( 'jquery-table-hotkeys' ); enqueue_comment_hotkeys_js();
} }
require_once('admin-header.php'); ?> require_once('admin-header.php'); ?>

View File

@ -220,6 +220,10 @@ foreach ( $_wp_admin_css_colors as $color => $color_info ): ?>
<?php endforeach; ?> <?php endforeach; ?>
</fieldset></td> </fieldset></td>
</tr> </tr>
<tr>
<th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
<td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php checked('true', $profileuser->comment_shortcuts); ?> /> <?php _e( 'Enable keyboard shortcuts for comment moderation. <a href="http://codex.wordpress.org/Keyboard_Shortcuts">More information</a>' ); ?></label></td>
</tr>
<?php <?php
endif; endif;
do_action('personal_options', $profileuser); do_action('personal_options', $profileuser);

View File

@ -154,6 +154,9 @@ function wp_insert_user($userdata) {
if ( empty($rich_editing) ) if ( empty($rich_editing) )
$rich_editing = 'true'; $rich_editing = 'true';
if ( empty($comment_shortcuts) )
$comment_shortcuts = 'false';
if ( empty($admin_color) ) if ( empty($admin_color) )
$admin_color = 'fresh'; $admin_color = 'fresh';
$admin_color = preg_replace('|[^a-z0-9 _.\-@]|i', '', $admin_color); $admin_color = preg_replace('|[^a-z0-9 _.\-@]|i', '', $admin_color);
@ -183,6 +186,7 @@ function wp_insert_user($userdata) {
update_usermeta( $user_id, 'aim', $aim ); update_usermeta( $user_id, 'aim', $aim );
update_usermeta( $user_id, 'yim', $yim ); update_usermeta( $user_id, 'yim', $yim );
update_usermeta( $user_id, 'rich_editing', $rich_editing); update_usermeta( $user_id, 'rich_editing', $rich_editing);
update_usermeta( $user_id, 'comment_shortcuts', $comment_shortcuts);
update_usermeta( $user_id, 'admin_color', $admin_color); update_usermeta( $user_id, 'admin_color', $admin_color);
update_usermeta( $user_id, 'use_ssl', $use_ssl); update_usermeta( $user_id, 'use_ssl', $use_ssl);

View File

@ -155,7 +155,7 @@ function wp_default_scripts( &$scripts ) {
'good' => __('Medium'), 'good' => __('Medium'),
'strong' => __('Strong') '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( $scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
'pending' => __('%i% pending'), // must look like: "# blah blah" 'pending' => __('%i% pending'), // must look like: "# blah blah"
'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),