Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 需要一次wordpress错误与插件\u url_Php_Wordpress - Fatal编程技术网

Php 需要一次wordpress错误与插件\u url

Php 需要一次wordpress错误与插件\u url,php,wordpress,Php,Wordpress,我正在为wordpress开发一个自定义插件,向用户显示维护模式屏幕。我遵循了指南,但在调试代码时遇到了一些问题。 xdebug将向我显示以下错误: 警告:require_once():http://wrapper在服务器配置中被allow_url_include=0禁用 警告:require_once():无法打开流:找不到合适的包装器 致命错误:require_once():无法打开所需的“”(include_path='。:/usr/local/php5/lib/php') 我正在使用pl

我正在为wordpress开发一个自定义插件,向用户显示维护模式屏幕。我遵循了指南,但在调试代码时遇到了一些问题。 xdebug将向我显示以下错误:

警告:require_once():http://wrapper在服务器配置中被allow_url_include=0禁用

警告:require_once():无法打开流:找不到合适的包装器

致命错误:require_once():无法打开所需的“”(include_path='。:/usr/local/php5/lib/php')

我正在使用
plugins\u url
加载保存maintenance.php文件的路径,在出现错误之前,我正在使用
plugins\u dir\u path
但结果相同

有解决办法吗

class Maintenance {

  public function init()
  {
    add_action( 'wp_loaded', array($this, 'maintenance_mode') );
    //add_action( 'admin_init', array($this, 'maintenance_settings') );
  }

  public function maintenance_mode()
  {
    global $pagenow;
    if( $pagenow !== 'wp-login.php' && !current_user_can('manage_options') && !is_admin() ){
      header( $_SERVER['SERVER_PROTOCOL'] . '503 Service Temporarily Unavailable', true, 503 );
      header( 'Content-Type: text/html; charset=utf-8' );
      require_once plugins_url('assets/maintenance.php' ,__FILE__);
    }
    die();
  }
}
您可以使用:

require_once dirname( __FILE__ ) . '/assets/maintenance.php'
而不是

require_once plugins_url('assets/maintenance.php' ,__FILE__);

尝试使用
插件目录路径(\uuuu文件)


为什么要包含来自其他服务器的文件?您是否意识到这将服务于呈现的内容,而不包括这些文件的源代码?上述答案在我的情况下有效,但您必须在声明函数后使用文件名,例如:plugin_dir_path(FILE)。'single-job-detail-page.php';
class Maintenance {

    public function init()
    {
        add_action( 'wp_loaded', array($this, 'maintenance_mode') );
        //add_action( 'admin_init', array($this, 'maintenance_settings') );
    }

    public function maintenance_mode()
    {
        global $pagenow;
        if( $pagenow !== 'wp-login.php' && !current_user_can('manage_options') && !is_admin() ){
            header( $_SERVER['SERVER_PROTOCOL'] . '503 Service Temporarily Unavailable', true, 503 );
            header( 'Content-Type: text/html; charset=utf-8' );
            require_once plugin_dir_path( __FILE__ ) . 'assets/maintenance.php';
        }
        die();
    }
}