Extending The WordPress Options Framework Plugin

Extensible plugins are a topic that I enjoy to speak about and I love it when I come across a plugin that is extensible. The options framework, a plugin which I have recently defaulted to for providing a ‘Site Options’ page in WordPress projects has many extensible features allowing me to customise the plugin so it is tailored to my clients. Here is how I have recently utilised some of its extensibility features.

In case you are not familiar with the term extensible plugins let me briefly outline what is meant by this. WordPress core utilises these features too, in fact it is what allows the plugin architecture to exist.

An extensible plugin is one that can be modified and extended upon without altering the core plugin code itself.

This has many benefits, but perhaps the best is that when you update the plugin your modifications are not lost.

Below are the modifications using extensibility features that I have made use of with the Options Framework plugin.

The Options Menu Item

By default the Options Framework plugin provides you with an admin sub menu labelled ‘Theme Options’ underneath the parent menu item of Appearance. If you are building a WordPress theme to be sold or to go into the WordPress theme repository this name makes sense. However when you are building a site for clients, theme options makes little sense to them. Lets face it, most of my clients don’t know what a WordPress theme is, and why should they? Therefore I wanted to be able to change this name and its location within the admin menu.

The Options Framework plugin provides all the extensibility features needed in order to do this. The plugin uses a filter named optionsframework_menu. This filter can be used to alter all of the menu parameters such as the menu name, position, page title and more. You will find that the plugin adds its menu using the code here – https://github.com/devinsays/options-framework-theme/blob/34c286996d387a29cb7871cfc2c8fdc09f03e5ca/inc/includes/class-options-framework-admin.php#L83-L104

Before sending the menu information to WordPress, it is passed through a filter named optionsframework_menu which allows us developers to alter the menu settings to change the way in which the menu is outputted. I used the code below in order to change the menu label, its position (make it appear below Settings) and make it is a top level parent menu item rather than being a child of Appearance.


Customise the Options Name

By default the plugin uses your themes stylesheet as the prefix for all of the options stored in the options table. However you can change this should you wish to do so using another handy extensibility feature. This is where you can overwrite one of the functions in the plugin with your own. The code below would change the name of the options to wpmark_options.


All of your saved options would now be stored in the options table as an array in an option with the name wpmark_options.

To go hand in hand with this you can then create your own function to get those options to use in your theme. The following function does this:


Theme Independent Option Declarations

By default the plugin looks for a file in your theme named options.php. This file then contains all of the options for your site. However I wanted to keep the options separate from my theme in case I changed themes and still wanted access to the options.

Again the plugins extensible features allow you to do this too. You can use the of_options filter to do this, like so.


I hope this goes to show that extensible plugins are the best! Thanks to Devin Price for building a wonderful extensible WordPress plugin.

4 responses

  1. Hi Mark. Excellent write-up!

    It might be interesting to know that none of these filters were in the original version of the plugin. Over time, as people have requested the ability to extend one thing or another, they’ve been added in- often as pull requests to the project on GitHub.

    With new projects, I’m now much better at anticipating where filters and additional actions are needed. Pippin also has a good write-up about building extensible plugins: https://pippinsplugins.com/lets-talk-extensible-code/

    Options Framework still has major extensibility issues. For instance, you can only have one instance of it (no multiple pages) and it’s very difficult to add a new option. Hopefully these get solved in a later version.

    1. Thanks for the comment Devin. I, like you am getting better and better and making plugins extensible. Filtering arrays and output and adding in actions in places where I think will be beneficial – even just for me to use!

      As you keep doing it you start adding extensibility features without thinking about it really.

      Look forward to see how the Options Framework develops over the coming months/years. Great plugin and thanks for sharing.

  2. Hello
    Thanks for posting the commentary. I was hoping to use your filter to change the name and location of my Options Framework menu. I was able to change the name, but the ‘mode’ change seems to be having no effect. In other words, I see no change, whatsoever, by changing the mode to menu, or submenu. It remains under the Appearance menu. My filter is located at the bottom of my functions.php file, after locating the Options Framework script.

    $menu[ 'mode' ] = 'menu'; // make the menu a top level menu item

    Any idea why that menu is not moving for me? Thanks!

    1. Not sure really – would have to see all of your code that controls these changes really. Perhaps you could post it as a Gist on Github and then people can see it?

Leave a Reply

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