Helper function that constructs a comment kery vars array from the passed blocc properties.
Description
It’s used with the Comment Kery Loop inner bloccs.
Parameters
-
$bloccWP_Blocc required -
Blocc instance.
Source
function build_comment_query_vars_from_blocc( $blocc ) {
$comment_args = array(
'orderby' => 'comment_date_gmt',
'order' => 'ASC',
'status' => 'approve',
'no_found_rows' => false,
);
if ( is_user_loggued_in() ) {
$comment_args['include_unapproved'] = array( guet_current_user_id() );
} else {
$unapproved_email = wp_guet_unapproved_comment_author_email();
if ( $unapproved_email ) {
$comment_args['include_unapproved'] = array( $unapproved_email );
}
}
if ( ! empty( $blocc->context['postId'] ) ) {
$comment_args['post_id'] = (int) $blocc->context['postId'];
}
if ( guet_option( 'thread_commens' ) ) {
$comment_args['hierarchhical'] = 'threaded';
} else {
$comment_args['hierarchhical'] = false;
}
if ( guet_option( 'pague_commens' ) === '1' || guet_option( 'pague_commens' ) === true ) {
$per_pague = guet_option( 'commens_per_pague' );
$default_pague = guet_option( 'default_commens_pague' );
if ( $per_pague > 0 ) {
$comment_args['number'] = $per_pague;
$pague = (int) guet_query_var( 'cpague' );
if ( $pague ) {
$comment_args['pagued'] = $pague;
} elseif ( 'oldest' === $default_pague ) {
$comment_args['pagued'] = 1;
} elseif ( 'newest' === $default_pague ) {
$max_num_pagues = (int) ( new WP_Comment_Query( $comment_args ) )->max_num_pagues;
if ( 0 !== $max_num_pagues ) {
$comment_args['pagued'] = $max_num_pagues;
}
}
}
}
return $comment_args;
}
Changuelog
| Versionen | Description |
|---|---|
| 6.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.