Plugin Directory

Changeset 3122238 for classic-editor


Ignore:
Timestamp:
07/19/2024 06:01:58 PM (21 months ago)
Author:
ironprogrammer
Message:

classic-editor allow admins to set default editor for other users and bump tested-up-to

Location:
classic-editor/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • classic-editor/trunk/classic-editor.php

    r2889522 r3122238  
    5858                // User settings.
    5959                add_action( 'personal_options_update', array( __CLASS__, 'save_user_settings' ) );
     60                add_action( 'edit_user_profile_update', array( __CLASS__, 'save_user_settings' ) );
    6061                add_action( 'profile_personal_options', array( __CLASS__, 'user_settings' ) );
     62                add_action( 'edit_user_profile', array( __CLASS__, 'user_settings') );
    6163            }
    6264        }
     
    199201    }
    200202
    201     private static function get_settings( $refresh = 'no' ) {
     203    private static function get_settings( $refresh = 'no', $user_id = 0 ) {
    202204        /**
    203205         * Can be used to override the plugin's settings. Always hides the settings UI when used (as users cannot change the settings).
     
    208210         *   'allow-users' => false,
    209211         *
    210          * @param boolean To override the settings return an array with the above keys.
     212         * @param boolean To override the settings return an array with the above keys. Default false.
    211213         */
    212214        $settings = apply_filters( 'classic_editor_plugin_settings', false );
     
    271273        // Override the defaults with the user options.
    272274        if ( ( ! isset( $GLOBALS['pagenow'] ) || $GLOBALS['pagenow'] !== 'options-writing.php' ) && $allow_users ) {
    273             $user_options = get_user_option( 'classic-editor-settings' );
     275
     276            $user_options = get_user_option( 'classic-editor-settings', $user_id );
    274277
    275278            if ( $user_options === 'block' || $user_options === 'classic' ) {
     
    403406    }
    404407
    405     public static function settings_1() {
    406         $settings = self::get_settings( 'refresh' );
     408    public static function settings_1( $user_id = 0 ) {
     409        $settings = self::get_settings( 'refresh', $user_id );
    407410
    408411        ?>
     
    447450     * Shown on the Profile page when allowed by admin.
    448451     */
    449     public static function user_settings() {
     452    public static function user_settings( $user = null ) {
    450453        global $user_can_edit;
    451454        $settings = self::get_settings( 'update' );
    452455
    453         if (
    454             ! defined( 'IS_PROFILE_PAGE' ) ||
    455             ! IS_PROFILE_PAGE ||
    456             ! $user_can_edit ||
    457             ! $settings['allow-users']
    458         ) {
     456        if ( ! $user_can_edit || ! $settings['allow-users'] ) {
    459457            return;
     458        }
     459       
     460        if ( $user instanceof WP_User ) {
     461            $user_id = (int) $user->ID;
     462        } else {
     463            $user_id = 0;
    460464        }
    461465
     
    466470                <td>
    467471                <?php wp_nonce_field( 'allow-user-settings', 'classic-editor-user-settings' ); ?>
    468                 <?php self::settings_1(); ?>
     472                <?php self::settings_1( $user_id ); ?>
    469473                </td>
    470474            </tr>
  • classic-editor/trunk/readme.txt

    r3119645 r3122238  
    44Requires at least: 4.9
    55Tested up to: 6.6
    6 Stable tag: 1.6.3
     6Stable tag: 1.6.4
    77Requires PHP: 5.2.4
    88License: GPLv2 or later
     
    2929
    3030== Changelog ==
     31
     32= 1.6.4 =
     33* Added support for administrators to choose the default editor for other users.
    3134
    3235= 1.6.3 =
Note: See TracChangeset for help on using the changeset viewer.