@param string $full_name
@param int $post_id (optional)
@param string $contributor_type (optional)

@return array|false An array containing the `term_id` and `term_taxonomy_id`, false otherwise.
514665
public function insert( $full_name, $post_id = 0, $contributor_type = 'pb_authors' ) {
		$full_name = trim( $full_name );
		$slug = sanitize_title_with_dashes( remove_accents( $full_name ), '', 'save' );
		$term = get_term_by( 'slug', $slug, self::TAXONOMY );
		if ( $term ) {
			$results = [
				'term_id' => $term->term_id,
				'term_taxonomy_id' => $term->term_taxonomy_id,
			];
		} else {
			$results = wp_insert_term(
				$full_name, self::TAXONOMY, [
					'slug' => $slug,
				]
			);
		}

		if ( $post_id && is_array( $results ) ) {
			$this->link( $results['term_id'], $post_id, $contributor_type );
		}

		return is_array( $results ) ? $results : false;
	}
82709
private function create_taxonomy_replace_tag( $post_id, $permalink ) {
		$search  = array();
		$replace = array();

		$taxonomies = CPTP_Util::get_taxonomies( true );

		// %taxnomomy% -> parent/child
		foreach ( $taxonomies as $taxonomy => $objects ) {

			if ( false !== strpos( $permalink, '%' . $taxonomy . '%' ) ) {
				$terms = get_the_terms( $post_id, $taxonomy );

				if ( $terms && ! is_wp_error( $terms ) ) {
					$parents  = array_map( array( __CLASS__, 'get_term_parent' ), $terms );
					$newTerms = array();
					foreach ( $terms as $key => $term ) {
						if ( ! in_array( $term->term_id, $parents , true ) ) {
							$newTerms[] = $term;
						}
					}

					$term_obj  = reset( $newTerms );
					$term_slug = $term_obj->slug;

					if ( isset( $term_obj->parent ) && $term_obj->parent ) {
						$term_slug = CPTP_Util::get_taxonomy_parents_slug( $term_obj->parent, $taxonomy, '/', true ) . $term_slug;
					}
				}

				if ( isset( $term_slug ) ) {
					$search[]  = '%' . $taxonomy . '%';
					$replace[] = $term_slug;
				}
			}
		}

		return array(
			'search' => $search,
			'replace' => $replace,
		);
	}
601178
public static function guest_object_id( $object_id = 0, $object_type = null ) {
		global $pagenow;

		if ( is_null( $object_type ) ) {
			$object_type = static::guest_object_type();
		}

		switch ( $object_type ) {
			case 'user':
				$object_id = isset( $_REQUEST['user_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['user_id'] ) ) : $object_id;

				if ( ! $object_id && 'user-new.php' !== $pagenow && isset( $GLOBALS['user_ID'] ) ) {
					$object_id = $GLOBALS['user_ID'];
				}
				break;

			case 'comment':
				$object_id = isset( $_REQUEST['c'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['c'] ) ) : $object_id;

				if ( ! $object_id && isset( $GLOBALS['comments']->comment_ID ) ) {
					$object_id = $GLOBALS['comments']->comment_ID;
				}
				break;

			case 'term':
				$object_id = isset( $_REQUEST['tag_ID'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['tag_ID'] ) ) : $object_id;
				break;

			default:
				$object_id = isset( $GLOBALS['post']->ID ) ? $GLOBALS['post']->ID : $object_id;

				if ( ! $object_id && isset( $_REQUEST['post'] ) ) {
					$object_id = sanitize_text_field( wp_unslash( $_REQUEST['post'] ) );
				}
				break;
		}

		return absint( $object_id );
	}
769973
public static function get_custom_field_data( $post_id ) {

		global $post;
		if ( ! is_object( $post ) ) {
			$post = get_post( $post_id );
		}

		$raw_data = get_post_meta( $post_id  );

		if ( ! is_array( $raw_data ) ) {
			return;

		}
		
		// init the data array		
		$template_data = array();

		// add taxonomies in with a :taxonomy alias
		$taxonomies = get_object_taxonomies( $post );
		if( !empty( $taxonomies ) ){
			foreach ( $taxonomies as $taxonomy_name  ) {

				$taxonomy = get_taxonomy( $taxonomy_name );
				$template_data['taxonomy'][ $taxonomy_name ] = $template_data[ $taxonomy_name ] = wp_get_post_terms( $post->ID, $taxonomy_name, array("fields" => "all") );

			}
		}

		// break to standard arrays
		foreach( $raw_data as $meta_key=>$meta_data ){

			if( count( $meta_data ) === 1 ){
				if( strlen( trim( $meta_data[0] ) ) > 0 ){ // check value is something else leave it out.
					$template_data[$meta_key] = trim( $meta_data[0] );
				}
			}else{
				$template_data[$meta_key] = $meta_data;
			}
		}
		// ACF support
		if( class_exists( 'acf' ) ){
			$fields = get_fields( $post->ID );
			if ( is_array( $fields ) && ! empty( $fields ) ) {
				$template_data = array_merge( $template_data, $fields );
			}

		}
		// CFS support
		if( class_exists( 'Custom_Field_Suite' ) ){
			$fields = CFS()->get();
			if ( is_array( $fields ) && ! empty( $fields ) ) {
				$template_data = array_merge( $template_data, $fields );
			}

		}

		//Pods support
		if ( class_exists( 'Pods' ) && false != ( $pods = pods( $post->post_type, $post->ID, true ) ) ) {
			$fields = $pods->export();
			if ( is_array( $fields ) && ! empty( $fields ) ) {
				$template_data = array_merge( $template_data, $fields );
			}

		}


		// include post values if in a post
		if( !empty( $post ) ){
			foreach( $post as $post_key=>$post_value ){
				$template_data[$post_key] = $post_value;
			}
			// author details
			$template_data['post_author'] = get_userdata( $template_data['post_author'] );
			// add permalink
			$template_data['permalink'] = get_permalink( $post->ID );
			// core post object
			$template_data['post_format'] = get_post_format( $post );

		}

		return $template_data;

	}
1142028
protected function locateSection( $section_id, $post_type ) {
		if ( $post_type === 'glossary' ) {
			foreach ( $this->sourceBookGlossary as $k => $v ) {
				if ( $v['id'] === absint( $section_id ) ) {
					return $this->sourceBookGlossary[ $k ];
				}
			}
		} else {
			foreach ( $this->sourceBookStructure['_embedded'][ $post_type ] as $k => $v ) {
				if ( $v['id'] === absint( $section_id ) ) {
					return $this->sourceBookStructure['_embedded'][ $post_type ][ $k ];
				}
			};
		}
		return false;
	}
797151
public function save_taxonomy_track_changed_fields( $term_id, $taxonomy ) {

		$no_conflict = pods_no_conflict_check( 'term' );

		if ( ! $no_conflict ) {
			$pod = $taxonomy;
			$id  = $term_id;

			PodsAPI::handle_changed_fields( $pod, $id, 'reset' );
		}

	}
820645
public function getMeta($posts_id)
    {
        if (!is_array($posts_id)) {
            $posts_id = [$posts_id];
        }

        array_map([$this, 'checkId'], $posts_id);

        return $this->adapter->get(sprintf('/posts/meta?ids=%s', implode(',', $posts_id)));
    }
1290998
public function getPost($post_id)
    {
        $this->checkId($post_id);

        return $this->adapter->get(sprintf('/post/%d', $post_id));
    }
1313266
public function getCommentsForPost($post_id)
    {
        $this->checkId($post_id);

        return $this->adapter->get(sprintf('/comments/%d', $post_id));
    }
1345310
public function getPostMetaQuery($postId, $metaName)
    {
        return $this->createQueryBuilder('m')
            ->innerJoin('m.post', 'p')
            ->where('m.key = :metaName')
            ->andWhere('p.id = :postId')
            ->setParameter('postId', $postId)
            ->setParameter('metaName', $metaName)
            ->getQuery();
    }
1349134
public static function get_post_type_author_archive_support( $post_type ) {
		if ( is_string( $post_type ) ) {
			$post_type = get_post_type_object( $post_type );
		}

		if ( ! empty( $post_type->cptp ) && isset( $post_type->cptp['author_archive'] ) ) {
			return ! ! $post_type->cptp['author_archive'];
		}

		return true;

	}
743860
public static function findByExactMeta ($meta_key, $meta_value, $post_type = PostTypes::ANY)
    {
        return get_posts(array(
            'post_type'  => $post_type,
            'meta_key'   => $meta_key,
            'meta_value' => $meta_value
        ));
    }
907521
public function get_custom_taxonomy($custom_taxonomy_id){
    global $wpdb;

    $query = sprintf('SELECT * FROM %s WHERE id = %s',MF_TABLE_CUSTOM_TAXONOMY,$custom_taxonomy_id);
    $custom_taxonomy = $wpdb->get_row( $query, ARRAY_A );
    if($custom_taxonomy){
      $custom_taxonomy = unserialize($custom_taxonomy['arguments']);
      $custom_taxonomy['core']['id'] = $custom_taxonomy_id;
      return $custom_taxonomy;
    }
    return false;
  }
668426
public function getEntity($full_name)
    {
        if ( !array_key_exists($full_name, $this->entities) ) {
            $filePath = $this->getCacheFilePath(Util::toFileName($full_name, '.dat'));
            if ( $this->fs->exists($filePath) === false ) {
                return null;
            }
            $file = $this->fs->get($filePath);
            /** @var File $file */
            $file = $this->entities[ $full_name ] = unserialize($file);
            $file->getEntity();
        }
        return $this->entities[ $full_name ];
    }
1011932
public static function addSaveHooks($term_id)
    {
        // Assign vars
        $class = get_called_class();
        $instance = new $class;
        $updated_entry = new $class;
        $field_keys = array_merge(
            static::getCoreFieldKeys(),
            array_keys($instance->getFields())
        );
        foreach ($_POST as $k => $v) {
            if (in_array($k, $field_keys)) {
                $updated_entry->set($k, $v);
            }
        }

        // Not sure why WordPress uses tag_ID here and term_id otherwise
        if (array_key_exists('tag-name', $_POST)) {
            $updated_entry->set('name', $_POST['tag-name']);
        }
        if (array_key_exists('tag_ID', $_POST)) {
            $updated_entry->set(self::ID, $_POST['tag_ID']);
        }

        // Forcing $exclude_core to be true prevents an infinite loop
        return $updated_entry->save(true);
        // return $updated_entry->save(array_key_exists(self::ID, $updated_entry->getInfo()));
    }
1082920
public function setTerms($term_ids, $taxonomy = null, $append = false)
    {
        $taxonomy = ($taxonomy) ? $taxonomy : 'post_tag';
        if (!is_array($this->_terms)) {
            $this->_terms = array();
        }
        if (!array_key_exists($taxonomy, $this->_terms)) {
            $this->_terms[$taxonomy] = array();
        }

        $this->_terms[$taxonomy] = ($append)
            ? array_merge($this->_terms[$taxonomy], $term_ids)
            : $term_ids;
        return $this->_terms[$taxonomy];
    }
1196120
public function searchTerm($term, $vocabulary_id, $language_id = null, $exclude = [])
    {
        $language_id = $this->getLanguage($vocabulary_id, $language_id);

        $term = trim($term);
        if ($term == '') {
            return;
        }

        $query = TermData::select('taxonomy_terms.id')
            ->join('taxonomy_terms', 'taxonomy_terms.id', '=', 'taxonomy_terms_data.term_id')
            ->where('taxonomy_terms.vocabulary_id', $vocabulary_id)
            ->where('taxonomy_terms_data.language_id', $language_id)
            ->where('taxonomy_terms_data.title', $term);

        if (count($exclude)) {
            $query->whereNotIn('taxonomy_terms.id', $exclude);
        }

        return $query->value('id');
    }