PodsAPI::pod_exists PHP Method

pod_exists() public method

$params['id'] int Pod ID $params['name'] string Pod name
Since: 1.12
public pod_exists ( array $params, $type = null ) : boolean
$params array An associative array of parameters
return boolean True if exists
    public function pod_exists($params, $type = null)
    {
        if (is_string($params)) {
            $params = array('name' => $params);
        }
        $params = (object) pods_sanitize($params);
        if (!empty($params->id) || !empty($params->name)) {
            if (!isset($params->name)) {
                $pod = get_post($dummy = (int) $params->id);
            } else {
                $pod = get_posts(array('name' => $params->name, 'post_type' => '_pods_pod', 'posts_per_page' => 1));
            }
            if (!empty($pod) && (empty($type) || $type == get_post_meta($pod->ID, 'type', true))) {
                return true;
            }
        }
        return false;
    }