PHPackages                             yipresser/wp-settings-api-helper - 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. yipresser/wp-settings-api-helper

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

yipresser/wp-settings-api-helper
================================

A helper class to simplify WordPress Settings and creation of Settings page in WP plugins.

v1.1.2(1mo ago)070GPL-3.0-or-laterPHPPHP &gt;=7.2

Since Apr 23Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/yipresser/wp-settings-api-helper)[ Packagist](https://packagist.org/packages/yipresser/wp-settings-api-helper)[ RSS](/packages/yipresser-wp-settings-api-helper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (19)Used By (0)

wp-settings-api-helper
======================

[](#wp-settings-api-helper)

An abstract class that simplifies the process of creating WordPress admin settings pages using the WordPress Settings API.

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

[](#installation)

You can install this package via Composer:

```
composer require yipresser/wp-settings-api-helper
```

Alternatively, you can use this class in your WordPress plugins or themes to easily define settings sections, fields, and handle their saving process.

Usage
-----

[](#usage)

To use the helper, create a new class that extends `Yipresser\WpSettingsApiHelper\WP_Settings_API_Helper`.

### 1. Extend the Class and initialize the Settings

[](#1-extend-the-class-and-initialize-the-settings)

You need to define `$settings_options` for your database options and `$settings_sections` for the visual sections and fields you want to show on the page. Lastly, you need to run the `setup()` method.

```
namespace MyPlugin\Admin;

use Yipresser\WpSettingsApiHelper\WP_Settings_API_Helper;

class My_Settings extends WP_Settings_API_Helper {

    public function __construct() {
        add_action( 'admin_init', [ $this, 'init' ] );
	}

    /**
	 * Start the engine running
	 *
	 * @return void
	 */
	public function init() {
        // Define your options
        $this->settings_options = [
            [
                'option_group' => 'my_plugin_settings_group',
                'option_name'  => 'my_plugin_settings',
                // Optional args for register_setting():
                // 'args' => [ 'sanitize_callback' => [$this, 'sanitize_settings'] ]
            ]
        ];

        // Define your sections and fields
        $this->settings_sections = [
            [
                'id'          => 'my_plugin_general_section',
                'title'       => 'General Settings',
                'description' => 'These are the general settings for the plugin.',
                'menu_slug'   => 'my_plugin_slug', // Slug of the settings page
                'option_name' => 'my_plugin_settings',
                'fields'      => [
                    [
                        'type'    => 'text',
                        'title'   => 'API Key',
                        'id'      => 'api_key',
                        'name'    => 'api_key',
                        'default' => '',
                        'desc'    => 'Enter your API key here.',
                    ],
                    [
                        'type'    => 'checkbox',
                        'title'   => 'Enable Feature',
                        'id'      => 'enable_feature',
                        'name'    => 'enable_feature',
                        'label'   => 'Check to enable',
                        'default' => 0,
                    ]
                ]
            ]
        ];
        $this->setup();
    }
}
```

### 2. Display the Settings Form

[](#2-display-the-settings-form)

When rendering your options page HTML, call the `render_settings_on_page()` method so it can generate the settings form, fields, and submit button.

```
// Assuming this is inside your admin page callback function
public function my_plugin_options_page() {
    echo '';
    echo 'My Plugin Options';

    // Pass the menu_slug used in your $settings_sections
    $my_settings->render_settings_on_page( 'my_plugin_slug' );

    echo '';
}
```

Supported Field Types
---------------------

[](#supported-field-types)

The `type` key in your field configuration supports the following values:

- `text`
- `number` (supports `min` and `max` attributes)
- `email`
- `password`
- `textarea`
- `select` (requires a `choices` array `['value' => 'Label']`)
- `radio` (requires a `choices` array)
- `checkbox` (optional `label` for text next to checkbox)
- `checkboxes` (requires a `choices` array)
- `slider-checkbox`
- `dropdown_pages`
- `hidden`
- `callback` (requires `callback` and optional `param` keys to render custom HTML)

### Example Select Field

[](#example-select-field)

```
[
    'type'    => 'select',
    'title'   => 'Select Mode',
    'id'      => 'mode',
    'name'    => 'mode',
    'choices' => [
        'light' => 'Light Mode',
        'dark'  => 'Dark Mode'
    ],
    'default' => 'light'
]
```

Sanitization and Validation
---------------------------

[](#sanitization-and-validation)

By default, a placeholder `sanitize_settings` method is provided which returns the options untouched. You need to override `sanitize_settings($option)` in your child class to safely sanitize your data before saving them to the database.

```
public function sanitize_settings( $option ) {
    if ( isset( $option['api_key'] ) ) {
        $option['api_key'] = sanitize_text_field( $option['api_key'] );
    }
    return $option;
}
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance89

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.5% 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 ~20 days

Recently: every ~35 days

Total

18

Last Release

54d ago

### Community

Maintainers

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

---

Top Contributors

[![damienoh](https://avatars.githubusercontent.com/u/3203756?v=4)](https://github.com/damienoh "damienoh (21 commits)")[![yipresser](https://avatars.githubusercontent.com/u/180925948?v=4)](https://github.com/yipresser "yipresser (1 commits)")

### Embed Badge

![Health badge](/badges/yipresser-wp-settings-api-helper/health.svg)

```
[![Health](https://phpackages.com/badges/yipresser-wp-settings-api-helper/health.svg)](https://phpackages.com/packages/yipresser-wp-settings-api-helper)
```

###  Alternatives

[commerceguys/tax

Tax library with a flexible data model, predefined tax rates, powerful resolving logic.

286763.3k](/packages/commerceguys-tax)[wordpress-premium/advanced-custom-fields-pro

Advanced Custom Fields

2713.2k1](/packages/wordpress-premium-advanced-custom-fields-pro)[camcima/php-geohash

Refactored GeoHash package

1074.0k](/packages/camcima-php-geohash)[pqrs/l5b-crud

CRUD artisan command for rappasoft/laravel-5-boilerplate

2116.4k](/packages/pqrs-l5b-crud)[phlak/colorizer

Generate persistantly unique colors from a string.

1420.4k](/packages/phlak-colorizer)

PHPackages © 2026

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