public static function export_data_to_file( $file, $data, $single = false ) {

		$path = ABSPATH;

		// Detect path if it is set in the file param.
		if ( false !== strpos( $file, '/' ) ) {
			$path = dirname( $file );
			$file = basename( $file );
		}

		$format = 'json';

		// Detect the export format.
		if ( false !== strpos( $file, '.' ) ) {
			$format = explode( '.', $file );
			$format = end( $format );
		}

		$migrate_data = array(
			'items'  => array( $data ),
			'single' => $single,
		);

		$migrate = new self( $format, null, $migrate_data );

		// Handle processing the data into the format needed.
		$migrate->export();

		$save_params = array(
			'path'   => $path,
			'file'   => $file,
			'attach' => true,
		);

		return $migrate->save( $save_params );

	}