Code to Disable Theme and Plugin File Editing in WordPress

/* Disable Theme File Editing in WordPress */
define('DISALLOW_FILE_EDIT',true);

There are cases where we don’t update some of our WordPress sites regularly. Some portfolio sites, company websites, landing pages etc. are generally untouched for years.

As a security measure, we should disable theme and plugin file editing on those sites. To do so, add the above code to your wp-config.php file in the public_html folder.

Once you add this code, the ‘Theme File Editor‘ and ‘Plugin File Editor‘ will be vanished from the dashboard. If you are using any code snippets, if already added, they stay active. If you want to add new code snippets, you have to manually add from the Hosting Control Panel or FTP.

If you have clients who have access to those websites, you shouldn’t allow them to install new plugins and themes which can break the site.