PHPackages                             storepress/admin-utils - 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. storepress/admin-utils

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

storepress/admin-utils
======================

Utility Classes for WordPress Plugin Projects.

3.2.0(3mo ago)2980GPL-2.0-or-laterPHP

Since Nov 26Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/EmranAhmed/storepress-admin-utils)[ Packagist](https://packagist.org/packages/storepress/admin-utils)[ Docs](https://github.com/EmranAhmed/storepress-admin-utils#readme)[ RSS](/packages/storepress-admin-utils/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (15)Versions (42)Used By (0)

StorePress Admin Utils
======================

[](#storepress-admin-utils)

StorePress Admin Utils is a comprehensive PHP library for WordPress that simplifies the creation of admin interfaces for plugins. It provides a structured, object-oriented approach to building settings pages, managing plugin updates, handling rollbacks, and displaying administrative notices.

Core Features
-------------

[](#core-features)

Settings Framework
------------------

[](#settings-framework)

The library's cornerstone is its powerful settings framework, which allows developers to create complex settings pages with multiple tabs and a wide variety of field types.

### Field Types

[](#field-types)

It supports a rich set of field types including `text`, `unit`, `textarea`, `checkbox`, `toggle`,`radio`, `select`, `color`, `number`, and more advanced fields like `toggle` switches and `group` fields.

### Structure

[](#structure)

Settings are organized into sections and tabs, providing a clean and intuitive user experience. The framework handles the rendering of the entire settings page, including the navigation tabs, fields, and save/reset buttons.

### Data Management

[](#data-management)

It streamlines the process of saving, retrieving, and deleting plugin options from the database. It also includes mechanisms for data sanitization and validation.

Plugin Updater
--------------

[](#plugin-updater)

StorePress Admin Utils includes a robust module for managing plugin updates from a custom, non-WordPress.org server.

### Custom Update Server

[](#custom-update-server)

Developers can specify a URL to their own update server in the plugin's header. The library then communicates with this server to check for new versions.

### Update Process

[](#update-process)

It handles the entire update process, from checking for new versions and displaying update notifications in the WordPress admin to downloading and installing the new plugin package. The `README.md` file provides a clear example of how to set up the server-side endpoint to respond to update requests.

Plugin Rollback
---------------

[](#plugin-rollback)

A key feature is the ability to roll back a plugin to a previous version.

Simple DI Container
-------------------

[](#simple-di-container)

Simple DI Container with singleton and factory support.

### Rollback UI

[](#rollback-ui)

It adds a "Rollback" link to the plugin's action links on the plugins page. This leads to a dedicated page where the user can select a previous version to install.

### Version Management

[](#version-management)

The rollback functionality is tied into the update server, which must provide a list of available versions and their corresponding package URLs.

REST API Integration
--------------------

[](#rest-api-integration)

The settings framework can automatically expose plugin settings via the WordPress REST API.

### Endpoints

[](#endpoints)

It creates REST API endpoints for fetching settings, allowing for headless WordPress implementations or integration with other applications.

### Configuration

[](#configuration)

Developers can easily enable or disable this feature and customize the API namespace and version.

Upgrade &amp; Compatibility Notices
-----------------------------------

[](#upgrade--compatibility-notices)

The library provides a class for managing admin notices, which is particularly useful for handling compatibility issues between a primary plugin and its extensions. It can display notices in the admin area and on the plugins page if an incompatible version of an extension is detected.

Usage and Implementation
------------------------

[](#usage-and-implementation)

To use StorePress Admin Utils, developers typically extend the core classes provided by the library, such as `Settings`, `Updater`, and `Upgrade_Notice`. By implementing the abstract methods in these classes, developers can configure the library to suit their plugin's specific needs.

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

[](#installation)

```
composer require storepress/admin-utils
```

Plugin Directory Structure
--------------------------

[](#plugin-directory-structure)

```
example/
│
├── example.php                            # Main plugin entry point, registers hooks, initializes Init class
├── composer.json                          # Composer dependencies & PSR-4 autoloading configuration
├── CLAUDE.md                              # AI assistant guidance for codebase conventions
├── README.md                              # Plugin Readme file
├── CHANGELOG.md                           # Plugin Changelog file
│
└── includes/                              # PHP source files (PSR-4: StorePress\Example\)
    │
    ├── Init.php                           # Plugin bootstrap: loads autoloader, registers/boots services
    ├── functions.php                      # Utility functions.
    │
    ├── Features/                          # Feature modules
    │   ├── Blocks.php                     # Gutenberg blocks.
    │
    ├── Integrations/                      # Classes that integrate with WordPress/external systems
    │   ├── AdminPage.php                  # Base settings page with sidebar and localized strings
    │   ├── DeactivationFeedback.php       # Collects user feedback on plugin deactivation via dialog
    │   ├── ProPluginInCompatibility.php   # Checks pro plugin version compatibility (v3.0.0+)
    │   └── Updater.php                    # Handles plugin updates from custom server with rollback
    │
    ├── ServiceContainers/                 # Dependency injection
    │   └── ServiceContainer.php           # DI container singleton for registering/resolving services
    │
    ├── ServiceProviders/                  # Service registration & bootstrapping
    │   └── ServiceProvider.php            # Registers all services and boots them in correct order
    │
    └── Services/                          # Business logic services
        └── Settings.php                   # Defines admin settings tabs and fields (General, Basic, Advanced, Rest)

```

Usage
-----

[](#usage)

### Plugin entry file.

[](#plugin-entry-file)

```
