mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://developer.wordpress.org/news/2024/07/04/15-ways-to-curate-the-wordpress-editing-experience/#disable-the-code-editor
11 lines
426 B
Text
11 lines
426 B
Text
function example_restrict_block_locking_and_code_editor_to_administrators( $settings, $context ) {
|
|
$is_administrator = current_user_can( 'edit_theme_options' );
|
|
|
|
if ( ! $is_administrator ) {
|
|
$settings[ 'canLockBlocks' ] = false;
|
|
$settings[ 'codeEditingEnabled' ] = false;
|
|
}
|
|
|
|
return $settings;
|
|
}
|
|
add_filter( 'block_editor_settings_all', 'example_restrict_block_locking_and_code_editor_to_administrators', 10, 2 );
|