当我在www.newswars.org上访问wp-admin时,我看到以下错误:
警告:无法修改标头信息 - 已经发送的标头(/home/newswars/public_html/wp-content/themes/videoplus/functions.php:38中的输出)/ home / newswars / public_html / wp-includes第563行/option.php
警告:无法修改标头信息 - 已经发送的标头(/home/newswars/public_html/wp-content/themes/videoplus/functions.php:38中的输出)/ home / newswars / public_html / wp-includes第564行的/option.php
你能帮忙吗?
编辑:好的,这就是问题所在。$user_ej = wp_get_current_user();
if ($user_ej->roles[0] == 'contributor')
{ ?>
这是36-38行。由于某些原因,它搞砸了。我还不太清楚问题是什么。我试过删除?>但这给了我一个语法错误。我不知所措。这绝对是问题领域,因为只有当有人登录“贡献者”时才会出现。
<?php
// Translations can be filed in the /lang/ directory
load_theme_textdomain( 'themejunkie', TEMPLATEPATH . '/lang' );
require_once(TEMPLATEPATH . '/includes/sidebar-init.php');
require_once(TEMPLATEPATH . '/includes/custom-functions.php');
require_once(TEMPLATEPATH . '/includes/post-thumbnails.php');
require_once(TEMPLATEPATH . '/includes/theme-postmeta.php');
require_once(TEMPLATEPATH . '/includes/theme-options.php');
require_once(TEMPLATEPATH . '/includes/theme-widgets.php');
require_once(TEMPLATEPATH . '/functions/theme_functions.php');
require_once(TEMPLATEPATH . '/functions/admin_functions.php');
function wpr_snap($atts, $content = null) {
extract(shortcode_atts(array(
"snap" => 'http://s.wordpress.com/mshots/v1/',
"url" => 'http://www.catswhocode.com',
"alt" => 'My image',
"w" => '400', // width
"h" => '300' // height
), $atts));
$img = '<img src="' . $snap . '' . urlencode($url) . '?w=' . $w . '&h=' . $h . '" alt="' . $alt . '"/>';
return $img;
}
add_shortcode("snap", "wpr_snap");
$user_ej = wp_get_current_user();
if ($user_ej->roles[0] == 'contributor')
{ ?>
<style type="text/css">
#menu-dashboard, #toplevel_page_wpcf7, #menu-tools
{
display:none;
}
</style>
<?php }
add_filter( 'gettext', 'change_post_to_portfolio' );
add_filter( 'ngettext', 'change_post_to_portfolio' );
function change_post_to_portfolio( $translated ) {
$translated = str_ireplace( 'Posts', 'VIDEOS', $translated ); // ireplace is PHP5 only
return $translated;
}
// Uncomment this to test your localization, make sure to enter the right language code.
// function test_localization( $locale ) {
// return "nl_NL";
// }
// add_filter('locale','test_localization');
// Adds categories to pages
add_action('admin_init', 'reg_tax');
function reg_tax() {
register_taxonomy_for_object_type('category', 'page');
add_post_type_support('page', 'category');
}
add_action('admin_footer', 'my_admin_footer');
function my_admin_footer()
{
$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : NULL ;
$message = NULL;
if ($uri AND strpos($uri,'edit.php'))
{
if (strpos($uri,'post_type=page'))
{
$message = '1.In the ‘Video Embed Code section,’ enter the video embed code. 2.Enter the title and text in the main panel below. 3.Choose which continent and category is most fitting for your video. 4.Press ‘Publish’';
}
else
{
$message = 'ALL VIDEOS';
}
}
elseif ($uri AND strpos($uri,'post-new.php'))
{
if (strpos($uri,'post_type=page'))
{
$message = 'Add pages here';
}
else
{
$message = '1.In the ‘Video Embed Code section,’ enter the video embed code. 2.Enter the title and text in the main panel below. 3.Choose which continent and category is most fitting for your video. 4.Press ‘Publish’';
}
}
elseif ($uri AND strpos($uri,'post.php'))
{
$message = 'THREE';
}
if ($message)
{
?><script>
jQuery(function($)
{
$('<div style="margin-bottom:15px; color:#FF0000;"></div>').text('<?php echo $message; ?>').insertAfter('#wpbody-content .wrap h2:eq(0)');
});
</script><?php
}
}
?>
答案 0 :(得分:0)
add_shortcode("snap", "wpr_snap");
$user_ej = wp_get_current_user();
if ($user_ej->roles[0] == 'contributor')
{ ?>
<style type="text/css">
#menu-dashboard, #toplevel_page_wpcf7, #menu-tools
{
display:none;
}
</style>
<?php }
add_filter( 'gettext', 'change_post_to_portfolio' );
add_filter( 'ngettext', 'change_post_to_portfolio' );
不在函数内部。因此,只要文件加载就会调用它。这意味着所有输出都立即发送到屏幕。这个东西应该在一个函数内,然后在正确的时间调用(就像其他位一样)。