我知道还有另一个类似的问题,但我的问题看起来很奇怪。深处的字符串(如果我错了,请道歉,我是新手。)。我正在运行PHP脚本,并不断收到错误:
注意:未定义索引:默认位于D:\ SERVER-MYWEB \ InstantWP_4.3.1 \ iwpserver \ htdocs \ wordpress \ wp-content \ themes \ MYTHEME \ admin \ library \ options \ options.php 843行
第843行看起来像这样:
$value['default']['font-family']);
这里是代码:
$family = isset($option['font']) && $option['font'] ? $option['font'] :
(isset($value['default']['font-family'])?$value['default']['font-family']:
$value['default']['font-family']);
编辑完整代码:
<?php
}
function upfw_typography($value,$attr){
global $up_options,$up_fonts,$wpdb;
$option = (isset($up_options->$value['id'])?$up_options->$value['id']:'');
if(!$option):
global $default_options;
$option = isset($value['value'])?$value['value']:array();
endif;
$family = isset($option['font']) && $option['font'] ? $option['font'] : (isset($value['default']['font-family'])?$value['default']['font-family']:$value['default']['font-family']);
$fontsize = isset($option['fontsize']) && $option['fontsize'] ? $option['fontsize']: (isset($value['default']['font-size']) ? $value['default']['font-size'] : '');
$fontstyle = isset($option['fontstyle']) && $option['fontstyle'] ? $option['fontstyle']: (isset($value['default']['font-style']) ? $value['default']['font-style'] : '');
$lineheight = isset($option['lineheight']) && $option['lineheight'] ? $option['lineheight'] : (isset($value['default']['line-height']) ? $value['default']['line-height'] : '');
$texttransform = isset($option['texttransform']) && $option['texttransform'] ? $option['texttransform'] : (isset($value['default']['text-transform']) ? $value['default']['text-transform'] : '');
$fontweight = isset($option['fontweight']) && $option['fontweight'] ? $option['fontweight'] : (isset($value['default']['font-weight']) ? $value['default']['font-weight'] : '');
$textdecoration = isset($option['textdecoration']) && $option['textdecoration'] ? $option['textdecoration'] : (isset($value['default']['text-decoration']) ? $value['default']['text-decoration'] : '');
$textshadow = isset($option['textshadow']) && $option['textshadow'] ? $option['textshadow'] : (isset($value['default']['text-shadow']) ? $value['default']['text-shadow'] : '');
$letterspacing = isset($option['letterspacing']) && $option['letterspacing'] ? $option['letterspacing'] : (isset($value['default']['letter-spacing']) ? $value['default']['letter-spacing'] : '');
$show_selector = (isset($value['show_selector']) ? $value['show_selector'] : '');
$selector = isset($option['selector']) && $option['selector'] ? $option['selector'] : (isset($value['selector']) ? $value['selector'] : '');
$fonts = $up_fonts; ?>
有解决这些错误的快速解决方法吗? 非常感谢任何帮助
谢谢
答案 0 :(得分:0)
在使用之前,您应该检查default
索引:
if(isset($value['default'])) {
//your code here
$family = isset($option['font']) && $option['font'] ? $option['font'] :
(isset($value['default']['font-family'])?$value['default']['font-family']:
$value['default']['font-family']);
}
答案 1 :(得分:0)
怎么样?
$family = (isset($option['font']) && $option['font'])? $option['font'] :((isset($value['default']))?((isset($value['default']['font-family']))?$value['default']['font-family']:"Arial"):"Arial");