public function loadTerms()
    {
        $taxonomy_keys = $this->getTaxonomyKeys();
        if (!Arr::iterable($taxonomy_keys)) {
            return false;
        }
        
        // TODO Move this to somewhere more efficient
        // Check if this should be an instance of TacoTerm.
        // If not, the object will just be a default WP object from wp_get_post_terms below.
        $taxonomies_subclasses = array();
        $subclasses = Term\Loader::getSubclasses();
        foreach ($subclasses as $subclass) {
            $term_instance = new $subclass;
            $term_instance_taxonomy_key = $term_instance->getKey();
            foreach ($taxonomy_keys as $taxonomy_key) {
                if (array_key_exists($taxonomy_key, $taxonomies_subclasses)) {
                    continue;
                }
                if ($term_instance_taxonomy_key !== $taxonomy_key) {
                    continue;
                }

                $taxonomies_subclasses[$taxonomy_key] = $subclass;
                break;
            }
        }

        foreach ($taxonomy_keys as $taxonomy_key) {
            $terms = wp_get_post_terms($this->get(self::ID), $taxonomy_key);
            if (!Arr::iterable($terms)) {
                continue;
            }
            
            $terms = array_combine(
                array_map('intval', Collection::pluck($terms, 'term_id')),
                $terms
            );

            // Load Taco\Term if applicable
            if (array_key_exists($taxonomy_key, $taxonomies_subclasses)) {
                $terms = Term\Factory::createMultiple($terms, $taxonomy_key);
            }

            $this->_terms[$taxonomy_key] = $terms;
        }
        
        return true;
    }
public function loadTerms()
    {
        $taxonomy_keys = $this->getTaxonomyKeys();
        if (!Arr::iterable($taxonomy_keys)) {
            return false;
        }
        
        // TODO Move this to somewhere more efficient
        // Check if this should be an instance of TacoTerm.
        // If not, the object will just be a default WP object from wp_get_post_terms below.
        $taxonomies_subclasses = array();
        $subclasses = Term\Loader::getSubclasses();
        foreach ($subclasses as $subclass) {
            $term_instance = new $subclass;
            $term_instance_taxonomy_key = $term_instance->getKey();
            foreach ($taxonomy_keys as $taxonomy_key) {
                if (array_key_exists($taxonomy_key, $taxonomies_subclasses)) {
                    continue;
                }
                if ($term_instance_taxonomy_key !== $taxonomy_key) {
                    continue;
                }

                $taxonomies_subclasses[$taxonomy_key] = $subclass;
                break;
            }
        }

        foreach ($taxonomy_keys as $taxonomy_key) {
            $terms = wp_get_post_terms($this->get(self::ID), $taxonomy_key);
            if (!Arr::iterable($terms)) {
                continue;
            }
            
            $terms = array_combine(
                array_map('intval', Collection::pluck($terms, 'term_id')),
                $terms
            );

            // Load Taco\Term if applicable
            if (array_key_exists($taxonomy_key, $taxonomies_subclasses)) {
                $terms = Term\Factory::createMultiple($terms, $taxonomy_key);
            }

            $this->_terms[$taxonomy_key] = $terms;
        }
        
        return true;
    }
public function loadTerms ( ) { $ taxonomy_keys = $ this -> getTaxonomyKeys ( ) ; if ( ! Arr :: iterable ( $ taxonomy_keys ) ) { return false ; } // TODO Move this to somewhere more efficient // Check if this should be an instance of TacoTerm. // If not, the object will just be a default WP object from wp_get_post_terms below. $ taxonomies_subclasses = array ( ) ; $ subclasses = Term \ Loader :: getSubclasses ( ) ; foreach ( $ subclasses as $ subclass ) { $ term_instance = new $ subclass ; $ term_instance_taxonomy_key = $ term_instance -> getKey ( ) ; foreach ( $ taxonomy_keys as $ taxonomy_key ) { if ( array_key_exists ( $ taxonomy_key , $ taxonomies_subclasses ) ) { continue ; } if ( $ term_instance_taxonomy_key !== $ taxonomy_key ) { continue ; } $ taxonomies_subclasses [ $ taxonomy_key ] = $ subclass ; break ; } } foreach ( $ taxonomy_keys as $ taxonomy_key ) { $ terms = wp_get_post_terms ( $ this -> get ( self :: ID ) , $ taxonomy_key ) ; if ( ! Arr :: iterable ( $ terms ) ) { continue ; } $ terms = array_combine ( array_map ( 'intval' , Collection :: pluck ( $ terms , 'term_id' ) ) , $ terms ) ; // Load Taco\Term if applicable if ( array_key_exists ( $ taxonomy_key , $ taxonomies_subclasses ) ) { $ terms = Term \ Factory :: createMultiple ( $ terms , $ taxonomy_key ) ; } $ this -> _terms [ $ taxonomy_key ] = $ terms ; } return true ; }
Load the terms
@return bool
Load the terms