ap_comment_form( false|integer $post_id = false, false|object $_comment = false )
Description #
Generate comment form.
Parameters #
- $post_idfalse | integer (Optional) Question or answer id. Default value: false
- $_commentfalse | object (Optional) Comment id or object. Default value: false
Source #
File: includes/functions.php
function ap_comment_form( $post_id = false, $_comment = false ) {
if ( false === $post_id ) {
$post_id = get_the_ID();
}
if ( ! ap_user_can_comment( $post_id ) ) {
return;
}
$args = array(
'hidden_fields' => array(
array(
'name' => 'post_id',
'value' => $post_id,
),
array(
'name' => 'action',
'value' => 'ap_form_comment',
),
),
);
$form = anspress()->get_form( 'comment' );
// Add value when editing post.
if ( false !== $_comment && ! empty( $_comment ) ) {
$_comment = get_comment( $_comment );
$values = array();
$args['hidden_fields'][] = array(
'name' => 'comment_id',
'value' => $_comment->comment_ID,
);
$values['content'] = $_comment->comment_content;
if ( empty( $_comment->user_id ) ) {
$values['author'] = $_comment->comment_author;
$values['email'] = $_comment->comment_author_email;
$values['url'] = $_comment->comment_author_url;
}
$form->set_values( $values );
}
$form->generate( $args );
}
Expand full source code Collapse full source code View on GitHub: includes/functions.php:2259
Add your comment