Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
    
It might be preferential to put those defines in wp-config.php instead. On a side note, if you can edit files with the file editor, so can a malicious plugin or a hacker, so having WordPress files and folders, editable by apache/WordPress is a bit of a bad thing really. Edit the file via (S)FTP is the preferred method. (As is uploading plugin updates) –  Barry Carlyon Jan 10 '13 at 13:06
    
Agree. Using the built in file editor is like working working on an airplane while it is flying. There are countless threads on the wordpress.org forums that are essentially "I was using the file editor and now my site is broken and I can't get in to fix it." –  s_ha_dum Jan 10 '13 at 14:33

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.