一切都
很好,我可以在本地wamp服务器中激活我的插件,但是当我尝试在网站上上传和激活我的插件时,我得到了一个致命的错误,说找不到类。
我试图在我的网站上使用ssh运行作曲家init和作曲家安装,但不起作用
这是我的主要插件PHP文件:
if( file_exists( dirname(__FILE__) . '/vendor/autoload.php'))
require_once plugin_dir_path(__FILE__) . '/vendor/autoload.php';
function activate_aa_test()
{
IncBaseActivate::activate();
}
function deactivate_aa_test()
{
IncBaseDeactivate::deactivate();
}
register_activation_hook(__FILE__, 'activate_aa_test');
register_deactivation_hook(__FILE__, 'deactivate_aa_test');
这是作曲家.json
"name": "vahid/aa-test",
"description": "test",
"type": "project",
"license": "GPL",
"authors": [
{
"name": "Vahid",
"email": "test@test.com"
}
],
"minimum-stability": "dev",
"require": {},
"autoload": {
"psr-4": {"Inc\": "./inc"}
}
}
这些是WordPress错误:
Fatal error: Uncaught Error:
Class 'IncBaseActivate' not found in /home/vahidsapp/public_html/wp-content/plugins/aa-test/aa-test.php:34
Stack trace: #0 /home/vahidsapp/public_html/wp-includes/class-wp-hook.php(286): activate_aa_test('')
#1 /home/vahidsapp/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array)
#2 /home/vahidsapp/public_html/wp-includes/plugin.php(465): WP_Hook->do_action(Array)
#3 /home/vahidsapp/public_html/wp-admin/plugins.php(177): do_action('activate_aa-tes...')
#4 {main} thrown in /home/vahidsapp/public_html/wp-content/plugins/aa-test/aa-test.php on line 34
我发现了问题,我必须将类映射添加到 composer.json 中:
"require": {},
"config": {
"optimize-autoloader": true
},
"autoload": {
"psr-4": {"Inc\": "./inc"},
"classmap": ["inc/"]
}