ap_select_answer_btn_html( mixed $_post = null )
Description #
Print select anser HTML button.
Parameters #
- $_postmixed (Optional) Post. Default value: null
Source #
File: includes/theme.php
function ap_select_answer_btn_html( $_post = null ) { if ( ! ap_user_can_select_answer( $_post ) ) { return; } $_post = ap_get_post( $_post ); $nonce = wp_create_nonce( 'select-answer-' . $_post->ID ); $q = wp_json_encode( array( 'answer_id' => $_post->ID, '__nonce' => $nonce, ) ); $active = false; $title = __( 'Select this answer as best', 'anspress-question-answer' ); $label = __( 'Select', 'anspress-question-answer' ); $have_best = ap_have_answer_selected( $_post->post_parent ); $selected = ap_is_selected( $_post ); $hide = false; if ( $have_best && $selected ) { $title = __( 'Unselect this answer', 'anspress-question-answer' ); $label = __( 'Unselect', 'anspress-question-answer' ); $active = true; } if ( $have_best && ! $selected ) { $hide = true; } return '<a href="#" class="ap-btn-select ap-btn ' . ( $active ? ' active' : '' ) . ( $hide ? ' hide' : '' ) . '" ap="select_answer" apquery="' . esc_js( $q ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $label ) . '</a>'; }
Expand full source code Collapse full source code View on GitHub: includes/theme.php:811
Add your comment