wordpress/wp-content/themes/basic/themify/themify-builder/classes/class-themify-global-styles.php
/**
	 * Handle Ajax request for import global style posts (Copy & Paste Module)
	 *
	 * @access public
	 */
Handle Ajax request for import global style posts (Copy & Paste Module)
@access public
Handle Ajax request for import global style posts ( Copy & Paste Module ) @access public
public static function import_posts_ajax() {
		if ( isset( $_POST['imgid'] ) ) {
			$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' => 'tb_import_gs_posts_ajax' ) );
			if ( !empty( $file['error'] ) ) {
				echo json_encode( $file );
				exit;
			}
			$ext = explode( '/', $file['type'] );
			if ( '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;
				if ( $wp_filesystem->exists( $file['file'] ) ) {
					$data = $wp_filesystem->get_contents( $file['file'] );
					$data = json_decode( $data, true );
					$wp_filesystem->delete( $file['file'] );
				} else {
					$file['error'] = __( 'Data could not be loaded', 'themify' );
				}
			}
		} else {
			check_ajax_referer( 'tb_load_nonce', 'tb_load_nonce' );
			$data = !empty( $_POST['data'] ) ? (is_array($_POST['data'])?$_POST['data']:json_decode(stripslashes_deep($_POST['data']),true)): array();
		}
		$globalStyles = self::builder_import( $data,!empty( $_POST['onlySave'] ) );
		if ( isset( $_POST['imgid'] ) ) {
			$file['type'] = $ext[1];
			echo json_encode( $file );
			exit;
		} else {
			wp_send_json( $globalStyles );
		}
	}
public static function import_posts_ajax ( ) { if ( isset ( $ _POST [ 'imgid' ] ) ) { $ 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' => 'tb_import_gs_posts_ajax' ) ) ; if ( ! empty ( $ file [ 'error' ] ) ) { echo json_encode ( $ file ) ; exit ; } $ ext = explode ( '/' , $ file [ 'type' ] ) ; if ( '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 ; if ( $ wp_filesystem -> exists ( $ file [ 'file' ] ) ) { $ data = $ wp_filesystem -> get_contents ( $ file [ 'file' ] ) ; $ data = json_decode ( $ data , true ) ; $ wp_filesystem -> delete ( $ file [ 'file' ] ) ; } else { $ file [ 'error' ] = __ ( 'Data could not be loaded' , 'themify' ) ; } } } else { check_ajax_referer ( 'tb_load_nonce' , 'tb_load_nonce' ) ; $ data = ! empty ( $ _POST [ 'data' ] ) ? ( is_array ( $ _POST [ 'data' ] ) ? $ _POST [ 'data' ] : json_decode ( stripslashes_deep ( $ _POST [ 'data' ] ) , true ) ) : array ( ) ; } $ globalStyles = self :: builder_import ( $ data , ! empty ( $ _POST [ 'onlySave' ] ) ) ; if ( isset ( $ _POST [ 'imgid' ] ) ) { $ file [ 'type' ] = $ ext [ 1 ] ; echo json_encode ( $ file ) ; exit ; } else { wp_send_json ( $ globalStyles ) ; } }
Handle Ajax request for import global style posts (Copy & Paste Module)
 @access public
Handle Ajax request for import global style posts ( Copy & Paste Module ) @access public
//let's see if it's a text file