How should you write a WordPress Application?
-
I’ve found a bunch of stuff about the detailed API calls that are available, but nothing that explains at a fundamental level how I should approach writing a WordPress application (Not a plugin that modifies/adds to post content, a fully fledged app).
There isn’t a concept of an “application” under WordPress, the only items that are accessible are “posts” and “pages”. As far as I can tell, I have two options:
1. Publish a post/page with no content other than a special string (E.g. [my-app]) and then write a plugin that filters post content and replaces the magic string with the output from the application
2. Create a page, and assign it a custom template. Implement your application in that custom templateOption 1
It works, I know because this is what I did ?? However there is a performance penalty, your application code is called on every post, and so you have to take steps to make sure it doesn’t run unnecessarily. The other disadvantage is that well, it just doesn’t seem clean.Option 2
This seems a little nicer, but doesn’t really fit with WordPress’ nice plugin installation architecture – as far as I can tell plugins can’t auto-install into the current theme directory, and custom templates can’t live anywhere else.I originally posted this as a blog post at https://www.leewillis.co.uk/writing-a-wordpress-application/ but didn’t really get an answer (Although a few people agreed on the blog and on twitter that they didn’t really know either).
Is there a “proper” way to do this? Does WordPress need to add “Application” as a high level entity alongside Posts, and Pages?
- The topic ‘How should you write a WordPress Application?’ is closed to new replies.