The Problem

I first noticed this with the plugin Quick-Cache, which activates without problem, but doesn't shows up anywhere. Its menu it's simply not there. Found why, and became aware of the conflict, in the forums.

Problem is that the plugin does all the capability checking using edit_plugins, removed by the constant...

Now I found that the plugin Search and Replace also bugs with the constant.
enter image description here

The solution

I just added this information to the Codex.

And would like to search for alternatives to enabling DISALLOW_FILE_EDIT.

Filtering the map_meta_cap, obviously, doesn't works.
What I can think of is removing the submenu item, the action link and, case someone lands in /plugin-editor.php by a direct URL, make the editor window read-only.

I already assembled this code and will post as an answer, but would be glad to know this community opinion and other possible approaches.


I guess this would be of better use as a mu-plugin.

EDIT: Now available as drop & play MU-Plugin. Also disables the »Theme« editor.

! defined( 'ABSPATH' ) AND exit;
/** Plugin Name: Disable »Theme/Plugin Editor« */

if ( ! class_exists( 'disable_admin_editor' ) )
    add_action( 'plugins_loaded', array( 'disable_admin_editor', 'init' ) );

class disable_admin_editor
    public static $instance;

    public static function init()
        null === self :: $instance AND self :: $instance = new self;
        return self :: $instance;

    public function __construct()
        ! defined( 'DISALLOW_FILE_EDIT' ) AND define( 'DISALLOW_FILE_EDIT', true );

        add_action( 'admin_init', array( $this, 'remove_edit_submenu' ) );
        add_filter( 'plugin_action_links', array( $this, 'remove_edit_action' ), 10, 2 );
        add_action( 'admin_footer-plugin-editor.php', array( $this, 'readonly_textarea' ) );

     * Remove Edit submenu
    public function remove_edit_submenu()
        remove_submenu_page( 'plugins.php', 'plugin-editor.php' );
        remove_submenu_page( 'themes.php', 'theme-editor.php' );

     * Remove the »Edit« link from all plugins
     * @param  array  $links
     * @param  string $file
     * @return array  $links
    public function remove_edit_action( $links, $file ) 
        unset( $links['edit'] );
        return $links;

     * Makes the editor read-only and removes the Update button
    public function readonly_textarea()
        echo '<script type="text/javascript">
        jQuery(document).ready( function($) {
            $( "#newcontent" ).attr( "readonly", true );
            $( "input#submit" ).remove();
        } );     
} // END Class 

} // endif;
  • The update I made has three(!!) ways to handle it. It's much too much, but better be on the safe side. – kaiser Sep 15 '12 at 20:00
  • 1
    Hey, this is Adding Class to a rough idea in many many senses. (bow) bloody cool, thx – brasofilo Sep 16 '12 at 11:00

It is not possible to change this check via hook; but i will change this in a newxt version; I have see this problem for long time ago, but not enough time for an update. Yes, it is possible via constant, that you remove this right-capability and then it is not possible to use this plugin. I will ask for manage_options, but is not the best for this plugin, change hard on the tables and i think it is liek to an update capabilities; ther is also change it.

  • Yep, I see the point of hard changes in the database posed by Search-and-Replace... Maybe a good option would be checking for the capability and then checking if the constant is set, so we can filter the error message... – brasofilo Jun 5 '12 at 11:30
  • yes, its possible to check for the constant, if is true, then use an other capability. – bueltge Jun 6 '12 at 8:14

Likewise you can remove the other submenu via admin_init

remove_submenu_page( 'themes.php', 'theme-editor.php' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.