First Attempt…Take One!

On one of my current website projects (which I’ll promote as soon as it’s ready) I’m linking to various bible scriptures on different web sites. I want to be able to quickly link to scripture without having to add the entire url each and every time. This plugin will allow a shortcode that looks something like this:

[bible scripture=2,Corinthians,1,20-22 version=NASB]2 Corinthians 1:20-22[/bible]

Elevator Pitch Explanation

I’ll assume that you’re familiar with shortcodes (if not, ElegantThemes has a great starter tutorial). In its most basic form a shortcode will perform an action (usually returning text or html) wherever it’s placed on a page or post.

Now, when you type [hello] on a post or page it’ll display the text Hello There! instead of the shortcode.

Simple.

Back to my short…code

Although you can manually add the code to the functions.php file, or even create a plugin by using a text editor and uploading to the website, I chose to use Pluginception which greatly simplifies plugin creation and editing.

Anywho, here’s the code that I’ve created.

In short, all this does is parse the attributes (scripture & version) and then passes those attributes to a function that concatenates them into a url.

I will eventually add another parameter (site) that will let me choose which site I want to use; for now it’s BibleGateway.

My Plea

This is one of my first true ventures into PHP and an actual attempt at finishing a plugin. I’m sure that there are things that can be done better so I will happily accept suggestions and corrections. Feel free to sound off in the comments below.

Happy Coding!