mundschenk-at / check-wp-requirements
一个类,允许WordPress插件在激活前检查某些运行时要求。
v2.0.0
2019-06-25 17:42 UTC
Requires
- php: >=5.2.0
Requires (Dev)
- brain/monkey: ^2.0@dev
- dealerdirect/phpcodesniffer-composer-installer: ^0.5
- mikey179/vfsstream: ~1
- phpcompatibility/php-compatibility: ^9.0
- phpunit/phpunit: 5.*|6.*|7.*
- squizlabs/php_codesniffer: ^3.0
- wp-coding-standards/wpcs: ^2.0
README
WordPress插件的辅助类,用于检查PHP版本和其他要求。
要求
- PHP 5.6.0 或更高版本
- WordPress 5.2 或更高版本。
安装
通过Composer使用此包是最佳方式
$ composer require mundschenk-at/check-wp-requirements
基本用法
- 创建一个
\Mundschenk\WP_Requirements
对象,并在构造函数中设置要求。 - 调用
\Mundschenk\WP_Requirements::check()
方法,如果返回true
则正常启动插件。
// Set up autoloader. require_once __DIR__ . '/vendor/autoload.php'; /** * Load the plugin after checking for the necessary PHP version. * * It's necessary to do this here because main class relies on namespaces. */ function run_your_plugin() { $requirements = new \Mundschenk\WP_Requirements( 'Your Plugin Name', __FILE__, 'your-textdomain', [ 'php' => '5.6.0', 'multibyte' => true, 'utf-8' => false, ] ); if ( $requirements->check() ) { // Autoload the rest of your classes. // Create and start the plugin. ... } } run_your_plugin();
许可证
check-wp-requirements 在GNU通用公共许可证2或更高版本下授权 - 请参阅LICENSE文件获取详细信息。