function documentate_template_chooser($template)
{
    global $wp_query;
    $template_path = documentate_get_template_path();
    $archive_page_id = documentate_get_option('archive_page_id');
    $find = array();
    $file = '';
    if (is_single() && get_post_type() == 'document') {
        $file = 'single-document.php';
        $find[] = $file;
        $find[] = $template_path . $file;
    } elseif (is_tax(array('docu_cat', 'docu_tag'))) {
        $term = get_queried_object();
        $file = 'taxonomy-' . $term->taxonomy . '.php';
        $find[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
        $find[] = $template_path . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
        $find[] = 'taxonomy-' . $term->taxonomy . '.php';
        $find[] = $template_path . 'taxonomy-' . $term->taxonomy . '.php';
        $find[] = $file;
        $find[] = $template_path . $file;
    } elseif (is_post_type_archive('document') || $archive_page_id && is_page($archive_page_id)) {
        $file = 'archive-document.php';
        $find[] = $file;
        $find[] = $template_path . $file;
    }
    if ($file) {
        $template = locate_template(array_unique($find));
        if (!$template) {
            $template = trailingslashit(Docu()->plugin_path()) . 'templates/' . $file;
        }
    }
    return $template;
}
 /**
  * Register Custom Tags Taxonomy
  * @since  1.0.0
  */
 public static function register_tag_taxonomy()
 {
     $labels = array('name' => __('Document Tags', 'documentate'), 'singular_name' => __('Document Tag', 'documentate'), 'search_items' => __('Search Document Tags', 'documentate'), 'all_items' => __('All Document Tags', 'documentate'), 'edit_item' => __('Edit Document Tag', 'documentate'), 'update_item' => __('Update Document Tag', 'documentate'), 'add_new_item' => __('Add New Document Tag', 'documentate'), 'new_item_name' => __('New Document Tag Name', 'documentate'), 'menu_name' => __('Tags', 'documentate'));
     $tag_base = documentate_get_option('tag_base');
     $args = apply_filters('docu_tag_args', array('hierarchical' => false, 'labels' => $labels, 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => $tag_base, 'with_front' => true)));
     register_taxonomy('docu_tag', array('document'), $args);
 }
 /**
  * Sanitize and validate plugin settings
  * @param  array $input
  * @return array
  * @since  1.0.0
  */
 public function validate_settings($input)
 {
     $clean = array();
     $clean['archive_page_id'] = isset($input['archive_page_id']) && !is_wp_error(get_post(intval($input['archive_page_id']))) ? intval($input['archive_page_id']) : 0;
     $clean['archive_display'] = isset($input['archive_display']) && in_array($input['archive_display'], array('documents', 'subcategories', 'both')) ? $input['archive_display'] : 'subcategories';
     $clean['docu_qty'] = isset($input['archive_display']) ? intval($input['docu_qty']) : 0;
     $clean['category_display'] = isset($input['category_display']) && in_array($input['category_display'], array('documents', 'subcategories', 'both')) ? $input['category_display'] : 'subcategories';
     $clean['search_setting'] = isset($input['search_setting']) && $input['search_setting'] == 'show' ? 'show' : 'hide';
     $clean['breadcrumbs_setting'] = isset($input['breadcrumbs_setting']) && $input['breadcrumbs_setting'] == 'show' ? 'show' : 'hide';
     $radio = array('left', 'right', 'hide');
     $clean['sidebar'] = isset($input['sidebar']) && $input['sidebar'] == 'show' ? 'show' : 'hide';
     $clean['comments_setting'] = isset($input['comments_setting']) && $input['comments_setting'] == 'show' ? 'show' : 'hide';
     $clean['uninstall_mode'] = isset($input['uninstall_mode']) && in_array($input['uninstall_mode'], array('nuclear', 'settings', 'none')) ? $input['uninstall_mode'] : 'hide';
     // maybe clear category transients
     $docu_qty = max(array(documentate_get_option('docu_qty'), documentate_get_option('cat_docu_qty')));
     if (isset($clean['docu_qty']) && $clean['docu_qty'] > $docu_qty || isset($clean['cat_docu_qty']) && $clean['cat_docu_qty'] > $docu_qty) {
         Docu()->admin->clear_transients();
     }
     return $clean;
 }
 /**
  * Show subcategory thumbnails.
  *
  * @param mixed $category
  * @subpackage  Loop
  */
 function documentate_subcategory_documents($category)
 {
     $number_docs = intval(documentate_get_option('docu_qty'));
     if ($number_docs > 0) {
         if (false === ($documents = get_transient('documentate_posts_in_' . $category->slug))) {
             $args = array('post_type' => 'document', 'posts_per_page' => $number_docs, 'orderby' => 'menu_order', 'order' => 'ASC', 'tax_query' => array(array('taxonomy' => 'docu_cat', 'field' => 'slug', 'terms' => $category->slug)));
             $documents = new WP_Query(apply_filters('documentate_category_documents', $args, $category));
             set_transient('documentate_posts_in_' . $category->slug, $documents);
         }
         if ($documents->have_posts()) {
             documentate_document_loop_start();
             while ($documents->have_posts()) {
                 $documents->the_post();
                 documentate_get_template_part('content', 'document');
             }
             // end of the loop.
             documentate_document_loop_end();
         }
         wp_reset_postdata();
     }
 }
 /**
  * Shop breadcrumb
  */
 private function add_crumbs_document_archive()
 {
     if (get_option('page_on_front') == ($page_id = documentate_get_option('archive_page_id'))) {
         return;
     }
     $_name = $page_id ? get_the_title($page_id) : '';
     if (!$_name) {
         $document_post_type = get_post_type_object('document');
         $_name = $document_post_type->labels->singular_name;
     }
     $this->add_crumb($_name, get_post_type_archive_link('document'));
 }
Пример #6
0
<?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' => '&larr;', 'next_text' => '&rarr;', 'type' => 'list', 'end_size' => 3, 'mid_size' => 3)));
?>
</nav>
 /**
  * is_document_archive - Returns true when viewing the document type archive (shop).
  * @return bool
  */
 function is_document_archive()
 {
     return is_post_type_archive('document') || is_page(documentate_get_option('archive_page_id')) ? true : false;
 }
Пример #8
0
<?php

/**
 * Search Section
 *
 * @author      helgatheviking
 * @package 	Documentate/Templates
 * @version     0.1-beta
 */
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
if (documentate_get_option('search_setting') == 'show') {
    ?>
	<div class="documentate-search">
		<?php 
    get_document_search_form();
    ?>
	</div>
	<?php 
}
 /**
  * Save the permalinks
  * @since  1.0.0
  */
 public function validate_permalinks()
 {
     // @todo check permissions
     // We need to save the options ourselves; settings api does not trigger save for the permalinks page
     if (isset($_POST['documentate_permalinks'])) {
         $input = $_POST['documentate_permalinks'];
         $permalinks = array();
         $permalinks['category_base'] = isset($input['category_base']) ? untrailingslashit(sanitize_text_field($input['category_base'])) : '';
         $permalinks['tag_base'] = isset($input['tag_base']) ? untrailingslashit(sanitize_text_field($input['tag_base'])) : '';
         // document base
         $document_permalink = isset($input['document_permalink']) ? untrailingslashit(sanitize_text_field($input['document_permalink'])) : '';
         if ($document_permalink == 'custom') {
             // Get permalink without slashes
             $document_permalink = trim(sanitize_text_field($input['document_permalink_structure']), '/');
             // This is an invalid base structure and breaks pages
             if ('%docu_cat%' == $document_permalink) {
                 $document_permalink = _x('document', 'slug', 'documentate') . '/' . $document_permalink;
             }
             // Prepending slash
             $document_permalink = '/' . $document_permalink;
         } elseif (empty($document_permalink)) {
             $document_permalink = false;
         }
         $permalinks['document_base'] = untrailingslashit($document_permalink);
         // Shop base may require verbose page rules if nesting pages
         $archive_page_id = documentate_get_option('archive_page_id');
         $archive_permalink = $archive_page_id > 0 && get_post($archive_page_id) ? get_page_uri($archive_page_id) : _x('documents', 'default-slug', 'documentate');
         if ($archive_page_id && trim($permalinks['document_base'], '/') === $archive_permalink) {
             $permalinks['use_verbose_page_rules'] = true;
         }
         update_option('documentate_permalinks', $permalinks);
     }
 }
_e('Hide', 'documentate');
?>
</label>
							</fieldset>
						</td>
						
					</tr>
					<tr>
						<th><?php 
_e('Uninstall Mode', 'documentate');
?>
</th>
						<td>
							<fieldset>
								<?php 
$uninstall_mode = documentate_get_option('uninstall_mode');
?>
								<label><input type="radio" name="documentate_settings[uninstall_mode]" id="documentate_uninstall_nuclear" value="nuclear" <?php 
checked($uninstall_mode, 'nuclear');
?>
><?php 
_e('Everything', 'documentate');
?>
</label>
								<label><input type="radio" name="documentate_settings[uninstall_mode]" id="documentate_uninstall_settings" value="settings" <?php 
checked($uninstall_mode, 'settings');
?>
><?php 
_e('Settings Only', 'documentate');
?>
</label>
 * Document Admin Permalinks
 *
 * @version     0.1-beta
 * @author      helgatheviking
 * @category    Admin
 * @package     Documentate/Admin
 */
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
echo wpautop(__('These settings control the permalinks used for documents. These settings only apply when <strong>not</strong> using "default" permalinks above.', 'documentate'));
$document_permalink = documentate_get_option('document_base');
$category_slug = documentate_get_option('category_base');
// Get archive page
$archive_page_id = documentate_get_option('archive_page_id');
$archive_slug = urldecode($archive_page_id > 0 && get_post($archive_page_id) ? get_page_uri($archive_page_id) : _x('documents', 'default slug', 'documentate'));
$default_base = _x('document', 'default slug', 'documentate');
$structures = array(0 => '', 1 => '/' . trailingslashit($default_base), 2 => '/' . trailingslashit($archive_slug), 3 => '/' . trailingslashit($archive_slug) . trailingslashit('%docu_cat%'));
?>
<table class="form-table">
	<tbody>
		<tr>
			<th><label><input name="documentate_permalinks[document_permalink]" type="radio" value="<?php 
echo esc_attr($structures[0]);
?>
" class="kbetog" <?php 
checked($structures[0], $document_permalink);
?>
 /> <?php 
_e('Default', 'documentate');