WordPress - 'strpos() empty needle'和'cannot modify header'警告



几个月前,我在.htaccess文件中放置了一个301重定向规则,用于将所有www请求重定向到non-www请求。

问题是两天前,当我试图使用www.example.net访问我的example.net网站时,我在页面中收到以下警告,并且网站未加载。

https://i.stack.imgur.com/nXBMF.png

以下是相应的行:

1.Plugin.php第647行=if ( strpos( $file, $realdir ) === 0 ){

全功能:

/**
 * Gets the basename of a plugin.
 *
 * This method extracts the name of a plugin from its filename.
 *
 * @since 1.5.0
 *
 * @param string $file The filename of plugin.
 * @return string The name of a plugin.
 */
function plugin_basename( $file ) {
    global $wp_plugin_paths;
    foreach ( $wp_plugin_paths as $dir => $realdir ) {
        if ( strpos( $file, $realdir ) === 0 ) { /** LINE 646 */
            $file = $dir . substr( $file, strlen( $realdir ) );
        }
    }
    $file = wp_normalize_path( $file );
    $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
    $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR );
    $file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir
    $file = trim($file, '/');
    return $file;
}

2.Plugable.php第1178行=header("Location: $location", true, $status);

完整文件:http://pastebin.com/0zMJZxV0

我使用WordPress只是为了写一些文章。我的PHP知识非常基础,仅限于查找错误。

请帮我解决这个问题。正如我从CodexFAQ中读到的,他们说空字符串可能是pluggable.php错误的罪魁祸首。但我不知道如何找到它,我已经附上了文件供您参考。

请提供您的建议以避免将来出现此错误。提前谢谢。

3.EDIT-wp setting文件:(错误行-include_once( $plugin );

// Load active plugins.
foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
    wp_register_plugin_realpath( $plugin );
    include_once( $plugin );
}
unset( $plugin );

此处讨论了标头信息的问题:无法修改Wordpress中的标头信息错误。你能试试看这是否能解决你的这部分问题吗?。

关于另一个问题:尝试var_dump ($file)(例如--或echo$file)来查看它们实际包含的内容。

检查插件的配置路径:

var_dump($wp_plugin_paths);

由于$realdir为空,您出现错误。

相关内容

最新更新