If you have never built your own WordPress plugin before it can be quite daunting in terms of getting started. Hopefully by reading this blog post and watching the accompanying video you will feel much more confident.
The post is going to walk through building a social profiles widget which allows site owners to add the URLs to their social profiles in the WordPress customiser and then add these links to their site using a widget placed in a widgetised area or sidebar.
Plugin overview
Before watching the video below and taking a look at the plugin code, also provided below, it makes sense to give an overall outline of how the plugin works.
The plugin is based on the concept that social profiles are registered with WordPress, through the use of a filter. Registered social profiles are then added to the customiser to allow the site owner to enter their social profile URLs.
A WordPress widget is also created which then outputs a list of the social profile URLs the site owner has added.
The plugin is built extensibly allowing other developers to add, edit and remove social profiles, as well as easily altering the markup of the widget output. All this can be done without modifying the actual plugin code itself, through its extensible features.
Video
Watch the video below were I talk through the entire plugin from scratch!
The Code
The code is placed in the following Gist. The plugin itself is contained in the single file named hd-extensible-social-profiles-widget.php
. The extensible-changes.php
file shows how the plugin can be modified using its extensibility features.