makewp/theme

Make WordPress themes, better.

0.2.0 2025-07-11 01:56 UTC

This package is auto-updated.

Last update: 2025-07-11 01:59:37 UTC


README

Make WordPress themes, better.

Usage

require_functions()

The goal is to code-split functions.php. Typically, functions.php contains anything and everything. But we want to be tidy. And we don't need a functions.php with lines and lines of requires when we can access the file system.

// {your-theme}/functions.php
<?php
require_once 'vendor/autoload.php';
\MakeWP\Theme\require_functions();
// {your-theme}/functions/test.php
<?php
echo 'functions/test.php';

You should now see "functions/test.php" in your browser.

Ok but wait but we shouldn't be accessing the file system with every page lo-

I mean, but like, cache, right?

register_blocks()

Same as require_functions(), but register_block_type()'s all directories inside.

// {your-theme}/functions.php
<?php
require_once 'vendor/autoload.php';
\MakeWP\Theme\register_blocks();
// {your-theme}/blocks/carousel/block.json
{
  "name": "carousel"
}

enqueue_style()

style.css is required for all WordPress themes, but isn't automatically enqueued as a stylesheet. Let's do that for us.

// {your-theme}/functions.php
<?php
require_once 'vendor/autoload.php';
\MakeWP\Theme\enqueue_style();

all()

Want to use all of the above? Don't want to call them all separately? I gotchu.

// {your-theme}/functions.php
<?php
require_once 'vendor/autoload.php';
\MakeWP\Theme\all();