luizbills/wp-options-page
Composer 安装命令:
composer require luizbills/wp-options-page
包简介
Easy way to build options/settings pages in your WordPress plugins and themes.
README 文档
README
A class to build options pages for your WordPress plugins and themes.
Install
Install using composer:
composer require luizbills/wp-options-page
Getting Started
Just create an WP_Options_Page class instance on init action hook:
function yourprefix_create_settings_page () { $page = new WP_Options_Page(); // give your page a ID $page->id = 'my_settings_page'; // set the menu name $page->menu_title = 'My Settings'; // register your options fields $page->fields = [ // a simple text input field [ 'id' => 'api_key', 'title' => 'API Key', 'type' => 'text', ] ]; // register the page $page->init(); // access the stored options $api_key = $page->get_option( 'api_key' ); // store this page in a global object or variable // So you can easily your instance class later // example: My_Plugin->settings = $page; } add_action( 'init', 'yourprefix_create_settings_page' );
Or create your own derived class:
class My_Settings_Page extends WP_Options_Page { // I recommend using Singleton pattern // So you can easily retrieve the class later // example: My_Settings_Page::instance()->get_option( 'api_key' ); private static $instance = null; public static function instance () { if ( ! self::$instance ) self::$instance = new self(); return self::$instance; } private function __construct () { add_action( 'init', [ $this, 'init' ] ); } // overrides the `init` method to setup your page public function init () { // give your page a ID $this->id = 'my_settings_page'; // set the menu name $this->menu_title = 'My Settings'; // register the page parent::init(); } // overrides the `get_fields` method to register your fields public function get_fields () { return [ [ 'id' => 'api_key', 'title' => 'API Key', 'type' => 'text', ] ]; } } // start your class My_Settings_Page::instance();
Preview:
Learn More
Visit our wiki or study (and install) our Demo Plugin.
LICENSE
GPLv2 or later
luizbills/wp-options-page 适用场景与选型建议
luizbills/wp-options-page 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 758 次下载、GitHub Stars 达 26, 最近一次更新时间为 2023 年 01 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「library」 「wordpress」 「options」 「Settings」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 luizbills/wp-options-page 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 luizbills/wp-options-page 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 luizbills/wp-options-page 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Lightweight configuration interfaces and utilities
This extension provide application configuration support stored in database.
Array wrapper that eases the retrieval of values. Has parameters, options and settings and traits for inclusion in other libraries.
Inbox pattern process implementation for your Laravel Applications
Create database based options for your laravel projects
GUI for appui configuration
统计信息
- 总下载量: 758
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 26
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2023-01-28
