如何在Wordpress中为范围添加新值


How to add a new value to a range in Wordpress

使用此代码,我在选择框中显示0px到150px的值:

if ( ! function_exists( 'ot_recognized_line_heights' ) ) {
function ot_recognized_line_heights( $field_id ) {
$range = ot_range( 
  apply_filters( 'ot_line_height_low_range', 0, $field_id ), 
  apply_filters( 'ot_line_height_high_range', 150, $field_id ), 
  apply_filters( 'ot_line_height_unit_type', 1, $field_id )
);
$unit = apply_filters( 'ot_line_height_unit_type', 'px', $field_id );
foreach( $range as $k => $v ) {
  $range[$k] = $v . $unit;
}
return $range;
}
}

我需要添加新值"inherit",以便在选择框中将其显示为选项,但我不知道如何做到这一点。

return之前,我已经尝试过使用$range .= "inherit",但它不起作用。

提前谢谢。

编辑:

这是函数ot_range:

function ot_range( $start, $limit, $step = 1 ) {
if ( $step < 0 )
  $step = 1;
$range = range( $start, $limit, $step );
foreach( $range as $k => $v ) {
if ( strpos( $v, 'E' ) ) {
  $range[$k] = 0;
}

取决于数组中的键是什么,但如果是数字键,则:

$range[] = "inherit";
return $range;