ap_new_comment_btn( integer $post_id, boolean $echo = true )

Description #

Return or print new comment button.

Parameters #

  • $post_id
    integer (Required) Post id.
  • $echo
    boolean (Optional) Return or echo. Default is echo. Default value: true

Changelog #

VersionDescription
4.1.8Introduced.

Source #

File: includes/comments.php

function ap_new_comment_btn( $post_id, $echo = true ) {
	if ( ap_user_can_comment( $post_id ) ) {
		$output = '';

		$btn_args = wp_json_encode( array(
			'action'  => 'comment_modal',
			'post_id' => $post_id,
			'__nonce' => wp_create_nonce( 'new_comment_' . $post_id ),
		) );

		$output .= '<a href="#" class="ap-btn-newcomment" aponce="false" apajaxbtn apquery="' . esc_js( $btn_args ) . '">';
		$output .= esc_attr__( 'Add a Comment', 'anspress-question-answer' );
		$output .= '</a>';

		if ( false === $echo ) {
			return $output;

		}

		echo $output;
	}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment