wordpress/wp-content/themes/basic/themify/themify-builder/classes/class-themify-builder-layouts.php
/**
		 * Export Layouts and Layout Parts.
		 *
		 * @access public
		 */
Export Layouts and Layout Parts.
@access public
Export Layouts and Layout Parts . @access public
public function export_row_bulk( $redirect_to, $action, $pIds ) {
			if ( $action !== 'tbuilder-bulk-export' || empty( $pIds ) ) {
				return $redirect_to;
			}
			$data = array( 'import' => '', 'content' => array() );
			$type = get_post_type( $pIds[0] );
			$data['import'] = $type ===self::$layout_part_slug ? 'Layout Parts' : 'Layouts';
			$usedGS = array();
			foreach ( $pIds as $pId ) {
				$data['content'][] = array(
					'title' => get_the_title( $pId ),
					'settings' => get_post_meta( $pId, '_themify_builder_settings_json', true )
				);
				$usedGS = $usedGS + Themify_Global_Styles::used_global_styles( $pId );
			}
			if ( !function_exists( 'WP_Filesystem' ) ) {
				require_once ABSPATH . 'wp-admin/includes/file.php';
			}
			WP_Filesystem();
			global $wp_filesystem;
			if ( class_exists( 'ZipArchive' ) ) {
				$datafile = 'export_file.txt';
				$wp_filesystem->put_contents( $datafile, serialize( $data ) );
				$files_to_zip = array( $datafile );
				if ( !empty( $usedGS ) ) {
					foreach ( $usedGS as $gsID => $gsPost ) {
						unset( $usedGS[ $gsID ]['id'] );
						unset( $usedGS[ $gsID ]['url'] );
						$styling = Themify_Builder_Import_Export::prepare_builder_data( $gsPost['data'] );
						$styling = $styling[0];
						if ( $gsPost['type'] === 'row' || $gsPost['type'] === 'subrow' ) {
							$styling = $styling['styling'];
						} elseif ( $gsPost['type'] === 'column' ) {
							$styling = $styling['cols'][0]['styling'];
						} else {
							$styling = $styling['cols'][0]['modules'][0]['mod_settings'];
						}
						$usedGS[ $gsID ]['data'] = $styling;
					}
					$gs_data = json_encode( $usedGS );
					$gs_datafile = 'builder_gs_data_export.txt';
					$wp_filesystem->put_contents( $gs_datafile, $gs_data, FS_CHMOD_FILE );
					$files_to_zip[] = $gs_datafile;
				}
				$file = 'themify_' . $data['import'] . '_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="themify_' . $data['import'] . '_export_' . date( "Y_m_d" ) . '.txt"' );
				header( 'Content-Transfer-Encoding: binary' );
				ob_clean();
				flush();
				echo serialize( $data );
				exit();
			}
			return false;
		}
public function export_row_bulk ( $ redirect_to , $ action , $ pIds ) { if ( $ action !== 'tbuilder-bulk-export' || empty ( $ pIds ) ) { return $ redirect_to ; } $ data = array ( 'import' => '' , 'content' => array ( ) ) ; $ type = get_post_type ( $ pIds [ 0 ] ) ; $ data [ 'import' ] = $ type === self :: $ layout_part_slug ? 'Layout Parts' : 'Layouts' ; $ usedGS = array ( ) ; foreach ( $ pIds as $ pId ) { $ data [ 'content' ] [ ] = array ( 'title' => get_the_title ( $ pId ) , 'settings' => get_post_meta ( $ pId , '_themify_builder_settings_json' , true ) ) ; $ usedGS = $ usedGS + Themify_Global_Styles :: used_global_styles ( $ pId ) ; } if ( ! function_exists ( 'WP_Filesystem' ) ) { require_once ABSPATH . 'wp-admin/includes/file.php' ; } WP_Filesystem ( ) ; global $ wp_filesystem ; if ( class_exists ( 'ZipArchive' ) ) { $ datafile = 'export_file.txt' ; $ wp_filesystem -> put_contents ( $ datafile , serialize ( $ data ) ) ; $ files_to_zip = array ( $ datafile ) ; if ( ! empty ( $ usedGS ) ) { foreach ( $ usedGS as $ gsID => $ gsPost ) { unset ( $ usedGS [ $ gsID ] [ 'id' ] ) ; unset ( $ usedGS [ $ gsID ] [ 'url' ] ) ; $ styling = Themify_Builder_Import_Export :: prepare_builder_data ( $ gsPost [ 'data' ] ) ; $ styling = $ styling [ 0 ] ; if ( $ gsPost [ 'type' ] === 'row' || $ gsPost [ 'type' ] === 'subrow' ) { $ styling = $ styling [ 'styling' ] ; } elseif ( $ gsPost [ 'type' ] === 'column' ) { $ styling = $ styling [ 'cols' ] [ 0 ] [ 'styling' ] ; } else { $ styling = $ styling [ 'cols' ] [ 0 ] [ 'modules' ] [ 0 ] [ 'mod_settings' ] ; } $ usedGS [ $ gsID ] [ 'data' ] = $ styling ; } $ gs_data = json_encode ( $ usedGS ) ; $ gs_datafile = 'builder_gs_data_export.txt' ; $ wp_filesystem -> put_contents ( $ gs_datafile , $ gs_data , FS_CHMOD_FILE ) ; $ files_to_zip [ ] = $ gs_datafile ; } $ file = 'themify_' . $ data [ 'import' ] . '_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="themify_' . $ data [ 'import' ] . '_export_' . date ( " Y_m_d " ) . '.txt"' ) ; header ( 'Content-Transfer-Encoding: binary' ) ; ob_clean ( ) ; flush ( ) ; echo serialize ( $ data ) ; exit ( ) ; } return false ; }
Export Layouts and Layout Parts.
Export Layouts and Layout Parts .
// Check for attached GS // Export used global styles