LLMS_Post_Model::get_creation_args( array $args = null )
An array of default arguments to pass to $this->create() when creating a new post
Description Description
This should be overridden by child classes.
Parameters Parameters
- $args
-
(array) (Optional) Args of data to be passed to wp_insert_post.
Default value: null
Return Return
(array)
Source Source
File: includes/abstracts/abstract.llms.post.model.php
protected function get_creation_args( $args = null ) {
// Allow nothing to be passed in.
if ( empty( $args ) ) {
$args = array();
}
// Backwards compat to original 3.0.0 format when just a title was passed in.
if ( is_string( $args ) ) {
$args = array(
'post_title' => $args,
);
}
$args = wp_parse_args(
$args,
array(
'comment_status' => 'closed',
'ping_status' => 'closed',
'post_author' => get_current_user_id(),
'post_content' => '',
'post_excerpt' => '',
'post_status' => 'draft',
'post_title' => '',
'post_type' => $this->get( 'db_post_type' ),
)
);
/**
* Filters the llms post creation args
*
* The dynamic portion of this hook, `$this->model_post_type`, refers to the model's post type. For example "course",
* "lesson", "membership", etc...
*
* @since 3.24.0
*
* @param array $args Array of default creation args to be passed to `wp_insert_post()`.
* @param LLMS_Post_Model $llms_post The LLMS_Post_Model instance.
*/
return apply_filters( "llms_{$this->model_post_type}_get_creation_args", $args, $this );
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.18.0 | Unknown. |
| 3.0.0 | Introduced. |