Skip to content

Disabling theme and plugin editing inside WordPress admin

Why DISALLOW_FILE_EDIT and DISALLOW_FILE_MODS are the easiest WordPress hardening wins on cPanel, what each one blocks, and how to choose between them.

The Theme Editor and Plugin Editor inside WordPress admin are convenient. They are also, for an attacker who has acquired any administrator credential, a one-click path to executing arbitrary PHP on your server. Two constants in wp-config.php close both surfaces.

What’s happening

By default, any user with the edit_themes or edit_plugins capability can open the editor under Appearance > Theme File Editor or Plugins > Plugin File Editor and write PHP that runs on the next request. That’s the intended product behavior — and it’s why most compromised WordPress sites that go through admin show file modifications timestamped to the minute of the breach. DISALLOW_FILE_EDIT removes the editor UI. DISALLOW_FILE_MODS goes further: it disables the editor, plugin installation, plugin updates, theme installation, theme updates, and core updates from the dashboard.

How to verify

Check the current state of both constants:

wp config get DISALLOW_FILE_EDIT 2>/dev/null
wp config get DISALLOW_FILE_MODS 2>/dev/null

If both are empty, you have neither protection. Also browse to /wp-admin/theme-editor.php — if you see code, the editor is live.

The fix

  1. Decide which level you need. Most production sites want DISALLOW_FILE_EDIT (kills editor UI) while still allowing dashboard updates. Sites where you deploy via Git or WP-CLI and never want the dashboard to write to disk want DISALLOW_FILE_MODS (kills updates too).

  2. Add the appropriate constant to wp-config.php above the That's all, stop editing! line:

    // Editor only:
    define( 'DISALLOW_FILE_EDIT', true );
    
    // Editor + all dashboard-driven file changes:
    define( 'DISALLOW_FILE_MODS', true );
  3. Test. Log in as administrator and confirm Appearance > Theme File Editor and Plugins > Plugin File Editor are gone. If you went with DISALLOW_FILE_MODS, also confirm Plugins > Add New and Appearance > Themes > Add New are gone.

  4. If DISALLOW_FILE_MODS is set, build the parallel deploy path. The dashboard can no longer update plugins — your CI, WP-CLI, or operator process has to. The pattern:

    wp plugin update --all --dry-run
    wp plugin update --all
  5. Communicate the change to anyone with admin access. The most common helpdesk ticket after this change is “I can’t update X plugin from the admin” — answer is “correct, it’s by design, here’s how the new path works.”

  6. Where multiple WordPress sites on the same cPanel server need the same posture, enforce it via a deployment template rather than per-site edits. For managed fleets, Stack Harbor handles this as part of WHM server management.

Stack Harbor operates production WordPress at scale — see enterprise WordPress hosting for the managed model, or book a WordPress consult for a written read of your current shape.