PodsUI::delete PHP Method

delete() public method

public delete ( null $id = null ) : boolean | mixed
$id null
return boolean | mixed
    public function delete($id = null)
    {
        $this->do_hook('pre_delete', $id);
        if (false !== $this->callback_action('delete', $id)) {
            return null;
        }
        $id = pods_absint($id);
        if (empty($id)) {
            $id = pods_absint($this->id);
        }
        if ($id < 1) {
            return $this->error(__('<strong>Error:</strong> Invalid Configuration - Missing "id" definition.', 'pods'));
        }
        if (false === $id) {
            $id = $this->id;
        }
        if (is_object($this->pod)) {
            $check = $this->pod->delete($id);
        } else {
            $check = $this->pods_data->delete($this->sql['table'], array($this->sql['field_id'] => $id));
        }
        if ($check) {
            $this->message(sprintf(__("<strong>Deleted:</strong> %s has been deleted.", 'pods'), $this->item));
        } else {
            $this->error(sprintf(__("<strong>Error:</strong> %s has not been deleted.", 'pods'), $this->item));
        }
        $this->do_hook('post_delete', $id);
    }