LLMS_Post_Instructors::pre_set_instructors( array $instructors = array() )
Format an instructors array for saving to the db.
Parameters Parameters
- $instructors
-
(array) (Optional) Array of full (or partial) instructor data.
Default value: array()
Return Return
(array)
Source Source
File: includes/models/model.llms.post.instructors.php
public function pre_set_instructors( $instructors = array() ) { /** * We cannot allow no instructors to exist * so we'll revert to the default `post_author`. */ if ( ! $instructors ) { // Clear so the getter will retrieve the default author. $this->post->set( 'instructors', array() ); $instructors = $this->get_instructors(); } // Allow partial arrays to be passed & we'll fill em up with defaults. foreach ( $instructors as $i => &$instructor ) { $instructor = wp_parse_args( $instructor, llms_get_instructors_defaults() ); $instructor['id'] = absint( $instructor['id'] ); // Remove instructors without an ID. if ( empty( $instructor['id'] ) ) { unset( $instructors[ $i ] ); } } return array_values( $instructors ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.25.0 | Introduced. |