wordpress/wp-content/themes/basic/themify/themify-wpajax.php
/**
 * Export Settings to zip file and prompt to download
 * NOTE: This function is not called through AJAX but it is kept here for consistency. 
 * @since 1.1.3
 * @package themify
 */
Export Settings to zip file and prompt to download
NOTE: This function is not called through AJAX but it is kept here for consistency.
Export Settings to zip file and prompt to download NOTE : This function is not called through AJAX but it is kept here for consistency .
function themify_export() {
	if ( isset( $_GET['export'] ) && 'themify' === $_GET['export'] ) {
		check_admin_referer( 'themify_export_nonce' );
		$theme = wp_get_theme();
		$theme_name = $theme->display('Name');
		if ( ! function_exists( 'WP_Filesystem' ) ) {
			require_once ABSPATH . 'wp-admin/includes/file.php';
		}
		WP_Filesystem();
		global $wp_filesystem;
		if(class_exists('ZipArchive')){
			$theme_name_lc = strtolower($theme_name);
			$datafile = 'data_export.txt';
			$wp_filesystem->put_contents( $datafile, serialize( themify_get_data() ) );
			$files_to_zip = array(
				get_template_directory() . '/custom-modules.php',
				get_template_directory() . '/custom-functions.php',
				get_template_directory() . '/custom-config.php',
				get_template_directory() . '/custom_style.css',
				$datafile
			);
			$file = $theme_name . '_themify_export_' . date('Y_m_d') . '.zip';
			$result = themify_create_zip( $files_to_zip, $file, true );
		}
		if(isset($result) && $result){
			if ( ( isset( $file ) ) && ( $wp_filesystem->exists( $file ) ) ) {
				ob_start();
				header('Pragma:public');
				header('Expires:0');
				header('Content-type:application/force-download');
				header('Content-Disposition:attachment; filename="' . $file . '"');
				header('Content-Transfer-Encoding:Binary'); 
				header('Content-length:'.filesize($file));
				header('Connection:close');
				ob_clean();
				flush();
				echo $wp_filesystem->get_contents( $file );
				$wp_filesystem->delete( $datafile );
				$wp_filesystem->delete( $file );
				exit();
			} else {
				return false;
			}
		} else {
			if ( ini_get( 'zlib.output_compression' ) ) {
				ini_set( 'zlib.output_compression', 'Off' );
			}
			ob_start();
			header('Content-Type: application/force-download');
			header('Pragma: public');
			header('Expires: 0');
			header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
			header('Cache-Control: private',false);
			header('Content-Disposition: attachment; filename="'.$theme_name.'_themify_export_'.date("Y_m_d").'.txt"');
			header('Content-Transfer-Encoding: binary');
			ob_clean();
			flush();
			echo serialize(themify_get_data());
			exit();
		}
	}
	return false;
}
function themify_export ( ) { if ( isset ( $ _GET [ 'export' ] ) && 'themify' === $ _GET [ 'export' ] ) { check_admin_referer ( 'themify_export_nonce' ) ; $ theme = wp_get_theme ( ) ; $ theme_name = $ theme -> display ( 'Name' ) ; if ( ! function_exists ( 'WP_Filesystem' ) ) { require_once ABSPATH . 'wp-admin/includes/file.php' ; } WP_Filesystem ( ) ; global $ wp_filesystem ; if ( class_exists ( 'ZipArchive' ) ) { $ theme_name_lc = strtolower ( $ theme_name ) ; $ datafile = 'data_export.txt' ; $ wp_filesystem -> put_contents ( $ datafile , serialize ( themify_get_data ( ) ) ) ; $ files_to_zip = array ( get_template_directory ( ) . '/custom-modules.php' , get_template_directory ( ) . '/custom-functions.php' , get_template_directory ( ) . '/custom-config.php' , get_template_directory ( ) . '/custom_style.css' , $ datafile ) ; $ file = $ theme_name . '_themify_export_' . date ( 'Y_m_d' ) . '.zip' ; $ result = themify_create_zip ( $ files_to_zip , $ file , true ) ; } if ( isset ( $ result ) && $ result ) { if ( ( isset ( $ file ) ) && ( $ wp_filesystem -> exists ( $ file ) ) ) { ob_start ( ) ; header ( 'Pragma:public' ) ; header ( 'Expires:0' ) ; header ( 'Content-type:application/force-download' ) ; header ( 'Content-Disposition:attachment; filename="' . $ file . '"' ) ; header ( 'Content-Transfer-Encoding:Binary' ) ; header ( 'Content-length:' . filesize ( $ file ) ) ; header ( 'Connection:close' ) ; ob_clean ( ) ; flush ( ) ; echo $ wp_filesystem -> get_contents ( $ file ) ; $ wp_filesystem -> delete ( $ datafile ) ; $ wp_filesystem -> delete ( $ file ) ; exit ( ) ; } else { return false ; } } else { if ( ini_get ( 'zlib.output_compression' ) ) { ini_set ( 'zlib.output_compression' , 'Off' ) ; } ob_start ( ) ; header ( 'Content-Type: application/force-download' ) ; header ( 'Pragma: public' ) ; header ( 'Expires: 0' ) ; header ( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' ) ; header ( 'Cache-Control: private' , false ) ; header ( 'Content-Disposition: attachment; filename="' . $ theme_name . '_themify_export_' . date ( " Y_m_d " ) . '.txt"' ) ; header ( 'Content-Transfer-Encoding: binary' ) ; ob_clean ( ) ; flush ( ) ; echo serialize ( themify_get_data ( ) ) ; exit ( ) ; } } return false ; }
Export Settings to zip file and prompt to download
 NOTE: This function is not called through AJAX but it is kept here for consistency.
Export Settings to zip file and prompt to download NOTE : This function is not called through AJAX but it is kept here for consistency .
//print_r($files_to_zip); /**
				 * Turn off output buffer compression for proper zip download.
				 * @since 2.0.2
				 */