The plugin and theme editors are two default WordPress features that allow you to make changes to the theme or plugin files from the WordPress dashboard. This is a useful feature for making quick and simple changes to files such as adding/modifying CSS or adding a custom feature by using actions and filters.
However, this feature can break the site functionality when administrators edit the files directly without taking the necessary precautions. These precautions include deactivating the plugin as well as taking a file backup. Unless this feature is used frequently on your site, it's ideal to disable the feature to improve security.
In this recipe, we are going to completely disable theme and plugin file editing as well as conditionally disabling it for selected users using custom code.