Well I’ve decided to keep the site like this now. I found a way to make this style doable and it seems silly to continually seek out the most minimalist style when I could just use what I have and do something useful with time. Speaking of being useful with my time; I’ve been working on a Wordpress plugin that makes it easy to display some article properties in a nice way. When working with a friend of mine to create a blogging site in which we introduce a number of Open Source programs and tutorial them for our readers. After writing a few articles we realized something: not everyone writes at the same level; that is, some of us expect more from our readers. We also noticed that some of our applications weren’t totally cross platform. This sparked an idea for a Wordpress plugin. To simplify telling our readers, easily, what platforms and how difficult an article or tutorial will be.
First, I read the introduction Codex page for plugin development. This directed me across several of the Wordpress documentation pages so that I could find a basic understanding for how to approach my plugin. This was my first real plugin for something so I was very interested to see how the general idea is handled. Since its a plugin and you want someone to be able Install and Activate and start using, with no further customization. To a certain extent this seems limiting from a developer perspective because you cannot intervene anywhere else in your code to get your plugin to work, because if you had to do that then anyone else installing and using your plugin would have to get their hands dirty to get the plugin to work.
So Wordpress handles plugins by allowing developers to “hook” functions to standard Wordpress functions. For instance, when someone loads a Wordpress page there is a function called “the_content” that is run, which calls to the database and gets all of the content for that post/page. Without going into details about header information I must have this in php file:
1 2 3 4 5 | |
Quick notice: we gain access to the post content by using a parameter, Wordpress doesn’t make it too obvious that you have access to such parameters, but as far as I can tell, you have access to what the attachable function’s return. That is, here we have access to what the_content() would return. You want to be sure to return the one parameter you accept. Some explanation
This simple plugin will add “Hello plugin” at the beginning of each post content on loading each page. It will not alter the database information, but will only add the content on loading of each post. Part of the beauty of plugins is that we don’t have to screw up a user’s database in the process. One thing you may realize is that this is only part of what we need in a plugin like I want to achieve. I want something where each post has its own properties, that stick with that post. So we need to also handle usage of meta boxes on the post. Here there are a few options: let the user utilize meta boxes without guidance (dangerous, may render plugin near useless), fill in meta boxes using a little html magic, or fill in inivisble meta boxes. The last option is ideal because this stops the user from accidentally changing something, which could break the plugin or at least the reading of one of their posts. To add and save meta boxes we need something like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
Now with the above set of functions we just need to utilize our meta variables to insert something into the post, as I showed earlier in this post. If you’d like to see my project where I put all of this information together go to my github. As development proceeds I will be adding a global settings page where users can change everything about the plugin. Currently my plugin allows them to pick associated platforms so I’d like to allow them to change the icons and even what they’re including on each page. For instance instead of the plugin specifying platform or difficulty they can specify what general people or topics are being discussed on a post.