add_filter( 'woocommerce_form_field_args', 'custom_form_field_args', 10, 3 );
function custom_form_field_args( $args, $key, $value ) {
if ( $args['id'] == 'billing_city' ) {
$args = array(
'label' => __( 'Town / City', 'woocommerce' ),
'required' => TRUE,
'clear' => TRUE,
'type' => 'select',
'options' => array(
'' => ('Select City' ),
'Duliajan' => ('Duliajan' )
),
'class' => array( 'update_totals_on_change' )
);
} // elseif … and go on
return $args;
};
当我在(woocommerce)function.php中添加单个城市的代码时,我收到以下错误。
第2040行 - $field .= '<select name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" class="select ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" ' . implode( ' ', $custom_attributes ) . ' data-placeholder="' . esc_attr( $args['placeholder'] ) . '">
第2064行 - $field_html .= '<label for="' . esc_attr( $label_id ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) . '">' . $args['label'] . $required . '</label>';
如何解决错误?
答案 0 :(得分:0)
$args['input_class']
和$args['label_class']
必须是数组,因此它们可能不是。你应该检查:
if (!is_array($args['label_class']) {
// initialize to some empty array? depends on your application, what it needs to do
}