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_trash_item_post_type( int $id, string $post_type )

Delete / Trash a post type


Parameters Parameters

$id

(int) (Required) WP_Post ID.

$post_type

(string) (Required) Post type name.


Top ↑

Return Return

(boolean|WP_Error) true when successfully deleted or trashed. WP_Error for unsupported post types or when a deletion error is encountered.


Top ↑

Source Source

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

		if ( ! $question->delete_choice( $split[1] ) ) {
			// Translators: %s = Question choice ID.
			return new WP_Error( 'llms_builder_trash_custom_item', sprintf( esc_html__( 'Error deleting the question choice "%s"', 'lifterlms' ), $id ) );
		}

		// Success.
		return true;

	}

	/**
	 * Delete / Trash a post type
	 *
	 * @since 3.37.12
	 *
	 * @param int    $id        WP_Post ID.
	 * @param string $post_type Post type name.
	 * @return boolean|WP_Error `true` when successfully deleted or trashed.
	 *                          `WP_Error` for unsupported post types or when a deletion error is encountered.
	 */
	private static function process_trash_item_post_type( $id, $post_type ) {

		// Used for errors.
		$obj = get_post_type_object( $post_type );

		/**
		 * Filter course elements that can be deleted or trashed via the course builder.
		 *
		 * Note that the use of "trash" in the filter name is not semantically correct as this filter does not guarantee
		 * that the element will be sent to the trash. Use the filter `llms_builder_trash_{$post_type}_force_delete` to
		 * determine if the element is sent to the trash or deleted immediately.
		 *
		 * @since Unknown
		 * @since 3.37.12 The "question_choice" item was removed from the default list and is being handled as a "custom item".
		 *
		 * @param string[] $post_types Array of post type names.
		 */
		$post_types = apply_filters( 'llms_builder_trashable_post_types', array( 'lesson', 'llms_quiz', 'llms_question', 'section' ) );
		if ( ! in_array( $post_type, $post_types, true ) ) {
			// Translators: %s = Post type name.
			return new WP_Error( 'llms_builder_trash_unsupported_post_type', sprintf( esc_html__( '%s cannot be deleted via the Course Builder.', 'lifterlms' ), $obj->labels->name ) );
		}

		// Default force value: these post types are force deleted and others are moved to the trash.
		$force = in_array( $post_type, array( 'section', 'llms_question', 'llms_quiz' ), true );

		/**
		 * Determine whether or not a post type should be moved to the trash or deleted when trashed via the Course Builder.
		 *
		 * The dynamic portion of this hook, `$post_type`, refers to the post type name of the post that's being trashed.


Top ↑

Changelog Changelog

Changelog
Version Description
3.37.12 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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