LLMS_Post_Instructors::pre_set_instructors( array $instructors = array() )
Format an instructors array for saving to the db.
Description Description
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 current 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. |
User Contributed Notes User Contributed Notes
Permalink: