Grepping my WordPress database
I created WordPress::Grep (or in GitHub) as a way to do power searches through my WordPress databases. I've often wanted a tool that could search with Perl patterns or arbitrary code to find odd CSS uses, check links, and all sorts of other things. I didn't see an easy way to do the things I wanted with WordPress::API, which seems more of an authoring tool than an administration or editing tool.
Having some time after patch -p1 in Paris, I started to work on this. After dealing with the horror of the PHP front end, I was surprised at how easy I got something working--the database setup isn't that bad. Now I have a basic tool that I use like this:
% wpgrep --host ... --user ... --database ... --regex ...
I've got a good start and it's doing what I need for now, but there are other things on my mind:
- Make a mini-webserver backend with a simple HTML frontend so I can return results as links right into the editing screens
- Make it work across several databases (I have one per book)
- Experiment making changes in the database directly from Perl, like the various bots that work on Wikipedia.
- Create some ubertools that monitor things like links and other linty sorts of things I'd like to know about.
I'm not out to make anything fancier, which makes it easy to make my tool. I just want to grep posts, so I don't need to implement a general system to do much more and I don't feel so bad about looking under the hood.
Leave a comment