<?php /** * Pagination - Show numbered pagination for catalog pages. * * @author helgatheviking * @package Documentate/Templates * @version 2.2.2 */ if (!defined('ABSPATH')) { exit; // Exit if accessed directly } global $wp_query; // if no more than 1 page OR if post type archive and display mode is categories only if ($wp_query->max_num_pages <= 1 || is_document_archive() && documentate_get_option('archive_display') === 0) { return; } ?> <nav class="documentate-pagination"> <?php echo paginate_links(apply_filters('documentate_pagination_args', array('base' => esc_url_raw(str_replace(999999999, '%#%', get_pagenum_link(999999999, false))), 'format' => '', 'add_args' => '', 'current' => max(1, get_query_var('paged')), 'total' => $wp_query->max_num_pages, 'prev_text' => '←', 'next_text' => '→', 'type' => 'list', 'end_size' => 3, 'mid_size' => 3))); ?> </nav>
/** * Display document sub categories as thumbnails. * * @subpackage Loop * @param array $args * @return null|boolean */ function documentate_document_subcategories($args = array()) { global $wp_query; $defaults = array('before' => '', 'after' => '', 'force_display' => false); $args = wp_parse_args($args, $defaults); extract($args); // Main query only if (!is_main_query() && !$force_display) { return; } // Don't show when, searching or when on page > 1 and ensure we're on an document archive if (is_search() || is_paged() || !is_document_category() && !is_document_archive()) { return; } // Check categories are enabled if (is_document_archive() && documentate_get_option('archive_display') == 'documents') { return; } // Find the category + category parent, if applicable $term = get_queried_object(); $parent_id = !empty($term->term_id) ? $term->term_id : 0; if (is_document_category()) { $display_type = get_term_meta($term->term_id, 'display_type', true); switch ($display_type) { case 'documents': return; break; case '': if (documentate_get_option('category_display') == 'documents') { return; } break; } } // NOTE: using child_of instead of parent - this is not ideal but due to a WP bug ( http://core.trac.wordpress.org/ticket/15626 ) pad_counts won't work $document_categories = get_categories(apply_filters('documentate_document_subcategories_args', array('parent' => $parent_id, 'menu_order' => 'ASC', 'hide_empty' => 0, 'hierarchical' => 1, 'taxonomy' => 'docu_cat', 'pad_counts' => 1))); if (!apply_filters('documentate_document_subcategories_hide_empty', false)) { $document_categories = wp_list_filter($document_categories, array('count' => 0), 'NOT'); } if ($document_categories) { echo $before; foreach ($document_categories as $category) { documentate_get_template('content-docu_cat.php', array('category' => $category)); } // If we are hiding documents disable the loop and pagination if (is_document_category()) { $display_type = get_term_meta($term->term_id, 'display_type', true); switch ($display_type) { case 'subcategories': $wp_query->post_count = 0; $wp_query->max_num_pages = 0; break; case '': if (documentate_get_option('category_display') == 'subcategories') { $wp_query->post_count = 0; $wp_query->max_num_pages = 0; } break; } } if (is_document_archive() && documentate_get_option('archive_display') == 'subcategories') { $wp_query->post_count = 0; $wp_query->max_num_pages = 0; } echo $after; return true; } }
/** * is_documentate - Returns true if on a page which uses Documentate templates (cart and checkout are standard pages with shortcodes and thus are not included) * @return bool */ function is_documentate() { return apply_filters('is_documentate', is_document_archive() || is_document_taxonomy() || is_document() ? true : false); }