PHPackages                             yivi/wp\_optional - 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. yivi/wp\_optional

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

yivi/wp\_optional
=================

A helping hand to create option pages and option fields

0.1.0(8y ago)016GPL-3.0-or-laterPHPPHP ^7.1

Since Apr 10Pushed 8y ago1 watchersCompare

[ Source](https://github.com/yivi/WpOptional)[ Packagist](https://packagist.org/packages/yivi/wp_optional)[ RSS](/packages/yivi-wp-optional/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

WP Optional
===========

[](#wp-optional)

Library to help in generating option pages for plugins and themes.

Work in progress, but the basic usage is as follows:

### PageSettings object

[](#pagesettings-object)

```
$page_settings = new PageSettings(
                 'options_id',
                 'Options Page Title',
                 'Options Menu Title',
                 'options-general.php', // options menu parent
                 'manage_options'       // capability required
             );
```

### Subpages

[](#subpages)

When settings are long enough or complex enough, you may want to separate them in different "subpages" (or tabs) to make access easier. You always need at least one subpage

```
$page_general = $page_settings->addSubpage(
    'general',
    __( 'General', TEXT_DOMAIN ),
    'manage_options'
 );
```

### Sections

[](#sections)

Each page should have 1 or more "sections" to group settings

```
$general_main = $page_general->addSection( 'main', __( 'Automatic Generation', TEXT_DOMAIN ) );
```

### Fields

[](#fields)

Fields are added to each of the sections, directly.

```
 $field = $page_general->addField(
     // string identifying the field (will be concatenated to the section, page and options id)
     $id,
     // will be used as a label for the  element
     $title,
     // this should be a class that extends AbstractField,
     $type
 );
```

#### Field Types

[](#field-types)

- TextField
- PasswordField
- TextareaField
- SelectField
- SelectMultipleField
- CheckboxField

#### Field Configuration

[](#field-configuration)

##### Description

[](#description)

Sets the optional value for a field description. If provided, will be rendered close to the field

```
$field->setDescription('This field rocks and rolls');

```

##### Default

[](#default)

Default value for the field, if the user doesn't provide one

```
 $field->setDefault('1');

```

#### Class

[](#class)

If provided, this string will be rendered in the class attribute of the field

```
 $field->setClass('mucho-clase very-nav');

```

##### Extra Attributes

[](#extra-attributes)

This should be a associative array. Each key =&gt; value combination will be rendered as an additional attribute for the field

```
 $field->setAttributes(['rows' => '30', 'data-value' => $whatever ]);

```

#### Choices

[](#choices)

This is a list of values and labels, generally used for `` or ``

```
 $field->setChoices('WS' => 'Washington', 'NY', 'New York', 'MAD' => 'Madrid');

```

#### Example

[](#example)

Since these calls are chainable, you could do:

```
$page_general->addField($id, $title, SelectField::class)
             ->setClass('optional')
             ->setAttributes($attribute_array)
             ->setChoices($choices_array);
```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Unknown

Total

1

Last Release

2995d ago

### Community

Maintainers

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

---

Top Contributors

[![yivi](https://avatars.githubusercontent.com/u/1815039?v=4)](https://github.com/yivi "yivi (11 commits)")

### Embed Badge

![Health badge](/badges/yivi-wp-optional/health.svg)

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

###  Alternatives

[imdbphp/imdbphp

Library for retrieving film and tv information from IMDb

26681.7k2](/packages/imdbphp-imdbphp)[coreproc/nova-system-info-card

A Laravel Nova card that shows you your system information.

24148.0k](/packages/coreproc-nova-system-info-card)[rymanalu/factory-generator

Laravel 5 Model Factory Generator.

178.0k](/packages/rymanalu-factory-generator)

PHPackages © 2026

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