Deprecated
This function has been deprecated. This function is replaced by @see AnsPress::get_form() instead.
ap_get_ask_form_fields( integer|boolean $post_id = false )
Description #
Get all ask form fields.
Parameters #
- $post_idinteger | boolean (Optional) Post ID. Default value: false
Changelog #
Source #
File: includes/deprecated.php
function ap_get_ask_form_fields( $post_id = false ) { _deprecated_function( __FUNCTION__, '4.1.0', 'AnsPress::get_form()' ); global $editing_post; $editing = false; if ( $post_id && ap_user_can_edit_question( (int) $post_id ) ) { $editing = true; $editing_post = ap_get_post( (int) $post_id, 'OBJECT', 'edit' ); } $is_private = false; if ( $editing ) { $is_private = $editing_post->post_status == 'private_post' ? true : false; } $fields = array( array( 'name' => 'title', 'label' => __( 'Title', 'anspress-question-answer' ), 'type' => 'text', 'placeholder' => __( 'Question in one sentence', 'anspress-question-answer' ), 'value' => ( $editing ? $editing_post->post_title : ap_isset_post_value( 'title', '' ) ), 'order' => 5, 'attr' => 'data-action="suggest_similar_questions" data-loadclass="q-title"', 'autocomplete' => false, 'sanitize' => array( 'sanitize_text_field' ), 'validate' => array( 'required' => true, 'length_check' => ap_opt( 'minimum_qtitle_length' ), ), ), array( 'name' => 'suggestion', 'type' => 'custom', 'order' => 5, 'html' => '<div id="similar_suggestions"></div>', ), array( 'name' => 'description', 'label' => __( 'Description', 'anspress-question-answer' ), 'type' => 'editor', 'value' => ( $editing ? $editing_post->post_content : ap_isset_post_value( 'description', '' ) ), 'settings' => ap_tinymce_editor_settings( 'question' ), 'sanitize' => array( 'sanitize_description' ), 'validate' => array( 'length_check' => ap_opt( 'minimum_question_length' ) ), ), array( 'name' => 'ap_upload', 'type' => 'custom', 'html' => ap_post_upload_form( $editing ? $editing_post->ID : false ), 'order' => 10, ), array( 'name' => 'parent_id', 'type' => 'hidden', 'value' => ( $editing ? $editing_post->post_parent : get_query_var( 'parent' ) ), 'order' => 20, 'sanitize' => array( 'only_int' ), ), ); // Add name fields if anonymous is allowed. if ( ! is_user_logged_in() && ap_opt( 'allow_anonymous' ) ) { $fields[] = array( 'name' => 'anonymous_name', 'label' => __( 'Name', 'anspress-question-answer' ), 'type' => 'text', 'placeholder' => __( 'Enter your name to display', 'anspress-question-answer' ), 'value' => ap_isset_post_value( 'name', '' ), 'order' => 12, 'sanitize' => array( 'strip_tags', 'sanitize_text_field' ), ); } // Add private field checkbox if enabled. if ( ap_opt( 'allow_private_posts' ) ) { $fields[] = array( 'name' => 'is_private', 'type' => 'checkbox', 'desc' => __( 'Only visible to admin and moderator.', 'anspress-question-answer' ), 'value' => $is_private, 'order' => 12, 'show_desc_tip' => false, 'sanitize' => array( 'only_boolean' ), ); } if ( $editing ) { $fields[] = array( 'name' => 'edit_post_id', 'type' => 'hidden', 'value' => $editing_post->ID, 'order' => 20, 'sanitize' => array( 'only_int' ), ); } $fields[] = array( 'name' => 'ap_ajax_action', 'type' => 'hidden', 'value' => 'ask_form', 'order' => 20, ); /** * Filter for modifying ask form `$args`. * * @param array $fields Ask form fields. * @param bool $editing Currently editing form. * @since 2.0 * @deprecated 4.1.0 */ $fields = apply_filters( 'ap_ask_form_fields', [ 'fields' => $fields ], $editing ); return $fields['fields']; }
Expand full source code Collapse full source code View on GitHub: includes/deprecated.php:236
Add your comment