method_utility_option_key

 
 
 
 

apply_filters( 'method_utility_option_key', string $option_key )

Filters the wp_options key Method_Utility reads theme options from.


Description

When a Method_Utility instance is constructed it loads one option row — get_option( $option_key ) — and serves every get_option() / get_headline() call from it. This filter names that row. The default is method_options, which is also where Method’s CMB2 theme options page saves (option_key in lib/theme-options.php); lib/theme-setup.php attaches a callback that returns the same value, as a placeholder to copy. A child theme that keeps its options under another key points the class at it here. The key must match what the options page writes, or the utility sees nothing.


Parameters

$option_key (string) :
The option name. Default method_options.


Source

File: lib/class-method-utility.php, function Method_Utility::__construct()

PHP
$option_key = apply_filters( 'method_utility_option_key', 'method_options' );
$this->opts = get_option( $option_key );

Usage

child-theme/functions.php
add_filter( 'method_utility_option_key', function () {
    return 'child_options';
}, 20 ); // after the theme's own callback at priority 10

Notes

  • The parent theme’s callback (method_method_utility_option_key_callback(), priority 10) ignores its argument and returns method_options, so a child theme’s callback has to run later (priority 11 or more) to win.
  • Applied once per instance, in the constructor: new Method_Utility after changing the key sees the new row; existing instances keep theirs.
  • This is the key the class reads; the options page’s save location is set separately in lib/theme-options.php and documented on the Theme Options page.

Related


Changelog

VersionDescription
2.0.0Carried over from Method 1.x (introduced in 1.4.2, 95d6aad).