Make WordPress Core

Ticket #21414: 21414.1.patch

File 21414.1.patch, 12.3 KB (added by azaozz, 9 years ago)
  • src/wp-admin/includes/user.php

     
    9797        }
    9898
    9999        $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' == $_POST['comment_shortcuts'] ? 'true' : '';
     100        $user->editor_shortcuts = isset( $_POST['editor_shortcuts'] ) && 'true' === $_POST['editor_shortcuts'] ? 'true' : 'false';
    100101
    101102        $user->use_ssl = 0;
    102103        if ( !empty($_POST['use_ssl']) )
  • src/wp-admin/js/editor-expand.js

     
    11051105                        } );
    11061106
    11071107                        editor.addCommand( 'wpToggleDFW', toggle );
    1108                         editor.addShortcut( 'access+w', '', 'wpToggleDFW' );
     1108
     1109                        if ( ! editor.settings.wp_disable_custom_shortcuts ) {
     1110                                editor.addShortcut( 'access+w', '', 'wpToggleDFW' );
     1111                        }
    11091112                } );
    11101113
    11111114                $document.on( 'tinymce-editor-init.focus', function( event, editor ) {
  • src/wp-admin/user-edit.php

     
    257257if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?>
    258258<tr class="user-comment-shortcuts-wrap">
    259259<th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
    260 <td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( ! empty( $profileuser->comment_shortcuts ) ) checked( 'true', $profileuser->comment_shortcuts ); ?> /> <?php _e('Enable keyboard shortcuts for comment moderation.'); ?></label> <?php _e('<a href="https://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td>
     260<td>
     261        <fieldset>
     262        <legend class="screen-reader-text"><span><?php _e( 'Keyboard Shortcuts' ); ?></span></legend>
     263        <label for="comment_shortcuts">
     264                <input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( ! empty( $profileuser->comment_shortcuts ) ) checked( 'true', $profileuser->comment_shortcuts ); ?> />
     265                <?php _e('Enable keyboard shortcuts for comment moderation.'); ?>
     266        </label><br />
     267        <label for="editor_shortcuts">
     268                <input type="checkbox" name="editor_shortcuts" id="editor_shortcuts" value="true" <?php checked( ( ! isset( $profileuser->editor_shortcuts ) || $profileuser->editor_shortcuts !== 'false' ) ); ?> />
     269                <?php _e('Enable custom keyboard shortcuts for the Visual editor.'); ?>
     270        </label><br />
     271        <?php _e('<a href="https://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?>
     272        </fieldset>
     273</td>
    261274</tr>
    262275<?php endif; ?>
    263276<tr class="show-admin-bar user-admin-bar-front-wrap">
  • src/wp-includes/class-wp-editor.php

     
    554554                                        'wp_lang_attr' => get_bloginfo( 'language' )
    555555                                );
    556556
     557                                if ( is_user_logged_in() && 'false' === get_user_option( 'editor_shortcuts' ) ) {
     558                                        self::$first_init['wp_disable_custom_shortcuts'] = true;
     559                                        self::$first_init['wp_profile_url'] = admin_url( 'profile.php' );
     560                                }
     561
    557562                                if ( ! empty( $mce_external_plugins ) ) {
    558563                                        self::$first_init['external_plugins'] = wp_json_encode( $mce_external_plugins );
    559564                                }
     
    10631068                        'Ctrl + letter:' => __( 'Ctrl + letter:' ),
    10641069                        'Letter' => __( 'Letter' ),
    10651070                        'Action' => __( 'Action' ),
     1071                        'Currently disabled. Can be enabled in your %1$sprofile settings%2$s.' => __( 'Currently disabled. Can be enabled in your %1$sprofile settings%2$s.' ),
     1072                        'Can be disabled in your %1$sprofile settings%2$s.' => __( 'Can be disabled in your %1$sprofile settings%2$s.' ),
    10661073                        'To move focus to other buttons use Tab or the arrow keys. To return focus to the editor press Escape or use one of the buttons.' =>
    10671074                                __( 'To move focus to other buttons use Tab or the arrow keys. To return focus to the editor press Escape or use one of the buttons.' ),
    10681075                        'When starting a new paragraph with one of these formatting shortcuts followed by a space, the formatting will be applied automatically. Press Backspace or Escape to undo.' =>
  • src/wp-includes/css/editor.css

     
    127127        box-sizing: border-box;
    128128}
    129129
     130.mce-window .mce-wp-help a {
     131        color: #0073aa;
     132        text-decoration: underline;
     133}
     134
     135.mce-window .mce-wp-help a:hover,
     136.mce-window .mce-wp-help a:active {
     137        color: #00a0d2;
     138}
     139
    130140.mce-window .mce-wp-help > .mce-container-body {
    131141        width: auto !important;
    132142}
  • src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

     
    212212                        meta = tinymce.Env.mac ? __( 'Cmd + letter:' ) : __( 'Ctrl + letter:' ),
    213213                        table1 = [],
    214214                        table2 = [],
     215                        disabledStr,
    215216                        header, html, dialog, $wrap;
    216217
    217218                each( [
     
    254255                        return out + '</tr>';
    255256                }
    256257
     258                if ( editor.settings.wp_disable_custom_shortcuts ) {
     259                        disabledStr = __( 'Currently disabled. Can be enabled in your %1$sprofile settings%2$s.' );
     260                } else {
     261                        disabledStr = __( 'Can be disabled in your %1$sprofile settings%2$s.' );
     262                }
     263
     264                disabledStr = disabledStr.replace( '%1$s', '<a href="' + editor.settings.wp_profile_url + '">' ).replace( '%2$s', '</a>' );
     265
    257266                header = [ __( 'Letter' ), __( 'Action' ), __( 'Letter' ), __( 'Action' ) ];
    258267                header = '<tr><th>' + header.join( '</th><th>' ) + '</th></tr>';
    259268
     
    267276                                table1.join('') +
    268277                        '</table>' +
    269278                        '<h2>' + __( 'Additional shortcuts,' ) + ' ' + access + '</h2>' +
     279                        '<p>' + disabledStr + '</p>' +
    270280                        '<table class="wp-help-th-center fixed">' +
    271281                                header +
    272282                                table2.join('') +
     
    421431        });
    422432
    423433        editor.on( 'init', function() {
    424                 var env = tinymce.Env,
     434                var key,
     435                        env = tinymce.Env,
    425436                        bodyClass = ['mceContentBody'], // back-compat for themes that use this in editor-style.css...
    426437                        doc = editor.getDoc(),
    427438                        dom = editor.dom;
     
    502513                                });
    503514                        });
    504515                }
     516
     517                if ( editor.settings.wp_disable_custom_shortcuts ) {
     518                        // Remove TinyMCE custom shortcuts, but leave the standard OS shortcuts
     519                        // like Cmd/Ctrl+Z, Cmd/Ctrl+C, Cmd/Ctrl+V, etc.
     520                        for( key = 1; key < 10; key++ ) {
     521                                editor.shortcuts.remove( 'access+' + key );
     522                        }
     523                        // Remove the shortcut for the fullscreen plugin.
     524                        editor.shortcuts.remove( 'ctrl+shift+f' );
     525                }
    505526        });
    506527
    507528        editor.on( 'SaveContent', function( event ) {
     
    532553                        editor.settings.height = 300;
    533554                }
    534555
    535                 each( {
    536                         c: 'JustifyCenter',
    537                         r: 'JustifyRight',
    538                         l: 'JustifyLeft',
    539                         j: 'JustifyFull',
    540                         q: 'mceBlockQuote',
    541                         u: 'InsertUnorderedList',
    542                         o: 'InsertOrderedList',
    543                         s: 'unlink',
    544                         m: 'WP_Medialib',
    545                         z: 'WP_Adv',
    546                         t: 'WP_More',
    547                         d: 'Strikethrough',
    548                         h: 'WP_Help',
    549                         p: 'WP_Page',
    550                         x: 'WP_Code'
    551                 }, function( command, key ) {
    552                         editor.shortcuts.add( 'access+' + key, '', command );
    553                 } );
     556                if ( ! editor.settings.wp_disable_custom_shortcuts ) {
     557                        each( {
     558                                c: 'JustifyCenter',
     559                                r: 'JustifyRight',
     560                                l: 'JustifyLeft',
     561                                j: 'JustifyFull',
     562                                q: 'mceBlockQuote',
     563                                u: 'InsertUnorderedList',
     564                                o: 'InsertOrderedList',
     565                                s: 'unlink',
     566                                m: 'WP_Medialib',
     567                                z: 'WP_Adv',
     568                                t: 'WP_More',
     569                                d: 'Strikethrough',
     570                                h: 'WP_Help',
     571                                p: 'WP_Page',
     572                                x: 'WP_Code'
     573                        }, function( command, key ) {
     574                                editor.shortcuts.add( 'access+' + key, '', command );
     575                        } );
    554576
    555                 editor.addShortcut( 'meta+s', '', function() {
    556                         if ( wp && wp.autosave ) {
    557                                 wp.autosave.server.triggerSave();
    558                         }
    559                 } );
     577                        editor.addShortcut( 'meta+s', '', function() {
     578                                if ( wp && wp.autosave ) {
     579                                        wp.autosave.server.triggerSave();
     580                                }
     581                        } );
     582                }
    560583
    561584                if ( window.getUserSetting( 'editor_plain_text_paste_warning' ) > 1 ) {
    562585                        editor.settings.paste_plaintext_inform = false;
  • src/wp-includes/js/tinymce/plugins/wplink/plugin.js

     
    251251                        }
    252252                } );
    253253
    254                 // WP default shortcut
    255                 editor.addShortcut( 'access+a', '', 'WP_Link' );
    256                 // The "de-facto standard" shortcut, see #27305
    257                 editor.addShortcut( 'meta+k', '', 'WP_Link' );
     254                if ( ! editor.settings.wp_disable_custom_shortcuts ) {
     255                        // WP default shortcut
     256                        editor.addShortcut( 'access+a', '', 'WP_Link' );
     257                        // The "de-facto standard" shortcut, see #27305
     258                        editor.addShortcut( 'meta+k', '', 'WP_Link' );
     259                }
    258260
    259261                editor.addButton( 'link', {
    260262                        icon: 'link',
  • src/wp-includes/user.php

     
    13361336 * Insert a user into the database.
    13371337 *
    13381338 * Most of the `$userdata` array fields have filters associated with the values. Exceptions are
    1339  * 'ID', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl',
     1339 * 'ID', 'rich_editing', 'comment_shortcuts', 'editor_shortcuts', 'admin_color', 'use_ssl',
    13401340 * 'user_registered', and 'role'. The filters have the prefix 'pre_user_' followed by the field
    13411341 * name. An example using 'description' would have the filter called, 'pre_user_description' that
    13421342 * can be hooked into.
     
    13711371 *                                             False if not empty.
    13721372 *     @type string|bool $comment_shortcuts    Whether to enable comment moderation keyboard
    13731373 *                                             shortcuts for the user. Default false.
     1374 *     @type string|bool $editor_shortcuts     Whether to enable keyboard shortcuts for the
     1375 *                                             Visual editor. Default true.
    13741376 *     @type string      $admin_color          Admin color scheme for the user. Default 'fresh'.
    13751377 *     @type bool        $use_ssl              Whether the user should always access the admin over
    13761378 *                                             https. Default false.
     
    15831585
    15841586        $meta['comment_shortcuts'] = empty( $userdata['comment_shortcuts'] ) || 'false' === $userdata['comment_shortcuts'] ? 'false' : 'true';
    15851587
     1588        $meta['editor_shortcuts'] = empty( $userdata['editor_shortcuts'] ) || 'false' !== $userdata['editor_shortcuts'] ? 'true' : 'false';
     1589
    15861590        $admin_color = empty( $userdata['admin_color'] ) ? 'fresh' : $userdata['admin_color'];
    15871591        $meta['admin_color'] = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $admin_color );
    15881592
     
    16371641         *     @type string   $last_name            The user's last name.
    16381642         *     @type string   $description          The user's description.
    16391643         *     @type bool     $rich_editing         Whether to enable the rich-editor for the user. False if not empty.
    1640          *     @type bool     $comment_shortcuts    Whether to enable keyboard shortcuts for the user. Default false.
     1644         *     @type bool     $comment_shortcuts    Whether to enable keyboard shortcuts for comment moderation. Default false.
     1645         *     @type bool     $editor_shortcuts     Whether to enable keyboard shortcuts for the Visual editor. Default true.
    16411646         *     @type string   $admin_color          The color scheme for a user's admin screen. Default 'fresh'.
    16421647         *     @type int|bool $use_ssl              Whether to force SSL on the user's admin area. 0|false if SSL is
    16431648         *                                          not forced.
     
    19511956 * @return array List of user keys to be populated in wp_update_user().
    19521957 */
    19531958function _get_additional_user_keys( $user ) {
    1954         $keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front' );
     1959        $keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'editor_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front' );
    19551960        return array_merge( $keys, array_keys( wp_get_user_contact_methods( $user ) ) );
    19561961}
    19571962