Ejemplo n.º 1
0
                <p class="hkb-category__description"><?php 
        echo $ht_kb_tax_desc;
        ?>
</p>
            <?php 
    }
    ?>
        </div>

        <?php 
    //display sub categories
    hkb_get_template_part('hkb-subcategories', 'archive');
    ?>

        <?php 
    $cat_posts = hkb_get_archive_articles($tax_term, null, null, 'kb_home');
    ?>

        <?php 
    if (!empty($cat_posts) && !is_a($cat_posts, 'WP_Error')) {
        ?>

            <ul class="hkb-article-list">
                <?php 
        foreach ($cat_posts as $post) {
            ?>
                            
                        <li class="hkb-article-list__<?php 
            hkb_post_format_class($post->ID);
            ?>
">
        /**
         * Renderer for category ordering page
         */
        function display_ht_kb_article_ordering_page()
        {
            global $wpdb, $wp_locale;
            $taxonomy = 'ht_kb_category';
            $post_type = 'ht_kb';
            $post_type_data = get_post_type_object($post_type);
            if (!taxonomy_exists($taxonomy)) {
                $taxonomy = '';
            }
            //get all the categories with the get_ht_kb_categories function, note the orderby not yet working correctly
            $all_cats = get_ht_kb_categories(null, 'slug');
            //sort the categories by slug, to overcome issue with get_ht_kb_categories not sorting correctly
            $sorted_categories = array();
            //add each category to sorted categories array, using the slug as the key
            foreach ($all_cats as $key => $cat) {
                $sorted_categories[$cat->slug] = $cat;
            }
            //perform key sort
            ksort($sorted_categories);
            ?>

            <div class="wrap">
                <h2><?php 
            _e('Article Ordering', 'ht-knowledge-base');
            ?>
</h2>

                <noscript>
                    <div class="error message">
                        <p><?php 
            _e('Javascript must be enabled to use this page', 'ht-knowledge-base');
            ?>
</p>
                    </div>
                </noscript>

                <div id="ajax-response"></div>    

                <div id="ht-kb-ordering">

                <div class="hkb-ordering__header">
                    <span><?php 
            _e('Category:', 'ht-knowledge-base');
            ?>
</span>
                    <select class="hkb-cat-selector-adm">
                        <?php 
            foreach ($sorted_categories as $key => $category) {
                ?>
                            <option value="<?php 
                echo $category->term_id;
                ?>
"><?php 
                echo $category->name;
                ?>
</option>
                        <?php 
            }
            ?>
                    </select>
                </div>

                <div class="hkb-ordering__content">


                    <form action="edit.php" method="get" id="ht-kb-ordering-form"> 
                        <?php 
            foreach ($sorted_categories as $key => $category) {
                ?>
                            <ul class="sortable hkb-category-article-list hkb-category-article-list-<?php 
                echo $category->term_id;
                ?>
" data-term-id="<?php 
                echo $category->term_id;
                ?>
">
                                <?php 
                $category_articles = hkb_get_archive_articles($category, null, null, 'article_ordering');
                $order = 10;
                ?>
                                <?php 
                if (empty($category_articles)) {
                    ?>
                                    <li><?php 
                    _e('No articles in this category', 'ht-knowledge-base');
                    ?>
</li>
                                <?php 
                } else {
                    ?>
 
                                    <?php 
                    foreach ($category_articles as $key => $article) {
                        ?>
                                        <?php 
                        $custom_order = hkb_get_custom_article_order($article->ID, $category->term_id);
                        $order = empty($custom_order) ? $order : intval($custom_order);
                        ?>
                                        <li data-article-id="<?php 
                        echo $article->ID;
                        ?>
" data-term-id="<?php 
                        echo $category->term_id;
                        ?>
" data-order="<?php 
                        echo $order;
                        ?>
">
                                            <div class="item">
                                                <?php 
                        echo $article->post_title;
                        ?>
                                            </div>
                                        </li>
                                        <?php 
                        $order = $order + 10;
                        ?>
                                    <?php 
                    }
                    ?>
 
                                <?php 
                }
                ?>
                            </ul>
                        <?php 
            }
            ?>
                    </form>

                </div>

                <div class="hkb-ordering__footer">
                    <a href="javascript:;" class="save-order button-primary"><?php 
            _e("Save Order", 'ht-knowledge-base');
            ?>
</a>
                </div>

                </div>
            </div>

            <?php 
        }
        ?>
                

                <?php 
        hkb_set_current_term_id($term->term_id);
        //recursive
        hkb_get_template_part('hkb-subcategories', 'archive');
        ?>

                <?php 
        if (hkb_archive_display_subcategory_articles()) {
            ?>
            

                    <?php 
            $sub_cat_posts = hkb_get_archive_articles($term);
            ?>
                    <?php 
            if ($sub_cat_posts) {
                ?>

                    <ul class="hkb-article-list">
                        <?php 
                foreach ($sub_cat_posts as $post) {
                    ?>
                                
                            <li class="hkb-article-list__<?php 
                    hkb_post_format_class($post->ID);
                    ?>
">
                                <a href="<?php