Last active
September 4, 2015 15:48
-
-
Save karpstrucking/83f217e9a4c7e5100695 to your computer and use it in GitHub Desktop.
Force disabling of the expanded editor option in WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'init', 'gowp_disable_editor_expand_setting' ); | |
function gowp_disable_editor_expand_setting() { | |
global $_updated_user_settings; | |
$_updated_user_settings['editor_expand'] = 'off'; | |
} | |
add_action( 'admin_footer', 'gowp_disable_editor_expand_field' ); | |
function gowp_disable_editor_expand_field() { | |
$screen = get_current_screen(); | |
if ( 'post' == $screen->base ) : ?> | |
<script type="text/javascript"> | |
jQuery( document ).ready( function() { | |
jQuery( '#editor-expand-toggle' ).prop( 'disabled', true ); | |
} ); | |
</script> | |
<?php endif; | |
} |
This is great. Thanks!
@shackep After a little testing I found that most of the original code is unnecessary, so I've reduced it to a few lines and added a footer action to disable the input as well.
@shackep also, just found this in core trac, which is cleaner.
add_action( 'admin_init', 'my_deregister_editor_expand' );
function my_deregister_editor_expand() {
wp_deregister_script('editor-expand');
}
add_filter( 'tiny_mce_before_init', 'my_unset_autoresize_on' );
function my_unset_autoresize_on( $init ) {
unset( $init['wp_autoresize_on'] );
return $init;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could also add an action to disable the
#editor-expand-toggle
checkbox in Screen Options since this code will render it useless.