Ever have a client that can’t give you FTP access? Usually not a big deal if you’re using WP, because you can use the Theme Editor to edit your files. But then, surely you’ve noticed, the WP Theme Editor doesn’t allow you to edit JS files… (Though, really annoyingly, you can edit JS files via the Plugin Editor… whaaaat theeee…??)
I finally got sick of this and decided to figure out how to fix this issue. I mean, it might even be as simple as some
regex somewhere that was blocking anything with
Well, actually, yes, that’s almost exactly what it is. But unfortunately all the restriction takes place inside WP Core files, which I would really rather not edit, for obvious reasons, and I cannot find any hooks that will do the job…
I’ve found three solutions that do not satisfy me:
get_themes()on line 352, edit
if ( preg_match('|\.css$|', $file) )so it also allows
wp-admin/theme-editor.php, on line 58, just before
$allowed_filesis defined, add
$themes[$theme]['Stylesheet Files'] = TEMPLATEPATH.'/scripts.js';.
- Put my
scripts.jsfile into a folder inside
wp-content/pluginsso WP will think it’s a plug-in, allowing me to jump over the Plug-in Editor to edit it.
Any better ideas out there? Would love to hear them…