Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_Generator::create_section( array $raw, int $order, int $course_id, int $fallback_author_id = null )
Creates a new section Creates all lessons within the section data
Description Description
Parameters Parameters
- $raw
-
(array) (Required) raw section data
- $order
-
(int) (Required) order within the course (starts at 1)
- $course_id
-
(int) (Required) WP Post ID of the parent course
- $fallback_author_id
-
(int) (Optional) author ID to use as a fallback if no raw author data supplied for the lesson
Default value: null
Return Return
(int) WP Post ID of the Section
Source Source
File: includes/class.llms.generator.php
private function create_section( $raw, $order, $course_id, $fallback_author_id = null ) { $raw = apply_filters( 'llms_generator_before_new_section', $raw, $order, $course_id, $fallback_author_id, $this ); $author_id = $this->get_author_id_from_raw( $raw, $fallback_author_id ); // insert the course $section = new LLMS_Section( 'new', array( 'post_author' => $author_id, 'post_date' => isset( $raw['date'] ) ? $this->format_date( $raw['date'] ) : null, 'post_modified' => isset( $raw['modified'] ) ? $this->format_date( $raw['modified'] ) : null, 'post_status' => isset( $raw['status'] ) ? $raw['status'] : $this->get_default_post_status(), 'post_title' => $raw['title'], ) ); if ( ! $section->get( 'id' ) ) { return $this->error->add( 'section_creation', __( 'Error creating section', 'lifterlms' ) ); } $this->increment( 'sections' ); $section->set( 'parent_course', $course_id ); $section->set( 'order', $order ); if ( isset( $raw['lessons'] ) ) { foreach ( $raw['lessons'] as $lesson_order => $lesson ) { $this->create_lesson( $lesson, $lesson_order + 1, $section->get( 'id' ), $course_id, $author_id ); } } do_action( 'llms_generator_new_section', $section, $raw, $this ); return $section->get( 'id' ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.30.2 | Added hooks. |
3.3.0 | Introduced. |