# PHP functions

SleekView defines global PHP functions for its Views and Admin Pages, so a theme
or plugin reads them without knowing how SleekView stores them. They exist only
while SleekView is active, so guard calls with `function_exists()` in code that
can run without it. Its hooks, WP-CLI commands and REST operations are listed in
the generated references: [hooks](/docs/view/reference/hooks.md),
[CLI](/docs/view/reference/cli.md) and [REST](/docs/view/reference/rest.md).

Views and Admin Pages are kept in SleekView's own tables. Each is answered as
its record: `id`, `title`, `slug`, `status`, `author`, `data` (its settings),
`created_at` and `updated_at`.

## Functions

- `sleek_view_get_view( int $id ): ?array`: The View with this id, or `null`
  when no View has it.
- `sleek_view_get_views( array $statuses = [] ): array`: The Views, newest
  first: those of the given statuses, such as `['publish']`, or every one but
  trashed ones.
- `sleek_view_get_admin_page( int $id ): ?array`: The Admin Page with this id,
  or `null`. Its `data` lists the Views it shows.
- `sleek_view_get_admin_pages( array $statuses = [] ): array`: The Admin Pages,
  newest first, by status as for Views.

## Example

```php
if (function_exists('sleek_view_get_view')) {
    $board = sleek_view_get_view(42);
    if ($board !== null) {
        echo esc_html($board['title']);
    }
}
```
