我在wordpress网站上收到以下错误。知道我们做错了什么吗?这是在我们升级到WP 4.1.5
时开始的注意:未定义的变量:第332行的/custom_helpers.php中的arr警告:第332行的/custom_helpers.php中为foreach()提供的参数无效注意:未定义的变量:第332行的/custom_helpers.php中的arr警告:在第332行的/custom_helpers.php中为foreach()提供的参数无效注意:在第339行的/custom_helpers.php中,类stdClass的对象无法转换为int注意:类stdClass的对象无法在/ custom_helpers中转换为int第345行的.php
这是第332行
function filter_pr_review( $field, $content ) {
if( empty($content) )
{
if($field == 'lens_shift') return 'No';
return false;
}
if( is_array( $content ) )
{
return $content->name;
}
else
{
foreach ($arr as $key => $value) {
if( $key === $field )
{
return $content->name;
}
}
if ($content == 0)
{
return $content;
//return $content->name;
//return '0';
}
elseif($content == 1)
{
//return '1';
//return $value;
return $content->name;
//return $content[1];
}
这是生成表格的代码
$specs = array(
'model_number' => 'Projector Model',
'technology' => 'Technology',
'price' => 'Price',
'brightness' => 'Brightness (Manufacturer Claim)',
'contrast' => 'Contrast Ratio',
'native_resolution' => 'Native Resolution',
'max_resolution' => 'Max Resolution',
'3d' => '3D',
'aspect_ratio' => 'Native Aspect Ratio',
'video_compatibility' => 'Video Compatibility',
'hdtv' => 'HDTV',
'lamp_life' => 'Lamp Life',
'noise_level' => 'Noise Level (-db)',
'audio' => 'Audio',
'hdmi_dvi' => 'DVI or HDMI',
'power_zoom/focus' => 'Power Zoom/Focus',
'lens_shift' => 'Optional Lens Shift',
'zoom_lens_ratio' => 'Zoom Lens Ratio',
'lens_shift' => 'Lens Shift',
'optional_lenses' => 'Optional Lens',
'classroom' => 'Classroom',
'wireless_networking' => 'Wireless Networking',
'dimensions' => 'Dimensions',
'weight' => 'Weight',
'warranty' => 'Warranty'
);
<table id="specs-full" class="specs-table" cellpadding="5" cellspacing="2">
<thead>
<tr>
<th class="sec-header" colspan="2"><?php echo $manufacturer . " " . get_field('model_number', $post->post_parent) ?> Specs</th>
</tr>
</thead>
<tbody>
<?php
foreach ( $specs as $spec => $title )
{
$field = get_field( $spec, $post->post_parent );
$output = filter_pr_review( $spec, get_field($spec, $post->ID) );
$override = array('3d','aspect_ratio','video_compatibility','hdtv','lamp_life','noise_level','audio','hdmi_dvi','power_zoom/focus','lens_shift','zoom_lens_ratio','lens_shift','optional_lenses','classroom','wireless_networking','dimensions','weight','warranty');
if(in_array($spec, $override))
{
if($output == '' || $output == '-') $output = 'No';
}
echo '<tr>';
echo '<td class="title">' . $title . '</td>';
echo '<td>' . $output . '</td>';
echo '</tr>';
}
?>