CourseBuilder::_delete_section( $section_id )


Parameters

$section_id

(Required) Delete Section and all it's related, lecture, quiz, assignments, etc.


Source

File: classes/CourseBuilder.php

	public function _delete_section( $section_id ) {
		global $wpdb;

		do_action( 'dozent/delete_section/before', $section_id );

		$lecture_ids = (array) $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = {$section_id} " );

		wp_delete_post( $section_id, true );

		/**
		 * Delete all data related this section.
		 */
		$wpdb->delete( $wpdb->posts, [ 'post_parent' => $section_id ] );
		if ( dozent_count( $lecture_ids ) ) {
			$lecture_ids = implode( ',', array_map( 'absint', $lecture_ids ) );
			$wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE post_id IN({$lecture_ids})" );
		}

		do_action( 'dozent/delete_section/after', $section_id );
	}