LLMS_Post_Model::__construct( string|int|LLMS_Post_Model|WP_Post $model, array $args = array() )
Constructor
Description Description
Setup ID and related post property.
Parameters Parameters
- $model
-
(string|int|LLMS_Post_Model|WP_Post) (Required) 'new', WP post id, instance of an extending class, instance of WP_Post.
- $args
-
(array) (Optional) Args to create the post, only applies when $model is 'new'.
Default value: array()
Return Return
(void)
Source Source
File: includes/abstracts/abstract.llms.post.model.php
public function __construct( $model, $args = array() ) { if ( 'new' === $model ) { $model = $this->create( $args ); if ( ! is_wp_error( $model ) ) { $created = true; } } else { $created = false; } if ( empty( $model ) || is_wp_error( $model ) ) { return; } if ( is_numeric( $model ) ) { $this->id = absint( $model ); $this->post = get_post( $this->id ); } elseif ( is_subclass_of( $model, 'LLMS_Post_Model' ) ) { $this->id = absint( $model->id ); $this->post = $model->post; } elseif ( $model instanceof WP_Post && isset( $model->ID ) ) { $this->id = absint( $model->ID ); $this->post = $model; } if ( $created ) { $this->after_create(); } }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.13.0 | Unknown. |
3.0.0 | Introduced. |