-1

我在本地创建了一个自定义 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';
    }
}

如何激活我的插件,我到底需要更改什么?

4

1 回答 1

0

dirname 只接受一个参数,你传递了两个。即需要dirname(__FILE__)

于 2019-04-15T13:23:28.187 回答