In my apartment all of my lights are controlled via an outlet. These outlets are not connected to a light switch. As a first step towards convenience I purchased an EtekCity wireless outlet and switch. Every Friday these lights are put on a timer until Saturday night. That meant removing the existing outlet adapter and putting on one of the lovely cheap timers for the day. The timers only have a 24 hour cycle so it did not make sense to leave them on for the rest of the week. Within the timer there is also an audible mechanical clicking. There had to be a better solution.
Of course! I already have a wireless light switch. Why not somehow interface with it? A quick search on a hackaday lead me to others who have done similar, such as this and this. It was possible and not too hard.
Before creating a plugin it's helpful to determine the tools you need for your plugin to function and then determine how to integrate them into WordPress. In this guide I will be teaching by example. The plugin we will be creating is a simple post text replacement plugin. In the WP Admin panel we will be able to modify the search and replace parameters. We also will have a replacement color and toggle color. After some planning I've determined this plugin will require the following:
- jQuery : We need jQuery to toggle the class on our replacement text when clicked.
- Database : We need our settings stored permanently. Of course you already have a database set up for WordPress. We will use that.
- CSS : We will use two stylesheets, one for the admin side and one for the client side.
As mentioned before we want the plugin to have an admin panel accessible from the WordPress panel. We also need to hook into posts/pages for our search matching.
The following are WordPress documents that are essential for reference when creating a plugin. It will prove useful to have them bookmarked and opened in your browser at all times.