on not leaving junk files in your theme directory

I’ve had a couple of ‘life lessons’ this week related to keeping my WordPress theme directory clean. I have not fully embraced Source Code management on all my projects and have gotten into the habit of copying files and directories before I edit them. This is cool since it means I can revert changes easily, however  leaving all sorts of stuff laying around is bad, tut tut.

This came back to bite me when I spent a very confused 30 minutes editing a javascript file to add a few lines of code.  I could see the file was being   used for a page in my theme so just needed to add in the snippet. My console.log’s were not appearing in code that I was sure ought to be running. I even commented out chunks of code and mysteriously things were still working. I ended up enqueing a new script ( the proper way to add scripts under WordPress) Then it hit me, I’d been editing a copy of the .js file I’d made in my theme root folder ( I have no idea when or why!) DOH that’ll explain it then.

The other very good reason for not leaving junk files ( I’m sure there are actually many good reasons) is that it screws up the built in editor in the admin panel. I was in a remote office today with only a web browser ( locked down chrome in-fact) to use.I discovered today that in the admin panel you can actually load any template file you like into its basic text editor, and keep on hacking ! Again it greatly helps if you have not got a huge amount of crud files in there, since they all show up. I actually fell for the same thing twice in one week!

facebooktwitterlinkedinrssfacebooktwitterlinkedinrss

Leave a Reply

Your email address will not be published. Required fields are marked *