WP Controls, Multiple Icons & Images for WordPress

Lately I have been working on a new theme from our Designer where I needed a theme customizer control that didn’t exist. I also wanted to replicate the social media icons system from Hueman. To do this I created a repository of WP Controls. These controls are self contained and can just be included in any theme by requiring one file.

You can view this Repository over on Git Hub.

Using WP Controls

Grab a copy of the repository and place it in a folder in your theme. In your functions.php add a call to require_once('path/to/wp-controls/controls.php'); This then loads all the controls into your theme.

The WordPress codex has a nice article on the theme customization api. To use the WP-Contols controls create a control using the provided classes.

Multi Images Control

Control Class: Multi_Image_Control

Multi Images Control allows you to create an array of multiple images. It stores the attachment ID for the images.

wp controls multi images

Users can select one or more images and a time and their thumbnails all appear below the control name with a button to remove it.

Your code would look something like this:

Multi Images Control is pretty easy to use and does exactly what it says on the tin. You can use the image url in anyway you want.

Media Icons Control

Control Class: Media_Icons_Control

Media Icons Control uses Font Awesome to give infinite media icons. This is similar to how the Hueman theme works and I completely admit that this is a copy of the functionality but not the design.

wp_controls_media_icons

From here a user can select any font awesome icon, URL and colour for their icons. Icons can be moved up & down and removed entirely. There is no limit on the number of icons a user can have.

Your code for using these icons would look something like this:

You would then style the links how ever you want but the user has control over the chose icon and the background colour.

The Future

I plan on adding any controls I create into this repo. I’d like to build up a large library of controls that can be leveraged into any framework etc…

If anyone out there wants to add their controls or improve the ones I created feel free to open a PR on GitHub.

Adam Laycock

IT Engineer and Developer working in education. I try to do everything in my power to create better systems for schools be it the windows domain or a plugin for their WordPress site.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *