/**
* Get pagination.
*
* @param array $prefs
* @return array mixed
*/
public static function get_pagination($prefs = array())
{
global $wp_query;
global $paged;
global $wp_rewrite;
$args = array();
$args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']);
if ($wp_rewrite->using_permalinks()) {
$url = explode('?', get_pagenum_link(0));
if (isset($url[1])) {
parse_str($url[1], $query);
$args['add_args'] = $query;
}
$args['format'] = $wp_rewrite->pagination_base . '/%#%';
$args['base'] = trailingslashit($url[0]) . '%_%';
} else {
$big = 999999999;
$args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big)));
}
$args['type'] = 'array';
$args['current'] = max(1, get_query_var('paged'));
$args['mid_size'] = max(9 - $args['current'], 3);
if (is_int($prefs)) {
$args['mid_size'] = $prefs - 2;
} else {
$args = array_merge($args, $prefs);
}
$data = array();
$data['current'] = $args['current'];
$data['total'] = $args['total'];
$data['pages'] = Helper::paginate_links($args);
// decrement current so that it matches up with the 0 based index used by the pages array
$current = $data['current'] - 1;
// set next and prev using pages array generated by paginate links
if (isset($data['pages'][$current + 1])) {
$data['next'] = array('link' => untrailingslashit($data['pages'][$current + 1]['link']), 'class' => 'page-numbers next');
}
if (isset($data['pages'][$current - 1])) {
$data['prev'] = array('link' => untrailingslashit($data['pages'][$current - 1]['link']), 'class' => 'page-numbers prev');
}
if ($paged < 2) {
$data['prev'] = '';
}
if ($data['total'] === (double) 0) {
$data['next'] = '';
}
return $data;
}