Download the PHP package storepress/admin-utils without Composer
On this page you can find all versions of the php package storepress/admin-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download storepress/admin-utils
More information about storepress/admin-utils
Files in storepress/admin-utils
Package admin-utils
Short Description Utility Classes for WordPress Plugin Projects.
License GPL-2.0-or-later
Homepage https://github.com/EmranAhmed/storepress-admin-utils#readme
Informations about the package 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
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
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
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
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
StorePress Admin Utils includes a robust module for managing plugin updates from a custom, non-WordPress.org 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
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
A key feature is the ability to roll back a plugin to a previous version.
Simple DI Container
Simple DI Container with singleton and factory support.
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
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
The settings framework can automatically expose plugin settings via the WordPress REST API.
Endpoints
It creates REST API endpoints for fetching settings, allowing for headless WordPress implementations or integration with other applications.
Configuration
Developers can easily enable or disable this feature and customize the API namespace and version.
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
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
Usage
Plugin entry file plugin-example.php
Sample includes/functions.php file
Sample includes/Plugin.php class file
Sample ServiceProviders class
AbstractSettings class usages example
SettingsServiceProvider class example.
Settings REST API
- URL will be:
/wp-json/<get_page_slug>/<rest_api_version>/<rest_api_base> - Default IS:
/wp-json/<get_page_slug>/<rest_api_version>/<rest_api_base> - Example:
/wp-json/plugin-example/v1/settings
WordPress Data Store Usages example
NOTE: If menu_slug return as sub-menu like:
It will create like:
NOTE: You can override methods show_in_rest(), rest_api_base(), get_menu_slug(), get_page_slug() from Settings class or in AdminPage class.
- See: @wordpress/core-data
Settings Section data structure
Field data options
AbstractProPluginInCompatibility class usages example
- Show notice for incompatible pro or extended plugin.
AbstractUpdater class usages example
-
NOTE: Update server and plugin SHOULD NOT be in same WordPress setup.
-
You must add
Update URI:on plugin file header to perform update. - It's highly RECOMMENDED to use
httpsprotocol forUpdate URI:server.
AbstractDeactivationFeedback class usages example
ServiceContainer class usages example
Sample Cache class
StorePress\AdminUtils\Abstracts\AbstractCacheis a base class for caching data in your plugin.- It automatically uses the persistent object cache (Redis, Memcached) when one is available, and transparently falls back to versioned WordPress transients otherwise
- so you write your caching logic once and it works on any host.
- When no persistent object cache is present,
AbstractCachestores each value alongside a group version token (based ontime()). - On read, it compares the stored version against the current group version — if they differ, the value is treated as a miss.
- Calling
flush()regenerates the token, so every old entry is invalidated at once without per-key deletes. - This is why you should always go through
get()/set()rather than touching transients directly — the version wrapper is what makes group invalidation work.
Store and retrieve data
- Use
set()to store andget()to read. Values can be strings or arrays. get()returnsfalseon a miss. Usehas()/is_empty()to branch cleanly
Preparing Pro plugin-pro/plugin-pro.php version example
Preparing PluginPro class
Preparing Update Server
Preparing Feedback Server
Best Practices to write plugin based on this package
- Use Singleton Pattern - All services should use
SingletonTrait - Register Before Boot - Always register services before booting
- Lazy Loading - Services are only instantiated when resolved
- Single Responsibility - Each service handles one concern
- Extend Base Classes - Use abstract classes from AdminUtils