【发布时间】:2019-04-15 13:19:40
【问题描述】:
我在本地创建了一个自定义 wordpress 插件。我想把它上传到网站上,但现在当我尝试激活时出现错误。
这是错误:
Warning: dirname() expects exactly 1 parameter, 2 given in /home/x/x/x/x/x/wp-content/plugins/X-plugin/inc/Base/BaseController.php on line 18
Warning: dirname() expects exactly 1 parameter, 2 given in /home/x/x/x/x/x/wp-content/plugins/X-plugin/inc/Base/BaseController.php on line 19
Warning: dirname() expects exactly 1 parameter, 2 given in /home/x/x/x/x/x/wp-content/plugins/X-plugin/inc/Base/BaseController.php on line 20
Warning: dirname() expects exactly 1 parameter, 2 given in /home/x/x/x/x/x/wp-content/plugins/X-plugin/inc/Base/BaseController.php on line 18
Warning: dirname() expects exactly 1 parameter, 2 given in /home/x/x/x/x/x/wp-content/plugins/X-plugin/inc/Base/BaseController.php on line 19
Warning: dirname() expects exactly 1 parameter, 2 given in /home/x/x/x/x/x/wp-content/plugins/X-plugin/inc/Base/BaseController.php on line 20
我的代码是:
<?php
/**
* @package XPlugin
*/
namespace Inc\Base;
class BaseController
{
public $plugin_path;
public $plugin_url;
public $plugin;
public function __construct() {
$this->plugin_path = plugin_dir_path( dirname( __FILE__, 2 ) );
$this->plugin_url = plugin_dir_url( dirname( __FILE__, 2 ) );
$this->plugin = plugin_basename( dirname( __FILE__, 3 ) ) . '/X-plugin.php';
}
}
如何激活我的插件,我到底需要更改什么?
【问题讨论】:
标签: php wordpress plugins controller dirname