Accessing Headway theme-wide options outside blocks

I’m building up the tools needed for my latest undertaking of mine and the last missing part is the one that will allow me to get access to theme-wide settings outside of an Headway block.

An image is worth a thousand words

A theme-wide option is one like Setup in the below picture

Theme-wide option
Theme-wide option

this is the one Headway comes with and any setting set here will be valid not for one particular block but for the theme.
Fiddling around with the code I’ve found out that block plugin developers can add their own theme-wide setting menus and those settings can later be accessed using the method

HeadwayOption::get($option = null, $group_name = false, $default = null, $main_site = false);

While that’s convenient that’s also not accessible at plugin time.

WordPress order

WordPress will load its components in an order that’s, roughly, like

  • mu-plugins
  • plugins
  • themes

Headway is a theme and any function, class and methods the theme defines, like HeadwayOption::get, will not be available until the after_setup_theme hook happens.
Hence accessing Headway theme-wide, or even block-specific, settings before Headway has loaded cannot be done using methods provided by Headway.

Of course I need to use them before

If a block-specific or theme-wide setting is needed at plugin loading time than the road to reach those options from the database is a self-made one. A block plugin is still a WordPress plugin able to add menus and options and meta-boxes and whistles. Some of those operations might be conditioned by the theme designer decisions as per the meta-programming language example

if the theme designer decided something
    do something
else
    do something else

Code please

The HeadwayGlobalSetting class will read the serialized Headway options from the database and will make them accessible at plugin-time via an object-oriented API like

$settings = new \tad\wrappers\HeadwayGlobalSetting('fancy-slider');

// DB setting will be something like 'fancy-slider-allow-slider-time-setting'
$allowSliderTimeSetting = $settings->allowSliderTimeSetting;

if ($allowSliderTimeSetting) {
    ...
} else {
    ...
}

A quick look at action order will reveal that this is not the only way to access block settings as after_setup_theme hook, while happening later than the hooks related to plugins, will still happen pretty early in the action queue and delaying the execution of code depending on Headway defined functions or methods until that moment is possible if applicable.
I like decoupled and testable code and the class helps in that context.
The code is on GitHub along with the other classes.

I appreciate your input