wordpress/wp-content/themes/basic/themify/customizer/class-themify-customizer.php
/**
		 * AJAX - Plupload execution routines for customizer import file
		 * @since 3.0.2
		 * @package themify
		 */
Plupload execution routines for customizer import file
@since 3.0.2
@package themify
Plupload execution routines for customizer import file @since 3 . 0 . 2 @package themify
function customizer_import() {
			$imgid = $_POST['imgid'];
			! empty( $_POST[ '_ajax_nonce' ] ) && check_ajax_referer($imgid . 'themify-plupload');
			$file = wp_handle_upload($_FILES[$imgid . 'async-upload'], array('test_form' => true, 'action' => 'themify_plupload_customizer'));
			if (isset($file['error']) && !empty($file['error'])) {
				echo json_encode($file);
				exit;
			}
			$ext = explode('/', $file['type']);
			if ('zip' === $ext[1] || 'rar' === $ext[1] || 'plain' === $ext[1]) {
				$url = wp_nonce_url('customize.php');
				if (false === ($creds = request_filesystem_credentials($url) )) {
					return true;
				}
				if (!WP_Filesystem($creds)) {
					request_filesystem_credentials($url, '', true);
					return true;
				}
				global $wp_filesystem;
				$base_path = themify_upload_dir();
				$base_path = trailingslashit($base_path['path']);
				if ('zip' === $ext[1] || 'rar' === $ext[1]) {
					unzip_file($file['file'], $base_path);
					if ($wp_filesystem->exists($base_path . 'customizer_export.txt')) {
						$data = $wp_filesystem->get_contents($base_path . 'customizer_export.txt');
						$this->set_data(unserialize($data));
						$wp_filesystem->delete($base_path . 'customizer_export.txt');
						$wp_filesystem->delete($file['file']);
					} else {
						$file['error'] = __('Data could not be loaded1', 'themify');
					}
				} else {
					if ($wp_filesystem->exists($file['file'])) {
						$data = $wp_filesystem->get_contents($file['file']);
						$this->set_data(unserialize($data));
						$wp_filesystem->delete($file['file']);
					} else {
						$file['error'] = __('Data could not be loaded2', 'themify');
					}
				}
			}
			$file['type'] = $ext[1];
			echo json_encode($file);
			exit;
		}
function customizer_import ( ) { $ imgid = $ _POST [ 'imgid' ] ; ! empty ( $ _POST [ '_ajax_nonce' ] ) && check_ajax_referer ( $ imgid . 'themify-plupload' ) ; $ file = wp_handle_upload ( $ _FILES [ $ imgid . 'async-upload' ] , array ( 'test_form' => true , 'action' => 'themify_plupload_customizer' ) ) ; if ( isset ( $ file [ 'error' ] ) && ! empty ( $ file [ 'error' ] ) ) { echo json_encode ( $ file ) ; exit ; } $ ext = explode ( '/' , $ file [ 'type' ] ) ; if ( 'zip' === $ ext [ 1 ] || 'rar' === $ ext [ 1 ] || 'plain' === $ ext [ 1 ] ) { $ url = wp_nonce_url ( 'customize.php' ) ; if ( false === ( $ creds = request_filesystem_credentials ( $ url ) ) ) { return true ; } if ( ! WP_Filesystem ( $ creds ) ) { request_filesystem_credentials ( $ url , '' , true ) ; return true ; } global $ wp_filesystem ; $ base_path = themify_upload_dir ( ) ; $ base_path = trailingslashit ( $ base_path [ 'path' ] ) ; if ( 'zip' === $ ext [ 1 ] || 'rar' === $ ext [ 1 ] ) { unzip_file ( $ file [ 'file' ] , $ base_path ) ; if ( $ wp_filesystem -> exists ( $ base_path . 'customizer_export.txt' ) ) { $ data = $ wp_filesystem -> get_contents ( $ base_path . 'customizer_export.txt' ) ; $ this -> set_data ( unserialize ( $ data ) ) ; $ wp_filesystem -> delete ( $ base_path . 'customizer_export.txt' ) ; $ wp_filesystem -> delete ( $ file [ 'file' ] ) ; } else { $ file [ 'error' ] = __ ( 'Data could not be loaded1' , 'themify' ) ; } } else { if ( $ wp_filesystem -> exists ( $ file [ 'file' ] ) ) { $ data = $ wp_filesystem -> get_contents ( $ file [ 'file' ] ) ; $ this -> set_data ( unserialize ( $ data ) ) ; $ wp_filesystem -> delete ( $ file [ 'file' ] ) ; } else { $ file [ 'error' ] = __ ( 'Data could not be loaded2' , 'themify' ) ; } } } $ file [ 'type' ] = $ ext [ 1 ] ; echo json_encode ( $ file ) ; exit ; }
AJAX - Plupload execution routines for customizer import file
 @since 3.0.2
 @package themify
AJAX - Plupload execution routines for customizer import file @since 3 . 0 . 2 @package themify
/** Handle file upload storing file|url|type. @var Array */ // if $file returns error, return it and exit the function //let's see if it's an image, a zip file or something else // Import routines // send the uploaded file url in response