roots/support
General-purpose helper functions used across Roots WordPress projects. Includes Laravel-style env() lookup, value() for closures, utilities to add/remove callbacks across multiple WordPress actions/filters, and a wp_die() wrapper with Roots defaults.
General-purpose helper functions used across Roots WordPress projects.
Roots is an independent open source org, supported only by developers like you. Your sponsorship funds WP Packages and the entire Roots ecosystem, and keeps them independent. Support us by purchasing Radicle or sponsoring us on GitHub — sponsors get access to our private Discord.
composer require roots/support
This package autoloads helpers.php and provides:
Roots\env($key, $default = null)\Illuminate\Support\Env is available (it delegates there automatically).Roots\value($value)$value() if the value is a closure, otherwise returns the value unchanged.Roots\add_filters(iterable $filters, $callback, $priority = 10, $args = 2)Roots\remove_filters(iterable $filters, $callback, $priority = 10)Roots\add_actions(iterable $actions, $callback, $priority = 10, $args = 2)add_filters.Roots\remove_actions(iterable $actions, $callback, $priority = 10)remove_filters.Roots\wp_die($message, $subtitle = '', $title = '', $footer = '')wp_die() with Roots-flavored defaults.<?php
use function Roots\add_actions;
use function Roots\env;
$apiKey = env('API_KEY', '');
add_actions(
['init', 'wp_loaded'],
function () use ($apiKey) {
if (! $apiKey) {
return;
}
// Do work...
}
);
Keep track of development and community news.
How can I help you explore Laravel packages today?