wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi
get_comment_pages_count › WordPress Function
Da2.7.0
Deprecaton/a
› get_comment_pages_count ( $comments = null, $per_page = null, $threaded = null )
| Parametri: (3) |
|
| Usi: |
|
| Ritorna: |
|
| Definito a: |
|
| Codex: |
Calculates the total number of comment pages.
Funzioni correlate: get_comment_count, get_comment_author, get_comment_date, get_comment_guid, get_comment_meta
Sorgenti
function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) {
global $wp_query;
if ( null === $comments && null === $per_page && null === $threaded && ! empty( $wp_query->max_num_comment_pages ) ) {
return $wp_query->max_num_comment_pages;
}
if ( ( ! $comments || ! is_array( $comments ) ) && ! empty( $wp_query->comments ) ) {
$comments = $wp_query->comments;
}
if ( empty( $comments ) ) {
return 0;
}
if ( ! get_option( 'page_comments' ) ) {
return 1;
}
$per_page ??= (int) get_query_var( 'comments_per_page' );
if ( 0 === $per_page ) {
$per_page = (int) get_option( 'comments_per_page' );
}
if ( 0 === $per_page ) {
return 1;
}
$threaded ??= get_option( 'thread_comments' );
if ( $threaded ) {
$walker = new Walker_Comment();
$count = ceil( $walker->get_number_of_root_elements( $comments ) / $per_page );
} else {
$count = ceil( count( $comments ) / $per_page );
}
return (int) $count;
}