Returns All Terms From Post.

@param string $taxonomy
@param array  $args

@return array|\WP_Error
171137
public function get_terms( $taxonomy = '', $args = array() ) {
		if ( isset( $this->{$taxonomy} ) && empty( $args ) ) {
			return $this->{$taxonomy};
		} else {
			$name = $taxonomy . '_' . md5( json_encode( $args ) );
			if ( isset( $this->{$name} ) ) {
				return $this->{$name};
			}
			$data          = \wp_get_post_terms( $this->id(), $taxonomy, $args );
			$this->{$name} = $data;
			return $data;
		}
	}
489613
public static function getPageCount($args = array())
    {
        $instance = Post\Factory::create(get_called_class());

        $posts_per_page = $instance->getPostsPerPage();
        $criteria = array(
            'post_type'=>$instance->getPostType(),
            'posts_per_page'=>-1
        );
        $criteria = array_merge($criteria, $args);

        $query = new \WP_Query($criteria);
        $n = 0;
        while ($query->have_posts()) {
            $n++;
            $query->next_post();
        }

        return ceil($n / $posts_per_page);
    }
3987
public static function getAll()
    {
        global $wpdb;
        if (false === ($results = get_transient(self::TRANSIENT_ALL_TAGS))) {
            $results = $wpdb->get_results('
				SELECT ta.term_taxonomy_id as taxonomy_id, name, slug, count(*) total
				FROM ' . $wpdb->prefix . 'term_taxonomy ta
				JOIN ' . $wpdb->prefix . 'terms te ON (te.term_id = ta.term_id)
				JOIN ' . $wpdb->prefix . 'term_relationships re ON (re.term_taxonomy_id = ta.term_taxonomy_id)
				WHERE taxonomy = "post_tag"
				GROUP BY name, slug, taxonomy_id
				ORDER BY total DESC, name, slug');
            set_transient(self::TRANSIENT_ALL_TAGS, $results, 12 * HOUR_IN_SECONDS);
        }
        return $results;
    }
755723
function get_terms( $value, $taxonomy = 'category' ) {
		
		// load terms in 1 query to save multiple DB calls from following code
		if( count($value) > 1 ) {
			
			$terms = get_terms($taxonomy, array(
				'hide_empty'	=> false,
				'include'		=> $value,
			));
			
		}
		
		
		// update value to include $post
		foreach( array_keys($value) as $i ) {
			
			$value[ $i ] = get_term( $value[ $i ], $taxonomy );
			
		}
		
		
		// filter out null values
		$value = array_filter($value);
		
		
		// return
		return $value;
	}
1166658
function getTaxonomy($taxonomy)
    {
        $params = array(1, $this->username, $this->password, $taxonomy);

        return $this->sendRequest('wp.getTaxonomy', $params);
    }
290245
public function getTaxonomyValues()
    {
        if (!isset($_POST['tax']) || empty($_POST['tax'])) {
            echo '0';
            die();
        }

        $taxonomy = $_POST['tax'];
        $post = $_POST['post'];

        $result = array(
            'tax' => get_terms($taxonomy, array(
                'hide_empty' => false,
            )),
            'curr' => get_field('posts_taxonomy_value', $post)
        );

        echo json_encode($result);
        die();
    }
939903
public function getTerms($post)
    {
        $taxonomies = get_field('taxonomy_display', $this->data['ID']);

        if (empty($taxonomies)) {
            return [];
        }


        $terms = array();
        if (!empty($taxonomies)) {
            foreach ($taxonomies as $taxonomy) {
                $terms = array_merge($terms, get_the_terms($post->ID, $taxonomy));
            }
        }

        return $terms;
    }
1086661
public function get( $args, $assoc_args ) {
		list( $object_id, $meta_key ) = $args;

		$object_id = $this->check_object_id( $object_id );

		$value = $this->get_metadata( $object_id, $meta_key, true );

		if ( '' === $value ) {
			die( 1 );
		}

		WP_CLI::print_value( $value, $assoc_args );
	}
986793
public function getTerms(Post $post, $taxonomy)
    {
        $model = App::make(TaxonomyModel::class);

        return $model->make($taxonomy)->postTerms($post);
    }
1143233
public static function get_terms( $taxonomies ) {
		$items = [];

		// Get the post types.
		$terms = get_terms( $taxonomies );

		// Build the array.
		foreach ( $terms as $term ) {
			$items[ $term->term_id ] = $term->name;
		}

		return $items;
	}
649342
public function setArguments(array $args): TaxonomyInterface
    {
        $this->args = array_merge($this->args, $args);

        return $this;
    }
16091
public function all(array $args = []): array
    {
        // Establish args.

        $default_args = [
            // Unique.
            'max'         => PHP_INT_MAX,
            'fail_on_max' => false,

            // Also used by {@link total()}.
            'filters' => [
                'orderby' => 'display_name',
            ],
            'no_cache' => false,
        ];
        $args = array_merge($default_args, $args);
        $args = array_intersect_key($args, $default_args);

        // Unique.
        $args['max']         = max(1, (int) $args['max']);
        $args['fail_on_max'] = (bool) $args['fail_on_max'];

        // Also used by {@link total()}.
        $args['filters']  = (array) $args['filters'];
        $args['no_cache'] = (bool) $args['no_cache'];

        // Check cache; already did this query?

        $cache_keys = $args; // Keys to consider when checking the cache.
        unset($cache_keys['no_cache']); // Cache key exclusions.

        if (($users = &$this->cacheKey(__FUNCTION__, $cache_keys)) !== null && !$args['no_cache']) {
            return $users; // Already cached this.
        }
        // Automatically fail if there are too many; when/if desirable.

        if ($args['fail_on_max'] && $this->total($args) > $args['max']) {
            return $users = []; // Fail; too many.
        }
        // Return the array of all user objects now.

        $WP_User_Query = new \WP_User_Query(array_merge($args['filters'], [
            'fields' => 'all_with_meta', 'offset' => 0, 'paged' => 1, 'number' => -1, 'count_total' => true,
        ]));
        return $users = $WP_User_Query->get_results();
    }
1020884
public function getTerms($taxonomy = null)
    {
        if ($taxonomy) {
            return (array_key_exists($taxonomy, $this->_terms))
                ? $this->_terms[$taxonomy]
                : array();
        }

        return $this->_terms;
    }
1151918
public static function createMultiple($terms, $taxonomy = null)
    {
        if (!Arr::iterable($terms)) {
            return $terms;
        }
        
        $out = array();
        foreach ($terms as $term) {
            $instance = self::create($term, $taxonomy);
            $out[$instance->get('term_id')] = $instance;
        }
        return $out;
    }
875031
public function set_terms( $terms = array(), $taxonomy = '', $append = false ) {
		return \wp_set_post_terms( $this->id(), $terms, $taxonomy, $append );
	}
459863
public function register_taxonomy_rules( $taxonomy, $object_type, $args ) {
		global $wp_rewrite;

		/* for 4.7 */
		$args = (array) $args;

		if ( CPTP_Util::get_no_taxonomy_structure() ) {
			return;
		}

		if ( ! empty( $args['_builtin'] ) ) {
			return;
		}

		if ( false === $args['rewrite'] ) {
			return;
		}

		$post_types = $args['object_type'];
		foreach ( $post_types as $post_type ) :
			$post_type_obj = get_post_type_object( $post_type );
			if ( ! empty( $post_type_obj->rewrite['slug'] ) ) {
				$slug = $post_type_obj->rewrite['slug'];
			} else {
				$slug = $post_type;
			}

			if ( ! empty( $post_type_obj->has_archive ) && is_string( $post_type_obj->has_archive ) ) {
				$slug = $post_type_obj->has_archive;
			};

			if ( ! empty( $post_type_obj->rewrite['with_front'] ) ) {
				$slug = substr( $wp_rewrite->front, 1 ) . $slug;
			}

			if ( 'category' === $taxonomy ) {
				$cb            = get_option( 'category_base' );
				$taxonomy_slug = ( $cb ) ? $cb : $taxonomy;
				$taxonomy_key  = 'category_name';
			} else {
				// Edit by [Xiphe].
				if ( isset( $args['rewrite']['slug'] ) ) {
					$taxonomy_slug = $args['rewrite']['slug'];
				} else {
					$taxonomy_slug = $taxonomy;
				}
				// [Xiphe] stop
				$taxonomy_key = $taxonomy;
			}

			$rules = array(
				// feed.
				array(
					'regex'    => '%s/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&feed=\$matches[2]",
				),
				array(
					'regex'    => '%s/(.+?)/(feed|rdf|rss|rss2|atom)/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&feed=\$matches[2]",
				),
				// year.
				array(
					'regex'    => '%s/(.+?)/date/([0-9]{4})/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]",
				),
				array(
					'regex'    => '%s/(.+?)/date/([0-9]{4})/page/?([0-9]{1,})/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&paged=\$matches[3]",
				),
				// monthnum.
				array(
					'regex'    => '%s/(.+?)/date/([0-9]{4})/([0-9]{1,2})/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&monthnum=\$matches[3]",
				),
				array(
					'regex'    => '%s/(.+?)/date/([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&monthnum=\$matches[3]&paged=\$matches[4]",
				),
				// day.
				array(
					'regex'    => '%s/(.+?)/date/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&monthnum=\$matches[3]&day=\$matches[4]",
				),
				array(
					'regex'    => '%s/(.+?)/date/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&year=\$matches[2]&monthnum=\$matches[3]&day=\$matches[4]&paged=\$matches[5]",
				),
				// paging.
				array(
					'regex'    => '%s/(.+?)/page/?([0-9]{1,})/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]&paged=\$matches[2]",
				),
				// tax archive.
				array(
					'regex'    => '%s/(.+?)/?$',
					'redirect' => "index.php?{$taxonomy_key}=\$matches[1]",
				),
			);

			// no post_type slug.
			foreach ( $rules as $rule ) {
				$regex    = sprintf( $rule['regex'], "{$taxonomy_slug}" );
				$redirect = $rule['redirect'];
				add_rewrite_rule( $regex, $redirect, 'top' );
			}

			if ( get_option( 'add_post_type_for_tax' ) ) {
				foreach ( $rules as $rule ) {
					$regex    = sprintf( $rule['regex'], "{$slug}/{$taxonomy_slug}" );
					$redirect = $rule['redirect'] . "&post_type={$post_type}";
					add_rewrite_rule( $regex, $redirect, 'top' );
				}
			} else {
				foreach ( $rules as $rule ) {
					$regex    = sprintf( $rule['regex'], "{$slug}/{$taxonomy_slug}" );
					$redirect = $rule['redirect'];
					add_rewrite_rule( $regex, $redirect, 'top' );
				}
			}

			do_action( 'CPTP_registered_' . $taxonomy . '_rules', $object_type, $args, $taxonomy_slug );

		endforeach;
	}
713284
public function query($args = [])
    {
        $defaults = [
            'orderby'       => 'id',
            'order'         => 'DESC',
            'paginate'      => Option::get('default_posts_paginate', 20),
            'cat_in'        => [], //ids
            'cat_not_in'    => [], //ids
            'tag_in'        => [], //ids
            'tag_not_in'    => [], //ids
            'parent_in'     => [], //ids
            'parent_not_in' => [],
            'meta_query'    => [], // Array Of Arrays

        ];

        $args = array_merge($defaults, $args);

        $current_page = Request::get('page', 1);
        $cache_key = 'posts_' . md5(http_build_query($args) . '_' . $current_page);
        if (Cache::tags('posts')->has($cache_key)) {
            $posts = Cache::tags('posts')->get($cache_key);
        } else {
            $posts = $this->postRepository->queryPosts($args);

            if ( ! count($posts) > 0) {
                return new EtherError('No Posts were found');
            }

            Cache::tags('posts')->put($cache_key, $posts, \Option::get('posts_cache_expires', 60));

        }

        return $posts;
    }