use*_*154 3 php wordpress configuration-files pluggable http-headers
尝试登录管理面板时遇到此错误。我无法理解它。
Warning: Cannot modify header information - headers already sent by (output started at /home/xxxxxx/public_html/wordpress/wp-config.php:1) in /home/xxxxxx/public_html/wordpress/wp-includes/pluggable.php on line 881
Run Code Online (Sandbox Code Playgroud)
pluggable.php 881:
function wp_redirect($location, $status = 302) {
global $is_IIS;
$location = apply_filters('wp_redirect', $location, $status);
$status = apply_filters('wp_redirect_status', $status, $location);
if ( !$location ) // allows the wp_redirect filter to cancel a redirect
return false;
$location = wp_sanitize_redirect($location);
if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )
status_header($status); // This causes problems on IIS and some FastCGI setups
header("Location: $location", true, $status);
}
endif;
Run Code Online (Sandbox Code Playgroud)
我使用的是最新版本的 wordpress 3.4.2。我的网站似乎工作得很好,但错误阻止我进入登录页面,这意味着我根本无法管理或卸载似乎触发了此问题的插件(dbc 备份 2)。我已经使用 HTML-kit 工具检查了 wp.config 文件数百次,并且在文件的开头和结尾都没有可见的空格。我有:
...并且错误仍然存在
唯一留给我尝试的是有人在 wordpress 论坛上发布的这段代码,声称他通过将以下代码插入 wp-config.php 文件解决了这个问题:
<?
//dont use header function in wordpress-wp_signup.php
global $domain;
global $path;
//change urlnew variable as per requirment
$urlnew = "http://".$domain.$path."/wp-admin/admin.php;
echo "<script>";
echo "location = '$urlnew';";
echo "</script>";
echo $urlnew;
?>
Run Code Online (Sandbox Code Playgroud)
我不愿意添加代码,因为我不熟悉 html 或 php,我不完全理解这段代码的功能,也没有详细的说明在哪里放置它。有什么更好的建议吗?
Themes function.php 文件是这样结束的,我应该在哪里准确插入代码?:
// include custom widget
$temp_root = get_root_directory('include/plugin/custom-widget/custom-blog-widget.php');
include_once($temp_root . 'include/plugin/custom-widget/custom-blog-widget.php');
$temp_root = get_root_directory('include/plugin/custom-widget/custom-port-widget.php');
include_once($temp_root . 'include/plugin/custom-widget/custom-port-widget.php');
$temp_root = get_root_directory('include/plugin/custom-widget/custom-port-widget-2.php');
include_once($temp_root . 'include/plugin/custom-widget/custom-port-widget-2.php');
$temp_root = get_root_directory('include/plugin/custom-widget/popular-post-widget.php');
include_once($temp_root . 'include/plugin/custom-widget/popular-post-widget.php');
$temp_root = get_root_directory('include/plugin/custom-widget/contact-widget.php');
include_once($temp_root . 'include/plugin/custom-widget/contact-widget.php');
$temp_root = get_root_directory('include/plugin/custom-widget/flickr-widget.php');
include_once($temp_root . 'include/plugin/custom-widget/flickr-widget.php');
$temp_root = get_root_directory('include/plugin/custom-widget/twitter-widget.php');
include_once($temp_root . 'include/plugin/custom-widget/twitter-widget.php');
// get the path for the file ( to support child theme )
function get_root_directory( $path ){
if( file_exists( STYLESHEETPATH . '/' . $path ) ){
return STYLESHEETPATH . '/';
}else{
return TEMPLATEPATH . '/';
}
}
?>
Run Code Online (Sandbox Code Playgroud)
如果您的当前主题目录中有 functions.php 文件,则在您的 functions.php 文件中执行以下操作
//allow redirection, even if your theme starts to send output to the browser
add_action('init', 'clean_output_buffer');
function clean_output_buffer() {
ob_start();
}
Run Code Online (Sandbox Code Playgroud)
如何删除 BOM
为了删除 BOM,Lafontaine 建议使用免费软件实用程序 XVI32,这是一个免费的十六进制编辑器。编辑器不会安装,您可以直接从 ZIP 运行 EXE 文件。这个过程很简单——只需将“受影响”的 PHP 文件(在我的例子中是 wp_config.php)拖到 XVI32 中,它就会在一个整洁的字节网格中打开。然后,您应该看到文件中的前三个字节是“”,后跟 php 标记。
如果确实如此,您应该依次选择每个字符并删除它(按 Del 键)。当您保存 (Ctrl+S) 文件时,它将与以前完全相同,只是没有前导 BOM。
完整文章链接:http : //blog.scribz.net/2010/12/windows-live-writer-wordpress-unicode-bom-error/