WordPress plugin development

Lately, im heavily involved into developing on WordPress. Some small projects, and recently some bigger ones. So, the wiser decision was to transform most of my code into wordpress plugins. The benefits from such a decision are many and some big ones, like the ability to access all the core wordpress functions without including any additional files and direct access to the wp database with the $wpdb.

Until now i was developing inside the wp theme, adding there some smaller bits of code and having a separate folder (not wp related) for the “bigger” scripts. Creating a wp plugin is rather easy, since its just your function that is available all over wordpress with some comments that indicate that this is a plugin. The last few days, im working on transforming most of my code into wp plugins. From a simple text cutter that just cuts the text depending on the character limit you set, that also tries not to split words, to the latest wp that is better described as a custom wp admin panel.

As you can understand, this plugin is a huge beast, which is quite flexible and fast though. Its main purpose is to let users (registered or not) to submit content without having to see the real wp admin panel. It takes longer than i thought to develop it, but in some aspects, its even more powerful that the real admin panel itself, while it really sucks in other points, like the media management where I only implemented the ability to upload and delete a file. It supports many input types, like photos, textfields, textareas, dropdowns, dates, times and checkboxes, while handling the categories as a special dropdown. Thats much more than wp can handle, so, the post_meta database table becomes very handy in saving most of this data.

The main submit function is finished, so does most of the work too, but here lies a small trap which is the editing part. Sometimes, the changes should be reviewed before applied, and an activity (editing) stream should be recorded for each user, so the next step is to record all changes as a revision, and apply them only if the admin approves them. Thats not something difficult to create (after you think that solution) and the same “submit” function can be used with an “edit=true” parameter, but thats probably not the best solution if more features should be added in the future.

And last after edit, is the ability to delete something. Not such a big deal, simple, easy and only one way to do it 😛