AnsPress_Tag::ap_question_form_fields( array $form )
Description #
Add tag field in question form.
Parameters #
- $formarray (Required) AnsPress form arguments.
Source #
File: addons/free/tag.php
public static function ap_question_form_fields( $form ) {
$editing_id = ap_sanitize_unslash( 'id', 'r' );
$form['fields']['tags'] = array(
'label' => __( 'Tags', 'anspress-question-answer' ),
'desc' => sprintf(
// Translators: %1$d contain minimum tags required and %2$d contain maximum tags allowed.
__( 'Tagging will helps others to easily find your question. Minimum %1$d and maximum %2$d tags.', 'anspress-question-answer' ),
ap_opt( 'min_tags' ),
ap_opt( 'max_tags' )
),
'type' => 'tags',
'array_max' => ap_opt( 'max_tags' ),
'array_min' => ap_opt( 'min_tags' ),
'js_options' => array(
'create' => true,
),
);
// Add value when editing post.
if ( ! empty( $editing_id ) ) {
$tags = get_the_terms( $editing_id, 'question_tag' );
if ( $tags ) {
$tags = wp_list_pluck( $tags, 'term_id' );
$form['fields']['tags']['value'] = $tags;
}
}
return $form;
}
Expand full source code Collapse full source code View on GitHub: addons/free/tag.php:349
Add your comment