Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Security · Guide

How to Disable the Theme and Plugin File Editor

How to Disable the Theme and Plugin File Editor

Short answer

To disable the WordPress file editor, add define( 'DISALLOW_FILE_EDIT', true ); to wp-config.php above the 'That's all, stop editing!' line. Both editor menus vanish from the dashboard at once, and files can still be edited over SFTP.

Key takeaways

  • The dashboard file editor is often the first tool an attacker uses after logging in, since it allows code to run.
  • One line in wp-config.php removes the theme and plugin editors for every admin at once.
  • DISALLOW_FILE_MODS also blocks installs and updates, so use it only when updates happen another way.
  • Files can still be edited over SFTP or in the host file manager after the editor is off.
  • Some plugins check for the edit_plugins capability and may break when the editor is disabled.

What is the WordPress file editor?

The file editor is a built-in dashboard tool that lets admins edit theme and plugin PHP files from the browser.

You will find it under Appearance, then Theme File Editor, and under Plugins, then Plugin File Editor. It opens the code of the active theme or any installed plugin in a text box, with a save button below.

The editor exists so small fixes can be made without FTP or a file manager. It works on any admin account, with no extra check beyond the login itself.

That ease is also the risk. Anyone who reaches an admin account reaches the editor, and the editor can run code on the server. This guide shows how to switch it off and how to edit files safely instead.

Why should you disable the file editor?

Disable it because a stolen admin login turns into code running on your server the moment the editor is used.

The hardening guide is blunt about this: the dashboard allows admins to edit PHP files, and this is often the first tool an attacker will use if able to log in, since it allows code execution.

An attacker who pastes a small script into a theme file gains the same control as the web server itself.

Disabling the editor does not fix a weak password or a hacked account. It limits what the account can do next, which is the containment idea the hardening guide is built on: keep the damage small if someone gets in.

The change is quick, free, and easy to undo. There is no good reason to leave the editor on for day-to-day work, since theme and plugin files change rarely once a site is live.

How do you disable the file editor with wp-config.php?

Add define( 'DISALLOW_FILE_EDIT', true ); to wp-config.php, above the line that reads “That's all, stop editing!”.

The wp-config.php handbook documents this constant. It says disabling the editor adds a layer of safety if an attacker gains access to a well-privileged user account, and it guards against overzealous users editing sensitive files and crashing the site.

Follow these steps:

  1. Back up wp-config.php and download a copy to your computer.
  2. Open wp-config.php in a plain text editor, through SFTP or your host file manager.
  3. Paste the line above the “That's all, stop editing!” comment.
  4. Save the file and upload it if you edited it locally.
  5. Open the dashboard and confirm both editor menus are gone.

The change takes effect at once, with no restart and no plugin to install. Every admin account loses the editor at the same time, since the constant applies to the whole site.

If the menus are still there after saving, check that you edited the right file. Some hosts keep a second wp-config.php in a staging folder, and edits there change nothing on the live site.

How do you disable the file editor without editing files by hand?

Use your host file manager to edit wp-config.php in the browser, which needs no FTP client and no code editor on your computer.

Not every site owner uses SFTP. Most hosting panels include a file manager that can open and save wp-config.php, and the same line goes in the same place.

Follow these steps in a typical panel:

  1. Open the file manager and go to the folder where WordPress is installed.
  2. Right-click wp-config.php and choose Edit, then confirm the warning if one appears.
  3. Find the “That's all, stop editing!” comment near the bottom of the file.
  4. Paste define( 'DISALLOW_FILE_EDIT', true ); on the line above it.
  5. Save, then open the dashboard to confirm the editors are gone.

Some panels ask you to confirm the character set before editing. Accept the default and continue, and use a plain text editor on your computer if the panel editor adds odd characters.

This method changes the same constant as the SFTP method, so the result is the same. Pick whichever route you can do with care, and back the file up first either way.

What is the difference between DISALLOW_FILE_EDIT and DISALLOW_FILE_MODS?

DISALLOW_FILE_EDIT removes only the file editor, while DISALLOW_FILE_MODS also blocks installing, updating, and deleting plugins and themes from the dashboard.

The handbook states that setting DISALLOW_FILE_MODS also disables the plugin and theme file editor, so you do not need both lines. The stronger constant covers everything the weaker one does, plus more.

ConstantFile editorInstall plugins and themesUpdate plugins and themes
DISALLOW_FILE_EDITOffStill worksStill works
DISALLOW_FILE_MODSOffBlockedBlocked

Use DISALLOW_FILE_EDIT on almost every site. It stops the dangerous part while leaving normal updates working from the dashboard.

Use DISALLOW_FILE_MODS only when updates happen another way, such as WP-CLI, a deployment tool, or a managed host that updates for you. The wp-config.php handbook warns that the constant blocks install and update screens, so a site with it set cannot be updated from the dashboard at all.

If you set DISALLOW_FILE_MODS by mistake, remove the line and the dashboard install and update screens come back. Nothing is deleted by the constant itself.

How do you edit theme and plugin files after disabling the editor?

Edit files over SFTP or in your host file manager, then test the change on a staging copy before touching the live site.

Disabling the editor does not block file edits. It only moves them out of the browser and into a tool that leaves a trace and asks for server access first.

Follow this routine for any code change:

  1. Download the file you plan to change, so you have a copy to restore.
  2. Edit it in a plain text or code editor on your computer.
  3. Upload it back over SFTP or through the file manager.
  4. Load the affected page and confirm it still works.
  5. Keep the original copy until the change has run for a day.

For larger changes, use a staging site instead of the live site. The guide to setting up a staging site for WordPress shows how to build one, and the guide to setting correct file permissions in WordPress explains who should be able to write to each folder.

A child theme is the right place for theme changes. Editing a parent theme directly means the next theme update wipes the change, editor or no editor.

How do you check that the editor is gone?

Open Appearance and Plugins in the dashboard: both file editor links should be missing, and the direct editor URLs should refuse access.

Run these three checks after adding the constant:

  1. Open Appearance and confirm Theme File Editor is gone from the menu.
  2. Open Plugins and confirm Plugin File Editor is gone from the menu.
  3. Try the direct URL wp-admin/theme-editor.php and confirm WordPress blocks it.

If either menu is still visible, the constant is not active. Common causes are editing the wrong wp-config.php, placing the line below the “That's all, stop editing!” comment, or a caching plugin serving an old dashboard page.

Clear the cache and log out and back in before you conclude the change failed. Dashboard menus are cached in some setups, and a fresh login rebuilds them.

What should you do if a plugin stops working?

Check whether the plugin checks for the edit_plugins capability, since the handbook notes that some plugins are affected by this constant.

The wp-config.php handbook warns that some plugins use current_user_can('edit_plugins') in their code, and those plugins may break when the editor is off. Plugin authors are told to check for the constant and show a proper error, but not all of them do.

If a plugin fails right after you set the constant, try these steps in order:

  1. Remove the constant for a short test and see if the plugin works again.
  2. If it does, read the plugin docs or support forum for a fix.
  3. Replace the plugin with one that works without the editor.
  4. Keep the constant on and accept the trade-off if the plugin is not essential.

Do not leave the editor on for one plugin. A single plugin is not worth an open code editor on every admin account, and a replacement usually exists.

What else should you lock down at the same time?

Set safe file permissions, move wp-config.php above the web root if your host allows it, and review who holds an admin account.

The editor is one door, not the only one. The hardening guide pairs it with file permissions: folders at 755, files at 644, and wp-config.php at 400 or 440. The guide to setting correct file permissions in WordPress gives the full scheme.

The same guide says wp-config.php can sit one folder above the WordPress install, outside the web root, where browsers cannot reach it at all. Some hosts do not allow this, so ask yours before moving the file.

Rotate the security keys at the same time. Fresh values come from the official secret-key generator, and changing them signs every user out at once, which is what you want after a suspected break-in.

The Kinsta guide to changing WordPress security keys shows the manual method and the plugin method side by side, so pick the one that fits how you manage the site.

Review the user list while you are there. The hardening guide also advises against guessable admin names such as admin, and suggests a different table prefix on new installs, since many published attacks assume the default wp_ prefix.

The guide to hardening WordPress on shared hosting covers the rest of this list for sites on shared plans, where neighbours on the same server add their own risks.

Frequently asked questions

Does disabling the file editor stop me editing theme files?

No. It only removes the editor from the dashboard. You can still edit theme and plugin files over SFTP or in your host file manager, which is the safer way to change code.

Should I use DISALLOW_FILE_EDIT or DISALLOW_FILE_MODS?

Use DISALLOW_FILE_EDIT on almost every site. Use DISALLOW_FILE_MODS only when updates happen through WP-CLI, a deployment tool, or a managed host, since it also blocks installing and updating from the dashboard.

The editor menus are still there. What went wrong?

Check that you edited the right wp-config.php and that the line sits above the 'That's all, stop editing!' comment. Then clear the cache and log out and back in, since dashboard menus can be cached.

Can I turn the file editor back on later?

Yes. Remove the line from wp-config.php and both editors come back at once. Nothing is deleted by the constant itself, so the change is easy to undo.

Does disabling the editor make my site fully safe?

No. It removes one path an attacker can use after logging in, but it does not stop file uploads or fix a weak password. Pair it with strong logins, safe file permissions, and current software.

Sources

  1. Hardening WordPress WordPress Developer Resources
  2. wp-config.php WordPress Developer Resources
  3. Version 7.1.4 WordPress.org
  4. Secret-Key Generator WordPress.org
  5. How To Change Your WordPress Security Keys Kinsta

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.