AnsPress_Category::ask_from_category_field( array $args, boolean $editing )
Description #
Add category field in ask form.
Parameters #
- $argsarray (Required) Ask form arguments.
- $editingboolean (Required) true if is edit form.
Source #
File: addons/free/category.php
public static function ask_from_category_field( $args, $editing ) { if ( wp_count_terms( 'question_category' ) == 0 ) { // WPCS: loose comparison okay. return $args; } global $editing_post; $catgeory = ap_sanitize_unslash( 'category', 'request' ); if ( $editing ) { $category = get_the_terms( $editing_post->ID, 'question_category' ); $catgeory = $category[0]->term_id; } $args['fields'][] = array( 'name' => 'category', 'label' => __( 'Category', 'anspress-question-answer' ), 'type' => 'taxonomy_select', 'value' => ( ! empty( $catgeory ) ? $catgeory: '' ), 'taxonomy' => 'question_category', 'orderby' => ap_opt( 'form_category_orderby' ), 'desc' => __( 'Select a topic that best fits your question', 'anspress-question-answer' ), 'order' => 6, 'sanitize' => [ 'only_int' ], 'validate' => [ 'required' ], ); return $args; }
Expand full source code Collapse full source code View on GitHub: addons/free/category.php:402
Add your comment