public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/functions.php
/**
 * Replace all of the email tags with the actual details.
 *
 * @since 1.0.0
 *
 * @param object $unitParentData The parent data for a unit.
 * @param object $userDetails The details of the user who's done the completing.
 * @param array  $tagList The list of tags found in the template.
 * @param string $emailData The data to replace the strings with.
 *
 * @return The modified email data ready for sending.
 */
Replace all of the email tags with the actual details.

@param object $unitParentData The parent data for a unit.
@param object $userDetails The details of the user who's done the completing.
@param array  $tagList The list of tags found in the template.
@param string $emailData The data to replace the strings with.

@return The modified email data ready for sending.
Replace all of the email tags with the actual details . @param object $unitParentData The parent data for a unit . @param object $userDetails The details of the user who ' s done the completing . @param array $tagList The list of tags found in the template . @param string $emailData The data to replace the strings with . @return The modified email data ready for sending .
function WPCW_email_replaceTags_generic( $unitParentData, $userDetails, $tagList, $emailData ) {
	if ( empty( $tagList ) ) {
		return $emailData;
	}
	foreach ( $tagList as $tagToReplace ) {
		switch ( $tagToReplace ) {
			case '{USER_NAME}':
				$emailData = str_replace( '{USER_NAME}', $userDetails->display_name, $emailData );
				break;
			case '{FIRST_NAME}':
				if ( ! isset( $userDetails->first_name ) ) {
					$userDetails = get_userdata( $userDetails->user_id );
				}
				$emailData = str_replace( '{FIRST_NAME}', $userDetails->first_name, $emailData );
				break;
			case '{LAST_NAME}':
				if ( ! isset( $userDetails->first_name ) ) {
					$userDetails = get_userdata( $userDetails->user_id );
				}
				$emailData = str_replace( '{LAST_NAME}', $userDetails->last_name, $emailData );
				break;
			case '{SITE_NAME}':
				$emailData = str_replace( '{SITE_NAME}', get_bloginfo( 'name' ), $emailData );
				break;
			case '{SITE_URL}':
				$emailData = str_replace( '{SITE_URL}', site_url(), $emailData );
				break;
			case '{COURSE_TITLE}':
				$emailData = str_replace( '{COURSE_TITLE}', $unitParentData->course_title, $emailData );
				break;
			case '{MODULE_TITLE}':
				$moduleTitle = false;
				if ( isset( $unitParentData->module_title ) ) {
					$moduleTitle = $unitParentData->module_title;
				}
				$emailData = str_replace( '{MODULE_TITLE}', $moduleTitle, $emailData );
				break;
			case '{MODULE_NUMBER}':
				$moduleNumber = false;
				if ( isset( $unitParentData->module_number ) ) {
					$moduleNumber = $unitParentData->module_number;
				}
				$emailData = str_replace( '{MODULE_NUMBER}', $moduleNumber, $emailData );
				break;
			case '{UNIT_TITLE}':
				$emailData = str_replace( '{UNIT_TITLE}', get_the_title( $unitParentData->unit_id ), $emailData );
				break;
			case '{UNIT_URL}':
				$emailData = str_replace( '{UNIT_URL}', get_permalink( $unitParentData->unit_id ), $emailData );
				break;
			case '{CERTIFICATE_LINK}':
				$certificateLink = false;
				if ( 'use_certs' == $unitParentData->course_opt_use_certificate ) {
					$certificateDetails = WPCW_certificate_getCertificateDetails( $userDetails->ID, $unitParentData->course_id, false );
					if ( $certificateDetails ) {
						$certificateLink = WPCW_certificate_generateLink( $certificateDetails->cert_access_key );
					}
				}
				$emailData = str_ireplace( '{CERTIFICATE_LINK}', $certificateLink, $emailData );
				break;
		}
	}
	return apply_filters( 'wpcw_email_data', $emailData );
}
function WPCW_email_replaceTags_generic ( $ unitParentData , $ userDetails , $ tagList , $ emailData ) { if ( empty ( $ tagList ) ) { return $ emailData ; } foreach ( $ tagList as $ tagToReplace ) { switch ( $ tagToReplace ) { case '{USER_NAME}' : $ emailData = str_replace ( '{USER_NAME}' , $ userDetails -> display_name , $ emailData ) ; break ; case '{FIRST_NAME}' : if ( ! isset ( $ userDetails -> first_name ) ) { $ userDetails = get_userdata ( $ userDetails -> user_id ) ; } $ emailData = str_replace ( '{FIRST_NAME}' , $ userDetails -> first_name , $ emailData ) ; break ; case '{LAST_NAME}' : if ( ! isset ( $ userDetails -> first_name ) ) { $ userDetails = get_userdata ( $ userDetails -> user_id ) ; } $ emailData = str_replace ( '{LAST_NAME}' , $ userDetails -> last_name , $ emailData ) ; break ; case '{SITE_NAME}' : $ emailData = str_replace ( '{SITE_NAME}' , get_bloginfo ( 'name' ) , $ emailData ) ; break ; case '{SITE_URL}' : $ emailData = str_replace ( '{SITE_URL}' , site_url ( ) , $ emailData ) ; break ; case '{COURSE_TITLE}' : $ emailData = str_replace ( '{COURSE_TITLE}' , $ unitParentData -> course_title , $ emailData ) ; break ; case '{MODULE_TITLE}' : $ moduleTitle = false ; if ( isset ( $ unitParentData -> module_title ) ) { $ moduleTitle = $ unitParentData -> module_title ; } $ emailData = str_replace ( '{MODULE_TITLE}' , $ moduleTitle , $ emailData ) ; break ; case '{MODULE_NUMBER}' : $ moduleNumber = false ; if ( isset ( $ unitParentData -> module_number ) ) { $ moduleNumber = $ unitParentData -> module_number ; } $ emailData = str_replace ( '{MODULE_NUMBER}' , $ moduleNumber , $ emailData ) ; break ; case '{UNIT_TITLE}' : $ emailData = str_replace ( '{UNIT_TITLE}' , get_the_title ( $ unitParentData -> unit_id ) , $ emailData ) ; break ; case '{UNIT_URL}' : $ emailData = str_replace ( '{UNIT_URL}' , get_permalink ( $ unitParentData -> unit_id ) , $ emailData ) ; break ; case '{CERTIFICATE_LINK}' : $ certificateLink = false ; if ( 'use_certs' == $ unitParentData -> course_opt_use_certificate ) { $ certificateDetails = WPCW_certificate_getCertificateDetails ( $ userDetails -> ID , $ unitParentData -> course_id , false ) ; if ( $ certificateDetails ) { $ certificateLink = WPCW_certificate_generateLink ( $ certificateDetails -> cert_access_key ) ; } } $ emailData = str_ireplace ( '{CERTIFICATE_LINK}' , $ certificateLink , $ emailData ) ; break ; } } return apply_filters ( 'wpcw_email_data' , $ emailData ) ; }
Replace all of the email tags with the actual details.
Replace all of the email tags with the actual details .
// Replace each tag for quiz-related data. // Certificates - generate a link if enabled.