public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/setup.php
/**
 * Function called on initialisation of the function to clean up orphan tags.
 *
 * @since 4.1.0
 */
Function called on initialisation of the function to clean up orphan tags.
Function called on initialisation of the function to clean up orphan tags .
function WPCW_tag_cleanup() {
	global $wpdb, $wpcwdb;
	$wpdb->show_errors();
	if ( ! is_null( $wpdb->get_var( "SHOW TABLES LIKE '$wpcwdb->question_tag_mapping'" ) ) ) {
		$tags = $wpdb->get_results( "SELECT tm.*, qq.question_id AS jn_question_id
				FROM $wpcwdb->question_tag_mapping tm
				LEFT JOIN $wpcwdb->quiz_qs qq ON qq.question_id = tm.question_id
				WHERE qq.question_id IS NULL
				" );
		if ( $tags ) {
			foreach ( $tags as $tag ) {
				WPCW_questions_tags_removeTag( $tag->question_id, $tag->tag_id );
			}
		}
	}
}
function WPCW_tag_cleanup ( ) { global $ wpdb , $ wpcwdb ; $ wpdb -> show_errors ( ) ; if ( ! is_null ( $ wpdb -> get_var ( " SHOW TABLES LIKE ' $ wpcwdb -> question_tag_mapping ' " ) ) ) { $ tags = $ wpdb -> get_results ( " SELECT tm.*, qq.question_id AS jn_question_id
				FROM  $ wpcwdb -> question_tag_mapping  tm
				LEFT JOIN  $ wpcwdb -> quiz_qs  qq ON qq.question_id = tm.question_id
				WHERE qq.question_id IS NULL
				 " ) ; if ( $ tags ) { foreach ( $ tags as $ tag ) { WPCW_questions_tags_removeTag ( $ tag -> question_id , $ tag -> tag_id ) ; } } } }
Function called on initialisation of the function to clean up orphan tags.
Function called on initialisation of the function to clean up orphan tags .
// If table doesn't exist, don't run maintenance. // We want to find all unique questions that have been deleted. We do this by // joining the tag table with the table of questions. WHERE filters out where // a tag exists, but a question does. // Delete the tag from each question that we've found above, which will also // update the tag popularity once deleted.