【问题标题】:Can't upload my custom plugin because of a Warning: dirname()由于警告无法上传我的自定义插件:dirname()
【发布时间】: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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多