问题描述
当我进入wp -admin on www.newswars.org,我看到以下错误:
你能帮忙吗?
编辑:好吧,这是我的问题。
$ user_ej = wp_get_cur rent_user();
if($ user_ej-> roles [0] =='contributor')
{?>
这是36-38行。出于某种原因,它变得混乱起来。我仍然不确定问题在哪。我尝试删除?>但这给了我一个语法错误。我很茫然。这肯定是问题所在,因为只有当某人登录贡献者时才会出现。
<?php
//翻译可以归入/ lang /目录
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');
函数wpr_snap($ atts,$ content = null){
extract(shortcode_atts(array(
snap=>'http://s.wordpress.com/mshots/v1 /',
url=>'http://www.catswhocode.com',
alt=>'我的图片',
w=> '400',//宽度
h=>'300'//高度
),$ atts));
$ img ='< img src =''。$ snap。''。urlencode($ url)。'?w ='。$ w。'& h ='。$ h ''alt =''。$ alt。'/>';
返回$ 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($ translation){
$ translated = str_ireplace('Posts','VIDEOS',$ translation); // ireplace只有PHP5
return $翻译;
}
//取消注释以测试您的本地化,确保输入正确的语言代码。
// function test_localization($ locale){
// returnnl_NL;
//}
// add_filter('locale','test_localization');
//向页面添加类别
add_action('admin_init','reg_tax');
函数reg_tax(){
register_taxonomy_for_object_type('category','page');
add_post_type_support('page','category');
}
add_action('admin_footer','my_admin_footer');
函数my_admin_footer()
{
$ uri = isset($ _ SERVER ['REQUEST_URI'])? $ _SERVER ['REQUEST_URI']:NULL;
$ message = NULL;
$ b $ if($ uri AND strpos($ uri,'edit.php'))
{
if(strpos($ uri,'post_type = page'))
{
$ message ='1.在'视频嵌入代码'部分,输入视频嵌入代码。 2.在下面的主面板中输入标题和文字。 3.选择哪个大陆和类别最适合您的视频。 4.按发布;
}
else
{
$ message ='ALL VIDEOS';
$ b $ else if $($ uri和strpos($ uri,'post-new.php'))
{
if(strpos( $ uri,'post_type = page'))
{
$ message ='在此处添加页面';
}
else
{
$ message ='1.在'视频嵌入代码'部分,输入视频嵌入代码。 2.在下面的主面板中输入标题和文字。 3.选择哪个大陆和类别最适合您的视频。 4.按发布;
$ b $ elseif($ uri和strpos($ uri,'post.php'))
{
$ message ='THREE' ;
}
if($ message)
{
?>< script>
jQuery(函数($)
{
$('< div style =margin-bottom:15px; color:#FF0000;>< / div>')。 text('<?php echo $ message;?>')。insertAfter('#wpbody-content .wrap h2:eq(0)');
});
< / script><?php
}
}
?>
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');
不在函数内。所以只要文件加载就会被调用。这意味着所有的输出立即发送到屏幕上。这些东西应该放在一个函数中,然后在正确的时间调用(像其他位一样)。
When I go into wp-admin on www.newswars.org, I see the following error:
Can you please help?
EDIT: Ok its this that is causing me the problem.
$user_ej = wp_get_current_user();
if ($user_ej->roles[0] == 'contributor')
{ ?>
This is 36-38 lines. For some reason its getting all messed up. Still I'm not quite sure what the problem is. I tried removing ?> but that gave me a syntax error. I'm at a loss. It is definitely the problem area as it only comes up when someone logs in a 'contributor'.
<?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
}
}
?>
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' );
isn't inside a function. So it's being called as soon as the file loads. This means all output is sent to the screen immediately This stuff should be inside a function which is then called at the right time (like the other bits).
这篇关于无法修改标题信息 - 标题已在WordPress中发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!