Is it safe to use the file editor to make customizations?

I’m constantly reading stuff on the wordpress forum where people are making all mannar of customizations by modifying php or css files using the file editor. But aren’t all those files generated? Don’t these files get reverted when a change is made to the website through the wp-admin console or when wordpress updates?

Related posts

Leave a Reply

2 comments

  1. Updates run for themes and plugins only if there is a registered update server. If you have a custom (child) theme, or a plugin not hosted on wordpress.org and without a custom update mechanism there will be no updates.

    In all other cases: Yes, you are right, the changes could be overwritten.

    But this is not the only problem. Editing files per back-end may have side effects:

    • If you have an error in the edited code the whole back-end might become inaccessible, so you couldn’t even fix that error.
    • There is no version control, changes are not reversible, and if other people aren’t aware of those changes they might overwrite what you have done with their updates per FTP or SSH.

    I recommend a simple mu-plugin with just one line of code:

    ! defined( 'DISALLOW_FILE_EDIT' ) and define( 'DISALLOW_FILE_EDIT', TRUE );
    

    This will disable the file editor.

    @BarryCarlyon recommends the wp-config.php for this. That’s a valid point; I prefer a mu-plugin because it easier to see in back-end why something doesn’t work when there is a dedicated plugin.

  2. Files don’t generally get reverted back when a change is done in the wp-admin console. But, yes, files with your modifications will generally be overwritten if the theme is updated.

    So, you should first determine if the theme you are working on will get updated via the WordPress update system. If not – which usually applies to custom made themes – then you can do your customizations without fear of your changes being overwritten.

    If the theme you are using could be updated however – like themes downloaded from WordPress.org – then it would be best to first create a child theme off of it and do your changes to the child theme instead.