piotrpress/wordpress-plugin
Composer 安装命令:
composer require piotrpress/wordpress-plugin
包简介
This library is WordPress plugin singleton base class with methods to get data from plugin's header fields.
README 文档
README
This library is WordPress plugin singleton base class with methods to get data from plugin's header fields.
Installation
composer require piotrpress/wordpress-plugin
Usage
/** * Plugin Name: Example Plugin * Plugin URI: https://example.com/plugin/ * Description: Example Plugin description. * Version: 1.0.0 * Requires at least: 6.2.2 * Requires PHP: 7.4 * Author: John Smith * Author URI: https://example.com/plugin/author/ * License: GPL v3 or later * License URI: https://www.gnu.org/licenses/gpl-3.0.txt * Update URI: https://example.com/plugin/update/ * Text Domain: example-plugin * Domain Path: /languages */ require __DIR__ . '/vendor/autoload.php'; use PiotrPress\WordPress\Plugin; class Example extends Plugin { public function activation() : void {} public function deactivation() : void {} } Example::getInstance( __FILE__ ); echo Example::getName();
NOTE: Plugin's translations are loaded automatically according to Text Domain and Domain Path plugin's header fields.
Methods
Basic static methods handling plugin's default header fields
getName()- returnsstringwith the name of the plugin fromPlugin Nameheader fieldgetPluginURI()- returnsstringwith the home page of the plugin or emptystringifPlugin URIheader field is not setgetVersion()- returnsstringwith the current version number of the plugin or emptystringifVersionheader field is not setgetDescription()- returnsstringwith a short description of the plugin or emptystringifDescriptionheader field is not setgetAuthor()- returnsstringwith the name of the plugin author or emptystringifAuthorheader field is not setgetAuthorURI()- returnsstringwith the website of the plugin's author or emptystringifAuthor URIheader field is not setgetTextDomain()- returnsstringwith the gettext text domain of the plugin or directory name of the plugin ifText Domainheader field is not setgetDomainPath()- returnsstringwith the path to translations directory or emptystringifDomain Pathheader field is not setgetNetwork()- returnsboolwhether the plugin can only be activated network-wide according toNetworkheader fieldgetRequiresWP()- returnsstringwith the lowest WordPress version that the plugin will work on or emptystringifRequires at leastheader field is not setgetRequiresPHP()- returnsstringwith the minimum required PHP version or emptystringifRequires PHPheader field is not setgetUpdateURI()- returnsstringwith third-party plugin's update server or emptystringifUpdate URIheader field is not setRequiresPlugins()- returnsstringwith the comma-separated list of WordPress.org-formatted slugs for its dependencies or emptystringifRequires Pluginsheader field is not set
Additional static methods handling plugin's paths
getSlug()- returnsstringwith the sanitized name of the plugingetPrefix()- returnsstringwith the prefix for plugin's hooksgetFile()- returnsstringwith the path to main plugin's filegetDir()- returnsstringwith the path to plugin's directorygetUrl()- returnsstringwith the url to plugin's directorygetBaseName()- returnsstringwith the basename of the plugingetDirName()- returnsstringwith the directory name of the plugin
Inherited Singleton's static methods
getInstance()- returns the instance of the Plugin class
Abstract methods handling plugin's de/activation
activation()- executed while plugin activationdeactivation()- executed while plugin deactivation
Handling custom plugin's header fields
- Add WordPress support for extra plugin's header fields using
extra_plugin_headersfilter:
add_filter( 'extra_plugin_headers', function () { return [ 'License', 'License URI' ]; } );
- Add methods to handle extra plugin's header fields:
class Example extends Plugin { public static function getLicenseURI() { return self::get( 'License URI' ); } }
NOTE: get prefixed methods are automagically created for plugin's header fields that meet valid function name rules. e.g. getLicense() method.
Requirements
PHP >= 7.4 version.
License
piotrpress/wordpress-plugin 适用场景与选型建议
piotrpress/wordpress-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 120 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 11 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugins」 「plugin」 「bootstrap」 「template」 「wordpress」 「boilerplate」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 piotrpress/wordpress-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 piotrpress/wordpress-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 piotrpress/wordpress-plugin 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Views for the package MedicOneSystems Livewire Datatables with Bootstrap 4
bootstrap select field module implementing http://silviomoreto.github.io/bootstrap-select/
Selectize Theme for Bootstrap 4
Plugin for YOURLS. Default tools to use in some laemmi plugins
Cross browser time implementation using CSS and JQuery. Compatible with Twitter Bootstrap
统计信息
- 总下载量: 120
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2021-11-26