Populate category hierarchy when on a single post.

@access public
335732
public function populate_category_items() {
		if ( ! ( is_single() && 'post' == get_post_type() ) ) {
			return;
		}

		$taxonomy      = 'category';
		$categories    = wp_get_object_terms( get_the_ID(), $taxonomy, array( 'orderby' => 'term_id' ) );
		$last_category = array_pop( $categories );
		$locator       = Carbon_Breadcrumb_Locator::factory( 'term', $taxonomy );
		$items         = $locator->get_items( 700, $last_category->term_id );
		$this->get_trail()->add_item( $items );
	}
946032
static function updateCategory($category)
    {
        // Update the category thread and post counts
        $threads = $category->threads()->where('deleted_at', null)->get();
        $category->thread_count = $threads->count();

        $postCount = 0;
        foreach ($threads as $thread) {
            $postCount += $thread->posts->count();
        }

        $category->post_count = $postCount;
        $category->saveWithoutTouch();
    }
929572
protected function ensure_categories_loaded() {
        global $DB;
        $this->ensure_category_loaded();
        if (!is_null(end($this->_categories))) {
            return; // Already done.
        }
        $idstoload = array_keys($this->_categories);
        array_shift($idstoload);
        $categories = $DB->get_records_list('course_categories', 'id', $idstoload);
        foreach ($idstoload as $catid) {
            $this->_categories[$catid] = $categories[$catid];
        }
    }
37455
protected function setDataNavbarIndexCategory()
    {
        $data = array(
            'total' => $this->data_total,
            'view' => $this->query_filter['view'],
            'quantity' => count($this->data_products),
            'sort' => "{$this->query_filter['sort']}-{$this->query_filter['order']}"
        );

        $this->setData('navbar', $this->render('category/navbar', $data));
    }
1111153
protected function hierarchy() {

		// Uses the slugs to build a hierarchy.
		foreach ( $this->slugs as $slug ) {

			$templates[] = "{$this->name}/{$slug}.php";
		}

		// Add in a `default.php` template.
		if ( ! in_array( 'default', $this->slugs ) ) {

			$templates[] = "{$this->name}/default.php";
		}

		// Fallback to `{$name}.php` as a last resort.
		$templates[] = "{$this->name}.php";

		// Allow developers to overwrite the hierarchy.
		return apply_filters( "hybrid/view/{$this->name}/hierarchy", $templates, $this->slugs );
	}
49204
def _category_slugs(self, category):
        """"""
        key = self._category_key(category)
        slugs = self.r.smembers(key)
        return slugs
324246
function() {
        // Initialize category filters
        this._categoryFilters = [];
        var aInitialCategories = Logger.categories;

        for(var j=0; j < aInitialCategories.length; j++) {
            var sCategory = aInitialCategories[j];

            // Add category to the internal array of filters
            this._categoryFilters.push(sCategory);

            // Add checkbox element if UI is enabled
            if(this._elCategoryFilters) {
                this._createCategoryCheckbox(sCategory);
            }
        }
    }
982219
private function fill_defaults()
	{
		if ( ! array_key_exists('ID', $this->attributes) ) {

			$this->attributes['post_type'] = $this->type;

			$this->attributes['post_status'] = $this->status;

		}
	}
240059
protected function submitAddCategory()
    {
        $this->setSubmitted(null, $this->getParam());
        $this->validateComponent('category');
        $this->addCategory();
    }
1245458
public void setSelectedCategories(Collection<CmsCategory> categories) {

        for (Entry<CmsCategory, CheckBox> entry : m_checkboxes.entrySet()) {
            entry.getValue().setValue(Boolean.valueOf(categories.contains(entry.getKey())));
            CmsCategory parentCat = (CmsCategory)getParent(entry.getKey());
            if (parentCat != null) {
                setCollapsed(parentCat, false);
            }
        }
    }
836712
def category(self, categories):
        
        if isinstance(categories, list):
            for c in categories:
                self.add_category(c)
        else:
            self.add_category(categories)
453473
protected function set_categories() {
		$categories = get_the_category( get_the_ID() );
		if ( $categories ) {
			$category = array_shift( $categories );
			$this->set_ancestors( $category->term_id, 'category' );
			$this->set( $category->name, get_term_link( $category ) );
		}
	}
96951
protected function setChildrenCategory()
    {
        $this->data_children = array();

        foreach ($this->data_categories as $item) {
            if (in_array($this->data_category['category_id'], $item['parents'])) {
                $this->data_children[] = $item;
            }
        }
    }
166039
protected function wizardAddCategory()
    {
        // Required
        $this->validatePrompt('title', $this->text('Title'), 'category');
        $this->validatePrompt('category_group_id', $this->text('Category group ID'), 'category');

        // Optional
        $this->validatePrompt('parent_id', $this->text('Parent category ID'), 'category', 0);
        $this->validatePrompt('description_1', $this->text('First description'), 'category', '');
        $this->validatePrompt('description_2', $this->text('Second description'), 'category', '');
        $this->validatePrompt('meta_title', $this->text('Meta title'), 'category', '');
        $this->validatePrompt('meta_description', $this->text('Meta description'), 'category', '');
        $this->validatePrompt('status', $this->text('Status'), 'category', 0);
        $this->validatePrompt('weight', $this->text('Weight'), 'category', 0);

        $this->validateComponent('category');
        $this->addCategory();
    }
588097
public function root()
    {
        $category = $this->createModel();

        $category = $category->whereExists(function($query)
        {
            $query->select(\DB::raw(1))
                  ->from('category_hierarchy')
                  ->whereRaw(DB::getTablePrefix().'categories.id = '.DB::getTablePrefix().'category_hierarchy.category_id')
                  ->where('category_hierarchy.category_parent_id', 0);
        });

        return $category;
    }
501976
protected function _ppAddContentCategories()
    {
        // load content pages for adding them into menu tree
        $oContentList = oxNew(\OxidEsales\Eshop\Application\Model\ContentList::class);
        $oContentList->loadCatMenues();

        foreach ($oContentList as $sCatId => $aContent) {
            if (array_key_exists($sCatId, $this->_aArray)) {
                $this[$sCatId]->setContentCats($aContent);
            }
        }
    }
1152124
def set_category(self, category):
        
        pcategory = self.find("general/category")
        pcategory.clear()
        name = ElementTree.SubElement(pcategory, "name")
        if isinstance(category, Category):
            id_ = ElementTree.SubElement(pcategory, "id")
            id_.text = category.id
            name.text = category.name
        elif isinstance(category, basestring):
            name.text = category