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_Admin_Builder::process_detachments( array $data )

Process lesson detachments from the heartbeat data


Parameters Parameters

$data

(array) (Required) Array of lesson ids.


Top ↑

Return Return

(array)


Top ↑

Source Source

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

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

		</div>

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

	}

	/**
	 * Process lesson detachments from the heartbeat data
	 *
	 * @since 3.16.0
	 * @since 3.27.0 Unknown.
	 *
	 * @param array $data Array of lesson ids.
	 * @return array
	 */
	private static function process_detachments( $data ) {

		$ret = array();

		foreach ( $data['detach'] as $id ) {

			$res = array(
				// Translators: %s = Item id.
				'error' => sprintf( esc_html__( 'Unable to detach "%s". Invalid ID.', 'lifterlms' ), $id ),
				'id'    => $id,
			);

			$type = get_post_type( $id );

			$post_types = apply_filters( 'llms_builder_detachable_post_types', array( 'lesson', 'llms_question', 'llms_quiz' ) );
			if ( ! is_numeric( $id ) || ! in_array( $type, $post_types ) ) {
				array_push( $ret, $res );
				continue;
			}

			$post = llms_get_post( $id );
			if ( ! is_a( $post, 'LLMS_Post_Model' ) ) {
				array_push( $ret, $res );
				continue;
			}

			if ( 'lesson' === $type ) {
				$post->set( 'parent_course', '' );
				$post->set( 'parent_section', '' );
			} elseif ( 'llms_question' === $type ) {


Top ↑

Changelog Changelog

Changelog
Version Description
3.27.0 Unknown.
3.16.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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