LLMS_Admin_Builder::output()

Output the page content


Return Return

(void)


Top ↑

Source Source

File: includes/admin/class.llms.admin.builder.php

	public static function output() {

		global $post;

		$course_id = isset( $_GET['course_id'] ) ? absint( $_GET['course_id'] ) : null;
		if ( ! $course_id || ( $course_id && 'course' !== get_post_type( $course_id ) ) ) {
			esc_html_e( 'Invalid course ID', 'lifterlms' );
			return;
		}

		$post = get_post( $course_id );

		if ( ! current_user_can( 'edit_course', $course_id ) ) {
			esc_html_e( 'You cannot edit this course!', 'lifterlms' );
			return;
		}

		if ( 'auto-draft' === $post->post_status ) {
			wp_update_post(
				array(
					'ID'          => $course_id,
					'post_status' => 'draft',
					'post_title'  => __( 'New Course', 'lifterlms' ),
				)
			);

			$post = get_post( $course_id );
		}

		$course = llms_get_post( $post );

		remove_all_actions( 'the_title' );
		remove_all_actions( 'the_content' );

		global $llms_builder_lazy_load;
		$llms_builder_lazy_load = true;
		?>

		<div class="wrap lifterlms llms-builder">

			<?php do_action( 'llms_before_builder', $course_id ); ?>

			<div class="llms-builder-main" id="llms-builder-main"></div>

			<aside class="llms-builder-sidebar" id="llms-builder-sidebar"></aside>

			<?php
				$templates = array(
					'assignment',
					'course',
					'editor',
					'elements',
					'lesson',
					'lesson-settings',
					'quiz',
					'question',
					'question-choice',
					'question-type',
					'section',
					'settings-fields',
					'sidebar',
					'utilities',
				);

				foreach ( $templates as $template ) {
					// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
					echo self::get_template(
						$template,
						array(
							'course_id' => $course_id,
						)
					);
					// phpcs:enable
				}

				?>

			<script>window.llms_builder =
			<?php
			echo json_encode(
				/**
				 * Filters the settings passed to the builder.
				 *
				 * @since 7.2.0
				 *
				 * @param array $settings Associative array of settings passed to the LifterLMS course builder.
				 */
				apply_filters(
					'llms_builder_settings',
					array(
						'autosave'               => self::get_autosave_status(),
						'admin_url'              => admin_url(),
						'course'                 => $course->toArray(),
						'debug'                  => array(
							'enabled' => ( defined( 'LLMS_BUILDER_DEBUG' ) && LLMS_BUILDER_DEBUG ),
						),
						'questions'              => array_values( llms_get_question_types() ),
						'schemas'                => self::get_custom_schemas(),
						'sync'                   => apply_filters(
							/**
							 * Filters the sync builder settings.
							 *
							 * @since 3.16.0
							 *
							 * @param array $settings Associative array of settings passed to the LifterLMS course builder used for the sync.
							 */
							'llms_builder_sync_settings',
							array(
								'check_interval_ms' => ( 'yes' === self::get_autosave_status() ? 10000 : 1000 ),
							)
						),
						'enable_video_explainer' => true,
						'home_url'               => home_url(),
					)
				)
			);
			?>
			</script>

			<?php do_action( 'llms_after_builder', $course_id ); ?>

		</div>

		<?php
		$llms_builder_lazy_load = false;
		self::handle_post_locking( $course_id );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
7.6.0 Removed video explainer template.
7.2.0 Added video explainer template.
4.14.0 Added builder autosave preference defaults.
3.19.2 Unknown.
3.13.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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