SWG Return Time Plugin

Written By: on July 23, 2020 swg return time

I have been doing programming, web development, and digital marketing for the past 17 years. When I place a statement such as “past 17 years“, I now run the risk of becoming out-of-date every time an anniversary passes. I figured today would be the day I came up with a solution. 

Coming Up With a Solution 

I have decided to build a plugin that will return a numerical value based on a date parameter passed inside the shortcode. My first version is going to be super simple and now allow for any “non-year” returns. I will name my plugin SWG Return Time. I will pass in a value, and it will return the length of time directly into the WordPress page/post.   

How the Plugin Works

In my beta-version, I have just one possibility for input/return with no error checking implemented. The format needed to pass inside the shortcode is SWGReturnTime year=”dd-mm-yyyy” (adding the shortcode brackets to call the function). The plugin calculates the current day (today) and returns years since the passed date, rounded down.

Examples of Practical Use:

“We have been open for 25 years now!” 

By adding the “28“ inside the above sentence, I am passing July 21, 1998 (remember I am passing in day/month/year for my fellow Americans), which will be subtracted from today’s date. 

By adding the above shortcode, what I see on my post or page will be 

“We have been open for 25 years now!”. I no longer have to remember to update WordPress pages/posts based on length of years in service/business.

SWG Return Time Page Use Example
Example of shortcode added to a WordPress page
SWG Return Time Example
WordPress page with shortcode added

Expansion of the Plugin’s Capabilities

Just allowing for a return value to my WordPress page/post in a numerical format might be a bit of a limitation. I might want to return the years written out. An example of this would be one/two/three vs. 1/2/3. I will need to look for a function to change the returned value to “nine” instead of 9. So far, I have not seen a PHP function that does that. I might have to store the “decimal to text” relationship in a function array inside my plugin. 

Another feature that would be cool is the option to return other formats such as days, weeks, and months. With the basic framework built, I am able to able to add features to enhance the output slowly.

Uploading My Plugin To WordPress.org

I am nowhere close to being ready to upload my plugin to the WordPress repository, but at some point will upload it for general public use. I will first optimize the code and make sure there is “error checking” in place. The process to upload to WordPress.org is pretty straightforward. Once a plugin is submitted, it is sent over for manual review that can take 1 – 10 business days. 

Summary:

This plugin is a work in progress but satisfies a small but annoying need for my page/post content. I made a short video to demonstrate the current functionality. If you have questions, comments, or concerns about web development and business marketing, feel free to contact me.

About Shane Clark

Shane Clark

Shane Clark has 21+ years of experience in web development and digital marketing. He started as a network consultant in 1999 and later became a software engineer. Through ShaneWebGuy, he helps businesses and marketing agencies across the United States with websites, SEO, Google Ads, and AI automation. His interests include travel, family time, and writing practical technology articles.

Website

Shane Clark

About: Shane Clark

Author Information

Bio:

Shane Clark has 21+ years of experience in web development and digital marketing. He started as a network consultant in 1999 and later became a software engineer. Through ShaneWebGuy, he helps businesses and marketing agencies across the United States with websites, SEO, Google Ads, and AI automation. His interests include travel, family time, and writing practical technology articles.


To contact Shane, visit the contact page. For media Inquiries, click here. View all posts by | Website