New 24/7 monitoring and daily cloud backups now included in every Shield Pro plan.

Security

Learn how to disable WordPress file editing.

The built-in theme and plugin editors let Administrators change PHP from the browser. One mistake whitescreens the site. Disabling file editing forces changes through version control or SFTP.

Time: 10-15 minutes Level: Beginner
Neil McNaught, founder of BugShield and WordPress author
Written by
Written by
Updated
Updated

What this problem looks like

DISALLOW_FILE_EDIT removes the Theme Editor and Plugin Editor submenus. It does not stop uploads or plugin installs by itself.

Compromised admin accounts cannot use the dashboard to drop PHP backdoors into theme files when editing is disabled, though they may still upload malicious plugins without broader hardening.

Step 1: Disable file editing constant

Open wp-config.php in your site root, next to wp-admin and wp-content. Search for DISALLOW_FILE_EDIT first. If the line already exists, set it to true instead of adding a duplicate. If it does not exist, paste the constant above the line that says stop editing:

php
define( 'DISALLOW_FILE_EDIT', true );

Step 2: What this does and does not block

  • Removes Appearance → Theme File Editor.
  • Removes Plugin → Plugin File Editor.
  • Does not block plugin installation or updates.
  • Does not replace SFTP access for attackers with stolen credentials.

Step 3: Safer ways to edit code

Use a child theme and deploy changes via File Manager, SFTP, Git, or CI. Test on staging before production.

Step 4: Optional DISALLOW_FILE_MODS

Search for DISALLOW_FILE_MODS in wp-config.php first. If the line already exists, update it instead of adding a duplicate. If it does not exist, add this stronger constant above the stop editing line:

php
define( 'DISALLOW_FILE_MODS', true );

Step 5: Verify after security plugins

Some security plugins re-enable editors or duplicate the setting. Check effective constants with wp config get DISALLOW_FILE_EDIT over SSH.

When to stop DIY and hire help

Hardening production without breaking agency workflows needs staging exceptions and role planning. BugShield secures WordPress sites at a confirmed fixed price with monitored updates.

Questions answered

Disabling WordPress file editing FAQs

Answers about DISALLOW_FILE_EDIT, plugin and theme updates, deployment workflows, permissions, and reducing damage from a compromised account.

Will this break the Customizer?

No. Customizer and Site Editor still work. Only direct PHP file editors in admin are removed.

Can I disable editing on multisite only?

Network admins can define constants in wp-config.php for the entire network. Per-site overrides are uncommon.

How do I re-enable editors temporarily?

Remove or set DISALLOW_FILE_EDIT to false in wp-config.php and reload admin.

Is DISALLOW_FILE_EDIT enough for security?

No. Pair it with strong passwords, 2FA, least-privilege roles, and updated plugins.

What does disabling WordPress file editing do?

It removes the built-in theme and plugin code editors from wp-admin, reducing the chance of accidental edits or code injection through a stolen administrator session.

Where do I add DISALLOW_FILE_EDIT in WordPress?

Add define( 'DISALLOW_FILE_EDIT', true ); to wp-config.php above the stop-editing line, then confirm the code editors no longer appear.

Can WordPress still update plugins after file editing is disabled?

Yes. DISALLOW_FILE_EDIT removes the editors but normally leaves installation and updates available. DISALLOW_FILE_MODS is the stricter setting.

How should I edit WordPress theme files after disabling the editor?

Use version-controlled local development and a tested deployment process, or edit through secure hosting access with a backup and rollback path.

Do file permissions still matter when the WordPress editor is disabled?

Yes. The web server and compromised plugins may still modify writable files. Use appropriate ownership and permissions alongside the dashboard restriction.

Will disabling WordPress file editing stop malware?

No. It removes one convenient route, but vulnerable plugins, stolen hosting access, and writable files can still be abused. Use layered security and monitoring.

Would you rather a developer fixed it?

Request a fix at a confirmed price and speak directly with the BugShield developer working on your site.

Request a Fix