public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/functions.php
/**
 * Migrate certificate data to each course.
 *
 * @since 1.0.0
 */
Migrate certificate data to each course.
Migrate certificate data to each course .
function WPCW_database_migrate_certificateData() {
	global $wpdb, $wpcwdb;
	$findCoursesToUpdateSQL = "SELECT * FROM $wpcwdb->courses";
	$rowsToUpdate = $wpdb->get_results( $findCoursesToUpdateSQL );
	$wpcwSettings = WPCW_TidySettings_getSettings( WPCW_DATABASE_SETTINGS_KEY );
	$wpcwSettingsValues = array(
		'cert_signature_type'        => WPCW_arrays_getValue( $wpcwSettings, 'cert_signature_type' ),
		'cert_sig_text'              => WPCW_arrays_getValue( $wpcwSettings, 'cert_sig_text' ),
		'cert_sig_image_url'         => WPCW_arrays_getValue( $wpcwSettings, 'cert_sig_image_url' ),
		'cert_logo_enabled'          => WPCW_arrays_getValue( $wpcwSettings, 'cert_logo_enabled' ),
		'cert_logo_url'              => WPCW_arrays_getValue( $wpcwSettings, 'cert_logo_url' ),
		'cert_background_type'       => WPCW_arrays_getValue( $wpcwSettings, 'cert_background_type' ),
		'cert_background_custom_url' => WPCW_arrays_getValue( $wpcwSettings, 'cert_background_custom_url' ),
	);
	foreach ( $rowsToUpdate as $singleRow ) {
		if ( ! isset( $singleRow->course_id ) ) {
			continue;
		}
		$wpdb->query(
			$wpdb->prepare( "
		            UPDATE $wpcwdb->courses
		            SET cert_signature_type = %s, 
		                cert_sig_text = %s, 
		                cert_sig_image_url = %s, 
		                cert_logo_enabled = %s,
		                cert_logo_url = %s,
		                cert_background_type = %s,
		                cert_background_custom_url = %s
		            WHERE course_id = %d;",
				$wpcwSettingsValues['cert_signature_type'],
				$wpcwSettingsValues['cert_sig_text'],
				$wpcwSettingsValues['cert_sig_image_url'],
				$wpcwSettingsValues['cert_logo_enabled'],
				$wpcwSettingsValues['cert_logo_url'],
				$wpcwSettingsValues['cert_background_type'],
				$wpcwSettingsValues['cert_background_custom_url'],
				$singleRow->course_id
			)
		);
	}
}
function WPCW_database_migrate_certificateData ( ) { global $ wpdb , $ wpcwdb ; $ findCoursesToUpdateSQL = " SELECT * FROM  $ wpcwdb -> courses " ; $ rowsToUpdate = $ wpdb -> get_results ( $ findCoursesToUpdateSQL ) ; $ wpcwSettings = WPCW_TidySettings_getSettings ( WPCW_DATABASE_SETTINGS_KEY ) ; $ wpcwSettingsValues = array ( 'cert_signature_type' => WPCW_arrays_getValue ( $ wpcwSettings , 'cert_signature_type' ) , 'cert_sig_text' => WPCW_arrays_getValue ( $ wpcwSettings , 'cert_sig_text' ) , 'cert_sig_image_url' => WPCW_arrays_getValue ( $ wpcwSettings , 'cert_sig_image_url' ) , 'cert_logo_enabled' => WPCW_arrays_getValue ( $ wpcwSettings , 'cert_logo_enabled' ) , 'cert_logo_url' => WPCW_arrays_getValue ( $ wpcwSettings , 'cert_logo_url' ) , 'cert_background_type' => WPCW_arrays_getValue ( $ wpcwSettings , 'cert_background_type' ) , 'cert_background_custom_url' => WPCW_arrays_getValue ( $ wpcwSettings , 'cert_background_custom_url' ) , ) ; foreach ( $ rowsToUpdate as $ singleRow ) { if ( ! isset ( $ singleRow -> course_id ) ) { continue ; } $ wpdb -> query ( $ wpdb -> prepare ( " 
		            UPDATE  $ wpcwdb -> courses 
		            SET cert_signature_type = %s, 
		                cert_sig_text = %s, 
		                cert_sig_image_url = %s, 
		                cert_logo_enabled = %s,
		                cert_logo_url = %s,
		                cert_background_type = %s,
		                cert_background_custom_url = %s
		            WHERE course_id = %d; " , $ wpcwSettingsValues [ 'cert_signature_type' ] , $ wpcwSettingsValues [ 'cert_sig_text' ] , $ wpcwSettingsValues [ 'cert_sig_image_url' ] , $ wpcwSettingsValues [ 'cert_logo_enabled' ] , $ wpcwSettingsValues [ 'cert_logo_url' ] , $ wpcwSettingsValues [ 'cert_background_type' ] , $ wpcwSettingsValues [ 'cert_background_custom_url' ] , $ singleRow -> course_id ) ) ; } }
Migrate certificate data to each course.
Migrate certificate data to each course .
// 1 - Define SQL to lookup courses with certs enabled. // 2 - Get Results from db. // 3 - Get Settings for the certificate // 4 - Get the Settings Values // 5 - Go through each db row // Check // 6 - Migrate Certificate Settings already set.