PHPackages                             underpin/option-loader - 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. underpin/option-loader

ActiveLibrary

underpin/option-loader
======================

Option loader for Underpin

1.1.0(4y ago)13271[1 issues](https://github.com/Underpin-WP/option-loader/issues)2GPL-2.0-or-laterPHP

Since May 6Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Underpin-WP/option-loader)[ Packagist](https://packagist.org/packages/underpin/option-loader)[ RSS](/packages/underpin-option-loader/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (3)Dependencies (1)Versions (5)Used By (2)

Underpin Option Loader
======================

[](#underpin-option-loader)

Loader That assists setting, saving, and deleting options from a WordPress website.

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

[](#installation)

### Using Composer

[](#using-composer)

`composer require underpin/option-loader`

### Manually

[](#manually)

This plugin uses a built-in autoloader, so as long as it is required *before*Underpin, it should work as-expected.

`require_once(__DIR__ . '/underpin-options/options.php');`

Setup
-----

[](#setup)

1. Install Underpin. See [Underpin Docs](https://www.github.com/underpin-wp/underpin)
2. Register new options menus as-needed.

Example
-------

[](#example)

A very basic example could look something like this.

```
// Register option
underpin()->options()->add( 'example-option', [
	'key'           => 'example-option', // required
	'default_value' => 'optional default option value',
	'name'          => 'Human-readable name',
	'description'   => 'Human-readable description',
] );
```

Alternatively, you can extend `Option` and reference the extended class directly, like so:

```
underpin()->options()->add('option-key','Namespace\To\Class');
```

Accessing Options
-----------------

[](#accessing-options)

### Basic Example

[](#basic-example)

```
// Fetch from global context
underpin()->options()->get( 'example-option')->get();
```

### Access when object is directly accessible

[](#access-when-object-is-directly-accessible)

```
// Fetch, given a meta factory
$meta = underpin()->options()->get('example-meta-field');

$meta->get( $object_id );
```

### Get all registered options

[](#get-all-registered-options)

```
// Fetch all registered options

// Typecasting options gets array of registered options objects.
$registered_options = (array) underpin()->options();
$values             = [];

foreach ( $registered_options as $key => $object ) {
	$values[ $key ] = $object->get();
}
```

### Reset all registered options

[](#reset-all-registered-options)

```
// Reset all options
$registered_options = (array) underpin()->options();

foreach($registered_user_meta as $object){
  $object->reset();
}
```

### Pluck an option value from an option stored as an array

[](#pluck-an-option-value-from-an-option-stored-as-an-array)

In WordPress, it is quite common to store a serialized array of options in-favor of creating multiple database records. Because of this, Underpin has a baked-in helper method to fetch a single value from an array of options that are stored in the database. This method makes it possible to get an option value quickly.

Given this option, where the value stored is an array:

```
underpin()->options()->add( 'example-option', [
	'key'           => 'example-option', // required
	'default_value' => [ 'item' => 'name', 'another_item' => 'another_value' ],
	'name'          => 'Human-readable name',
	'description'   => 'Human-readable description',
] );
```

You can do this, and fetch the individual values:

```
underpin()->options()->pluck( 'example-option', 'another_item' ); // 'another_value'
underpin()->options()->pluck( 'example-option', 'invalid' ); // WP_Error
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~100 days

Total

3

Last Release

1637d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e6206223bd6f2a57b8ac80605b1b5c3521faaec18ad3f20f25fb728a9a13784?d=identicon)[tstandiford](/maintainers/tstandiford)

---

Top Contributors

[![alexstandiford](https://avatars.githubusercontent.com/u/8210827?v=4)](https://github.com/alexstandiford "alexstandiford (12 commits)")

---

Tags

optionsunderpinwordpress

### Embed Badge

![Health badge](/badges/underpin-option-loader/health.svg)

```
[![Health](https://phpackages.com/badges/underpin-option-loader/health.svg)](https://phpackages.com/packages/underpin-option-loader)
```

PHPackages © 2026

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