11 Feb

CSS files do not show up in WordPress theme editor

One day I was creating a simple site. I’ve found a great theme, selected the appropriate theme and began to edit it.

WordPress has a built-in editor for that. You can reach it through the menu “Appearance” -> “Editor”. The editor looks like a large text field in the middle and some files of selected theme, that placed on the right side.

I’ve edited all necessary php-files. Next I would like to correct a page style. The editor though shows me only one empty style.css, though I could observe a lot of css-files in my browser. That puzzled me. I couldn’t edit the page style, but I saw that the file “theme-editor.php” was in charge of editing of files.
I investigated this file and discovered the function “get_files()” was responsible for listing the files which can be seen on the right side in the editor.

For php-files the line was:

but for css-files the line was:

This function takes two parameter. The first parameter accepts an extension to filter files and the second is the depth of the search.

The required css-files were not in the root folder of the theme but they were located in a subfolder, just like the php-files. I’ve changed the function call to:

and got all necessary css-files in WordPress Editor.

Share this

Leave a reply