public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/admin/functions.php
/**
 * Given the tag and question IDs, remove the association.
 *
 * @since 1.0.0
 *
 * @param integer $questionID The ID of the question to remove the tag from.
 * @param integer $tagID The ID of the tag to remove from the questio
 */
Given the tag and question IDs, remove the association.

@param integer $questionID The ID of the question to remove the tag from.
@param integer $tagID The ID of the tag to remove from the questio
Given the tag and question IDs remove the association . @param integer $questionID The ID of the question to remove the tag from . @param integer $tagID The ID of the tag to remove from the questio
function WPCW_questions_tags_removeTag( $questionID, $tagID ) {
	global $wpdb, $wpcwdb;
	$wpdb->show_errors();
	if ( absint( $questionID ) === 0 ) {
		$tagFound = $wpdb->get_row( $wpdb->prepare( "
			SELECT *
			  FROM $wpcwdb->question_tags
			  WHERE question_tag_id = %d
		", $tagID ) );
		if ( $tagFound ) {
			$wpdb->query( $wpdb->prepare( "
                UPDATE $wpcwdb->question_tags
                SET question_tag_usage = %d
                WHERE question_tag_id = %d
            ", 0, $tagID ) );
		}
	} else {
		$tagFound = $wpdb->get_row( $wpdb->prepare( "
			SELECT *
			  FROM $wpcwdb->question_tag_mapping
			WHERE question_id = %d
			  AND tag_id = %d
		", $questionID, $tagID ) );
		if ( $tagFound ) {
			$wpdb->query( $wpdb->prepare( "
                DELETE FROM $wpcwdb->question_tag_mapping
                WHERE question_id = %d
                  AND tag_id = %d
            ", $questionID, $tagID ) );
			WPCW_questions_tags_updatePopularity( $tagID );
		}
	}
}
function WPCW_questions_tags_removeTag ( $ questionID , $ tagID ) { global $ wpdb , $ wpcwdb ; $ wpdb -> show_errors ( ) ; if ( absint ( $ questionID ) === 0 ) { $ tagFound = $ wpdb -> get_row ( $ wpdb -> prepare ( " 
			SELECT *
			  FROM  $ wpcwdb -> question_tags 
			  WHERE question_tag_id = %d
		 " , $ tagID ) ) ; if ( $ tagFound ) { $ wpdb -> query ( $ wpdb -> prepare ( " 
                UPDATE  $ wpcwdb -> question_tags 
                SET question_tag_usage = %d
                WHERE question_tag_id = %d
             " , 0 , $ tagID ) ) ; } } else { $ tagFound = $ wpdb -> get_row ( $ wpdb -> prepare ( " 
			SELECT *
			  FROM  $ wpcwdb -> question_tag_mapping 
			WHERE question_id = %d
			  AND tag_id = %d
		 " , $ questionID , $ tagID ) ) ; if ( $ tagFound ) { $ wpdb -> query ( $ wpdb -> prepare ( " 
                DELETE FROM  $ wpcwdb -> question_tag_mapping 
                WHERE question_id = %d
                  AND tag_id = %d
             " , $ questionID , $ tagID ) ) ; WPCW_questions_tags_updatePopularity ( $ tagID ) ; } } }
Given the tag and question IDs, remove the association.
Given the tag and question IDs remove the association .
// Check that the tag exists first... // Update the count in the tag field // Check that the tag exists first... // Only remove if found... // Update tag usage count.