LLMS_Generator_Courses::create_section( array $raw, int $order, int $course_id, int $fallback_author_id = null )

Creates a new section


Description Description

Creates all lessons within the section data.


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 section. When not supplied the fall back will be on the current user ID.

Default value: null


Top ↑

Return Return

(int)


Top ↑

Source Source

File: includes/class-llms-generator-courses.php

	protected function create_section( $raw, $order, $course_id, $fallback_author_id = null ) {

		/**
		 * Filter raw section import data prior to generation
		 *
		 * @since 3.30.2
		 *
		 * @param array          $raw                Raw quiz data array.
		 * @param int            $order              Order within the course (starts at 1).
		 * @param int            $course_id          WP Post ID of the parent course.
		 * @param int            $fallback_author_id Optional author ID to use as a fallback if no raw author data supplied for the section.
		 * @param LLMS_Generator $generator          Generator instance.
		 */
		$raw = apply_filters( 'llms_generator_before_new_section', $raw, $order, $course_id, $fallback_author_id, $this );

		$raw['parent_course'] = $course_id;
		$raw['order']         = $order;

		$section = $this->create_post( 'section', $raw, $fallback_author_id );

		if ( isset( $raw['lessons'] ) ) {
			foreach ( $raw['lessons'] as $lesson_order => $lesson ) {
				$this->create_lesson( $lesson, ++$lesson_order, $section->get( 'id' ), $course_id, $section->get( 'author' ) );
			}
		}

		/**
		 * Action triggered immediately following generation of a new section
		 *
		 * @since 3.30.2
		 *
		 * @param LLMS_Section   $section   Generated section object.
		 * @param array          $raw       Original raw section data array.
		 * @param LLMS_Generator $generator Generator instance.
		 */
		do_action( 'llms_generator_new_section', $section, $raw, $this );

		return $section->get( 'id' );

	}

Top ↑

Changelog Changelog

Changelog
Version Description
4.7.0 Use create_post() from abstract.
3.30.2 Added hooks.
3.3.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.