phpwordpresswp-editor

How to make the wordpress editor readonly?


How to make the wordpress editor readonly like readonly inputs. i am using following code for to display the editor in the page

<?php
$args= array( 
'quicktags' => false,
'media_buttons' => false
);
wp_editor( wpautop(stripslashes($my_text)), "my_text", $args);
?>

any option available in its settings or any other method?


Solution

  • You can use tiny_mce_before_init to modify the tiny mce arguments to set it as readonly

    add_filter( 'tiny_mce_before_init', function( $args ) {
    
        if ( 1 == 1 )
             $args['readonly'] = 1;
    
        return $args;
    } );