Theme Options

 
 
 
 

Method registers one options page, Method Settings, as a top-level admin menu item (position 2, with Method’s own icon). It is a CMB2 options page, which is why CMB2 is a required plugin, and everything on it is stored in a single option, method_options. The fields are declared in lib/theme-options.php.

This page is about the settings a site administrator fills in. The configuration a child theme supplies in code — breakpoints, breakpoint colors, font-size presets — is a different thing: the METHOD_OPTIONS constant in lib/config.php, overridden by a child theme’s METHOD_CHILD_OPTIONS. The panel shows the loaded configuration in its Diagnostics section, but never edits it.


Reading a setting

Two routes, used side by side in Method itself:

PHP
// Through Method_Utility (the option key comes from the method_utility_option_key filter;
// Method's own callback returns 'method_options')
$util = new Method_Utility;
$tag  = $util->get_option( 'ga_id', '' );

// Or straight from the option, which is how the Breadcrumb and Mapbox Map blocks read it
$options = get_option( 'method_options' );
$sep     = ! empty( $options['bc_sep'] ) ? $options['bc_sep'] : '/';

Group fields (Social Media Links) come back as an array of rows; everything else is a scalar. Checkboxes are on when checked and absent when not, so test them with ! empty().


Sections and fields

Social Media Links

FieldKeyTypeRead by
Link {#} (repeatable, sortable group)social_accountsgroupmethod_build_social_nav_items() → the Social Nav block.
Servicesocial_accounts[n][service]radio_inlineChoices come from method_get_options_page_social_options(), built from method_get_social_platforms(); add a platform with the method_available_social_platforms filter.
Profile URLsocial_accounts[n][url]text_urlThe link target. A row with a service and no URL renders as an icon without a link.

Breadcrumb Trail Configuration

Read by the Breadcrumb block when it builds a trail. The per-type fields are generated at runtime from get_post_types() and get_taxonomies() (public, not built in), so a child theme’s post types appear here without any registration.

FieldKeyTypeEffect
Include Homebc_homecheckboxAdds a link to the front page as the first item of every trail.
Include Current Itembc_currentcheckboxAdds the item being viewed as the last item (no link).
Seperatorbc_septext_smallCharacter between items; / when empty.
Seperator Inclusionbc_sep_inclusioncheckboxKeeps the separator after the last item too.
Posts › Parent Pagebc_post_behaviorselectThe base of the trail for posts: the posts archive, or a page from method_get_hierarchical_page_options().
Posts › Archivebc_post_archivecheckboxInclude the posts archive as a trail item.
Posts › Archive Labelbc_post_labeltextLabel for that item; the post type label when empty.
{Post type} › Parent Pagebc_{post_type}_behaviorselectOne set per public, non-built-in post type. Types with an archive also get bc_{post_type}_archive and bc_{post_type}_label.
Categories › Parent Pagebc_category_behaviorselectThe base for category term trails.
Tags › Parent Pagebc_post_tag_behaviorselectThe base for tag term trails.
{Taxonomy} › Parent Pagebc_{taxonomy}_behaviorselectOne per public, non-built-in taxonomy.

Google Analytics

FieldKeyTypeRead by
Add Tagga_enablecheckboxmethod_inject_gtag() on wp_head.
Tag IDga_idtext_mediumPrinted into the gtag.js snippet when both fields are set. A GA4 measurement ID (G-…).

Additional Information

Two read-only textareas (save_field => false, so nothing is stored): Diagnostic Details — Method version, child theme version (THEME_VERSION, when the child defines it), WordPress version, user agent, PHP version — and Loaded Theme Data, a dump of METHOD_CHILD_OPTIONS if defined, otherwise METHOD_OPTIONS, with a note saying which.


HTTP Auth Support

FieldKeyTypeRead by
Enable Supporthttp_auth_enabledcheckboxAn http_request_args filter in lib/theme-setup.php.
Userhttp_auth_usertextCombined into an Authorization: Basic header.
Passwordhttp_auth_passtextStored in plain text in the option; use the host’s basic-auth credentials, never a WordPress login.

When all three are set, WordPress’s own HTTP requests to the site’s host (loopback requests, the block editor fetching styles through the REST API) carry the header, so an environment behind basic auth stops failing those loads. Requests to other hosts are untouched.


Extending the panel

  • The method_options_before_fields action fires with the CMB2 box right after it is created and before Method adds its own fields, so fields added there appear at the top of the panel and are stored in the same method_options option.
  • The method_utility_option_key filter changes which option Method_Utility::get_option() reads. Method registers its own callback returning method_options; a plugin can point it elsewhere.
  • The cmb2-mapbox plugin is an example of both: with its Method integration on, it adds a mapbox_api_token field to this panel, and the Mapbox Map block reads that token from method_options when no method_mapbox_token filter supplies one.

Changelog

VersionDescription
2.0.0-alpha4Introduced, with the Social Media Links group (101e7a5).
2.0.0-beta5HTTP Auth Support (e9e3183); Breadcrumb Trail Configuration (8831843).
2.0.0-beta6Google Analytics: Add Tag and Tag ID, read by method_inject_gtag() (dc49eb3).