ap_comment_btn_html( mixed $_post = null )
Description #
Load comment form button.
Parameters #
- $_postmixed (Optional) Post ID or object. Default value: null
Changelog #
Version | Description |
---|---|
4.1.2 | Hide comments button if comments are already showing. |
4.1.0 | Added @see ap_user_can_read_comments() check. |
0.1 | Introduced. |
Source #
File: includes/comments.php
function ap_comment_btn_html( $_post = null ) { if ( ! ap_user_can_read_comments( $_post ) ) { return; } $_post = ap_get_post( $_post ); if ( 'question' === $_post->post_type && ap_opt( 'disable_comments_on_question' ) ) { return; } if ( 'answer' === $_post->post_type && ap_opt( 'disable_comments_on_answer' ) ) { return; } $comment_count = get_comments_number( $_post->ID ); $args = wp_json_encode( array( 'post_id' => $_post->ID, '__nonce' => wp_create_nonce( 'comment_form_nonce' ), ) ); $unapproved = ''; if ( ap_user_can_approve_comment() ) { $unapproved_count = ! empty( $_post->fields['unapproved_comments'] ) ? (int) $_post->fields['unapproved_comments'] : 0; $unapproved = '<b class="unapproved' . ( $unapproved_count > 0 ? ' have' : '' ) . '" ap-un-commentscount title="' . esc_attr__( 'Comments awaiting moderation', 'anspress-question-answer' ) . '">' . $unapproved_count . '</b>'; } $output = ap_new_comment_btn( $_post->ID, false ); return $output; }
Expand full source code Collapse full source code View on GitHub: includes/comments.php:224
Add your comment