抱歉,如果我在问题中使用了一些错误的术语。我是自学成才,还在学习。下面的代码是表单模板的一部分。我想向数组添加一些其他属性。
我想知道如何在不清除模板的现有属性的情况下做到这一点?
我想将其他属性保留在子主题的functions.php文件中。
这是我要更改的相关插件功能:
/**
* Output product title
*
* @since 1.0.0
*
* @param int $post_id post_id for this meta if any
*/
public static function title( $post_id, $product_title ) {
WCVendors_Pro_Form_Helper::input(
apply_filters(
'wcv_product_title',
array(
'post_id' => $post_id,
'id' => 'post_title',
'label' => __( 'Product name', 'wcvendors-pro' ),
'value' => $product_title,
'custom_attributes' => array(
'required' => '',
'data-parsley-maxlength' => '100',
'data-parsley-error-message' => __( 'Product name is required or too long.', 'wcvendors-pro' ),
),
)
)
);
}
这是我要添加的内容:
'placeholder' => __( 'Here is some placeholder text', 'wcvendors-pro' ),
'desc_tip' => 'true',
'description' => __( 'Here is some description text.', 'wcvendors-pro' ),
尝试以下操作,因为有一个过滤器钩子:
add_filter( 'wcv_product_title', 'customize_wcv_form_field' );
function customize_wcv_form_field( $args ) {
$more_args = array(
'placeholder' => __( 'Here is some placeholder text', 'wcvendors-pro' ),
'desc_tip' => 'true',
'description' => __( 'Here is some description text.', 'wcvendors-pro' ),
);
return array_merge( $args, $more_args);
}
代码进入活动子主题(或活动主题)的functions.php文件中。它应该工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句