"Larger Text in the Editor" Profile Option
Adds a checkbox to each user's profile that makes the text in the block editor larger and more spaced out, for authors who find the default editor text hard to read.
Opens WPIDE on
Code
add_action( 'personal_options', function ( $user ) {
printf(
'<tr><th scope="row">Editor text</th><td><label><input type="checkbox" name="wpide_editor_large" value="1" %s> Show larger text in the block editor</label></td></tr>',
checked( get_user_meta( $user->ID, 'wpide_editor_large', true ), '1', false )
);
} );
$wpide_save_editor_pref = function ( $user_id ) {
if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_POST['_wpnonce'] ), 'update-user_' . $user_id ) ) {
update_user_meta( $user_id, 'wpide_editor_large', empty( $_POST['wpide_editor_large'] ) ? '0' : '1' );
}
};
add_action( 'personal_options_update', $wpide_save_editor_pref );
add_action( 'edit_user_profile_update', $wpide_save_editor_pref );
add_filter( 'block_editor_settings_all', function ( $settings ) {
if ( '1' === get_user_meta( get_current_user_id(), 'wpide_editor_large', true ) ) {
$settings['styles'][] = array( 'css' => 'body{font-size:22px!important;line-height:1.7!important;}p,li{letter-spacing:.01em;}' );
}
return $settings;
}, 20 );
Notes
Only changes how content looks while editing; the published page is not affected.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.