WordPress.org

Make WordPress Core

Ticket #7643: hotkeys-opt-in.diff

File hotkeys-opt-in.diff, 4.7 KB (added by nbachiyski, 7 years ago)

Disable shortcuts by default, add a personal option for turning them on

  • wp-includes/registration.php

     
    154154        if ( empty($rich_editing) ) 
    155155                $rich_editing = 'true'; 
    156156 
     157        if ( empty($comment_shortcuts) ) 
     158                $comment_shortcuts = 'false'; 
     159 
    157160        if ( empty($admin_color) ) 
    158161                $admin_color = 'fresh'; 
    159162        $admin_color = preg_replace('|[^a-z0-9 _.\-@]|i', '', $admin_color); 
     
    183186        update_usermeta( $user_id, 'aim', $aim ); 
    184187        update_usermeta( $user_id, 'yim', $yim ); 
    185188        update_usermeta( $user_id, 'rich_editing', $rich_editing); 
     189        update_usermeta( $user_id, 'comment_shortcuts', $comment_shortcuts); 
    186190        update_usermeta( $user_id, 'admin_color', $admin_color); 
    187191        update_usermeta( $user_id, 'use_ssl', $use_ssl); 
    188192 
  • wp-admin/edit-comments.php

     
    1212$title = __('Edit Comments'); 
    1313wp_enqueue_script( 'admin-comments' ); 
    1414wp_enqueue_script( 'admin-forms' ); 
    15 wp_enqueue_script( 'jquery-table-hotkeys' ); 
     15enqueue_comment_hotkeys_js(); 
    1616 
    1717if ( ( isset( $_POST['delete_all_spam'] ) || isset( $_POST['delete_all_spam2'] ) ) && !empty( $_POST['pagegen_timestamp'] ) ) { 
    1818        check_admin_referer('bulk-spam-delete'); 
  • wp-admin/includes/comment.php

     
    151151        return "$avatar $name"; 
    152152} 
    153153 
     154function enqueue_comment_hotkeys_js() { 
     155        if ( 'true' == get_user_option( 'comment_shortcuts' ) ) 
     156                wp_enqueue_script( 'jquery-table-hotkeys' ); 
     157} 
     158 
    154159if ( is_admin() && ('edit-comments.php' == $pagenow || 'edit.php' == $pagenow) ) { 
    155160        if ( get_option('show_avatars') ) 
    156161                add_filter( 'comment_author', 'floated_admin_avatar' ); 
  • wp-admin/includes/user.php

     
    9898        else 
    9999                $user->rich_editing = 'true'; 
    100100 
     101        $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] )? $_POST['comment_shortcuts'] : '';  
     102         
    101103        $user->use_ssl = 0; 
    102104        if ( !empty($_POST['use_ssl']) ) 
    103105                $user->use_ssl = 1; 
  • wp-admin/post.php

     
    140140        wp_enqueue_script('media-upload'); 
    141141        wp_enqueue_script('word-count'); 
    142142        wp_enqueue_script( 'admin-comments' ); 
    143         wp_enqueue_script( 'jquery-table-hotkeys' ); 
     143        enqueue_comment_hotkeys_js(); 
    144144 
    145145        if ( current_user_can('edit_post', $post_ID) ) { 
    146146                if ( $last = wp_check_post_lock( $post->ID ) ) { 
  • wp-admin/upload.php

     
    140140 
    141141if ( is_singular() ) { 
    142142        wp_enqueue_script( 'admin-comments' ); 
    143         wp_enqueue_script( 'jquery-table-hotkeys' ); 
     143        enqueue_comment_hotkeys_js(); 
    144144} 
    145145 
    146146require_once('admin-header.php'); ?> 
  • wp-admin/edit.php

     
    7777 
    7878if ( 1 == count($posts) && is_singular() ) { 
    7979        wp_enqueue_script( 'admin-comments' ); 
    80         wp_enqueue_script( 'jquery-table-hotkeys' ); 
     80        enqueue_comment_hotkeys_js(); 
    8181} 
    8282 
    8383require_once('admin-header.php'); 
  • wp-admin/user-edit.php

     
    220220        <?php endforeach; ?> 
    221221</fieldset></td> 
    222222</tr> 
     223<tr> 
     224<th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th> 
     225<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> 
     226</tr> 
    223227<?php 
    224228endif; 
    225229do_action('personal_options', $profileuser); 
  • wp-admin/edit-pages.php

     
    9595 
    9696if ( is_singular() ) { 
    9797        wp_enqueue_script( 'admin-comments' ); 
    98         wp_enqueue_script( 'jquery-table-hotkeys' ); 
     98        enqueue_comment_hotkeys_js(); 
    9999} 
    100100 
    101101require_once('admin-header.php'); ?>