我有此代码:
add_filter( 'woocommerce_form_field_checkboxes', 'pm_form_field_modify', 10, 4 );
function pm_form_field_modify( $field, $key, $args, $value ) {
ob_start();
pm_print_list_field( $key, $args, $value );
$field = ob_get_clean();
if ( $args['return'] ) {
return $field;
} else {
echo $field;
}
}
,我正在尝试将其编写为类。我有一个类格式,该类格式具有在实例化但在编写时运行的功能:
add_filter( 'woocommerce_form_field_checkboxes', array( $this,'pm_form_field_modify' ));
我无法传递$ priority和$ accepted_args,因为该数组正好需要2个参数。如何将这些参数传递给我的公共函数类,因为我需要为函数指定4个参数。
我检查了here,但发现在使用类和OOP时缺乏说明。
答案 0 :(得分:1)
add_filter( 'woocommerce_form_field_checkboxes', array( $this,'pm_form_field_modify' ), 10, 4);