roots/support

Maintainers

👁 retlehs
👁 QWp6t

Package info

github.com/roots/support

Homepage

Forum

pkg:composer/roots/support

Fund package maintenance!

roots

Statistics

Installs: 2 334 202

Dependents: 7

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2024-05-08 21:05 UTC

Requires

  • php: >=5.6

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT e1b76fb2feb806e195833b125b6d23d598a88bb3

  • QWp6t <hi.woop@qwp6t.me>

This package is auto-updated.

Last update: 2026-05-28 02:29:53 UTC


README

General-purpose helper functions used across Roots WordPress projects.

👁 Packagist Downloads
👁 Follow Roots
👁 Sponsor Roots

Support us

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.

Requirements

  • PHP 5.6+

Installation

composer require roots/support

Helpers

This package autoloads helpers.php and provides:

  • Roots\env($key, $default = null)
    Laravel-compatible environment lookup.
    Deprecated when \Illuminate\Support\Env is available (it delegates there automatically).
  • Roots\value($value)
    Returns $value() if the value is a closure, otherwise returns the value unchanged.
  • Roots\add_filters(iterable $filters, $callback, $priority = 10, $args = 2)
    Registers one callback across many filter hooks.
  • Roots\remove_filters(iterable $filters, $callback, $priority = 10)
    Removes one callback across many filter hooks.
  • Roots\add_actions(iterable $actions, $callback, $priority = 10, $args = 2)
    Alias of add_filters.
  • Roots\remove_actions(iterable $actions, $callback, $priority = 10)
    Alias of remove_filters.
  • Roots\wp_die($message, $subtitle = '', $title = '', $footer = '')
    Wrapper around WordPress wp_die() with Roots-flavored defaults.

Usage

<?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...
 }
);

Community

Keep track of development and community news.