GravityKit\GravityView\View\ViewCollection
A collection of View objects.
Since:
2.03.0.0(Migrated to GravityKit\GravityView\View namespace.)
Source: src/View/ViewCollection.php:19
Details
- Kind:
class - Namespace:
GravityKit\GravityView\View - Extends:
GV\Collection
Methods
| Method | Description |
|---|---|
all() | |
add() | Add a View to this collection. |
get() | Get a View from this list. |
contains() | Check whether \GV\View with an ID is already here. |
from_post() | Get a list of View objects inside the supplied \WP_Post. |
from_content() | Get a list of detected View objects inside the supplied content. |
Method Reference
all()
public function all()
Returns
View[]
Source: src/View/ViewCollection.php:25
add()
public function add( $view )
Add a View to this collection.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$view | View | The view to add to the internal array. |
Returns
void
Since: 2.0
Source: src/View/ViewCollection.php:38
get()
public function get( $view_id )
Get a View from this list.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$view_id | int | The ID of the view to get. |
Returns
\GV\View|null— The \GV\View with the $view_id as the ID, or null if not found.
Since: 2.0
Source: src/View/ViewCollection.php:58
contains()
public function contains( $view_id )
Check whether \GV\View with an ID is already here.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$view_id | int | The ID of the view to check. |
Returns
boolean— Whether it exists or not.
Since: 2.0
Source: src/View/ViewCollection.php:77
from_post()
public static function from_post( \WP_Post $post )
Get a list of View objects inside the supplied \WP_Post.
The post can be a gravityview post, which is the simplest case. The post can contain gravityview shortcodes as well. The post meta can contain gravityview shortcodes.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$post | \WP_Post | The \WP_Post object to look into. |
Returns
ViewCollection— A ViewCollection instance containing the views inside the supplied \WP_Post.
Since: 2.0
Source: src/View/ViewCollection.php:94
from_content()
public static function from_content( $content )
Get a list of detected View objects inside the supplied content.
The content can have a shortcode, this is the simplest case.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$content | string | The content to look into. |
Returns
ViewCollection— A ViewCollection instance containing the views inside the supplied \WP_Post.
Since: 2.0
Source: src/View/ViewCollection.php:193