WP Broadbean v2.0 Coming Soon

My WP Broadbean plugin to integrate jobs posted via Broadbean Adcourier has been a success in the recent months with many different recruitment companies using the plugin to get jobs they post on Broadbean to appear on their WordPress websites. Now it is time to take the plugin to the next level and coming soon with be the second version of the plugin with updates and enhancements. Lets take a look at what is planned.

Having been working on the plugin for well over 18 months now, in my spare time between projects and with a number of clients using the plugin I have learnt a lot about what changes would enhance the plugin. Here are what is planned in the new release:

Improved Extensibility

This is something that I am passionate about in plugins. The ability for a developer to make modifications and functionality changes without altering the core plugin code itself. In the next release there will be major extensibility offerings, some of which are outlined below.

Better Declaration of Fields for Each Job

At the moment the plugin comes with a set of job fields that are added when each job is published on the site. These include job reference, salary, contact name and email address etc. Adding your own fields up until now has been a little tricky to do and therefore the new version will easily allow you to declare what fields you want (additional) to the defaults. As well as this you can remove the defaults should you wish to do so.

Below is a simple example of how you could add your own fields to a job:

This will add the meta box field on the post editor for the job. Perhaps the best part as well is that it will also handle all of the saving of the post meta when the job gets saved.

It is worth noting here that this field would have to be added to your feed sent by Broadbean. They can do this as support and would not be a problem. In this case we would just need to request that an additional text input field be sent with the XML node <internal_ref>.

Add Your Own Taxonomies

The plugin comes bundled with some default taxonomies that work well with the default feed that Broadbean uses. Adding your own is also really simple and works in a similar way to the fields as above. Below shows an example of how we would add a new taxonomy for country.

Again this handles all the saving of the terms in this taxonomy when they are sent over to your site. As with fields Broadbean would need to add this field to your feed. The broadbean_field arg in the code above states which XML node to look for in the feed.

Thanks must go to Dave Smith for his contribution to this part.

WP Broadbean Website

Along with the launch of version 2 of the plugin comes the new WP Broadbean website that is currently in development. The site will feature information and documentation as well as some paid services which users can opt into should they find them useful. More information on this soon.

Visit the current version (rough and ready!) of the WP Broadbean website here.

These are some of the major changes that have been introduced. It is worth noting that they are still in testing and I hope to have the new plugin version launched early in the new year.

Important Note

With all these changes there is an important note that I need to make. Users that are using the current plugin, version 1.0.2 or lower, the new versions changes are likely to break your version. This is far from ideal I know, but having gone back and forth on a number of occasions this I feel is still the best way forward.

If you are on versions at or below 1.0.2 then I would recommend you add the Block Specific Plugin Updates plugin from the WordPress plugin repository and set it to prevent updating the WP Broadbean plugin until you are ready to move ahead with the new version 2 plugin.

Adding a Class to Every nth Post

A project I was working on recently had a series of sections on a page. They ran in 3’s in that the 1st, 4th, 7th and so on and the 2nd, 5th, 8th (you get the idea!) were styled the same. Therefore I needed a way to add a class to each div which indicated which section it was. Here is how I did it.

I was able to create a loop (we use them a lot in WordPress!) and then use a counter to find out which section were we in, in order to add the correct class. The code I used is below:

As you can see this uses the PHP operator modulus, which would check out on the PHP site here.

You could of course adapt this to suit other patterns of post classes, quite easily.

WordPress Front End Profile Plugin

Have you ever worked on a site where you have lots of users on the site but they should never need to go into the WordPress admin area? Maybe you have different roles setup to show them different types of content. However you would like them to be able to edit the information on their profile page? Well now you can allow them to do this without going near the WordPress admin buy using my new WP Front End Profile plugin. Lets take a look at it.

Put simply this plugin provides you with a function for which you can add to your themes template files. When you do this the function outputs a profile editor on the front end. The function in question is:

wpfep_show_profile();

Once you add this you will be presented on the front end, in whichever template you added it to with the following profile editing screen.

Screen Shot 2014-12-06 at 11.15.28

As you can see, by default the profile editor has two tabs named Profile and Password. Each tab contains a set of fields which the user can edit. The profile tab has the majority of things that can be edited on the profile admin screen, such as first and last name, URL, email address and the bio or description. The password tab allows the user to change their password, entering it twice to confirm.

All that sounds great, but that it not really the best part of the plugin, this comes in the form of its extensibility. The plugin is built in a way that easily allows developers to add their own tabs and their own fields, either to tabs they have added or to existing tabs. What is also good, is that all of the saving is taken care of for you. Lets took at look how.

Adding Your Own Tabs

To do this you will need to use the wpfep_tabs filter. An example of how to add a new tab is given below:

As you can see you declare a number of tab args when adding the tab. Perhaps the most important of these in the Tab ID. This is used for adding fields to your tab. So lets take a look at how to add fields to your tabs.

Adding Fields to a Tab

All fields that you add are added to the user as user meta (you can use the wpfep_reserved_ids filter to save to the user table rather than user meta but that is for another day!). Fields are added to a tab using a dynamic filter. The filter is dynamic as it uses the tab ID from when the tab was added. The filter takes the following format:

wpfep_fields_$tab_id

Here the tab id is the ID of any added tab. The ID of the default tabs are profile and password. The ID of the tab we added above is wpmark_tab. Therefore to add fields to this tab we would use a filter named:

wpfep_fields_wpmark_tab

The code below is an example of how we do this:

Here we have added a select input setting the type to select and adding and options arg to give the different select options. Other types you could add include WYSIWYG, text, textarea, checkbox, password and email.

Actions and Filters Available

There are also a number of actions and filters that developers can use to modify things such as password length requirements and whether or not to use the plugins built in styles and javascript. Take a look at the Wiki on Github in order to find out more.

You can download the WP Front End Profile Plugin in the WordPress.org plugin repository or view the code and submit issues on Github.

WP Post Type Meta WordPress Plugin

Working with custom post types for the last 3 or 4 years has on the whole been great. However there was always one thing that I found lacking and that was the lack of an (editable) post type description. Therefore I set about to try and change this, adding some extras along the way. Let me introduce the WP Post Type Meta WordPress plugin.

I must start off this post by letting you know that this idea is not new. In fact my idea for this came from Steven Jones in his post 5 Improvements to WordPress’ User Experience. In this post Steven added a simple link to a plugin that adds a post type description to custom post types. Essentially this is what WP Post Type Meta does “out of the box”, however I wanted to take this further and allow further meta to be added to custom post types.

Screen Shot 2014-12-01 at 18.40.59

The need for this was seen when I was working on sites that made use of the term description field in a taxonomy term. This description is often displayed at the top of the archive for that term to indicate the nature of the posts found in the term archive. This was something that a lot of my clients wanted for custom post types. For example many want an FAQ section and I often deliver this through a custom post type with an accordion style jQuery addition on the front end. The post type archive acts as the FAQ page. However many clients wanted to have a paragraph of text appear at the top of this archive to explain the page. The problem them comes as to how to allow the client to edit the text. There are other ways to achieve a solution to this such as a page that is pulled in at the top and also a theme option style settings, however I was not really happy with either. Steven’s post type description plugin did the job.

This got me thinking that we could actually add other fields to the post type description page added in the admin. For example what if you had a post type about products and you wanted to add a standard sizing link to a PDF that would show on the archive page at the top in useful info. You can easily add a text input box and add your link into that or even a post type select input to choose a page for the sizing information.

This is what the WP Post Type Meta plugin does. It provides an additional sub admin menu for each custom post type in your site named {Post Type} Meta. By default on the page is a description box to add a post type description, however the plugin is extensible and easily allows you to add other fields including text, textarea, WYSISYG, select and checkbox inputs. The post type description field is added in this way.

All of the plugin meta data is stored in the WordPress option named wpptm_meta as an array. Each piece of meta added is prefixed with the post type name. For example to get the post type description field you would use the following:

You can add your own fields by using the wpptm_settings filter. The example below shows you how to add a select input:

Other fields can be added in a similar way. The field above would be retrieved on the front end like so:

I have tried to build the plugin in an extensible way to allow developers to build upon and extend its functionality. I look forward to using it in the future.

You can download the WP Post Type Meta plugin on WordPress.org or add it to your site through your WordPress dashboard.