How to Disable Theme and Plugin Editors in WordPress

Posted by Lasantha Bandara File Under : security, wordpress

How to Disable Theme and Plugin Editors in WordPress

By default, WordPress allows administrators to directly edit theme and plugin files through the dashboard. Although this feature is helpful, it can be a security risk if someone who shouldn't have access gets into the admin area.

You can disable the built-in Theme Editor and Plugin Editor by adding the following line to your wp-config.php file:

// Disable the themes and plugins editor in WordPress Admin
define('DISALLOW_FILE_EDIT', true);

Add this line just above the following line in your wp-config.php file:

/* That's all, stop editing! Happy publishing. */

Once added, the following editor URLs will be inaccessible and will show a permissions error message:

  • Theme Editor: http://example.com/wp-admin/theme-editor.php
  • Plugin Editor: http://example.com/wp-admin/plugin-editor.php

Here is an example of how the code should appear in your file:

Disable the themes / plugins editor in WP Admin

After applying this setting, attempting to access the editor pages will result in an error message like this:

Themes Editor Access Block Message

How to Disable All File Modifications?

If you also want to block all types of file modifications, such as installing or updating plugins and themes, you can use the following code instead of the one above:

define('DISALLOW_FILE_MODS', true);

This code disables all file modifications through the WordPress admin panel, including the Theme and Plugin Editors, plugin and theme installation, updates, and core updates.

Note: This method is fully compatible with all recent WordPress versions.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.