Disable File Editing

WordPress includes built-in editors for themes and plugins — right in the admin dashboard. Convenient? Maybe. Dangerous? Definitely. If an attacker gains admin access, these editors let them inject malicious code directly into your site files. If an inexperienced user makes a typo, they can break the entire site. This module removes the editors entirely.

Use Cases

  • Prevent attackers from injecting malicious code through the dashboard
  • Stop accidental code breakage by inexperienced administrators
  • Enforce proper development workflows (edit locally, deploy properly)
  • Meet security compliance requirements that prohibit in-dashboard editing
  • Protect production sites from “quick fixes” that cause problems

How It Works

This is a toggle module — enable it and the file editors disappear. No configuration needed.

When enabled, the module defines the WordPress constant:

define('DISALLOW_FILE_EDIT', true);

This removes:

  • Appearance → Theme File Editor — Gone
  • Plugins → Plugin File Editor — Gone
  • Direct URL access to editor pages — Blocked

What Gets Removed

LocationStatus
Appearance → Theme File EditorMenu removed
Plugins → Plugin File EditorMenu removed
/wp-admin/theme-editor.phpAccess blocked
/wp-admin/plugin-editor.phpAccess blocked
Edit links on individual theme/plugin pagesRemoved

The Security Risk

The built-in editors are a favorite target for attackers because:

  1. No authentication beyond admin — If they’re in, they can edit
  2. Immediate effect — Changes are live instantly
  3. Persistent access — Injected code survives password changes
  4. Hard to detect — Malicious code hides in legitimate files
  5. Full server access — PHP code can do anything on your server

Common attack scenario:

  1. Attacker gets admin credentials (phishing, weak password, etc.)
  2. Logs into your WordPress admin
  3. Goes to Appearance → Theme File Editor
  4. Adds malicious code to functions.php
  5. Now they have a backdoor even after you change passwords

This module prevents step 3.

Verification

After enabling:

  1. Go to Appearance menu — “Theme File Editor” should be missing
  2. Go to Plugins menu — “Plugin File Editor” should be missing
  3. Try visiting yoursite.com/wp-admin/theme-editor.php directly
  4. Should see “Sorry, you are not allowed to edit themes for this site.”

Still Need to Edit Files?

If you need to edit theme or plugin files, use proper methods:

MethodDescription
FTP/SFTPConnect to your server and edit files directly
File ManagerUse your host’s control panel file manager
Local DevelopmentEdit locally, deploy via Git or upload
Code Snippets PluginFor small PHP additions without file editing
Child ThemeOverride theme files safely

These methods are:

  • More secure (not accessible from WordPress admin)
  • More traceable (FTP logs, Git history)
  • Less prone to mistakes (proper editors with syntax highlighting)

The wp-config.php Alternative

You can also disable file editing by adding this to wp-config.php:

define('DISALLOW_FILE_EDIT', true);

This module does the same thing but:

  • Can be toggled without editing wp-config.php
  • Is part of your centralized Switchboard configuration
  • Can be disabled if needed without server access

FAQ

Will this affect plugin/theme updates?No. Updates are separate from file editing. This only disables the manual code editors. Automatic and manual updates still work (unless you also use the “Disable All Updates” module).
Can I still install new plugins and themes?Yes. Installation is separate from editing. You can still install, activate, and delete plugins and themes normally.
What if I need to make a quick fix?Use FTP, your host’s file manager, or SSH. The “quick fix in the dashboard” workflow is exactly what this module prevents — it’s too risky for production sites.
Does this prevent all file changes?No. It only disables the WordPress admin editors. Code can still be changed via FTP, SSH, cPanel, or any server-level access. For full file integrity monitoring, you’d need a security plugin like Wordfence.
What about the Site Editor (Full Site Editing)?The Site Editor for block themes (Appearance → Editor) is different from the file editors. It edits templates stored in the database, not PHP files. This module doesn’t affect Full Site Editing.
I already have DISALLOW_FILE_EDIT in wp-config.php. Do I need this?No. If it’s already defined in wp-config.php, this module respects that setting. Having both doesn’t hurt, but it’s redundant.

Security Best Practices

Disabling file editing is just one part of WordPress security hardening:

PracticeWhy It Matters
Disable file editingPrevent code injection via admin
Use strong passwordsPrevent admin access in the first place
Enable 2FAExtra layer even if password is compromised
Regular backupsRecover if something does go wrong
Keep updatedFix security vulnerabilities

This is a “no-brainer” security setting. Almost no legitimate workflow requires editing code through the WordPress dashboard. Enable this module and forget about it.

This module defines DISALLOW_FILE_EDIT, not DISALLOW_FILE_MODS. File editing is disabled, but plugin/theme uploads and updates still work.

PRO

Get access to all 147 modules with a single license

Upgrade to Pro