我在本地创建了一个自定义的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';
}
}
如何激活我的插件,到底需要更改什么?
答案 0 :(得分:0)
dirname仅接受一个参数,您正在传递两个参数。即必须为dirname(__FILE__)