PHPackages                             arraypress/wp-stasher - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. arraypress/wp-stasher

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

arraypress/wp-stasher
=====================

A utility for capturing and storing WordPress filter values for later use within the same request.

10PHP

Since Nov 30Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/arraypress/wp-stasher)[ Packagist](https://packagist.org/packages/arraypress/wp-stasher)[ RSS](/packages/arraypress-wp-stasher/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Stasher
=======

[](#stasher)

A lightweight utility for capturing WordPress filter values and making them available later in the same request.

Installation
------------

[](#installation)

```
composer require arraypress/stasher
```

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

```
// Capture all parameters from a filter
stash( 'my_plugin_filter' );

// Use the values later
$value = stashed( 'my_plugin_filter', 0 );  // First parameter
$all   = stashed( 'my_plugin_filter' );     // All parameters
```

### Named Parameters

[](#named-parameters)

```
// Store with named parameters for readability
stash( 'affwp_get_affiliate_rate', [ 'rate', 'affiliate_id', 'type', 'reference' ] );

// Access by name
$rate = stashed( 'affwp_get_affiliate_rate', 'rate' );
$type = stashed( 'affwp_get_affiliate_rate', 'type' );
```

### Store Only Once

[](#store-only-once)

```
// Only store the first time the filter runs
stash( 'my_filter', [], true );
```

### Required Parameters

[](#required-parameters)

```
// Only store when specific parameters have values
stash(
    'affwp_get_affiliate_rate',
    [ 'rate', 'affiliate_id', 'type', 'reference' ],
    false,
    [ 'rate', 'reference' ]  // Both must be non-empty
);
```

### Real World Example

[](#real-world-example)

```
// Capture the affiliate rate from an early filter
add_action( 'init', function() {
    stash(
        'affwp_get_affiliate_rate',
        [ 'rate', 'affiliate_id', 'type', 'reference' ],
        true,
        [ 'rate' ]
    );
});

// Use the rate later in a different filter
add_filter( 'affwp_calc_referral_amount', function( $amount ) {
    $rate = stashed( 'affwp_get_affiliate_rate', 'rate' );

    if ( $rate !== null ) {
        $amount = $amount * $rate;
    }

    return $amount;
});
```

### Checking and Clearing

[](#checking-and-clearing)

```
// Check if values exist
if ( has_stashed( 'my_filter' ) ) {
    // Use the values
}

// Clear specific filter
clear_stashed( 'my_filter' );

// Clear all stored values
clear_stashed();
```

### Using the Class Directly

[](#using-the-class-directly)

```
use ArrayPress\Stasher\Stasher;

Stasher::stash( 'my_filter', [ 'param1', 'param2' ] );
$value = Stasher::get( 'my_filter', 'param1' );

Stasher::has( 'my_filter' );   // Check if exists
Stasher::clear( 'my_filter' ); // Clear specific
Stasher::clear();              // Clear all
Stasher::all();                // Get all stashed values
Stasher::keys();               // List all filter names
```

Functions
---------

[](#functions)

FunctionDescription`stash( $filter, $names, $once, $required )`Capture filter values`stashed( $filter, $key )`Get stashed values`has_stashed( $filter )`Check if filter has values`clear_stashed( $filter )`Clear stashed valuesRequirements
------------

[](#requirements)

- PHP 7.4+
- WordPress 5.0+

License
-------

[](#license)

GPL-2.0-or-later

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance48

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd6eb8aff0903d87eb674d1ba3c5f3653899c0d7661504eb0deb7798ed86b643?d=identicon)[arraypress](/maintainers/arraypress)

---

Top Contributors

[![arraypress](https://avatars.githubusercontent.com/u/22668877?v=4)](https://github.com/arraypress "arraypress (9 commits)")

### Embed Badge

![Health badge](/badges/arraypress-wp-stasher/health.svg)

```
[![Health](https://phpackages.com/badges/arraypress-wp-stasher/health.svg)](https://phpackages.com/packages/arraypress-wp-stasher)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
