LLMS_Controller_Quizzes::maybe_handle_reporting_actions()

Handle quiz reporting screen actions buttons


Description Description

On the quiz reporting screen this allows orphaned quizzes to be deleted.


Top ↑

Return Return

(null|false|WP_Post) null if the form wasn't submitted or the nonce couldn't be verified.<br> false if an error was encountered.<br> WP_Post of the deleted quiz on success.


Top ↑

Source Source

File: includes/controllers/class.llms.controller.quizzes.php

	public function maybe_handle_reporting_actions() {

		if ( ! isset( $_REQUEST['_llms_quiz_actions_nonce'] ) ) {
			return null;
		}
		if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_llms_quiz_actions_nonce'] ) ), 'llms-quiz-actions' ) ) {
			return null;
		}

		$id = llms_filter_input( INPUT_POST, 'llms_del_quiz', FILTER_SANITIZE_NUMBER_INT );
		if ( $id && 'llms_quiz' === get_post_type( $id ) ) {
			if ( ! current_user_can( 'delete_post', $id ) ) {
				return false;
			}
			$quiz = llms_get_post( $id );
			if ( $quiz && ( $quiz->is_orphan( true ) || ! $quiz->get_course() ) ) {
				return wp_delete_post( $id, true );
			}
		}

		return false;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
9.2.3 Add capability check before deleting quiz.
5.1.0 Use a deep orphan check to determine if the quiz can be deleted.
3.37.8 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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