For those of you who don’t already know – about a year ago I created my first WordPress plugin (that was put on the repository). DobsonDev Shortcodes is a plugin that contains a collection of useful shortcodes that I found useful for my own purposes (such as the GitHub Gist shortcode and the inline code shortcode) or that some of my friends thought would be useful (things like the Twitch and YouTube shortcodes). I recently received an email from someone asking if my plugin would handle GitHub markdown files – and at the time it didn’t, but I thought it would be a great addition so I added it to the plugin.
I hope that more emails like this will come in the future because I don’t always think of what could be useful for others – so please let me know what shortcodes you would like to see and I’ll try to do what I can do. Now let’s take a look at what’s been added in the new update.
I’ve recently update DobsonDev Shortcodes to include two new shortcodes focused on use with the GitHub API. These shortcodes are:
These can both be used to include contents from your (or someone else’s) GitHub repository into your WordPress website. Let’s go through each of the shortcodes and look at what they can do.
[embedGitHubReadme owner="SufferMyJoy" repo="dobsondev-shortcodes"]
This shortcode will display the contents of the repositories README file. These will be output as parsed markdown so they will match the look and feel of the site. I’ve chosen to go with Parsedown as my PHP markdown parser for the plugin because it works great and its extremely lightweight. Both the
owner=”” tag and the
repo=”” tag are REQUIRED for this shortcode to work. Please ensure you use both.
[embedGitHubContent owner="SufferMyJoy" repo="dobsondev-shortcodes" path="readme.md"]
[embedGitHubContent owner="SufferMyJoy" repo="dobsondev-shortcodes" path="readme.md" markdown="yes"]
This shortcode will display the contents of any file located in a GitHub repository. The file can be output one of two ways; it will either just output the contents of the file to the page or if you mark the file as a markdown file (like in the second example usage) then it will output parsed markdown just like the readme shortcode does. Again this shortcode also uses Parsedown as the PHP markdown parser. The
path=”” tag are REQUIRED for this shortcode to work, but the
markdown=”” tag is optional. The only time you have to use the markdown tag is when you want a markdown file to be parsed and output.
I want to say thank you to everyone who uses the DobsonDev Shortcodes plugin and I hope that these new additions will be helpful. As always thank you for checking out the update and please share it around as much as you can! Please feel free to put any suggestions or ideas for shortcodes you would like to see in the comments section below.