jayjay666/wp-requirements-checker
Composer 安装命令:
composer require jayjay666/wp-requirements-checker
包简介
Utility for WordPress plugin developers to check requirements. Lightweight library class for validation PHP version, PHP extensions, plugins and theirs versions in Wordpress Plugins.
关键字:
README 文档
README
Lightweight validator library class for check PHP version, PHP extensions, plugins and theirs versions in Wordpress Plugins.
Usage
Pass the requirements to a new instance of this class like so:
use jayjay666\WPRequirementsChecker\Validator; // ... code before plugin/theme init // ... start init code with // Set PHP version, plugin root file path and plugin text domain $validator = new Validator('7.1', 'my-awesome-plugin/my-awesome-plugin.php', 'my-awesome-plugin'); // Set plugins requirements $validator->add_required_plugin('woocommerce/woocommerce','1.2.1'); $validator->add_required_plugin('elementor/elementor.php','3.0'); // Set PHP extensions requirements $validator->add_required_extensions('curl'); if (!$validator->check()) { // ... min. requirements not valid. Automatic print error & disable plugin in check() method ad break code return; } // ... if requirements is valid, run your plugin code // ... your plugin init code for start plugin
Implementation & Instalation
There are two ways you can include WP Requirements in your project.
Copy this class (not recommended)
You can copy the class found in /src/Validator.php in this project.
Important! If you choose to do so, please rename this class with the prefix used by your project (for example: from Validator to My_Plugin_Validator). In this way there is less risk of a naming collision between projects. Also change namespace!
In case you want to include the file manually, please wrap the include or require call in a class_exists conditional, like so:
// Namespace & prefix must be yours!!! if (!class_exists( 'jayjay666\WPRequirementsChecker\Validator') ) { // do the file include or require here }
Use composer (recommended way)
Include this library with:
$ composer require jayjay666/wp-requirements-checker
Usage example
use Elementor\Controls_Manager;use Elementor\Element_Section; use jayjay666\WPRequirementsChecker\Validator; class MyAwesomePlugin{ const DOMAIN = 'my-awesome-plugin'; private static $_instance = null; public static function instance() { if (is_null(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; } public function __construct() { add_action('plugins_loaded', [$this, 'init']); } public function init() { // Check requirements $validator = new Validator('7.1', 'my-awesome-plugin/my-awesome-plugin.php', MyAwesomePlugin::DOMAIN); // OR $validator = new Validator('7.1', 'my-awesome-plugin/my-awesome-plugin.php', self::DOMAIN); $validator->add_required_plugin('elementor/elementor.php','3.0'); if (!$validator->check()) { return; } // add controlls to elementor add_action('elementor/element/section/section_layout/before_section_end', [__CLASS__, 'add_section_controls']); } public static function add_section_controls(Element_Section $element) { // // Přidám responzivní pro zarovnání slopců $element->add_responsive_control( 'scb_section_horizontal_align', [ 'label' => __('Horizontal align', MyAwesomePlugin::DOMAIN), 'type' => Controls_Manager::SELECT, 'default' => '', 'options' => [ '' => __('Default', 'elementor'), 'flex-start' => __('Start', 'elementor'), 'flex-end' => __('End', 'elementor'), 'center' => __('Center', 'elementor'), 'space-between' => __('Space Between', 'elementor'), 'space-around' => __('Space Around', 'elementor'), 'space-evenly' => __('Space Evenly', 'elementor'), ], 'selectors' => [ // Zde se předají data do CSS '{{WRAPPER}} .elementor-row' => 'justify-content: {{VALUE}};', ], ] ); } }
Tested on
Minimal requirements
| Version | |
|---|---|
| PHP | 7.1 |
| WordPress | 5.5 |
jayjay666/wp-requirements-checker 适用场景与选型建议
jayjay666/wp-requirements-checker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 41 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 12 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「wordpress」 「wordpress plugin development」 「wp」 「wordpress plugin」 「WP Plugin」 「WordPress Plugin Validator」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jayjay666/wp-requirements-checker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jayjay666/wp-requirements-checker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jayjay666/wp-requirements-checker 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Debugging a problem and need to login as one of your customers? This allows you to authenticate as any of your customers.
Library with classes to help you do batch.
GHT D-Tools Bundle
nabu-3 SDK package to extend Framework with extensions for developers
Use a translation namespace vor mutliple translation files.
统计信息
- 总下载量: 41
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2020-12-27