Who: Joseph Bisharat
Date: 2018 – Present
A WordPress plugin that triggers an image to slide across your browser screen to your desired tune by entering the correct secret code on your keyboard.
You could keep this Easter egg a secret and let users find out about this hidden gem on their own; or, you could prank someone’s computer by turning their volume all the way up and ask them to enter in the code.
The choice is yours!
There was plenty of exciting yet arduous obstacles in developing this WordPress plugin. The first was taking an outdated jQuery file and making a standard version compatible with WordPress. The second was generating input fields that would give users full control in setting the image speed, position, musical tone, but–most importantly–the coding sequence itself.
Before beginning any plugin development, making sure the script could run properly on a modern-day WordPress platform was the first step. The extremely outdated version of jQuery needed immediate attention and resolve.
I enqueued the script through the child theme’s function.php file and replaced the deprecated methods such as .bind() and .unbind() with the recommended .on() and .off() methods.
Once the script was capable of operating within the WordPress ecosystem with no errors, the next challenge was writing the plugin itself.
When writing the pseudo code, the initial purpose of the plugin was to give users two basic commands over the script: position and speed. I wanted users to have the ability to set where the animation would pop up on the site and how fast the image would slide across the screen.
Here are a list of functions used within the plugin and their overall responsibility:
Up until this point, the form and script have been independent of each other. In order to relay the information entered in from the form over to the script, wp_localize_script() was used. This bridges the communication and allows data to be parsed from PHP to JS.
Once that connection had been established, there was no limitation with what data could be passed over to the script. Eventually, I had created the fields for users to enter in the “secret” code, starting and ending positions, and the sliding speed.
Creating your own plugin is a strenuous yet gratifying journey. I mean, it’s no perilous quest to destroy a ring within a volcano, but the development sure feels like it!
The beneficial factor to plugin development is that it is an ever-growing and an ever-changing field. Since the early modifications, I have added the following:
- The ability for users to choose their own image that will slide across the screen
- Assigning what tune shall be playing in the background
- AJAX support
And development won’t stop there! Who knows what other cool features I’ll bring in store for future plugin updates.
Three brief details for each of these sections such as: