Method Child

 
 
 
 

Method Child is the starter child theme for Method v2: the smallest theme that activates on top of Method, with the parent’s extension points laid out as commented examples and a Sass build wired to Method’s variables. Most projects never clone it directly — Method Generator renders it with the project’s own name, text domain and function prefix — but a generated theme is this theme file for file, so this page documents both.

The source is pixelwatt/method-child, currently 1.0.0-beta5. The theme header’s Template: method line binds it to the parent, which must live in wp-content/themes/method; the header’s Version is what the theme reports as THEME_VERSION. The child declares no plugin requirements of its own: CMB2 arrives through Method’s Plugin Dependencies. For the step-by-step setup see Getting Started with Method v2; for the tool that renders this theme see Method Generator.


What’s in the theme

FilePurpose
style.cssTheme header only. Template: method, and the Version line that THEME_VERSION reads.
functions.phpDefines THEME_VERSION from the header, then requires the lib/ files in the order below. The require for lib/config.php ships commented out.
lib/config.phpThe METHOD_CHILD_OPTIONS constant — a child-side replacement for Method’s configuration (see Overriding Method’s configuration).
lib/theme-setup.phpmethod_child_scripts() on wp_enqueue_scripts (its front.min.css enqueue is commented out), plus commented examples for social platforms, options-page fields and responsive embeds.
lib/blocks.phpEnqueues assets/css/global.css on the front end and in the editor, removes core block patterns, and carries the block-editor examples: pattern and block categories, heading and button styles, icons.
lib/post-types-and-taxonomies.phpA commented news post type (with show_in_rest, so it uses the block editor) and a commented taxonomy.
lib/cmb2-helper-functions.phpmethod_child_cmb2_tinymce_options() (minimal / no-media editor presets) and two cmb2_show_on filters that add the default-page-template and front-page keys.
lib/cmb2-options-loader.phpmethod_child_load_cmb2_options( &$obj, $temps ): adds named field sets to a CMB2 box. One set, example, ships.
lib/cmb2-metaboxes.phpCommented box registrations on cmb2_admin_init — front page, default page template, a named page template — each calling the loader.
lib/admin-customization.phpEnqueues assets/css/admin.css on admin_enqueue_scripts.
assets/scss/ → assets/css/global, admin and front stylesheets, compiled to .css and .min.css (see Styles and the build).
gulpfile.js, package.json, .eslintrc.jsThe Sass build (gulp 4, gulp-dart-sass, autoprefixer, clean-css, BrowserSync) and lint setup (@wordpress/eslint-plugin recommended config, prettier).
screenshot.pngThe Appearance → Themes thumbnail. Replace it with the project’s.
CHANGELOG, README.mdRelease notes (reproduced below) and the one-paragraph readme.

How it loads

WordPress includes the child theme’s functions.php before the parent’s, so everything the child defines — THEME_VERSION, METHOD_CHILD_OPTIONS when it is enabled, and any hooks the lib/ files add — is in place before Method’s own lib/ files run. That ordering is what lets a constant defined here change how Method configures itself.

Two version constants exist side by side. THEME_VERSION is wp_get_theme()->get( 'Version' ), the active theme’s — the child’s — header. Method’s METHOD_VERSION resolves through $theme->parent(), so it is always the parent’s. On the Theme Options page, the Additional Information section’s Diagnostic Details field prints both versions, and its Loaded Theme Data field dumps the configuration array in effect, captioned “Using child theme overrides.” or “Using Method’s default configuration.”


Overriding Method’s configuration

lib/config.php defines METHOD_CHILD_OPTIONS with the same shape as Method’s METHOD_OPTIONS in lib/config.php. Nothing merges the two: every reader checks defined( 'METHOD_CHILD_OPTIONS' ) and, if so, uses the child array in place of Method’s, wholesale. An enabled override therefore has to carry every key Method reads. The readers are method_get_block_breakpoints(), method_get_all_bs_breakpoint_options(), method_get_breakpoint_class_prefixes(), method_get_breakpoint_colors(), method_get_font_size_presets() and the information pane on the Theme Options page.

KeyWhat Method does with it
breakpoints.unitsUnit appended to every dimension when media queries and the editor’s breakpoint hints are built.
breakpoints.dimensionsNamed widths (xs … xxl). method_get_all_bs_breakpoint_options() turns the list into the editor’s breakpoint choices.
mobile_max, tablet_min, tablet_max, wide_minNames from dimensions that bound the three responsive tiers: mobile is everything below dimensions[mobile_max], tablet runs from dimensions[tablet_min] up to dimensions[tablet_max], wide starts at dimensions[wide_min] (method_get_block_breakpoints() subtracts 1 from each upper bound).
baseThe breakpoint name used for base-tier class prefixes (method_get_breakpoint_class_prefixes()). Added to the child’s copy in 1.0.0-beta4.
breakpoint-colorsThe accent colors the editor gives each tier (see Editor Integration). Each of mobile, tablet and wide falls back to WordPress blue (#007CBA) when its key is missing, and all three do when enabled is missing or false.
typography.font-size-presetsThe name / slug / size list the typography controls offer.

To take it over, edit the array and uncomment the require:

lib/config.php
<?php
// lib/config.php — the whole array is used in place of METHOD_OPTIONS,
// so every key Method reads has to be here.
define( 'METHOD_CHILD_OPTIONS', array(
    'breakpoints' => array(
        'units'      => 'px',
        'dimensions' => array( 'xs' => 0, 'sm' => 576, 'md' => 768, 'lg' => 992, 'xl' => 1200, 'xxl' => 1600 ),
        'mobile_max' => 'md',
        'tablet_min' => 'md',
        'tablet_max' => 'xl',
        'base'       => 'xl',
        'wide_min'   => 'xxl',
    ),
    'breakpoint-colors' => array(
        'enabled' => true,
        'mobile'  => '#865EBF',
        'tablet'  => '#D94A64',
        'wide'    => '#F28729',
    ),
    'typography' => array(
        'font-size-presets' => array(
            array( 'name' => 'Small',  'slug' => 'sm', 'size' => '1rem' ),
            array( 'name' => 'Medium', 'slug' => 'md', 'size' => '1.25rem' ),
            array( 'name' => 'Large',  'slug' => 'lg', 'size' => '1.5rem' ),
            array( 'name' => 'Extra Large', 'slug' => 'xl', 'size' => '2rem' ),
        ),
    ),
) );
functions.php
// functions.php — the require ships commented out; uncomment it to take over.
require_once('lib/config.php');

Two things to keep in mind. The file is a snapshot of Method’s configuration as of the child release: 1.0.0-beta5’s copy still carries the previous accent palette (#865EBF / #D94A64 / #F28729), while Method 2.0.0-beta30 moved to #d17c28 / #2b9d9a / #9b2d8c (3fc99f5); once the override is enabled the child’s values win until you change them, so compare the two files after each parent upgrade. And the PHP breakpoints are independent of the Sass ones: variables.scss hard-codes its own $grid-breakpoints map, so moving a dimension here does not move the media queries in compiled stylesheets.


Styles and the build

Three stylesheets are compiled from assets/scss/ into assets/css/, each as a readable and a minified file. Only two of the three are enqueued:

StylesheetLoadedWhere
global.cssOn the front end from enqueue_block_assets, guarded by ! is_admin(), after wp-block-library, wp-block-library-theme and global-styles, versioned with THEME_VERSION. In the editor through add_editor_style( 'assets/css/global.css' ) (with editor-styles support), which scopes it to the content iframe instead of the whole editor screen.lib/blocks.php
admin.cssOn every admin screen from admin_enqueue_scripts.lib/admin-customization.php
front.cssCompiled but not enqueued. method_child_scripts() holds a commented enqueue of front.min.css for the front end.lib/theme-setup.php

global.scss and admin.scss open with @import "../../../method/assets/scss/variables.scss" — a relative path that resolves only when the parent is installed as themes/method next to the child. It brings in Bootstrap’s $grid-breakpoints map (24 columns, 1.5rem gutters), the grid and breakpoint mixins (media-breakpoint-up() and friends) and Method’s tier variables $method-mobile-max, $method-tablet-min, $method-tablet-max and $method-wide-min, so a child stylesheet can target the same tiers the blocks do.

Gulp taskWhat it does
compile-front-styles, compile-global-styles, compile-admin-stylesCompile one stylesheet: Sass → autoprefixer (last 2 versions) → .css, then clean-css level 2 → .min.css.
compile-all-styles (alias styles)The three compiles in series.
watch-stylesRecompile on any .scss change, without BrowserSync. Added in 1.0.0-beta2.
serveStart BrowserSync as a proxy for the local site (method-child.test in the reference copy; Method Generator substitutes the project’s URL), recompile on .scss changes and inject the result, reload on any other change.
Terminal
npm install
gulp serve            # compile, then proxy your local site through BrowserSync
gulp watch-styles     # recompile on save, no BrowserSync
gulp compile-all-styles

Extension points shipped as examples

Everything in the table is present in the theme as a commented block, with the function names and text domain already in place; uncommenting and editing is the whole job. Each row links to the page that documents the hook on Method’s side.

ExampleFileHook or APISee
Add a social platform to Method Settings and the Social Nav blocktheme-setup.phpmethod_available_social_platformsTheme Options
Add theme-specific fields to the Method Settings pagetheme-setup.phpmethod_options_before_fieldsTheme Options
Opt in to responsive embed wrappingtheme-setup.phpadd_theme_support( 'method-responsive-embeds' )Responsive Embeds
Register a block pattern categoryblocks.phpregister_block_pattern_category() (slug method-child-page-components)—
Prepend a block category for the theme’s own blocksblocks.phpblock_categories_all at priority 25—
Heading styles (as-h1 … as-h3)blocks.phpregister_block_style() on core/heading, core/post-title, core/query-title—
Theme Button block styles (Enclosed, Icon Only)blocks.phpregister_block_style( 'method/theme-button', … )Buttons
Secondary button styles and their panel labelblocks.phpmethod_block_theme_button_styles, method_block_theme_button_styles_labelButtons
Button label stylesblocks.phpmethod_block_theme_label_stylesButtons
Theme iconsblocks.phpmethod_theme_icons — the callback adds to the array Method passes in and returns it (1.0.0-beta5; earlier releases demonstrated method_block_theme_button_icons, which returned a replacement array)Theme Icons

One line in lib/blocks.php is active rather than commented: remove_theme_support( 'core-block-patterns' ). Comment it out to get WordPress’s bundled patterns back. Nothing in the starter declares required plugins; a child adds its own by shipping a wp-dependencies.json next to style.css or through the method/plugin_dependencies filter, both covered on the Plugin Dependencies page.


CMB2 helpers

The CMB2 files give the project a pattern for page metaboxes rather than any particular box. lib/cmb2-helper-functions.php registers two cmb2_show_on keys: front-page shows a box only on the page assigned as the static front page, and default-page-template only on pages with no template that are not the front page — so a box can target “ordinary” pages without listing templates. lib/cmb2-options-loader.php keeps field definitions in one function keyed by set name, and lib/cmb2-metaboxes.php shows boxes that register themselves on cmb2_admin_init and ask the loader for the sets they want:

lib/cmb2-metaboxes.php
add_action( 'cmb2_admin_init', 'method_child_register_page_front_metabox' );

function method_child_register_page_front_metabox() {
    $cmb_options = new_cmb2_box( array(
        'id'           => '_method_child_metabox_page_front',
        'title'        => esc_html__( 'Front Page Options', 'method-child' ),
        'object_types' => array( 'page' ),
        'show_on'      => array( 'key' => 'front-page', 'value' => '' ),
    ) );

    // Adds every field in the "elements" set defined in lib/cmb2-options-loader.php.
    method_child_load_cmb2_options( $cmb_options, array( 'elements' ) );
}

Versions and compatibility

Each Method Child release has a matching Method Generator release that templates it, and its examples assume the Method release whose hooks they call. Older Methods still activate the theme — the examples are comments — but an uncommented example aimed at a hook the parent does not have yet is a silent no-op.

Method ChildReleasedGeneratorExamples target
1.0.0-beta52026-09-18v2-1.0.0-beta5Method 2.0.0-beta18 or later (method_theme_icons arrived in beta18, 3064cd9).
1.0.0-beta42026-07-14v2-1.0.0-beta4Method 2.0.0-beta17 or later (method-responsive-embeds support, b4c7dcb).
1.0.0-beta32026-02-09v2-1.0.0-beta3Method 2.0.0-beta5 or later (method_block_theme_label_styles, cc3100d).
1.0.0-beta22025-12-21v2-1.0.0-beta2Method 2.0.0-beta1 or later (METHOD_CHILD_OPTIONS and the child-version line on the options page, feab227).
1.0.0-beta12025-12-21—As above.

Changelog

Commit links point at pixelwatt/method-child.

VersionDescription
1.0.0-beta5The theme-icon example now registers through method_theme_icons, adding to the array Method passes in, instead of returning a replacement array to method_block_theme_button_icons; the heading-style and button-style examples share one $styles variable; a missing brace in the options-page example and the missing */ on the theme header were fixed; Theme URI now points to method.wiki (bd85e16).
1.0.0-beta4Removed lib/theme-options.php and the child’s own “Theme Settings” page in favour of adding fields to Method’s page through method_options_before_fields; the lib/config.php require is now commented with a note; new commented examples for responsive embeds, pattern and block categories, and secondary button styles with their label; base added to the breakpoint config (4eeb064).
1.0.0-beta3The global stylesheet is enqueued on the front end only and loaded in the editor with add_editor_style(); core block patterns removed; commented examples for heading styles, theme button styles, label styles, button icons and social platforms; the news post type sets show_in_rest; text domain unified as method-child and example field ids prefixed _method_child_; theme header expanded; package renamed (a15a90d).
1.0.0-beta2Added the CHANGELOG, the readme banner and the watch-styles task (f3765fd, f60597e).
1.0.0-beta1Initial release: the lib/ layout, the three SCSS stylesheets and their enqueue functions (dc76e67, e988d3a).