Esempio n. 1
0
function orizon_breadcrumbs()
{
    if (function_exists('is_bbpress')) {
        if (is_bbpress()) {
            bbp_breadcrumb();
        } else {
            //      orizon_breadcrumbs_inner();}
            catreina_breadcrumbs();
        }
    } else {
        //    orizon_breadcrumbs_inner();
        catreina_breadcrumbs();
    }
}
    public function widget($args, $instance)
    {
        $title = apply_filters('widget_title', $instance['title']);
        // before and after widget arguments are defined by themes
        echo $args['before_widget'];
        // Display title
        if (!empty($title)) {
            echo $args['before_title'] . $title . $args['after_title'];
        }
        // Processing begins
        // Time to get the posts Data'
        global $post;
        // get publish and last modified timestamps for comparisons
        $pubDate = esc_html(get_the_date('c'));
        $modDate = esc_html(get_the_modified_date('c'));
        ?>

<div id="postmeta">
  <div>PATH: <span class="breadcrumb"><?php 
        echo catreina_breadcrumbs();
        ?>
</span></div>

<?php 
        if (!is_home() && !is_archive()) {
            // Show only the breadcrumbs for the Blog Index Page
            ?>
  <div>PERMALINK: <a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title_attribute();
            ?>
"><?php 
            the_title();
            ?>
</a></div>
<?php 
            // Allow editing of this post or page
            edit_post_link('Edit ' . (is_single() ? "Post" : "Page"), '<div>EDITABLE: <span class="meta-edit-link">', '</span></div>');
            if (is_single()) {
                ?>

  <div>POSTED IN: <?php 
                the_category(' ');
                ?>
</div>
<?php 
                $posttags = get_the_tags();
                if ($posttags) {
                    the_tags('<div>TAGGED: ', ', ', '</div>');
                }
            }
            // end if (is_single())
            if (is_page()) {
                // We need to get the category this page is a parent for. We have a custom meta entry
                // for each page that holds this data as an ID (category => 1)
                $category = get_category_by_slug(get_post_meta(get_the_ID(), 'category', TRUE));
                // If there is a category returned, we have a category-specific page
                if (!empty($category)) {
                    // Now get the number of posts in the category
                    $cat_ID = $category->cat_ID;
                    $cat_link = get_category_link($cat_ID);
                    $cat_name = $category->name;
                    $cat_posts = $category->count;
                    $subcategories = catreina_get_subcategories($cat_ID);
                    if ($subcategories) {
                        $subcat_posts = catreina_cat_post_count_recursive($cat_ID);
                        $subcat_posts = $subcat_posts - $cat_posts;
                        foreach ($subcategories as $subcategory) {
                            $child = get_term_by('id', $subcategory, 'category');
                            $subcats .= '<a href="' . get_term_link($subcategory, 'category') . '">' . $child->name . '</a> || ';
                        }
                        $subcats = substr($subcats, 0, strlen($subcats) - 3);
                        ?>
  <div>SUBCATEGORY POSTS: <?php 
                        echo $subcat_posts;
                        ?>
</div>
  <div>SUBCATEGORIES: <?php 
                        echo $subcats;
                        ?>
</div>
  <?php 
                    }
                    // end if ($subcategories)
                }
                // end if (!empty($category)
            }
            // end if (is_page())
            if ((is_page() || is_single()) && !bp_is_user()) {
                ?>
  <div class="meta-separator"></div>
<?php 
                if ($modDate > $pubDate) {
                    printf(__('<div>UPDATED: %1$s at %2$s %3$s</div>', 'catreina'), esc_html(get_the_modified_date()), esc_attr(get_the_modified_time()), esc_attr(date('T')));
                } else {
                    printf(__('<div>POSTED: %1$s at %2$s %3$s</div>', 'catreina'), esc_html(get_the_modified_date()), esc_attr(get_the_modified_time()), esc_attr(date('T')));
                }
                if (comments_open() && !is_page()) {
                    ?>
  <div>COMMENTS: OPEN - <?php 
                    comments_popup_link('' . __('No Comments', 'orizon') . '', __('One Comment', 'comments number', 'orizon'), __('% Comments', 'comments number', 'orizon'), 'comments-link', __('Off', 'orizon'));
                    ?>
</div>
  <div>COMMENT FEED: <?php 
                    comments_rss_link('RSS 2.0');
                    ?>
</div>
<?php 
                }
            }
            // If it IS an archive
        } elseif (is_archive()) {
            global $cat;
            ?>
  <div>PERMALINK: <a href="<?php 
            get_category_link($cat);
            ?>
" title="<?php 
            single_cat_title('', TRUE);
            ?>
"><?php 
            single_cat_title('', TRUE);
            ?>
</a></div>
<?php 
            // This is the blog posts index page, heh
        } elseif (is_home()) {
            // we want to display some statistics - total posts, total comments, total subscribers, etc
            // Get user and posts information
            $users = count_users();
            $users = $users['total_users'];
            // Get user count(s)
            $posts = wp_count_posts()->publish;
            // Get number of posts
            $pages = wp_count_posts('page')->publish;
            // Get number of pages
            $categories = wp_count_terms('category');
            // Get number of categories
            // Get comment information
            $comments_count = wp_count_comments();
            $commentsTotal = $comments_count->total_comments;
            $commentsApproved = $comments_count->approved;
            $commentsModerate = $comments_count->moderated;
            // Print out the information
            ?>
  <div class="meta-separator"></div>
  <div>TOTAL USERS: <?php 
            echo $users;
            ?>
</div>

  <div class="meta-separator"></div>
  <div>TOTAL CATEGORIES: <?php 
            echo $categories;
            ?>
</div>
  <div>TOTAL PAGES: <?php 
            echo $pages;
            ?>
</div>
  <div>TOTAL POSTS: <?php 
            echo $posts;
            ?>
</div>

  <div class="meta-separator"></div>
  <div>APPROVED COMMENTS: <?php 
            echo $commentsApproved;
            ?>
</div>
  <div>MODERATED COMMENTS: <?php 
            echo $commentsModerate;
            ?>
</div>
  <div>TOTAL COMMENTS: <?php 
            echo $commentsTotal;
            ?>
</div>
<?php 
        }
        // End widget
        ?>
</div>

<?php 
        echo $args['after_widget'];
    }