wordpress/wp-content/themes/basic/themify/themify-builder/classes/class-themify-builder-layouts.php
/**
		 * Import Layout and Layout Parts.
		 *
		 * @access public
		 */
Import Layout and Layout Parts.
@access public
Import Layout and Layout Parts . @access public
public function row_bulk_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' => 'tbuilder_plupload_layout' ) );
			if ( !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( 'edit.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 . 'export_file.txt' ) ) {
						$data = $wp_filesystem->get_contents( $base_path . 'export_file.txt' );
						$msg = $this->set_data( unserialize( $data ) );
						$gs_path = $base_path . 'builder_gs_data_export.txt';
						if ( $wp_filesystem->exists( $gs_path ) ) {
							$gs_data = $wp_filesystem->get_contents( $gs_path );
							$gs_data = is_serialized( $gs_data ) ? maybe_unserialize( $gs_data ) : json_decode( $gs_data );
							Themify_Global_Styles::builder_import( $gs_data );
							$wp_filesystem->delete( $gs_path );
						}
						if ( $msg )
							$file['error'] = $msg;
						$wp_filesystem->delete( $base_path . 'export_file.txt' );
						$wp_filesystem->delete( $file['file'] );
					} else {
						$file['error'] = __( 'Data could not be loaded', 'themify' );
					}
				} else {
					if ( $wp_filesystem->exists( $file['file'] ) ) {
						$data = $wp_filesystem->get_contents( $file['file'] );
						$msg = $this->set_data( unserialize( $data ) );
						if ( $msg )
							$file['error'] = $msg;
						$wp_filesystem->delete( $file['file'] );
					} else {
						$file['error'] = __( 'Data could not be loaded', 'themify' );
					}
				}
			}
			$file['type'] = $ext[1];
			echo json_encode( $file );
			exit;
		}
public function row_bulk_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' => 'tbuilder_plupload_layout' ) ) ; if ( ! 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 ( 'edit.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 . 'export_file.txt' ) ) { $ data = $ wp_filesystem -> get_contents ( $ base_path . 'export_file.txt' ) ; $ msg = $ this -> set_data ( unserialize ( $ data ) ) ; $ gs_path = $ base_path . 'builder_gs_data_export.txt' ; if ( $ wp_filesystem -> exists ( $ gs_path ) ) { $ gs_data = $ wp_filesystem -> get_contents ( $ gs_path ) ; $ gs_data = is_serialized ( $ gs_data ) ? maybe_unserialize ( $ gs_data ) : json_decode ( $ gs_data ) ; Themify_Global_Styles :: builder_import ( $ gs_data ) ; $ wp_filesystem -> delete ( $ gs_path ) ; } if ( $ msg ) $ file [ 'error' ] = $ msg ; $ wp_filesystem -> delete ( $ base_path . 'export_file.txt' ) ; $ wp_filesystem -> delete ( $ file [ 'file' ] ) ; } else { $ file [ 'error' ] = __ ( 'Data could not be loaded' , 'themify' ) ; } } else { if ( $ wp_filesystem -> exists ( $ file [ 'file' ] ) ) { $ data = $ wp_filesystem -> get_contents ( $ file [ 'file' ] ) ; $ msg = $ this -> set_data ( unserialize ( $ data ) ) ; if ( $ msg ) $ file [ 'error' ] = $ msg ; $ wp_filesystem -> delete ( $ file [ 'file' ] ) ; } else { $ file [ 'error' ] = __ ( 'Data could not be loaded' , 'themify' ) ; } } } $ file [ 'type' ] = $ ext [ 1 ] ; echo json_encode ( $ file ) ; exit ; }
Import Layout and Layout Parts.
Import Layout and Layout Parts .
/** 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 // Check for importing attached GS data // send the uploaded file url in response