wp-forge / wp-plugin-check
检查WordPress插件是否与当前环境兼容。
1.0
2020-04-20 16:55 UTC
This package is auto-updated.
Last update: 2024-09-21 20:25:56 UTC
README
检查WordPress插件是否与当前环境兼容。如果不兼容,它将自动禁用插件并向用户显示一条消息,告知他们可以如何处理。
注意: 仅支持检查PHP 5.2及以上版本。
安装
composer require wp-forge/wp-plugin-check
使用方法
以下是代码的使用方式
<?php // Plugin headers go here... require dirname( __FILE__ ) . '/vendor/autoload.php'; // Check plugin requirements global $pagenow; if ( 'plugins.php' === $pagenow ) { $plugin_check = new WP_Forge_Plugin_Check( __FILE__ ); $plugin_check->min_php_version = '5.6'; $plugin_check->min_wp_version = '5.0'; $plugin_check->req_php_extensions = array( 'json', 'SimpleXML' ); $plugin_check->check_plugin_requirements(); } require dirname( __FILE__ ) . '/includes/bootstrap.php';
根据需要更改WordPress版本、PHP版本和所需的PHP扩展。
重要: 不要在主插件文件中加载任何其他代码! PHP在运行代码之前会解析文件中的所有代码,因此在此检查之后添加的不兼容PHP代码将抵消进行兼容性检查的能力。