Php 带WordPress导航沃克功能的Stric标准误差
themeforest支持告诉我WordPress主题中有两个错误: 和 这是Php 带WordPress导航沃克功能的Stric标准误差,php,wordpress,Php,Wordpress,themeforest支持告诉我WordPress主题中有两个错误: 和 这是wp\u导航菜单walker功能: class description_walker extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args ) { global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", $depth
wp\u导航菜单walker功能:
class description_walker extends Walker_Nav_Menu
{
function start_el(&$output, $item, $depth, $args )
{
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
$class_names = ' class="'. esc_attr( $class_names ) . '"';
$output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
if($depth != 0)
{
$description = $append = $prepend = "";
}
$item_output = $args->before;
$item_output .= '<a'. $attributes .' class="external">';
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID );
$item_output .= '</a>';
$item_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
if ($item->menu_order == 1) {
$classes[] = 'first';
}
}
}
class description\u walker扩展了walker\u导航菜单
{
函数开始(&$output、$item、$depth、$args)
{
全局$wp_查询;
$indent=($depth)?str_repeat(“\t”,$depth):”;
$class_name=$value='';
$classes=空($item->classes)?array():(array)$item->classes;
$class_name=join(“”,应用_过滤器('nav_menu_css_class',数组_过滤器($classes),$item));
$class_names='class=“”.esc_attr($class_names)。”;
$output.=$indent.'';
$attributes=!empty($item->attr_title)?'title=“”.esc_attr($item->attr_title)。”:“”;
$attributes.=!empty($item->target)?'target=“”.esc_attr($item->target)。“:”;
$attributes.=!empty($item->xfn)?'rel=“”.esc_attr($item->xfn)。“:”;
$attributes.=!empty($item->url)?'href=“”.esc_attr($item->url)。“:”;
如果($depth!=0)
{
$description=$append=$prepend=“”;
}
$item_output=$args->before;
$item_输出='';
$item\u output.=$args->link\u before.apply\u过滤器('the\u title',$item->title,$item->ID);
$item_输出='';
$item_output.=$args->after;
$output.=apply_filters('walker_nav_menu_start_el'、$item_output、$item、$depth、$args);
如果($item->menu\u order==1){
$classes[]=“第一”;
}
}
}
问题是我的WordPress没有显示这个错误。我已将WordPress 3.8.1和
WP_DEBUG`设置为true
第一个错误似乎已修复更改此行:函数开始(&$output,$item,$depth=0,$args=array(),$id=0)
。
第二个错误我已经改变了$item\u output=$args->before代码>至$item_output=$args['before']代码>但这会导致错误:
致命错误:无法在第338行的/home/codetoco/public\u html/wp content/themes/quins/functions.php中将stdClass类型的对象用作数组
为什么他们会犯错误而不是我?如何修复此错误
第二个错误是我更改了$item_output=$args->before;到
$item_output=$args['before'];但这会导致一个错误:
致命错误:无法将stdClass类型的对象用作中的数组
/home/codetoco/public_html/wp content/themes/quins/functions.php on
第338行
这是因为$args是一个对象而不是数组,所以您需要使用->
而不是[]
您可能还想查看以了解有关在PHP中启用错误报告的更多信息。它确实有助于在开发过程中启用错误报告,因为它会在您出错时立即通知您。但在将代码推送到实时服务器时,一定要禁用它,因为这可能会导致泄漏您不想让外界知道的信息。“为什么他们会收到错误而不是我?”他们看到错误,因为E_都包括从PHP 5.4开始的E_严格要求。