Classes

All PHP classes are namespaced with Harmoni. An example configuration can look like this:

use harmoni\init; use harmoni\remove; add_action( 'init', function () { init::css(); init::twig(); init::favIcon(); init::bodyClassSlug(); remove::jquery(); remove::embed(); remove::emojis(); remove::gutenberg(); } );

init

This class sets up most of the files that need to be enqueued in order for the development to start.

init::Twig

Enables Twig. Needs Timber to work.

init::css

Enqueues a style.css file from the assets/css folder into the header.

init::js

Enqueues a scripts.js file from the assets/js folder into the footer.

init::favIcon

Loads favicons into the head just like WP core. Filenames are favicon-32x32.png, favicon-180x180.png and favicon-32x32.png and will be loaded from assets/images.

init::bodyClassSlug

Adds the page slug to the body as a class name, e.g. page-services .

get

Gets useful blocks of markup that are used frequently.

get::head

Inserts a head block. Includes wp_head() function.

get::inter

Inserts Inter font into the head.

remove

Removes unnecessary files from loading on your site.

remove::jquery

Removes jQuery from the frontend.

remove::embed

Removes oEmbed scripts from the frontend.

remove::emojis

Removes emojis from the frontend.

remove::gutenberg

Removes Gutenberg CSS from the frontend.

remove::extraRss

Removes RSS feeds from the frontend.

remove::recentCommentCss

Removes recent comments CSS from the frontend.

remove::galleryCss

Removes gallery CSS from the frontend.

remove::wordpress

Removes all other obscure WordPress things from the frontend. Check source code for a full list.

Twig

Harmoni adds various little Twig goodies to make developing faster and more efficient.

Filters

Filters are used to modify content.

Usage:

{{ source|filter }}

shuffle

Shuffles an array using PHPs shuffle function.

slugify

Slugifies a string, e.g. I am a string -> i-am-a-string

shuffle

Shuffles an array using PHPs shuffle function.

Variables

Variables in the global context are used to get content dynamic content.

Usage:

{{ variable }}

postLatest

Gets the latest post.

currentYear

Outputs the current year.

pluginRoot

Gets the the plugin root directory.

themeRoot

Gets the theme root directory.

themeRootUri

Gets the theme root directory URI.