public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/admin/functions.php
/**
 * Given a list of tags, try to add them without adding them to a specific question.
 *
 * @since 1.0.0
 *
 * @param array $tagList The list of tags to add.
 *
 * @return array The list of tags to be rendered again.
 */
Given a list of tags, try to add them without adding them to a specific question.

@param array $tagList The list of tags to add.

@return array The list of tags to be rendered again.
Given a list of tags try to add them without adding them to a specific question . @param array $tagList The list of tags to add . @return array The list of tags to be rendered again .
function WPCW_questions_tags_addTags_withoutQuestion( $tagList ) {
	global $wpdb, $wpcwdb;
	$wpdb->show_errors();
	$taglistToReturn = array();
	foreach ( $tagList as $tagToAdd ) {
		if ( ! current_user_can( 'manage_wpcw_settings' ) ) {
			$tagDetails = $wpdb->get_row( $wpdb->prepare( "
				SELECT question_tag_id
				  FROM $wpcwdb->question_tags
				WHERE question_tag_name = %s
				AND question_tag_author = %d
			", $tagToAdd, get_current_user_id() ) );
		} else {
			$tagDetails = $wpdb->get_row( $wpdb->prepare( "
				SELECT question_tag_id
				  FROM $wpcwdb->question_tags
				WHERE question_tag_name = %s
			", $tagToAdd ) );
		}
		if ( $tagDetails ) {
			$taglistToReturn[ $tagDetails->question_tag_id ] = $tagToAdd;
		} 
		else {
			$wpdb->query( $wpdb->prepare( "
				INSERT INTO $wpcwdb->question_tags
				(question_tag_name, question_tag_usage, question_tag_author) VALUES (%s, 1, %d)
				", $tagToAdd, get_current_user_id() ) );
			$taglistToReturn[ $wpdb->insert_id ] = $tagToAdd;
		}
	}
	return $taglistToReturn;
}
function WPCW_questions_tags_addTags_withoutQuestion ( $ tagList ) { global $ wpdb , $ wpcwdb ; $ wpdb -> show_errors ( ) ; $ taglistToReturn = array ( ) ; foreach ( $ tagList as $ tagToAdd ) { if ( ! current_user_can ( 'manage_wpcw_settings' ) ) { $ tagDetails = $ wpdb -> get_row ( $ wpdb -> prepare ( " 
				SELECT question_tag_id
				  FROM  $ wpcwdb -> question_tags 
				WHERE question_tag_name = %s
				AND question_tag_author = %d
			 " , $ tagToAdd , get_current_user_id ( ) ) ) ; } else { $ tagDetails = $ wpdb -> get_row ( $ wpdb -> prepare ( " 
				SELECT question_tag_id
				  FROM  $ wpcwdb -> question_tags 
				WHERE question_tag_name = %s
			 " , $ tagToAdd ) ) ; } if ( $ tagDetails ) { $ taglistToReturn [ $ tagDetails -> question_tag_id ] = $ tagToAdd ; } else { $ wpdb -> query ( $ wpdb -> prepare ( " 
				INSERT INTO  $ wpcwdb -> question_tags 
				(question_tag_name, question_tag_usage, question_tag_author) VALUES (%s, 1, %d)
				 " , $ tagToAdd , get_current_user_id ( ) ) ) ; $ taglistToReturn [ $ wpdb -> insert_id ] = $ tagToAdd ; } } return $ taglistToReturn ; }
Given a list of tags, try to add them without adding them to a specific question.
Given a list of tags try to add them without adding them to a specific question .
// Just get the IDs of tags (and add the missing ones) // Check permissions, so that users that are not administrators cannot use other peoples tags. // Got a tag already, so need the tag ID // Add to list that we're turning to AJAX. // We need to insert the tag to the tag table.