fix test if post is null on `get_collection()`

This commit is contained in:
vnmedeiros 2021-03-22 18:19:34 -03:00
parent 2e7365d73f
commit a6a9a71a22
1 changed files with 4 additions and 1 deletions

View File

@ -37,7 +37,10 @@ trait Entity_Collection_Relation {
return $this->collection;
}
} else {
$post_type = get_post($this->get_id())->post_type;
$post = get_post($this->get_id());
if (!$post || !$post->post_type)
return null;
$post_type = $post->post_type;
$matches = array();
$regex = '/' . Collection::$db_identifier_prefix . '([a-zA-Z0-9_]*)' . Collection::$db_identifier_sufix . '/';
preg_match($regex, $post_type, $matches);