Allcolates $post_type with current post type
@return  string / null
549704
public function getRequestedPostType()
    {
        if (!is_a($this->query, 'WP_Query')) {
            return null;
        }

        if (isset($this->query->query) && isset($this->query->query['post_type'])) {
            return $this->data['post_type'] = $this->query->query['post_type'];
        } else {
            return $this->data['post_type'] = null;
        }
    }
477782
public static function findByPostType($postTypeSlug)
    {
        $postType = PostType::findBySlug($postTypeSlug);
        if($postType) {
            return self::where('postTypeID', $postType->postTypeID)->get();
        }
        return;
    }
950940
public function getAllWithoutPaginationByPostType($lang = "", $postType = "")
    {
        return DB::table('tags')->join('post_type', 'post_type.postTypeID', 'tags.postTypeID')->where('post_type.slug', $postType)->orderBy('name', 'postTypeID')->get();
    }
123903
public static function getFields($post_type)
    {
        $postType = PostType::all()->where('slug', $post_type)->first();

        if($postType) {
            return $postType->fields;
        }
        
        return [];
    }
1326399
protected function andRelationToPostIn($query_type)
    {
        $andQuery = new Query();

        // Copy the current Query but remove the OR conditions.
        // They will be looked up as this instance goes on with
        // the process.
        $filterCopy = $this->filters;

        unset($filterCopy["limit"]);
        unset($filterCopy["posts_per_page"]);
        $filterCopy[$query_type]["OR"] = array();
        $filterCopy['nopaging'] = true;

        $andQuery->applyFilters($filterCopy);
        $andQuery->resetQueryRelation($query_type, 'OR');

        // This forces the AND relationships to be loaded before
        // comparing the or parameters
        $andIds = $andQuery->listing("ID", "ID");

        $this->where('post__in', array_values($andIds));
        $this->resetQueryRelation($query_type, 'AND');

        return $this;
    }
1117924
public function getInTableColumns($postType)
    {
        $inTableColumnsSlugs = [];
        $fields = PostType::getFields($postType);

        // default columns
        foreach(Post::$defaultListColumns as $key => $label){
            if(substr($label, 0, 2) == '__') {
                $label = __(substr($label, 2));
            }

            $inTableColumnsSlugs[$key] = $label;
        }

        // post type columns
        foreach($fields as $field){
            if($field->inTable) {
                $inTableColumnsSlugs[$field->slug] = $field->name;
            }
        }

        // custom events columns
        $customListColumms = Event::fire('post:table_list_columns', [$postType]);
        foreach($customListColumms as $customList){
            if(is_array($customList)) {
                foreach ($customList as $key => $value) {
                    $inTableColumnsSlugs[$key] = $value;
                }
            }
        }
        return $inTableColumnsSlugs;
    }
292685
public function post($element = null, $filter_type = null)
    {
        if (!$this->post) {
            $content_type = $this->getContentType();
            if ($content_type === 'application/json') {
                $json = file_get_contents('php://input');
                $this->post = json_decode($json, true);
            } elseif (!empty($_POST)) {
                $this->post = (array)$_POST;
            }

            $event = new Event(['post' => &$this->post]);
            Grav::instance()->fireEvent('onHttpPostFilter', $event);
        }

        if ($this->post && null !== $element) {
            $item = Utils::getDotNotation($this->post, $element);
            if ($filter_type) {
                $item = filter_var($item, $filter_type);
            }
            return $item;
        }

        return $this->post;
    }
874390
protected function getPostTypeObject()
    {
        if ($this->postTypeObj === null) {
            $this->postTypeObj = get_post_type_object($this->getType());
        }

        return $this->postTypeObj;
    }
723216
function get_posts( $post_ids )
	{
		// validate
		if( empty($post_ids) )
		{
			return $post_ids;
		}
		
		
		// vars
		$r = array();
		
		
		// find posts (DISTINCT POSTS)
		$posts = get_posts(array(
			'numberposts'	=>	-1,
			'post__in'		=>	$post_ids,
			'post_type'		=>	apply_filters('acf/get_post_types', array()),
			'post_status'	=>	'any',
		));

		
		$ordered_posts = array();
		foreach( $posts as $p )
		{
			// create array to hold value data
			$ordered_posts[ $p->ID ] = $p;
		}
		
		
		// override value array with attachments
		foreach( $post_ids as $k => $v)
		{
			// check that post exists (my have been trashed)
			if( isset($ordered_posts[ $v ]) )
			{
				$r[] = $ordered_posts[ $v ];
			}
		}
		
		
		// return
		return $r;
	}
296438
protected function get_post_field( $key, $default = null, $post_array = null, $setting = [], $filter = true ) {
		if ( isset( $post_array ) ) {
			$value = $this->app->utility->array_get( $post_array, $this->get_post_field_name( $key ), $default );
		} else {
			$value = $this->app->input->post( $this->get_post_field_name( $key ), $default );
		}

		if ( isset( $setting['null'] ) && empty( $setting['null'] ) && (string) $value === '' ) {
			$value = null;
		}

		if ( ! $filter ) {
			return $value;
		}

		return $this->filter_post_field( $key, $value, $default, $post_array );
	}
575130
public static function get_pure_post_content() {
		$post = get_post();

		if ( ! $post || ! isset( $post->post_content ) ) {
			return;
		}

		if ( post_password_required( $post ) ) {
			return;
		}

		$extended = get_extended( $post->post_content );
		$content  = $extended['main'];
		return $content;
	}
6340
public static function get_date_front( $post_type ) {
		$structure = CPTP_Util::get_permalink_structure( $post_type );

		$front = '';

		preg_match_all( '/%.+?%/', $structure, $tokens );
		$tok_index = 1;
		foreach ( (array) $tokens[0] as $token ) {
			if ( '%post_id%' === $token && ( $tok_index <= 3 ) ) {
				$front = '/date';
				break;
			}
			$tok_index ++;
		}

		return apply_filters( 'CPTP_date_front', $front, $post_type, $structure );
	}
1324262
public function delete_post_type(){
    global $wpdb;

    //checking the nonce
    check_admin_referer('delete_post_type_mf_posttype');

    if( isset($_GET['post_type']) ){
      $post_type = $_GET['post_type'];

      if( $post_type ){

        $sql = $wpdb->prepare( "DELETE FROM ".MF_TABLE_POSTTYPES." WHERE type = '%s'",$post_type );
        $wpdb->query($sql);

        //delete all groups of post_type
        $sql_fields = $wpdb->prepare( "DELETE FROM ".MF_TABLE_CUSTOM_GROUPS." WHERE post_type = '%s'",$post_type );
        $wpdb->query($sql_fields);

        //delete field of post_type
        $sql_fields = $wpdb->prepare( "DELETE FROM ".MF_TABLE_CUSTOM_FIELDS." WHERE post_type = '%s'",$post_type );
        $wpdb->query($sql_fields);

        $this->mf_redirect(null,null,array('message' => 'success'));
      }
    }
  }
406697
public function type() {
		if ( isset($this->custom['type']) ) {
			return $this->custom['type'];
		}
		if ( !$this->__type instanceof PostType ) {
			$this->__type = new PostType($this->post_type);
		}
		return $this->__type;
	}
1030666
public function get_post_type($post_type){
    global $wpdb;

    $query = $wpdb->prepare( "SELECT * FROM ".MF_TABLE_POSTTYPES." WHERE type = %s", array( $post_type ) );

    $post_type = $wpdb->get_row( $query, ARRAY_A );
    if($post_type){
      $post_type_id = $post_type['id'];
      $post_type = unserialize($post_type['arguments']);
      $post_type['core']['id'] = $post_type_id;
      return $post_type;
    }
    return false;
  }
1256200
public function getRequestedPostTypeArchivePermalink()
    {
        $requested_post_type = $this->getRequestedPostType();

        if (!is_null($requested_post_type)) {
            $this->data['post_type_permalink']  = get_post_type_archive_link($requested_post_type);
        } else {
            $this->data['post_type_permalink'] = false;
        }

        return;
    }
507987
public static function findBySlug($slug, $postTypeSlug = '')
    {
        $postTypeSlug = ($postTypeSlug ? $postTypeSlug : PostType::getSlug());

        $postObj = (new Post())->setTable($postTypeSlug);
        $post = $postObj
            ->where('slug_'.App::getLocale(), $slug)
            ->with($postObj->getDefaultRelations(getPostType($postTypeSlug)))
            ->first();

        return $post;
    }