first commit

This commit is contained in:
2024-07-15 11:28:08 +02:00
commit f52d538ea5
21891 changed files with 6161164 additions and 0 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -0,0 +1,19 @@
( function( $, JetDataExport ) {
"use strict";
JetDataExport = {
globalProgress: null,
init: function(){
$( '#jet-export' ).on( 'click', function( event ) {
var $this = $( this ),
href = $this.attr( 'href' );
event.preventDefault();
window.location = href + '&nonce=' + window.JetDataExportVars.nonce;
});
},
};
JetDataExport.init();
}( jQuery, window.JetDataExport ) );

View File

@@ -0,0 +1,404 @@
( function( $, JetDataImport ) {
"use strict";
JetDataImport = {
selectors: {
trigger: '#jet-import-start',
advancedTrigger: 'button[data-action="start-install"]',
popupTrigger: 'button[data-action="confirm-install"]',
removeContent: 'button[data-action="remove-content"]',
upload: '#jet-file-upload',
globalProgress: '#jet-import-progress'
},
globalProgress: null,
init: function(){
$( function() {
JetDataImport.globalProgress = $( JetDataImport.selectors.globalProgress ).find( '.cdi-progress__bar' );
$( 'body' )
.on( 'click.cdiImport', JetDataImport.selectors.trigger, JetDataImport.goToImport )
.on( 'click.cdiImport', JetDataImport.selectors.advancedTrigger, JetDataImport.advancedImport )
.on( 'click.cdiImport', JetDataImport.selectors.popupTrigger, JetDataImport.confirmImport )
.on( 'click.cdiImport', JetDataImport.selectors.removeContent, JetDataImport.removeContent )
.on( 'focus.cdiImport', '.cdi-remove-form__input', JetDataImport.clearRemoveNotices )
.on( 'change.cdiImport', 'input[name="install-type"]', JetDataImport.advancedNotice )
.on( 'click.cdiImport', '.cdi-advanced-popup__close', JetDataImport.closePopup );
$( document )
.on( 'tm-wizard-install-finished', JetDataImport.wizardPopup )
.on( 'cdiSliderInit', JetDataImport.initSlider );
if ( window.JetDataImportVars.autorun ) {
JetDataImport.startImport();
}
if ( undefined !== window.JetRegenerateData ) {
JetDataImport.regenerateThumbnails();
}
JetDataImport.fileUpload();
JetDataImport.initSlider();
} );
},
initSlider: function() {
var $slider = $( '.cdi-slider .swiper-container' );
if ( ! $slider.length ) {
return;
}
new Swiper( $slider[0], {
paginationClickable: true,
autoplay: 15000,
pagination: '.slider-pagination',
parallax: true,
speed: 600
} );
},
wizardPopup: function () {
$( '.cdi-advanced-popup' ).removeClass( 'popup-hidden' ).trigger( 'cdi-popup-opened' );
},
removeContent: function() {
var $this = $( this ),
$pass = $this.prev(),
$form = $this.closest( '.cdi-remove-form' ),
$notices = $( '.cdi-remove-form__notices', $form ),
data = {};
if ( $this.hasClass( 'in-progress' ) ) {
return;
}
data.action = 'jet-data-import-remove-content';
data.nonce = window.JetDataImportVars.nonce;
data.password = $pass.val();
$this.addClass( 'in-progress' );
$.ajax({
url: window.ajaxurl,
type: 'post',
dataType: 'json',
data: data,
error: function() {
$this.removeClass( 'in-progress' );
}
}).done( function( response ) {
if ( true === response.success ) {
$form.addClass( 'content-removed' );
$notices.removeClass( 'cdi-hide' );
$notices.html( response.data.message ).removeClass( 'cdi-error' );
if ( undefined !== response.data.slider ) {
JetDataImport.showSlider( $form, response.data.slider );
}
JetDataImport.startImport();
} else {
$notices.addClass( 'cdi-error' ).removeClass( 'cdi-hide' );
$notices.html( response.data.message );
}
$this.removeClass( 'in-progress' );
});
},
showSlider: function( where, slider ) {
setTimeout( function() {
where.before( slider );
where.remove();
console.log('');
$( document ).trigger( 'cdiSliderInit' );
}, 2000 );
},
clearRemoveNotices: function() {
var $this = $( this ),
$form = $this.closest( '.cdi-remove-form' ),
$notices = $( '.cdi-remove-form__notices', $form );
$notices.removeClass( 'cdi-error' ).addClass( 'cdi-hide' );
},
closePopup: function() {
$( '.cdi-advanced-popup' ).addClass( 'popup-hidden' ).data( 'url', null );
$( '.cdi-btn.in-progress' ).removeClass( 'in-progress' );
},
confirmImport: function() {
var $this = $( this ),
$popup = $this.closest( '.cdi-advanced-popup' ),
$checkbox = $( '.cdi-advanced-popup__item input[type="radio"]:checked', $popup ),
type = 'append',
url = $popup.data( 'url' );
$this.addClass( 'in-progress' );
if ( undefined !== $checkbox.val() && '' !== $checkbox.val() ) {
type = $checkbox.val();
}
url = url + '&type=' + type;
window.location = url;
},
advancedImport: function() {
var $this = $( this ),
$item = $this.closest( '.advanced-item' ),
$type = $( '.advanced-item__type-checkbox input[type="checkbox"]', $item ),
url = window.JetDataImportVars.advURLMask,
full = $item.data( 'full' ),
skin = $item.data( 'skin' ),
min = $item.data( 'lite' );
$this.addClass( 'in-progress' );
if ( $type.is(':checked') ) {
url = url.replace( '<-file->', min );
} else {
url = url.replace( '<-file->', full );
}
url += '&skin=' + skin;
$( '.cdi-advanced-popup' ).removeClass( 'popup-hidden' ).data( 'url', url );
},
advancedNotice: function() {
var $this = $( this ),
$popup = $this.closest( '.cdi-advanced-popup__content' ),
$notice = $( '.cdi-advanced-popup__warning', $popup );
if ( $this.is( ':checked' ) && 'replace' === $this.val() ) {
$notice.removeClass( 'cdi-hide' );
} else if ( ! $notice.hasClass( 'cdi-hide' ) ) {
$notice.addClass( 'cdi-hide' );
}
},
regenerateThumbnails: function() {
var data = {
action: 'jet-data-thumbnails',
offset: 0,
step: window.JetRegenerateData.step,
total: window.JetRegenerateData.totalSteps
};
JetDataImport.ajaxRequest( data );
},
ajaxRequest: function( data ) {
var complete;
data.nonce = window.JetDataImportVars.nonce;
data.file = window.JetDataImportVars.file;
data.skin = window.JetDataImportVars.skin;
data.xml_type = window.JetDataImportVars.xml_type;
$.ajax({
url: window.ajaxurl,
type: 'get',
dataType: 'json',
data: data,
error: function() {
if ( data.step ) {
complete = Math.ceil( ( data.offset + data.step ) * 100 / ( data.total * data.step ) );
JetDataImport.globalProgress
.css( 'width', complete + '%' )
.find( '.cdi-progress__label' ).text( complete + '%' );
data.offset = data.offset + data.step;
JetDataImport.ajaxRequest( data );
} else {
$( '#jet-import-progress' ).replaceWith(
'<div class="import-failed">' + window.JetDataImportVars.error + '</div>'
);
}
}
}).done( function( response ) {
if ( true === response.success && ! response.data.isLast ) {
JetDataImport.ajaxRequest( response.data );
}
if ( response.data && response.data.redirect ) {
window.location = response.data.redirect;
}
if ( response.data && response.data.complete ) {
JetDataImport.globalProgress
.css( 'width', response.data.complete + '%' )
.find( '.cdi-progress__label' ).text( response.data.complete + '%' )
.closest( '.cdi-progress__bar' )
.next( '.cdi-progress__sub-label' ).text( response.data.complete + '%' );
JetDataImport.globalProgress.siblings( '.cdi-progress__placeholder' ).remove();
}
if ( response.data && response.data.processed ) {
$.each( response.data.processed, JetDataImport.updateSummary );
}
});
},
updateSummary: function( index, value ) {
var $row = $( 'tr[data-item="' + index + '"]' ),
total = parseInt( $row.data( 'total' ), 10 ),
$done = $( '.cdi-install-summary__done', $row ),
$percent = $( '.cdi-install-summary__percent', $row ),
$progress = $( '.cdi-progress__bar', $row ),
$status = $( '.cdi-progress-status', $row ),
percentVal = Math.round( ( parseInt( value, 10 ) / total ) * 100 );
if ( $done.hasClass( 'is-finished' ) ) {
return;
}
if ( 100 === percentVal ) {
$done.addClass( 'is-finished' ).closest( 'td' ).addClass( 'is-finished' );
$status.html( '<span class="dashicons dashicons-yes"></span>' );
}
$done.html( value );
$percent.html( percentVal );
$progress.css( 'width', percentVal + '%' );
},
startImport: function() {
var data = {
action: 'jet-data-import-chunk',
chunk: 1
};
JetDataImport.ajaxRequest( data );
},
prepareImportArgs: function() {
var file = null,
$upload = $( 'input[name="upload_file"]' ),
$select = $( 'select[name="import_file"]' );
if ( $upload.length && '' !== $upload.val() ) {
file = $upload.val();
}
if ( $select.length && null === file ) {
file = $( 'option:selected', $select ).val();
}
return '&tab=' + window.JetDataImportVars.tab + '&step=2&file=' + file;
},
goToImport: function() {
var url = $('input[name="referrer"]').val();
if ( ! $( this ).hasClass( 'disabled' ) ) {
window.location = url + JetDataImport.prepareImportArgs();
}
},
fileUpload: function() {
var $button = $( JetDataImport.selectors.upload ),
$container = $button.closest('.import-file'),
$placeholder = $container.find('.import-file__placeholder'),
$input = $container.find('.import-file__input'),
uploader = wp.media.frames.file_frame = wp.media({
title: window.JetDataImportVars.uploadTitle,
button: {
text: window.JetDataImportVars.uploadBtn
},
multiple: false
}),
openFrame = function () {
uploader.open();
return !1;
},
onFileSelect = function() {
var attachment = uploader.state().get( 'selection' ).toJSON(),
xmlData = attachment[0],
inputVal = '';
$placeholder.val( xmlData.url );
JetDataImport.getFilePath( xmlData.url, $input );
};
$button.on( 'click', openFrame );
uploader.on('select', onFileSelect );
},
getFilePath: function( fileUrl, $input ) {
var $importBtn = $( JetDataImport.selectors.trigger ),
path = '';
$importBtn.addClass( 'disabled' );
$.ajax({
url: window.ajaxurl,
type: 'get',
dataType: 'json',
data: {
action: 'jet-data-import-get-file-path',
file: fileUrl,
nonce: window.JetDataImportVars.nonce
},
error: function() {
$importBtn.removeClass( 'disabled' );
return !1;
}
}).done( function( response ) {
$importBtn.removeClass( 'disabled' );
if ( true === response.success ) {
$input.val( response.data.path );
}
});
}
};
JetDataImport.init();
}( jQuery, window.JetDataImport ) );

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,76 @@
<?php
/**
* Base class for caching method. All caching methods must be extends from this class.
* All methods are required for child classes
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Data_Importer_Cache_Handler' ) ) {
/**
* Define Jet_Data_Importer_Cache_Handler class
*/
class Jet_Data_Importer_Cache_Handler {
/**
* Store passed value in cache with passed key.
*
* @param string $key Caching key.
* @param mixed $value Value to save.
* @param string $group Caching group.
* @return bool
*/
public function update( $key = null, $value = null, $group = 'global' ) {}
/**
* Create base caching group if not exist.
*/
public function setup_cahe() {}
/**
* Create new group in base caching group if not exists
*/
public function setup_cahe_group( $group = 'global' ) {}
/**
* Returns all stored cache
*
* @return array
*/
public function get_all() {}
/**
* Returns whole stored group
*
* @return array
*/
public function get_group( $group = 'global' ) {}
/**
* Returns whole stored group
*
* @return void
*/
public function clear_cache( $group = null ) {}
/**
* Returns current value by key
*
* @return array
*/
public function get( $key = null, $group = 'global' ) {}
/**
* Write object cahe to static cache (if current handler requires this)
*
* @return void
*/
public function write_cache() {}
}
}

View File

@@ -0,0 +1,156 @@
<?php
/**
* Base class for caching method. All caching methods must be extends from this class.
* All methods are required for child classes
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Data_Importer_File_Cache' ) ) {
/**
* Define Jet_Data_Importer_File_Cache class
*/
class Jet_Data_Importer_File_Cache extends Jet_Data_Importer_Cache_Handler {
private $_object_cache = null;
private $_updated = false;
/**
* Store passed value in cache with passed key.
*
* @param string $key Caching key.
* @param mixed $value Value to save.
* @param string $group Caching group.
* @return bool
*/
public function update( $key = null, $value = null, $group = 'global' ) {
$this->setup_cache_group( $group );
$this->_object_cache[ $group ][ $key ] = $value;
$this->_updated = true;
}
/**
* Returns all stored cache
*
* @return array
*/
public function get_all() {
if ( ! $this->_object_cache ) {
return array();
} else {
$this->_object_cache;
}
}
/**
* Returns whole stored group
*
* @return array
*/
public function get_group( $group = 'global' ) {
$this->setup_cache_group( $group );
if ( ! isset( $this->_object_cache[ $group ] ) ) {
return array();
}
return $this->_object_cache[ $group ];
}
/**
* Returns current value by key
*
* @return array
*/
public function get( $key = null, $group = 'global' ) {
$this->setup_cache_group( $group );
if ( ! isset( $this->_object_cache[ $group ] ) ) {
return false;
}
if ( ! isset( $this->_object_cache[ $group ][ $key ] ) ) {
return false;
}
return $this->_object_cache[ $group ][ $key ];
}
/**
* Create base caching group if not exist.
*/
public function setup_cache() {
if ( null === $this->_object_cache ) {
$current = jdi_files_manager()->get_json( 'cache.json' );
if ( ! $current ) {
$this->_object_cache = array();
} else {
$this->_object_cache = $current;
}
}
}
/**
* Create new group in base caching group if not exists
*/
public function setup_cache_group( $group = 'global' ) {
$this->setup_cache();
if ( ! isset( $this->_object_cache[ $group ] ) ) {
$this->_object_cache[ $group ] = array();
}
}
/**
* Returns whole stored group
*
* @return void
*/
public function clear_cache( $group = null ) {
if ( isset( $this->_object_cache['mapping'] ) ) {
update_option( 'cache', $this->_object_cache['mapping'] );
}
if ( null !== $group ) {
$this->_object_cache[ $group ] = array();
jdi_files_manager()->write_cache();
} else {
$this->_object_cache = array();
jdi_files_manager()->delete( 'cache.json' );
}
}
/**
* Write static cache
*
* @return [type] [description]
*/
public function write_cache() {
if ( true === $this->_updated ) {
jdi_files_manager()->put_json( 'cache.json', $this->_object_cache );
}
}
}
}

View File

@@ -0,0 +1,135 @@
<?php
/**
* Seesion cahce handler
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Data_Importer_Session_Cache' ) ) {
/**
* Define Jet_Data_Importer_Session_Cache class
*/
class Jet_Data_Importer_Session_Cache extends Jet_Data_Importer_Cache_Handler {
/**
* Base caching group name
*
* @var string
*/
private $base_group = null;
/**
* Constructor for the class
*/
public function __construct( $base_group ) {
$this->base_group = $base_group;
}
/**
* Store passed value in cache with passed key.
*
* @param string $key Caching key.
* @param mixed $value Value to save.
* @param string $group Caching group.
* @return bool
*/
public function update( $key = null, $value = null, $group = 'global' ) {
$this->setup_cahe_group( $group );
$_SESSION[ $this->base_group ][ $group ][ $key ] = $value;
}
/**
* Returns all stored cache
*
* @return array
*/
public function get_all() {
if ( ! isset( $_SESSION[ $this->base_group ] ) ) {
return array();
}
}
/**
* Returns whole stored group
*
* @return array
*/
public function get_group( $group = 'global' ) {
if ( ! isset( $_SESSION[ $this->base_group ][ $group ] ) ) {
return array();
}
return $_SESSION[ $this->base_group ][ $group ];
}
/**
* Returns current value by key
*
* @return array
*/
public function get( $key = null, $group = 'global' ) {
if ( ! isset( $_SESSION[ $this->base_group ][ $group ] ) ) {
return false;
}
if ( ! isset( $_SESSION[ $this->base_group ][ $group ][ $key ] ) ) {
return false;
}
return $_SESSION[ $this->base_group ][ $group ][ $key ];
}
/**
* Create base caching group if not exist.
*/
public function setup_cahe() {
if ( ! isset( $_SESSION[ $this->base_group ] ) ) {
$_SESSION[ $this->base_group ] = array();
}
}
/**
* Create new group in base caching group if not exists
*/
public function setup_cahe_group( $group = 'global' ) {
$this->setup_cahe();
if ( ! isset( $_SESSION[ $this->base_group ][ $group ] ) ) {
$_SESSION[ $this->base_group ][ $group ] = array();
}
}
/**
* Returns whole stored group
*
* @return void
*/
public function clear_cache( $group = null ) {
if ( isset( $_SESSION[ $this->base_group ]['mapping'] ) ) {
update_option( 'cache', $_SESSION[ $this->base_group ]['mapping'] );
}
if ( null !== $group ) {
$_SESSION[ $this->base_group ][ $group ] = array();
} else {
$_SESSION[ $this->base_group ] = array();
}
}
}
}

View File

@@ -0,0 +1,199 @@
<?php
/**
* Data cache handler
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Data_Importer_Cache' ) ) {
/**
* Define Jet_Data_Importer_Cache class
*/
class Jet_Data_Importer_Cache {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Import data caching metod.
*
* @var string
*/
private $caching_method = 'session';
/**
* Active cache handler instance
*
* @var null
*/
private $handler = null;
/**
* Registered cache handlers array
*
* @var array
*/
private $handlers = array();
/**
* Base caching group name
*
* @var string
*/
public $base_group = 'jet-importer';
/**
* Constructor for the class
*/
public function __construct() {
$this->handlers = array(
'session' => 'Jet_Data_Importer_Session_Cache',
'file' => 'Jet_Data_Importer_File_Cache',
);
require_once jdi()->path( 'includes/cache-handlers/class-jet-data-importer-cache-handler.php' );
$method = $this->get_caching_method();
if ( isset( $this->handlers[ $method ] ) ) {
$handler = $this->handlers[ $method ];
} else {
$handler = 'Jet_Data_Importer_Session_Cache';
}
$file = $this->get_file_name( $handler );
require_once jdi()->path( 'includes/cache-handlers/' . $file );
$this->handler = new $handler( $this->base_group );
}
/**
* Returns handler file name by class name.
*
* @param string $handler Handler class name.
* @return string
*/
private function get_file_name( $handler ) {
$file = str_replace( '_', ' ', $handler );
$file = strtolower( $file );
$file = str_replace( ' ', '-', $file );
return sprintf( 'class-%s.php', $file );
}
/**
* Returns appropriate caching method for current server/
*
* @return string
*/
private function get_caching_method() {
if ( ! session_id() ) {
$this->caching_method = 'file';
} else {
$this->caching_method = 'session';
}
$cache_handler = get_option( 'jdi_cache_handler', 'session' );
if ( $cache_handler ) {
$this->caching_method = $cache_handler;
}
return $this->caching_method;
}
/**
* Store passed value in cache with passed key.
*
* @param string $key Caching key.
* @param mixed $value Value to save.
* @param string $group Caching group.
* @return bool
*/
public function update( $key = null, $value = null, $group = 'global' ) {
$this->handler->update( $key, $value, $group );
}
/**
* Get value from cache by key.
*
* @param string $key Caching key.
* @param string $group Caching group.
* @return bool
*/
public function get( $key = null, $group = 'global' ) {
return $this->handler->get( $key, $group );
}
/**
* Get all group values from cache by group name.
*
* @param string $group Caching group.
* @return bool
*/
public function get_group( $group = 'global' ) {
return $this->handler->get_group( $group );
}
/**
* Clear cache for passed group or all cache if group not provided.
*
* @param string $group Caching group to clear.
* @return bool
*/
public function clear_cache( $group = null ) {
return $this->handler->clear_cache( $group );
}
/**
* Write object cahce to static.
*
* @param string $group Caching group to clear.
* @return bool
*/
public function write_cache() {
return $this->handler->write_cache();
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
}
/**
* Returns instance of Jet_Data_Importer_Cache
*
* @return object
*/
function jdi_cache() {
return Jet_Data_Importer_Cache::get_instance();
}

View File

@@ -0,0 +1,126 @@
<?php
/**
* Files manager
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Data_Importer_Files_Manager' ) ) {
/**
* Define Jet_Data_Importer_Files_Manager class
*/
class Jet_Data_Importer_Files_Manager {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Data inmporter file manager base path
* @var [type]
*/
private $base_path = false;
/**
* Returns base path
*
* @return string
*/
public function base_path() {
if ( ! $this->base_path ) {
$upload_dir = wp_upload_dir();
$upload_base_dir = $upload_dir['basedir'];
$this->base_path = trailingslashit( $upload_base_dir ) . 'jet-skins/';
if ( ! is_dir( $this->base_path ) ) {
mkdir( $this->base_path );
}
}
return $this->base_path;
}
/**
* Returns base path
*
* @return string
*/
public function put_json( $relative_path = null, $data = '' ) {
file_put_contents( $this->base_path() . $relative_path, json_encode( $data ) );
}
/**
* Returns base path
*
* @return string|bool
*/
public function get_json( $relative_path = null ) {
$file = $this->base_path() . $relative_path;
if ( ! is_file( $file ) ) {
return false;
}
ob_start();
include $file;
$content = ob_get_clean();
return json_decode( $content, true );
}
/**
* Delete file if exists
*
* @param [type] $relative_path [description]
* @return [type] [description]
*/
public function delete( $relative_path = null ) {
$file = $this->base_path() . $relative_path;
if ( is_file( $file ) ) {
unlink( $file );
}
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
}
/**
* Returns instance of Jet_Data_Importer_Files_Manager
*
* @return object
*/
function jdi_files_manager() {
return Jet_Data_Importer_Files_Manager::get_instance();
}

View File

@@ -0,0 +1,89 @@
<?php
/**
* Logger class
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Data_Importer_Logger' ) ) {
/**
* Define Jet_Data_Importer_Logger class
*/
class Jet_Data_Importer_Logger {
/**
* Add warning message into log.
*
* @param string $message Log message.
* @return void
*/
public function warning( $message = null ) {
$this->add_message( $message, 'warnings' );
}
/**
* Add info message into log.
*
* @param string $message Log message.
* @return void
*/
public function info( $message = null ) {
$this->add_message( $message, 'info' );
}
/**
* Add notice message into log.
*
* @param string $message Log message.
* @return void
*/
public function notice( $message = null ) {
$this->add_message( $message, 'notice' );
}
/**
* Add debug message into log.
*
* @param string $message Log message.
* @return void
*/
public function debug( $message = null ) {
$this->add_message( $message, 'debug' );
}
/**
* Add error message into log.
*
* @param string $message Log message.
* @return void
*/
public function error( $message = null ) {
$this->add_message( $message, 'error' );
}
/**
* Add passed message into passed log group.
*
* @param string $message Log message.
* @param string $type Message type.
* @return void
*/
public function add_message( $message = null, $type = 'info' ) {
$messages = jdi_cache()->get( $type, 'log' );
if ( empty( $messages ) || ! is_array( $messages ) ) {
$messages = array();
}
$messages[] = $message;
jdi_cache()->update( $type, $messages, 'log' );
}
}
}

View File

@@ -0,0 +1,193 @@
<?php
/**
* Import page slider
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Data_Importer_Slider' ) ) {
/**
* Define Jet_Data_Importer_Slider class
*/
class Jet_Data_Importer_Slider {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Slides list
*
* @var array
*/
private $slides = null;
/**
* Slider data
*
* @var array
*/
private $data = null;
/**
* Constructor for the class
*/
function __construct() {
$slider_data = jdi()->get_setting( array( 'slider' ) );
if ( empty( $slider_data ) || empty( $slider_data['path'] ) ) {
return;
}
$this->data = $slider_data;
if ( ! $this->get_slides() ) {
return;
}
}
/**
* Enqueue slider assets
*
* @return void
*/
public function slider_assets() {
wp_enqueue_script(
'swiper-jquery',
jdi()->url( 'assets/js/swiper.min.js' ),
array( 'jquery' ),
'2.0.0',
true
);
}
/**
* Render slider
*
* @return string|void
*/
public function render( $echo = true ) {
$slides = $this->get_slides();
if ( empty( $slides ) ) {
return;
}
$format = '<div class="swiper-slide">
<div class="slider-content">
<img src="%1$s" alt="" data-swiper-parallax="-100">
<h4 class="slider-title" data-swiper-parallax="-400">%2$s</h4>
<div class="slider-desc" data-swiper-parallax="-900">%3$s</div>
</div>
</div>';
$result = '';
foreach ( $slides as $slide ) {
$url = ! empty( $slide['image'] ) ? esc_url( $slide['image'] ) : false;
$title = ! empty( $slide['title'] ) ? wp_kses_post( $slide['title'] ) : false;
$desc = ! empty( $slide['desc'] ) ? wp_kses_post( $slide['desc'] ) : false;
$result .= sprintf( $format, $url, $title, $desc );
}
$result = sprintf(
'<div class="cdi-slider">
<div class="swiper-container">
<div class="swiper-wrapper">%1$s</div>
</div>
%2$s
</div>',
$result,
'<div class="slider-pagination"></div>'
);
if ( $echo ) {
echo $result;
} else {
return $result;
}
}
/**
* Retrieve slides list
*
* @return array|bool false
*/
public function get_slides() {
if ( ! empty( $this->slides ) ) {
return $this->slides;
}
$slides = get_transient( 'jet_data_importer_slides' );
if ( ! $slides ) {
$response = wp_remote_get( $this->data['path'], array( 'timeout' => 30 ) );
if ( ! $response || is_wp_error( $response ) ) {
return false;
}
$body = wp_remote_retrieve_body( $response );
if ( ! $body || is_wp_error( $body ) ) {
return false;
}
$slides = json_decode( $body, true );
if ( ! $slides ) {
return false;
}
}
$this->slides = $slides;
set_transient( 'jet_data_importer_slides', $this->slides, DAY_IN_SECONDS );
return $this->slides;
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
}
/**
* Returns instance of Jet_Data_Importer_Slider
*
* @return object
*/
function jdi_slider() {
return Jet_Data_Importer_Slider::get_instance();
}

View File

@@ -0,0 +1,292 @@
<?php
/**
* Tools class
*
* @package Jet_Data_Importer
* @author Cherry Team
* @license GPL-2.0+
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Data_Importer_Tools' ) ) {
/**
* Define Jet_Data_Importer_Tools class
*/
class Jet_Data_Importer_Tools {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Returns available widgets data.
*
* @return array
*/
public function available_widgets() {
global $wp_registered_widget_controls;
$widget_controls = $wp_registered_widget_controls;
$available_widgets = array();
foreach ( $widget_controls as $widget ) {
if ( ! empty( $widget['id_base'] ) && ! isset( $available_widgets[ $widget['id_base']] ) ) {
$available_widgets[ $widget['id_base'] ]['id_base'] = $widget['id_base'];
$available_widgets[ $widget['id_base'] ]['name'] = $widget['name'];
}
}
return apply_filters( 'jet-data-importer/export/available-widgets', $available_widgets );
}
/**
* Get page title
*
* @param string $before HTML before title.
* @param string $after HTML after title.
* @param bool $echo Echo or return.
* @return string|void
*/
public function get_page_title( $before = '', $after = '', $echo = false ) {
if ( ! isset( jdi()->current_tab ) || empty( jdi()->current_tab ) ) {
return;
}
$title = jdi()->current_tab['name'];
if ( 'import' === jdi()->current_tab['id'] ) {
$step = ! empty( $_GET['step'] ) ? intval( $_GET['step'] ) : 1;
switch ( $step ) {
case 2:
$title = esc_html__( 'Importing sample data', 'jet-data-importer' );
break;
case 3:
$title = esc_html__( 'Regenerating thumbnails', 'jet-data-importer' );
break;
case 4:
$title = esc_html__( 'Congratulations! Youre all Set!', 'jet-data-importer' );
break;
default:
$title = esc_html__( 'Select source to import', 'jet-data-importer' );
break;
}
}
$title = $before . apply_filters( 'jet-data-importer/tab-title', $title ) . $after;
if ( $echo ) {
echo $title;
} else {
return $title;
}
}
/**
* Get current page URL
*
* @return string
*/
public function get_page_url() {
return sprintf(
'%1$s://%2$s%3$s',
is_ssl() ? 'https' : 'http',
$_SERVER['HTTP_HOST'],
$_SERVER['REQUEST_URI']
);
}
/**
* Get recommended server params
*
* @return array
*/
public function server_params() {
return apply_filters(
'jet-data-importer/recommended-params',
array(
'memory_limit' => array(
'value' => 128,
'units' => 'Mb',
),
'post_max_size' => array(
'value' => 8,
'units' => 'Mb',
),
'upload_max_filesize' => array(
'value' => 8,
'units' => 'Mb',
),
'max_input_time' => array(
'value' => 45,
'units' => 's',
),
'max_execution_time' => array(
'value' => 30,
'units' => 's',
),
)
);
}
/**
* Check if passed table is exists in database
*
* @param string $table Table name.
* @return boolean
*/
public function is_db_table_exists( $table = '' ) {
global $wpdb;
$table_name = $wpdb->prefix . $table;
return ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name ) ) === $table_name );
}
/**
* Escape unsecure for public usage part of file path and return base64 encoded result.
*
* @param string $file Full file path
* @return string
*/
public function secure_path( $file ) {
if ( false !== strpos( $file, '/wpcom' ) ) {
return base64_encode( $file );
}
if ( false === strpos( $file, ABSPATH ) ) {
return 'remote';
}
return base64_encode( str_replace( ABSPATH, '', $file ) );
}
/**
* Gets base64 encoded part of path, decode it and adds server path
*
* @param string $file Encoded part of path.
* @return string
*/
public function esc_path( $file ) {
if ( 'remote' === $file ) {
return false;
}
$file = base64_decode( $file );
if ( false !== strpos( $file, '/wpcom' ) ) {
return $file;
}
return ABSPATH . $file;
}
/**
* Remove existing content from website
*
* @since 1.1.0
* @return null
*/
public function clear_content() {
if ( ! current_user_can( 'delete_users' ) ) {
return;
}
$attachments = get_posts( array(
'post_type' => 'attachment',
'posts_per_page' => -1,
) );
if ( ! empty( $attachments ) ) {
foreach ( $attachments as $attachment ) {
wp_delete_attachment( $attachment->ID, true );
}
}
global $wpdb;
$tables_to_clear = array(
$wpdb->commentmeta,
$wpdb->comments,
$wpdb->links,
$wpdb->postmeta,
$wpdb->posts,
$wpdb->termmeta,
$wpdb->terms,
$wpdb->term_relationships,
$wpdb->term_taxonomy,
);
foreach ( $tables_to_clear as $table ) {
$wpdb->query( "TRUNCATE {$table};" );
}
$options = apply_filters( 'jet-data-importer/clear-options-on-remove', array(
'sidebars_widgets',
) );
foreach ( $options as $option ) {
delete_option( $option );
}
/**
* Clear widgets data
*/
$widgets = $wpdb->get_results(
"SELECT * FROM $wpdb->options WHERE `option_name` LIKE 'widget_%'"
);
if ( ! empty( $widgets ) ) {
foreach ( $widgets as $widget ) {
delete_option( $widget->option_name );
}
}
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
}
/**
* Returns instance of Jet_Data_Importer_Tools
*
* @return object
*/
function jdi_tools() {
return Jet_Data_Importer_Tools::get_instance();
}

View File

@@ -0,0 +1,99 @@
<?php
/**
* Default config file
*
* @var array
*/
$config = array(
'xml' => array(
'enabled' => true,
'use_upload' => true,
'path' => false,
),
'import' => array(
'chunk_size' => $this->chunk_size,
'regenerate_chunk_size' => 3,
'allow_types' => false,
),
'remap' => array(
'post_meta' => array(),
'term_meta' => array(),
'options' => array(
'jet_woo_builder',
'woocommerce_catalog_columns',
'woocommerce_catalog_rows',
),
),
'export' => array(
'message' => __( 'Export all content with Jet Data Export tool', 'jet-data-importer' ),
'logo' => $this->url( 'assets/img/monster-logo.png' ),
'options' => array(),
'tables' => array(),
),
'success-links' => array(
'home' => array(
'label' => __( 'View your site', 'jet-data-importer' ),
'type' => 'primary',
'target' => '_self',
'icon' => 'dashicons-welcome-view-site',
'desc' => __( 'Take a look at your site', 'jet-data-importer' ),
'url' => home_url( '/' ),
),
'edit' => array(
'label' => __( 'Start editing', 'jet-data-importer' ),
'type' => 'primary',
'target' => '_self',
'icon' => 'dashicons-welcome-write-blog',
'desc' => __( 'Proceed to editing pages', 'jet-data-importer' ),
'url' => admin_url( 'edit.php?post_type=page' ),
),
'documentation' => array(
'label' => __( 'Check documentation', 'jet-data-importer' ),
'type' => 'primary',
'target' => '_blank',
'icon' => 'dashicons-welcome-learn-more',
'desc' => __( 'Get more info from documentation', 'jet-data-importer' ),
'url' => 'http://documentation.zemez.io/wordpress/index.php?project=crocoblock',
),
'knowledge-base' => array(
'label' => __( 'Knowledge Base', 'jet-data-importer' ),
'type' => 'primary',
'target' => '_blank',
'icon' => 'dashicons-sos',
'desc' => __( 'Access the vast knowledge base', 'jet-data-importer' ),
'url' => 'https://zemez.io/wordpress/support/knowledge-base/',
),
'community' => array(
'label' => __( 'Community', 'jet-data-importer' ),
'type' => 'primary',
'target' => '_blank',
'icon' => 'dashicons-facebook',
'desc' => __( 'Join community to stay tuned to the latest news', 'jet-data-importer' ),
'url' => 'https://www.facebook.com/groups/CrocoblockCommunity/',
),
),
'slider' => array(
'path' => 'https://raw.githubusercontent.com/ZemezLab/kava-slider/master/slides.json',
),
'advanced_import' => array(
'from_path' => 'https://account.crocoblock.com/wp-content/uploads/static/wizard-skins.json'
)
/*
'advanced_import' => array(
'default' => array(
'full' => get_template_directory() . '/assets/demo-content/default/default-full.xml',
'lite' => get_template_directory() . '/assets/demo-content/default/default-min.xml',
'thumb' => get_template_directory_uri() . '/assets/demo-content/default/default-thumb.png',
'plugins' => array(
'booked-appointments' => 'Booked Appointments',
'buddypress' => 'BuddyPress',
'cherry-projects' => 'Cherry Projects'
),
),
),
or
'advanced_import' => array(
'from_path' => 'https://account.crocoblock.com/wp-content/uploads/static/wizard-skins.json'
),
*/
);

View File

@@ -0,0 +1,150 @@
<?php
/**
* Exporter interface
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Data_Export_Interface' ) ) {
/**
* Define Jet_Data_Export_Interface class
*/
class Jet_Data_Export_Interface {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Constructor for the class
*/
function __construct() {
add_action( 'admin_menu', array( $this, 'menu_page' ) );
add_action( 'export_filters', array( $this, 'render_export_form' ) );
add_action( 'wp_ajax_jet-data-export', array( $this, 'run_export' ) );
}
/**
* Init exporter page
*
* @return void
*/
public function menu_page() {
jdi()->register_tab(
array(
'id' => 'export',
'name' => esc_html__( 'Export', 'jet-data-importer' ),
'cb' => array( $this, 'render_export_form' ),
)
);
}
/**
* Render export form HTML
*
* @return void
*/
public function render_export_form() {
ob_start();
jdi()->get_template( 'export.php' );
return ob_get_clean();
}
/**
* Run export process
*
* @return void
*/
public function run_export() {
if ( ! current_user_can( 'export' ) ) {
wp_send_json_error( array( 'message' => 'You don\'t have permissions to do this' ) );
}
if ( empty( $_REQUEST['nonce'] ) || ! wp_verify_nonce( $_REQUEST['nonce'], 'jet-data-export' ) ) {
wp_send_json_error( array( 'message' => 'You don\'t have permissions to do this' ) );
}
require jdi()->path( 'includes/export/class-jet-wxr-exporter.php' );
$xml = jdi_exporter()->do_export( false );
$this->download_headers( jdi_exporter()->get_filename() );
echo $xml;
die();
}
/**
* Send download headers
*
* @return void
*/
public function download_headers( $file = 'sample-data.xml' ) {
session_write_close();
header( 'Pragma: public' );
header( 'Expires: 0' );
header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
header( 'Cache-Control: public' );
header( 'Content-Description: File Transfer' );
header( 'Content-type: application/octet-stream' );
header( 'Content-Disposition: attachment; filename="' . $file . '"' );
header( 'Content-Transfer-Encoding: binary' );
}
/**
* Returns URL to generate export file (nonce must be added via JS, otherwise will not be processed)
*
* @return string
*/
public function get_export_url() {
return add_query_arg( array( 'action' => 'jet-data-export' ), admin_url( 'admin-ajax.php' ) );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
}
/**
* Returns instance of Jet_Data_Export_Interface
*
* @return object
*/
function jdi_export_interface() {
return Jet_Data_Export_Interface::get_instance();
}
jdi_export_interface();

View File

@@ -0,0 +1,355 @@
<?php
/**
* Main exporter class
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_WXR_Exporter' ) ) {
/**
* Define Jet_WXR_Exporter class
*/
class Jet_WXR_Exporter {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Options array to export
*
* @var array
*/
public $export_options = null;
/**
* Constructor for the class
*/
function __construct() {
include_once( ABSPATH . '/wp-admin/includes/class-pclzip.php' );
require_once( ABSPATH . '/wp-admin/includes/export.php' );
}
/**
* Get array of options to export with content
*
* @return void
*/
public function get_options_to_export() {
if ( null === $this->export_options ) {
$theme = get_option( 'stylesheet' );
$default_options = apply_filters( 'jet-data-importer/export/options-to-export', array(
'blogname',
'blogdescription',
'users_can_register',
'posts_per_page',
'date_format',
'time_format',
'thumbnail_size_w',
'thumbnail_size_h',
'thumbnail_crop',
'medium_size_w',
'medium_size_h',
'large_size_w',
'large_size_h',
'theme_mods_' . $theme,
'show_on_front',
'page_on_front',
'page_for_posts',
'permalink_structure',
$theme . '_sidebars',
$theme . '_sidbars',
'jet_site_conditions',
'elementor_container_width',
'jet-elements-settings',
) );
$user_options = jdi()->get_setting( array( 'export', 'options' ) );
if ( ! $user_options || ! is_array( $user_options ) ) {
$user_options = array();
}
$this->export_options = array_unique( array_merge( $default_options, $user_options ) );
}
return $this->export_options;
}
/**
* Process XML export
*
* @return string
*/
public function do_export( $into_file = true ) {
ob_start();
ini_set( 'max_execution_time', -1 );
set_time_limit( 0 );
$use_custom_export = apply_filters( 'jet-data-importer/export/use-custom-export', false );
if ( $use_custom_export && function_exists( $use_custom_export ) ) {
call_user_func( $use_custom_export );
} else {
export_wp();
}
$xml = ob_get_clean();
$xml = $this->add_extra_data( $xml );
if ( true === $into_file ) {
$upload_dir = wp_upload_dir();
$upload_base_dir = $upload_dir['basedir'];
$upload_base_url = $upload_dir['baseurl'];
$filename = $this->get_filename();
$xml_dir = $upload_base_dir . '/' . $filename;
$xml_url = $upload_base_url . '/' . $filename;
file_put_contents( $xml_dir, $xml );
return $xml_url;
} else {
return $xml;
}
}
/**
* Returns filename for exported sample data
*
* @return void
*/
public function get_filename() {
$date = date( 'm-d-Y' );
$template = get_template();
return apply_filters(
'jet-data-importer/export/filename',
'sample-data-' . $template . '-' . $date . '.xml'
);
}
/**
* Add options and widgets to XML
*
* @param string $xml Exported XML.
* @return string
*/
private function add_extra_data( $xml ) {
ini_set( 'max_execution_time', -1 );
ini_set( 'memory_limit', -1 );
set_time_limit( 0 );
$xml = str_replace(
"</wp:base_blog_url>",
"</wp:base_blog_url>\r\n" . $this->get_options() . $this->get_widgets() . $this->get_tables(),
$xml
);
return $xml;
}
/**
* Get options list in XML format.
*
* @return string
*/
public function get_options() {
$options = '';
$format = "\t\t<wp:%1$s>%2$s</wp:%1$s>\r\n";
$export_options = $this->get_options_to_export();
foreach ( $export_options as $option ) {
$value = get_option( $option );
if ( is_array( $value ) ) {
$value = json_encode( $value );
}
if ( ! empty( $option ) ) {
$value = wxr_cdata( $value );
$options .= "\t\t<wp:{$option}>{$value}</wp:{$option}>\r\n";
}
}
return "\t<wp:options>\r\n" . $options . "\t</wp:options>\r\n";
}
/**
* Get tables to export
*
* @return string
*/
public function get_tables() {
$user_tables = jdi()->get_setting( array( 'export', 'tables' ) );
if ( ! is_array( $user_tables ) ) {
$user_tables = array();
}
if ( class_exists( 'WooCommerce' ) && ! in_array( 'woocommerce_attribute_taxonomies', $user_tables ) ) {
$user_tables[] = 'woocommerce_attribute_taxonomies';
}
if ( empty( $user_tables ) ) {
return;
}
global $wpdb;
$result = '';
foreach ( $user_tables as $table ) {
if ( ! jdi_tools()->is_db_table_exists( $table ) ) {
continue;
}
$name = esc_attr( $wpdb->prefix . $table );
$data = $wpdb->get_results( "SELECT * FROM $name WHERE 1", ARRAY_A );
if ( empty( $data ) ) {
continue;
}
$data = maybe_serialize( $data );
$result .= "\t\t<" . $table . ">" . wxr_cdata( $data ) . "</" . $table . ">\r\n";
}
if ( empty( $result ) ) {
return;
}
return "\t<wp:user_tables>\r\n" . $result . "\r\n\t</wp:user_tables>\r\n";
}
/**
* Get widgets data to export
*
* @return string
*/
private function get_widgets() {
// Get all available widgets site supports
$available_widgets = jdi_tools()->available_widgets();
// Get all widget instances for each widget
$widget_instances = array();
foreach ( $available_widgets as $widget_data ) {
// Get all instances for this ID base
$instances = get_option( 'widget_' . $widget_data['id_base'] );
// Have instances
if ( ! empty( $instances ) ) {
// Loop instances
foreach ( $instances as $instance_id => $instance_data ) {
// Key is ID (not _multiwidget)
if ( is_numeric( $instance_id ) ) {
$unique_instance_id = $widget_data['id_base'] . '-' . $instance_id;
$widget_instances[ $unique_instance_id ] = $instance_data;
}
}
}
}
// Gather sidebars with their widget instances
$sidebars_widgets = get_option( 'sidebars_widgets' ); // get sidebars and their unique widgets IDs
$sidebars_widget_instances = array();
foreach ( $sidebars_widgets as $sidebar_id => $widget_ids ) {
// Skip inactive widgets
if ( 'wp_inactive_widgets' == $sidebar_id ) {
continue;
}
// Skip if no data or not an array (array_version)
if ( ! is_array( $widget_ids ) || empty( $widget_ids ) ) {
continue;
}
// Loop widget IDs for this sidebar
foreach ( $widget_ids as $widget_id ) {
// Is there an instance for this widget ID?
if ( isset( $widget_instances[ $widget_id ] ) ) {
// Add to array
$sidebars_widget_instances[ $sidebar_id ][ $widget_id ] = $widget_instances[ $widget_id ];
}
}
}
// Filter pre-encoded data
$data = apply_filters( 'jet-data-importer/export/pre-get-widgets', $sidebars_widget_instances );
// Encode the data for file contents
$encoded_data = json_encode( $data );
$encoded_data = apply_filters( 'jet-data-importer/export/get-widgets', $encoded_data );
// Return contents
return "\t<wp:widgets_data>" . wxr_cdata( $encoded_data ) . "</wp:widgets_data>\r\n";
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
}
/**
* Returns instance of Jet_WXR_Exporter
*
* @return object
*/
function jdi_exporter() {
return Jet_WXR_Exporter::get_instance();
}

View File

@@ -0,0 +1,216 @@
<?php
/**
* Importer extensions
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Data_Importer_Extensions' ) ) {
/**
* Define Jet_Data_Importer_Extensions class
*/
class Jet_Data_Importer_Extensions {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Constructor for the class
*/
public function __construct() {
// Prevent from errors triggering while MotoPress Booking posts importing (loving it)
add_filter( 'jet-data-importer/import/skip-post', array( $this, 'prevent_import_errors' ), 10, 2 );
// Clear fonts cache after import
add_action( 'jet-data-importer/import/finish', array( $this, 'clear_fonts_cache' ) );
// Allow switch Monstroid2 skins
add_action( 'jet-data-importer/import/before-skip-redirect', array( $this, 'switch_skin_on_skip' ) );
add_action( 'jet-data-importer/import/before-options-processing', array( $this, 'set_container_width' ) );
add_action( 'jet-data-importer/import/after-options-processing', array( $this, 'set_required_options' ) );
add_action( 'jet-data-importer/import/after-import-tables', array( $this, 'clear_woo_transients' ) );
}
/**
* Delete WooCommerce-related transients after new tables are imported
*
* @return void
*/
public function clear_woo_transients() {
delete_transient( 'wc_attribute_taxonomies' );
}
/**
* Preset elemntor container width if it was not passed in XML
*/
public function set_container_width( $data ) {
if ( ! isset( $data['elementor_container_width'] ) ) {
update_option( 'elementor_container_width', 1200 );
}
}
/**
* Set required Kava Extra and Jet Elements options
*/
public function set_required_options() {
if ( class_exists( 'Kava_Extra' ) ) {
$options = get_option( 'kava-extra-settings' );
if ( ! $options ) {
update_option( 'kava-extra-settings', array(
'nucleo-mini-package' => 'true',
) );
}
unset( $options );
}
if ( class_exists( 'Jet_Elements' ) ) {
$options = get_option( 'jet-elements-settings' );
if ( empty( $options ) ) {
$options = array();
}
if ( empty( $options['api_key'] ) ) {
$options['api_key'] = 'AIzaSyDlhgz2x94h0UZb7kZXOBjwAtszoCRtDLM';
}
update_option( 'jet-elements-settings', $options );
}
}
/**
* Switch Monstroid2 skin on skip demo content import.
*
* @return null
*/
public function switch_skin_on_skip() {
if ( ! isset( $_GET['file'] ) ) {
return;
}
preg_match( '/demo-content\/(.*?)\//', base64_decode( $_GET['file'] ), $matches );
if ( empty( $matches ) || ! isset( $matches[1] ) ) {
return;
}
$skin = esc_attr( $matches[1] );
$map = array(
'default' => 'default',
'skin-1' => 'skin1',
'skin-2' => 'skin2',
'skin-3' => 'skin8',
'skin-4' => 'skin3',
'skin-5' => 'skin4',
'skin-6' => 'skin9',
'skin-7' => 'skin5',
'skin-8' => 'skin7',
'skin-9' => 'skin6',
);
$mapped_skin = isset( $map[ $skin ] ) ? $map[ $skin ] : false;
if ( ! $mapped_skin ) {
return;
}
$skin_file = get_stylesheet_directory() . '/tm-style-switcher-pressets/' . $mapped_skin . '.json';
if ( ! file_exists( $skin_file ) ) {
return;
}
ob_start();
include $skin_file;
$skin_data = ob_get_clean();
$skin_data = json_decode( $skin_data, true );
if ( empty( $skin_data ) || ! isset( $skin_data['mods'] ) ) {
return;
}
foreach ( $skin_data['mods'] as $mod => $value ) {
set_theme_mod( $mod, $value );
}
}
/**
* Ckear Google fonts cache.
*
* @return void
*/
public function clear_fonts_cache() {
delete_transient( 'cherry_google_fonts_url' );
delete_transient( 'cx_google_fonts_url_kava' );
}
/**
* Prevent PHP errors on import.
*
* @param bool $skip Default skip value.
* @param array $data Plugin data.
* @return bool
*/
public function prevent_import_errors( $skip, $data ) {
if ( isset( $data['post_type'] ) && 'mphb_booking' === $data['post_type'] ) {
return true;
}
return $skip;
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
}
/**
* Returns instance of Jet_Data_Importer_Extensions
*
* @return object
*/
function jdi_extensions() {
return Jet_Data_Importer_Extensions::get_instance();
}
jdi_extensions();

View File

@@ -0,0 +1,956 @@
<?php
/**
* Importer interface
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Data_Importer_Interface' ) ) {
/**
* Define Jet_Data_Importer_Interface class
*/
class Jet_Data_Importer_Interface {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Variable for settings array.
*
* @var array
*/
public $settings = array();
/**
* Importer instance
*
* @var object
*/
private $importer = null;
/**
* Path to import file
*
* @var string|bool
*/
private $import_file = null;
/**
* Returns XML-files count
*
* @var int
*/
private $xml_count = null;
/**
* Importer slug
*
* @var string
*/
public $slug = 'import';
/**
* Data storage.
*
* @var array
*/
public $data = array();
/**
* Constructor for the class
*/
function __construct() {
add_action( 'admin_menu', array( $this, 'menu_page' ) );
add_action( 'wp_ajax_jet-data-import-chunk', array( $this, 'import_chunk' ) );
add_action( 'wp_ajax_jet-data-thumbnails', array( $this, 'regenerate_chunk' ) );
add_action( 'wp_ajax_jet-data-import-get-file-path', array( $this, 'get_file_path' ) );
add_action( 'wp_ajax_jet-data-import-remove-content', array( $this, 'remove_content' ) );
add_action( 'cherry-data-importer/before-messages', array( $this, 'check_server_params' ) );
add_action( 'admin_footer', array( $this, 'advanced_popup' ) );
add_action( 'init', array( $this, 'maybe_skip_installation' ), 20 );
}
/**
* Maybe skip demo content installation
*
* @return bool|void
*/
public function maybe_skip_installation() {
if ( ! isset( $_GET['page'] ) || jdi()->slug !== $_GET['page'] ) {
return false;
}
if ( ! isset( $_GET['step'] ) || '2' !== $_GET['step'] ) {
return false;
}
if ( isset( $_GET['type'] ) && 'skip' === $_GET['type'] ) {
require_once jdi()->path( 'includes/import/class-jet-data-importer-extensions.php' );
/**
* Hook before redirect on demo content installation skip
*/
do_action( 'jet-data-importer/import/before-skip-redirect' );
wp_redirect( jdi()->page_url( array( 'step' => 4 ) ) );
die();
}
return false;
}
/**
* Check user password before content replacing.
*
* @return void
*/
public function remove_content() {
$this->validate_request();
if ( empty( $_REQUEST['password'] ) ) {
jdi_cache()->write_cache();
wp_send_json_error( array(
'message' => esc_html__( 'Password is empty', 'jet-data-importer' ),
) );
}
$password = esc_attr( $_REQUEST['password'] );
$user_id = get_current_user_id();
$data = get_userdata( $user_id );
if ( wp_check_password( $password, $data->user_pass, $user_id ) ) {
jdi_tools()->clear_content();
jdi_cache()->write_cache();
wp_send_json_success( array(
'message' => esc_html__( 'Content successfully removed', 'jet-data-importer' ),
'slider' => jdi_slider()->render( false ),
) );
} else {
jdi_cache()->write_cache();
wp_send_json_error( array(
'message' => esc_html__( 'Entered password is invalid', 'jet-data-importer' ),
) );
}
}
/**
* PopUp installation
*/
public function advanced_popup() {
if ( ! $this->is_advanced_import() ) {
return;
}
if ( ! isset( $_GET['tab'] ) || 'import' !== $_GET['tab'] ) {
return;
}
jdi()->get_template( 'advanced-popup.php' );
}
/**
* Show content install type after plugins installation finished by Wizard.
*
* @return void
*/
public function wizard_popup() {
if ( ! isset( $_GET['step'] ) || 2 !== intval( $_GET['step'] ) ) {
return;
}
jdi()->get_template( 'advanced-popup.php' );
}
/**
* Check server params and show warning message if some of them don't meet requirements
*
* @return void
*/
public function check_server_params() {
$messages = '';
$format = esc_html__( '%1$s: %2$s required, yours - %3$s', 'jet-data-importer' );
foreach ( jdi_tools()->server_params() as $param => $data ) {
$val = ini_get( $param );
$val = ini_get( $param );
$current_value = wp_convert_hr_to_bytes( $val );
$recommended_value = wp_convert_hr_to_bytes( $data['value'] . $data['units'] );
if ( $current_value < $recommended_value ) {
$current = sprintf(
$format,
$param,
'<strong>' . $data['value'] . $data['units'] . '</strong>',
'<strong>' . (int) $val . $data['units'] . '</strong>'
);
$messages .= '<div>' . $current . '</div>';
}
}
if ( empty( $messages ) ) {
return;
}
$heading = '<div class="cdi-server-messages__heading">' . esc_html__( 'Some parameters from your server don\'t meet the requirements:', 'jet-data-importer' ) . '</div>';
echo '<div class="cdi-server-messages">' . $heading . $messages . '</div>';
}
/**
* Returns current chunk size
*
* @return void
*/
public function chunk_size() {
$size = jdi()->get_setting( array( 'import', 'chunk_size' ) );
$size = intval( $size );
if ( ! $size ) {
return jdi()->chunk_size;
} else {
return $size;
}
}
/**
* Init importer
*
* @return void
*/
public function menu_page() {
jdi()->register_tab(
array(
'id' => $this->slug,
'name' => esc_html__( 'Import', 'jet-data-importer' ),
'cb' => array( $this, 'dispatch' ),
)
);
}
/**
* Run Jet importer
*
* @return void
*/
public function dispatch() {
$step = ! empty( $_GET['step'] ) ? intval( $_GET['step'] ) : 1;
ob_start();
jdi_tools()->get_page_title( '<h2 class="page-title">', '</h2>', true );
wp_enqueue_script( 'jet-data-import' );
switch ( $step ) {
case 2:
$this->import_step();
break;
case 3:
$this->regenerate_thumbnails();
break;
case 4:
$this->import_after();
break;
default:
$this->import_before();
break;
}
return ob_get_clean();
}
/**
* First import step
*
* @return void
*/
private function import_before() {
jdi()->get_template( 'import-before.php' );
}
/**
* Last import step
*
* @return void
*/
private function import_after() {
jdi()->get_template( 'import-after.php' );
}
/**
* Show main content import step
*
* @return void
*/
private function import_step() {
if ( empty( $_GET['file'] ) || 'null' === $_GET['file'] ) {
wp_redirect( add_query_arg(
array(
'page' => jdi()->slug,
'tab' => $this->slug,
'step' => 1,
),
esc_url( admin_url( 'admin.php' ) )
) );
die();
}
$importer = $this->get_importer();
if ( ! $importer ) {
_e( 'Error! Import file not found. Please contact our support team.', 'jet-data-importer' );
return;
}
$importer->prepare_import();
$count = jdi_cache()->get( 'total_count' );
$chunks_count = ceil( intval( $count ) / $this->chunk_size() );
// Adds final step with ID and URL remapping. Sometimes it's expensice step separate it
$chunks_count++;
jdi_cache()->update( 'chunks_count', $chunks_count );
jdi()->get_template( 'import.php' );
jdi_cache()->write_cache();
}
/**
* Process regenerate thumbnails step.
*
* @return void
*/
public function regenerate_thumbnails() {
$count = wp_count_attachments();
$count = (array) $count;
$step = jdi()->get_setting( array( 'import', 'regenerate_chunk_size' ) );
$total = 0;
foreach ( $count as $mime => $num ) {
if ( false === strpos( $mime, 'image' ) ) {
continue;
}
$total = $total + (int) $num;
}
wp_localize_script( 'jet-data-import', 'JetRegenerateData', array(
'totalImg' => $total,
'totalSteps' => ceil( $total / $step ),
'step' => $step,
) );
jdi()->get_template( 'regenerate.php' );
}
/**
* Returns true if regenerate thumbnails step is required, false - if not.
*
* @return boolean
*/
private function is_regenerate_required() {
$count = wp_count_attachments();
$count = (array) $count;
if ( empty( $count ) ) {
return false;
}
$total = 0;
if ( ! empty( $count['image/jpeg'] ) ) {
$total += absint( $count['image/jpeg'] );
}
if ( ! empty( $count['image/png'] ) ) {
$total += absint( $count['image/png'] );
}
if ( 0 === $total ) {
return false;
}
return true;
}
/**
* Validate import-related ajax request.
*
* @return void
*/
private function validate_request() {
if ( ! isset( $_REQUEST['nonce'] ) || ! wp_verify_nonce( $_REQUEST['nonce'], 'jet-data-import' ) ) {
jdi_cache()->write_cache();
wp_send_json_error( array(
'message' => esc_html__( 'You don\'t have permissions to do this', 'jet-data-importer' ),
) );
}
if ( ! current_user_can( 'import' ) ) {
jdi_cache()->write_cache();
wp_send_json_error( array(
'message' => esc_html__( 'You don\'t have permissions to do this', 'jet-data-importer' ),
) );
}
}
/**
* Process single regenerate chunk
*
* @return void
*/
public function regenerate_chunk() {
$this->validate_request();
$required = array(
'offset',
'step',
'total',
);
foreach ( $required as $field ) {
if ( ! isset( $_REQUEST[ $field ] ) ) {
jdi_cache()->write_cache();
wp_send_json_error( array(
'message' => sprintf(
esc_html__( '%s is missing in request', 'jet-data-importer' ), $field
),
) );
}
}
$offset = (int) $_REQUEST['offset'];
$step = (int) $_REQUEST['step'];
$total = (int) $_REQUEST['total'];
$is_last = ( $total * $step <= $offset + $step ) ? true : false;
$attachments = get_posts( array(
'post_type' => 'attachment',
'numberposts' => $step,
'offset' => $offset,
) );
if ( ! empty( $attachments ) ) {
foreach ( $attachments as $attachment ) {
$id = $attachment->ID;
$file = get_attached_file( $id );
$metadata = wp_generate_attachment_metadata( $id, $file );
wp_update_attachment_metadata( $id, $metadata );
}
}
$data = array(
'action' => 'jet-data-thumbnails',
'offset' => $offset + $step,
'step' => $step,
'total' => $total,
'isLast' => $is_last,
'complete' => round( ( $offset + $step ) * 100 / ( $total * $step ) ),
);
if ( $is_last ) {
$data['redirect'] = jdi()->page_url( array( 'tab' => $this->slug, 'step' => 4 ) );
}
jdi_cache()->write_cache();
wp_send_json_success( $data );
}
/**
* Process single chunk import
*
* @return void
*/
public function import_chunk() {
$this->validate_request();
if ( empty( $_REQUEST['chunk'] ) ) {
jdi_cache()->write_cache();
wp_send_json_error( array(
'message' => esc_html__( 'Chunk number is missing in request', 'jet-data-importer' ),
) );
}
$chunk = intval( $_REQUEST['chunk'] );
$chunks = jdi_cache()->get( 'chunks_count' );
$processed = jdi_cache()->get( 'processed_summary' );
require_once jdi()->path( 'includes/import/class-jet-data-importer-extensions.php' );
switch ( $chunk ) {
case $chunks:
// Process last step (remapping and finalizing)
$this->remap_all();
jdi_cache()->clear_cache();
flush_rewrite_rules();
$redirect = jdi()->page_url(
array(
'tab' => $this->slug,
'step' => $this->is_regenerate_required() ? 3 : 4,
)
);
/**
* Hook on last import chunk
*/
do_action( 'jet-data-importer/import/finish' );
$data = array(
'isLast' => true,
'complete' => 100,
'processed' => $processed,
'redirect' => $redirect,
);
// Remove XML file for remote files after successfull import.
$file = $this->get_import_file();
if ( $file && isset( $_REQUEST['file'] ) && 'remote' === $_REQUEST['file'] ) {
unlink( $file );
}
break;
default:
// Process regular step
$offset = $this->chunk_size() * ( $chunk - 1 );
$importer = $this->get_importer();
$importer->chunked_import( $this->chunk_size(), $offset );
/**
* Hook on last import chunk
*/
do_action( 'jet-data-importer/import/chunk', $chunk );
$data = array(
'action' => 'jet-data-import-chunk',
'chunk' => $chunk + 1,
'complete' => round( ( $chunk * 100 ) / $chunks ),
'processed' => $processed,
);
break;
}
jdi_cache()->write_cache();
wp_send_json_success( $data );
}
/**
* Return importer object
*
* @return object
*/
public function get_importer() {
if ( null !== $this->importer ) {
return $this->importer;
}
require_once jdi()->path( 'includes/import/class-jet-wxr-importer.php' );
$options = array();
$file = $this->get_import_file();
if ( ! $file ) {
return false;
}
return $this->importer = new Jet_WXR_Importer( $options, $file );
}
/**
* Get path to imported XML file
*
* @return [type] [description]
*/
public function get_import_file() {
if ( null !== $this->import_file ) {
return $this->import_file;
}
$file = null;
if ( ! empty( $_REQUEST['file'] ) ) {
$file = jdi_tools()->esc_path( esc_attr( $_REQUEST['file'] ) );
}
if ( ! $file || ! file_exists( $file ) ) {
$file = jdi()->get_setting( array( 'xml', 'path' ) );
}
if ( is_array( $file ) ) {
$file = $file[0];
}
if ( isset( $_REQUEST['file'] ) && 'remote' === $_REQUEST['file'] ) {
$import_settings = jdi()->get_setting( array( 'advanced_import' ) );
$slug = isset( $_REQUEST['skin'] ) ? esc_attr( $_REQUEST['skin'] ) : 'default';
$xml_type = isset( $_REQUEST['xml_type'] ) ? esc_attr( $_REQUEST['xml_type'] ) : 'lite';
if ( isset( $import_settings[ $slug ][ $xml_type ] ) ) {
$file = $this->get_remote_file( $import_settings[ $slug ][ $xml_type ] );
}
}
if ( ! $file ) {
return false;
} else {
$this->import_file = $file;
return $this->import_file;
}
}
/**
* Get remoe file by URL
*
* @param [type] $file_path [description]
* @return [type] [description]
*/
public function get_remote_file( $file_url ) {
$filename = basename( $file_url );
$base_path = jdi_files_manager()->base_path();
if ( is_file( $base_path . $filename ) ) {
return $base_path . $filename;
}
$tmpath = download_url( esc_url( $file_url ) );
if ( ! $tmpath ) {
return false;
}
if ( ! copy( $tmpath, $base_path . $filename ) ) {
return false;
}
unlink( $tmpath );
return $base_path . $filename;
}
/**
* Remap all required data after installation completed
*
* @return void
*/
public function remap_all() {
require_once jdi()->path( 'includes/import/class-jet-data-importer-remap-callbacks.php' );
/**
* Attach all posts remapping related callbacks to this hook
*
* @param array Posts remapping data. Format: old_id => new_id
*/
do_action( 'jet-data-importer/import/remap-posts', jdi_cache()->get( 'posts', 'mapping' ) );
/**
* Attach all terms remapping related callbacks to this hook
*
* @param array Terms remapping data. Format: old_id => new_id
*/
do_action( 'jet-data-importer/import/remap-terms', jdi_cache()->get( 'term_id', 'mapping' ) );
/**
* Attach all comments remapping related callbacks to this hook
*
* @param array COmments remapping data. Format: old_id => new_id
*/
do_action( 'jet-data-importer/import/remap-comments', jdi_cache()->get( 'comments', 'mapping' ) );
/**
* Attach all posts_meta remapping related callbacks to this hook
*
* @param array posts_meta data. Format: new_id => related keys array
*/
do_action( 'jet-data-importer/import/remap-posts-meta', jdi_cache()->get( 'posts_meta', 'requires_remapping' ) );
/**
* Attach all terms meta remapping related callbacks to this hook
*
* @param array terms meta data. Format: new_id => related keys array
*/
do_action( 'jet-data-importer/import/remap-terms-meta', jdi_cache()->get( 'terms_meta', 'requires_remapping' ) );
}
/**
* Get welcome message for importer starter page
*
* @return string
*/
public function get_welcome_message() {
$files = $this->get_xml_count();
if ( 0 === $files ) {
$message = __( 'Upload XML file with demo content', 'jet-data-importer' );
}
if ( 1 === $files ) {
$message = __( 'We found 1 XML file with demo content in your theme, install it?', 'jet-data-importer' );
}
if ( 1 < $files ) {
$message = sprintf(
__( 'We found %s XML files in your theme. Please select one of them to install', 'jet-data-importer' ),
$files
);
}
return '<div class="cdi-message">' . $message . '</div>';
}
/**
* Get available XML count
*
* @return int
*/
public function get_xml_count() {
if ( null !== $this->xml_count ) {
return $this->xml_count;
}
$files = jdi()->get_setting( array( 'xml', 'path' ) );
if ( ! $files ) {
$this->xml_count = 0;
} elseif ( ! is_array( $files ) ) {
$this->xml_count = 1;
} else {
$this->xml_count = count( $files );
}
return $this->xml_count;
}
/**
* Returns HTML-markup of import files select
*
* @return string
*/
public function get_import_files_select( $before = '<div>', $after = '</div>' ) {
$files = jdi()->get_setting( array( 'xml', 'path' ) );
if ( ! $files && ! is_array( $files ) ) {
return;
}
if ( 1 > count( $files ) ) {
return;
}
$wrap_format = '<select name="import_file">%1$s</select>';
$item_format = '<option value="%1$s" %3$s>%2$s</option>';
$selected = 'selected="selected"';
$result = '';
foreach ( $files as $name => $file ) {
$result .= sprintf( $item_format, jdi_tools()->secure_path( $file ), $name, $selected );
$selected = '';
}
return $before . sprintf( $wrap_format, $result ) . $after;
}
/**
* Retuns HTML markup for import file uploader
*
* @param string $before HTML markup before input.
* @param string $after HTML markup after input.
* @return string
*/
public function get_import_file_input( $before = '<div>', $after = '</div>' ) {
if ( ! jdi()->get_setting( array( 'xml', 'use_upload' ) ) ) {
return;
}
$result = '<div class="import-file">';
$result .= '<input type="hidden" name="upload_file" class="import-file__input">';
$result .= '<input type="text" name="upload_file_nicename" class="import-file__placeholder">';
$result .= '<button class="cdi-btn primary" id="jet-file-upload">';
$result .= esc_html__( 'Upload File', 'jet-data-importer' );
$result .= '</button>';
$result .= '</div>';
return $before . $result . $after;
}
/**
* Check if advanced import is allowed
*
* @since 1.1.0
* @return boolean
*/
public function is_advanced_import() {
$advanced = jdi()->get_setting( array( 'advanced_import' ) );
return ! empty( $advanced );
}
/**
* Show advanced import block.
*
* @since 1.1.0
* @return null
*/
public function advanced_import() {
if ( ! $this->is_advanced_import() ) {
return;
}
$advanced = jdi()->get_setting( array( 'advanced_import' ) );
foreach ( $advanced as $slug => $item ) {
$this->data['advanced-item'] = $item;
$this->data['advanced-slug'] = $slug;
jdi()->get_template( 'import-advanced.php' );
}
}
/**
* Show password form if is replace installation type.
*
* @since 1.1.0
* @return null
*/
public function remove_content_form() {
if ( ! isset( $_GET['type'] ) || 'replace' !== $_GET['type'] ) {
return;
}
if ( ! current_user_can( 'delete_users' ) ) {
esc_html_e(
'You don\'t have permissions to replace content, please re-enter with admiistrator account',
'jet-data-importer'
);
return;
}
jdi()->get_template( 'remove-content-form.php' );
}
/**
* Retrieve XML file path by URL
*
* @return string
*/
public function get_file_path() {
$this->validate_request();
if ( ! isset( $_REQUEST['file'] ) ) {
jdi_cache()->write_cache();
wp_send_json_error( array(
'message' => esc_html__( 'XML file not passed', 'jet-data-importer' ),
) );
}
$path = str_replace( home_url( '/' ), ABSPATH, esc_url( $_REQUEST['file'] ) );
jdi_cache()->write_cache();
wp_send_json_success( array(
'path' => jdi_tools()->secure_path( $path ),
) );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
}
/**
* Returns instance of Jet_Data_Importer_Interface
*
* @return object
*/
function jdi_interface() {
return Jet_Data_Importer_Interface::get_instance();
}

View File

@@ -0,0 +1,694 @@
<?php
/**
* Jimporter post processing callbacks
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Data_Importer_Callbacks' ) ) {
/**
* Define Jet_Data_Importer_Callbacks class
*/
class Jet_Data_Importer_Callbacks {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Holder for terms data
*
* @var array
*/
public $terms = array();
public $pages = null;
/**
* Store processed shortcodes data
*
* @var array
*/
private $shortcodes_data = array();
/**
* Constructor for the class
*/
public function __construct() {
// Manipulations with posts remap array
add_action( 'jet-data-importer/import/remap-posts', array( $this, 'process_options' ) );
add_action( 'jet-data-importer/import/remap-posts', array( $this, 'postprocess_posts' ) );
add_action( 'jet-data-importer/import/remap-posts', array( $this, 'process_thumbs' ) );
add_action( 'jet-data-importer/import/remap-posts', array( $this, 'process_elementor_pages_posts' ) );
add_action( 'jet-data-importer/import/remap-posts', array( $this, 'process_home_page' ) );
// Manipulations with terms remap array
add_action( 'jet-data-importer/import/remap-terms', array( $this, 'process_term_parents' ) );
add_action( 'jet-data-importer/import/remap-terms', array( $this, 'process_nav_menu' ) );
add_action( 'jet-data-importer/import/remap-terms', array( $this, 'process_nav_menu_widgets' ) );
add_action( 'jet-data-importer/import/remap-terms', array( $this, 'process_elementor_pages_terms' ) );
add_action( 'jet-data-importer/import/remap-terms', array( $this, 'process_home_page' ) );
}
public function elementor_pages() {
if ( null === $this->pages ) {
$this->pages = get_posts( array(
'post_type' => array( 'page', 'jet-theme-core', 'elementor_library' ),
'posts_per_page' => -1,
) );
}
return $this->pages;
}
/**
* Remap elementor images
*
* @todo remplace images in elementor widgets with imported.
* @return void
*/
public function process_elementor_pages_posts( $data ) {
$pages = $this->elementor_pages();
foreach ( $pages as $page ) {
$elementor_data = get_post_meta( $page->ID, '_elementor_data', true );
if ( empty( $elementor_data ) ) {
continue;
}
$new_data = preg_replace_callback(
'/(\"id\":\"?(\d+)\"?,\"url\":\"([^\"\']*?)\"|\"url\":\"([^\"\']*?)\",\"id\":\"?(\d+)\"?)/',
function( $match ) use ( $data ) {
$id = false;
if ( ! empty( $match[1] ) ) {
$id = $match[1];
} elseif ( ! empty( $match[4] ) ) {
$id = $match[4];
}
if ( ! $id || ! isset( $data[ $id ] ) ) {
return $match[0];
} else {
$result = sprintf(
'"url":%2$s,"id":%1$s',
$data[ $id ],
json_encode( wp_get_attachment_url( $data[ $id ] ) )
);
return $result;
}
},
$elementor_data
);
$ids_keys = apply_filters( 'jet-data-importer/import/posts/elementor-ids-to-remap', array(
'panel_template_id',
'item_template_id',
) );
$ids_keys = implode( '|', $ids_keys );
$ids_regex = "/\\\"({$ids_keys})\\\":\\\"(\d+)\\\"/";
$new_data = preg_replace_callback( $ids_regex, function( $match ) use ( $data ) {
if ( isset( $data[ $match[2] ] ) ) {
return sprintf(
'"%1$s":"%2$s"',
$match[1],
$data[ $match[2] ]
);
} else {
return $match[0];
}
}, $new_data );
update_post_meta( $page->ID, '_elementor_data', wp_slash( $new_data ) );
}
}
public function process_elementor_pages_terms( $data ) {
$pages = $this->elementor_pages();
$ids_keys = apply_filters( 'jet-data-importer/import/terms/elementor-ids-to-remap', array(
'category_ids',
'menu',
'nav_menu',
) );
$ids_keys = implode( '|', $ids_keys );
$regex = '\"(' . $ids_keys . ')\":(\".*?\"|\[.*?\])';
foreach ( $pages as $page ) {
$elementor_data = get_post_meta( $page->ID, '_elementor_data', true );
if ( empty( $elementor_data ) ) {
continue;
}
$new_data = preg_replace_callback( '/' . $regex . '/', function( $match ) use ( $data ) {
$val = json_decode( $match[2], true );
if ( ! is_array( $val ) ) {
$new = isset( $data[ $val ] ) ? $data[ $val ] : $val;
$new = '"' . $new . '"';
} else {
$new = array();
foreach ( $val as $old_id ) {
$new = isset( $data[ $old_id ] ) ? $data[ $old_id ] : $old_id;
}
$new = json_encode( $new );
}
return sprintf(
'"%1$s":%2$s',
$match[1],
$new
);
}, $elementor_data );
update_post_meta( $page->ID, '_elementor_data', wp_slash( $new_data ) );
}
}
/**
* Remap IDs in home page content
*
* @param array $data Mapped terms data.
* @return void|false
*/
public function process_home_page( $data ) {
$regex = apply_filters( 'jet-data-importer/import/home-regex-replace', array() );
if ( empty( $regex ) ) {
return false;
}
$pages = apply_filters( 'jet-data-importer/import/add-pages-to-replace', array() );
if ( ! empty( $pages ) ) {
$pages = array_map( array( $this, 'get_page_ids' ), $pages );
}
$home_id = get_option( 'page_on_front' );
$pages = array_merge( array( $home_id ), $pages );
$pages = array_filter( $pages );
if ( ! $pages ) {
return false;
}
$regex = array_map( array( $this, 'prepare_regex' ), $regex );
foreach ( $pages as $page_id ) {
$page = get_post( $page_id );
$this->terms = $data;
$content = preg_replace_callback( $regex, array( $this, 'replace_ids' ), $page->post_content );
$new_page = array(
'ID' => $page_id,
'post_content' => $content,
);
wp_update_post( $new_page );
}
}
/**
* Get page ids by slug
*
* @return int|bool
*/
public function get_page_ids( $slug ) {
$page = get_page_by_path( $slug );
if ( $page ) {
return $page->ID;
} else {
return false;
}
return get_page_by_path( $slug );
}
/**
* Replace ids in shortcodes
*
* @return string
*/
public function replace_ids( $matches ) {
if ( 5 !== count( $matches ) ) {
return $matches[0];
}
$tag = $matches[2];
$attr = $matches[3];
$data = $this->shortcodes_data;
$delimiter = isset( $data[ $tag ][ $attr ] ) ? $data[ $tag ][ $attr ] : ',';
$ids = explode( $delimiter, $matches[4] );
$new_ids = array();
foreach ( $ids as $id ) {
if ( isset( $this->terms[ $id ] ) ) {
$new_ids[] = $this->terms[ $id ];
} else {
$new_ids[] = $id;
}
}
$new_ids = implode( $delimiter, $new_ids );
$return = sprintf( '%1$s="%2$s"', $matches[1], $new_ids );
return $return;
}
/**
* Callback for regex map
*
* @param array $item Regex item.
* @return string
*/
public function prepare_regex( $item ) {
$delimiter = isset( $item['delimiter'] ) ? $item['delimiter'] : ',';
$tag = $item['shortcode'];
$attr = $item['attr'];
if ( ! isset( $this->shortcodes_data[ $tag ] ) ) {
$this->shortcodes_data[ $tag ] = array();
}
$this->shortcodes_data[ $tag ][ $attr ] = $delimiter;
return '/(\[(' . $item['shortcode'] . ')[^\]]*(' . $item['attr'] . '))="([0-9\,\s]*)"/';
}
/**
* Set correctly term parents
*
* @param array $data Mapped terms data.
* @return void|false
*/
public function process_term_parents( $data ) {
$remap_terms = jdi_cache()->get( 'terms', 'requires_remapping' );
$processed_term_slug = jdi_cache()->get( 'term_slug', 'mapping' );
if ( empty( $remap_terms ) ) {
return false;
}
foreach ( $remap_terms as $term_id => $taxonomy ) {
$parent_slug = get_term_meta( $term_id, '_wxr_import_parent', true );
if ( ! $parent_slug ) {
continue;
}
$term_mapping_key = $taxonomy . '-' . $parent_slug;
if ( empty( $processed_term_slug[ $term_mapping_key ] ) ) {
continue;
}
wp_update_term( $term_id, $taxonomy, array(
'parent' => (int) $processed_term_slug[ $term_mapping_key ],
) );
}
}
/**
* Replace term thumbnails IDs with new ones
*
* @param array $data
* @return void
*/
public function process_thumbs( $data ) {
global $wpdb;
$query_term = "
SELECT term_id, meta_key, meta_value
FROM $wpdb->termmeta
WHERE meta_key LIKE '%_thumb'
";
$thumb_term = $wpdb->get_results( $query_term, ARRAY_A );
$query_post = "
SELECT post_id, meta_key, meta_value
FROM $wpdb->postmeta
WHERE meta_key = '_thumbnail_id'
";
$thumb_post = $wpdb->get_results( $query_post, ARRAY_A );
if ( empty( $thumb_term ) ) {
$thumb_term = array();
}
if ( empty( $thumb_post ) ) {
$thumb_post = array();
}
$thumbnails = array_merge( $thumb_term, $thumb_post );
foreach ( $thumbnails as $thumb_data ) {
$meta_key = $thumb_data['meta_key'];
$current = $thumb_data['meta_value'];
if ( '_thumbnail_id' === $meta_key ){
$id = $thumb_data['post_id'];
$func = 'update_post_meta';
} else {
$id = $thumb_data['term_id'];
$func = 'update_term_meta';
}
if ( ! empty( $data[ $current ] ) ) {
call_user_func( $func, $id, $meta_key, $data[ $current ] );
}
}
}
/**
* Post-process posts.
*
* @param array $todo Remap data.
* @return void
*/
public function postprocess_posts( $mapping ) {
$todo = jdi_cache()->get( 'posts', 'requires_remapping' );
$user_slug = jdi_cache()->get( 'user_slug', 'mapping' );
$url_remap = jdi_cache()->get_group( 'url_remap' );
foreach ( $todo as $post_id => $_ ) {
$data = array();
$updated_links = '';
$old_links = '';
$post = get_post( $post_id );
$parent_id = get_post_meta( $post_id, '_wxr_import_parent', true );
if ( ! empty( $parent_id ) && isset( $mapping['post'][ $parent_id ] ) ) {
$data['post_parent'] = $mapping['post'][ $parent_id ];
}
$author_slug = get_post_meta( $post_id, '_wxr_import_user_slug', true );
if ( ! empty( $author_slug ) && isset( $user_slug[ $author_slug ] ) ) {
$data['post_author'] = $user_slug[ $author_slug ];
}
$has_attachments = get_post_meta( $post_id, '_wxr_import_has_attachment_refs', true );
if ( ! empty( $has_attachments ) ) {
$content = $post->post_content;
// Replace all the URLs we've got
$new_content = str_replace( array_keys( $url_remap ), $url_remap, $content );
if ( $new_content !== $content ) {
$data['post_content'] = $new_content;
}
}
if ( in_array( get_post_type( $post_id ), array( 'page', 'post' ) ) ) {
$old_links = ! empty( $data['post_content'] ) ? $data['post_content'] : $post->post_content;
$updated_links = str_replace( jdi_cache()->get( 'home' ), home_url(), $old_links );
if ( $updated_links !== $old_links ) {
$data['post_content'] = $updated_links;
}
}
if ( get_post_type( $post_id ) === 'nav_menu_item' ) {
$this->postprocess_menu_item( $post_id );
}
// Do we have updates to make?
if ( empty( $data ) ) {
continue;
}
// Run the update
$data['ID'] = $post_id;
$result = wp_update_post( $data, true );
if ( is_wp_error( $result ) ) {
continue;
}
// Clear out our temporary meta keys
delete_post_meta( $post_id, '_wxr_import_parent' );
delete_post_meta( $post_id, '_wxr_import_user_slug' );
delete_post_meta( $post_id, '_wxr_import_has_attachment_refs' );
}
}
/**
* Post-process menu items.
*
* @param int $post_id Processed post ID
* @return void
*/
public function postprocess_menu_item( $post_id ) {
$menu_object_id = get_post_meta( $post_id, '_wxr_import_menu_item', true );
if ( empty( $menu_object_id ) ) {
// No processing needed!
return;
}
$processed_term_id = jdi_cache()->get( 'term_id', 'mapping' );
$processed_posts = jdi_cache()->get( 'posts', 'mapping' );
$menu_item_type = get_post_meta( $post_id, '_menu_item_type', true );
switch ( $menu_item_type ) {
case 'taxonomy':
if ( isset( $processed_term_id[ $menu_object_id ] ) ) {
$menu_object = $processed_term_id[ $menu_object_id ];
}
break;
case 'post_type':
if ( isset( $processed_posts[ $menu_object_id ] ) ) {
$menu_object = $processed_posts[ $menu_object_id ];
}
break;
default:
// Cannot handle this.
return;
}
if ( ! empty( $menu_object ) ) {
update_post_meta( $post_id, '_menu_item_object_id', wp_slash( $menu_object ) );
}
delete_post_meta( $post_id, '_wxr_import_menu_item' );
}
/**
* Remap page ids in imported options
*
* @param array $data Remap data.
* @return void
*/
public function process_options( $data ) {
$options_to_process = array(
'page_on_front',
'page_for_posts',
);
foreach ( $options_to_process as $key ) {
$current = get_option( $key );
if ( ! $current || ! isset( $data[ $current ] ) ) {
continue;
}
update_option( $key, $data[ $current ] );
}
// Update Jet Theme Core conditions
$conditions = get_option( 'jet_site_conditions' );
if ( ! empty( $conditions ) ) {
$new_conditions = array();
foreach ( $conditions as $location => $condition ) {
$new_conditions[ $location ] = array();
foreach ( $condition as $template_id => $rules ) {
if ( isset( $data[ $template_id ] ) ) {
$new_conditions[ $location ][ $data[ $template_id ] ] = $rules;
} else {
$new_conditions[ $location ][ $template_id ] = $rules;
}
}
}
update_option( 'jet_site_conditions', $new_conditions );
}
}
/**
* Remap nav menu ids
*
* @param array $data Remap data.
* @return void
*/
public function process_nav_menu( $data ) {
$locations = get_nav_menu_locations();
if ( empty( $locations ) ) {
return;
}
$new_locations = array();
foreach ( $locations as $location => $id ) {
if ( isset( $data[ $id ] ) ) {
$new_locations[ $location ] = $data[ $id ];
} else {
$new_locations[ $location ] = $id;
}
}
set_theme_mod( 'nav_menu_locations', $new_locations );
}
/**
* Remap menu IDs in widgets
*
* @param array $data Remap data.
* @return void
*/
public function process_nav_menu_widgets( $data ) {
$widget_menus = get_option( 'widget_nav_menu' );
if ( empty( $widget_menus ) ) {
return;
}
$new_widgets = array();
foreach ( $widget_menus as $key => $widget ) {
if ( '_multiwidget' === $key ) {
$new_widgets['_multiwidget'] = $widget;
continue;
}
if ( empty( $widget['nav_menu'] ) ) {
$new_widgets[] = $widget;
continue;
}
$id = $widget['nav_menu'];
if ( isset( $data[ $id ] ) ) {
$widget['nav_menu'] = $data[ $id ];
}
$new_widgets[ $key ] = $widget;
}
update_option( 'widget_nav_menu', $new_widgets );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
}
/**
* Returns instance of Jet_Data_Importer_Callbacks
*
* @return object
*/
function jdi_remap_callbacks() {
return Jet_Data_Importer_Callbacks::get_instance();
}
jdi_remap_callbacks();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.

View File

@@ -0,0 +1,845 @@
<?php
/**
* Plugin Name: Jet Data Importer
* Plugin URI: https://crocoblock.com
* Description: Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file.
* Author: Zemez
* Author URI:
* Version: 1.2.2
* Text Domain: jet-data-importer
* License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Data_Importer' ) ) {
/**
* Define Jet_Data_Importer class
*/
class Jet_Data_Importer {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Holder for importer object instance.
*
* @var object
*/
private $importer = null;
/**
* Holder for importer object instance.
*
* @var object
*/
private $exporter = null;
/**
* Plugin base url
*
* @var string
*/
private $url = null;
/**
* Plugin base path
*
* @var string
*/
private $path = null;
/**
* Items number in single chunk
*
* @var integer
*/
private $chunk_size = 10;
/**
* Registered page tabs
* @var array
*/
private $page_tabs = array();
/**
* External config
*
* @var array
*/
private $external_config = array();
/**
* External config status
*
* @var boolean
*/
private $has_external = false;
/**
* Menu page slug.
* @var string
*/
public $slug = 'jet-demo-content';
/**
* Dispalying tab data
* @var array
*/
public $current_tab = array();
/**
* Constructor for the class
*/
function __construct() {
// Internationalize the text strings used.
add_action( 'init', array( $this, 'lang' ), -999 );
add_action( 'init', array( $this, 'start_session' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'register_assets' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ), 20 );
add_filter( 'upload_mimes', array( $this, 'allow_upload_xml' ) );
add_action( 'init', array( $this, 'init' ) );
add_action( 'admin_menu', array( $this, 'menu_page' ), 30 );
// 1st wizard compat
add_filter( 'tm_wizard_template_path', array( $this, 'wizard_success_page' ), 10, 2 );
add_filter( 'tm_wizard_notice_visibility', array( $this, 'wizard_notice_visibility' ) );
// 2nd wizard compat
add_filter( 'cherry_plugin_wizard_template_path', array( $this, 'wizard_success_page' ), 10, 2 );
add_filter( 'cherry_plugin_wizard_notice_visibility', array( $this, 'wizard_notice_visibility' ) );
// Current wizard compat
add_filter( 'jet-plugins-wizard/template-path', array( $this, 'wizard_success_page' ), 10, 2 );
add_filter( 'jet-plugins-wizard/notice-visibility', array( $this, 'wizard_notice_visibility' ) );
}
/**
* Hide wizard notice on importer pages.
*
* @param bool $is_visible Default visibility value.
* @return bool
*/
public function wizard_notice_visibility( $is_visible ) {
if ( empty( $_GET['page'] ) || $this->slug !== $_GET['page'] ) {
return $is_visible;
}
return false;
}
/**
* Chenge wizard success page template
*
* @param string $file Template path.
* @param string $template Template name.
* @return string
*/
public function wizard_success_page( $file, $template ) {
if ( 'step-after-install.php' !== $template ) {
return $file;
}
if ( function_exists( 'tm_wizard_interface' ) && is_callable( array( tm_wizard_interface(), 'get_skin_data' ) ) ) {
return jdi()->path( 'templates/wizard-after-install.php' );
}
if ( function_exists( 'cherry_plugin_wizard_interface' ) && is_callable( array( cherry_plugin_wizard_interface(), 'get_skin_data' ) ) ) {
return jdi()->path( 'templates/wizard-after-install.php' );
}
if ( function_exists( 'jet_plugins_wizard_interface' ) && is_callable( array( jet_plugins_wizard_interface(), 'get_skin_data' ) ) ) {
return jdi()->path( 'templates/wizard-after-install.php' );
}
return $file;
}
/**
* Init plugin
*
* @return void
*/
public function init() {
$this->set_default_settings();
$this->set_theme_settings();
$this->load();
$this->load_import();
$this->load_export();
}
/**
* Loads the translation files.
*/
public function lang() {
load_plugin_textdomain( 'jet-data-importer', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
/**
* Register menu page
*/
public function menu_page() {
add_menu_page(
esc_html__( 'Demo Content ', 'jet-data-importer' ),
esc_html__( 'Demo Content ', 'jet-data-importer' ),
'manage_options',
$this->slug,
array( $this, 'render_plugin_page' ),
'dashicons-download',
76
);
$this->register_tab(
array(
'id' => 'settings',
'name' => esc_html__( 'Settings', 'jet-data-importer' ),
'cb' => array( $this, 'settings_page' ),
)
);
foreach ( $this->get_page_tabs() as $tab ) {
if ( empty( $tab['id'] ) || empty( $tab['name'] ) ) {
continue;
}
add_submenu_page(
$this->slug,
esc_html__( 'Demo Content ', 'jet-data-importer' ),
$tab['name'],
'manage_options',
sprintf( '%1$s&tab=%2$s', $this->slug, $tab['id'] ),
array( $this, 'render_plugin_page' )
);
}
remove_submenu_page( $this->slug, $this->slug );
}
/**
* Render settings page
*
* @return void
*/
public function settings_page() {
if ( isset( $_POST['jdi_cache_handler'] ) ) {
update_option( 'jdi_cache_handler', esc_attr( $_POST['jdi_cache_handler'] ), false );
}
ob_start();
$this->get_template( 'page-settings.php' );
return ob_get_clean();
}
/**
* Render plugin page html
*/
public function render_plugin_page() {
$this->get_template( 'page-header.php' );
$tabs = jdi()->get_page_tabs();
if ( ! $tabs ) {
return;
}
$menu = '';
$content = '';
$menu_format = '<li class="cdi-tabs__item"><a class="cdi-tabs__link%3$s" href="%1$s">%2$s</a></li>';
$content_format = '<div class="cdi-tabs_tab">%1$s</div>';
if ( empty( $_GET['tab'] ) ) {
$this->current_tab = $tabs[0];
$current_tab_id = $this->current_tab['id'];
} else {
$current_tab_id = esc_attr( $_GET['tab'] );
}
foreach ( $tabs as $tab ) {
$current = '';
if ( $current_tab_id === $tab['id'] ) {
$current = ' current-tab';
$this->current_tab = $tab;
if ( is_callable( $tab['cb'] ) ) {
$content = sprintf( $content_format, call_user_func( $tab['cb'] ) );
}
}
$menu .= sprintf( $menu_format, $this->get_tab_link( $tab['id'] ), $tab['name'], $current );
}
if ( apply_filters( 'jet-data-importer/tabs-menu-visibility', true ) ) {
printf( '<ul class="cdi-tabs__menu">%s</ul>', $menu );
}
printf( '<div class="cdi-tabs__content">%s</div>', $content );
$this->get_template( 'page-footer.php' );
}
/**
* Return page tabs array
*
* @return array
*/
public function get_page_tabs() {
return $this->page_tabs;
}
/**
* Returns current tab URL
*
* @param string $tab Current tab ID.
* @return string
*/
public function get_tab_link( $tab = '' ) {
return add_query_arg(
array(
'page' => $this->slug,
'tab' => $tab,
),
esc_url( admin_url( 'admin.php' ) )
);
}
/**
* Register new tab for plugin page.
*
* @param array $tab Tab data to registrate.
* @return void
*/
public function register_tab( $tab = array() ) {
$tab = wp_parse_args( $tab, array(
'id' => 'tab',
'name' => null,
'cb' => null,
) );
$this->page_tabs[] = $tab;
}
/**
* Add XML to alowed MIME types to upload
*
* @param array $mimes Allowed MIME-types.
* @return array
*/
public function allow_upload_xml( $mimes ) {
$mimes = array_merge( $mimes, array( 'xml' => 'application/xml' ) );
return $mimes;
}
/**
* Run session
*
* @return void
*/
public function start_session() {
if ( ! session_id() ) {
session_start();
}
}
/**
* Get plugin template
*
* @param string $template Template name.
* @return void
*/
public function get_template( $template ) {
$file = locate_template( 'jet-data-importer/' . $template );
if ( ! $file ) {
$file = $this->path( 'templates/' . $template );
}
if ( file_exists( $file ) ) {
include $file;
}
}
/**
* Load globally required files
*/
public function load() {
require $this->path( 'includes/class-jet-data-importer-cache.php' );
require $this->path( 'includes/class-jet-data-importer-logger.php' );
require $this->path( 'includes/class-jet-data-importer-tools.php' );
require $this->path( 'includes/class-jet-data-importer-slider.php' );
require $this->path( 'includes/class-jet-data-importer-files-manager.php' );
}
/**
* Set default importer settings
*
* @return void
*/
public function set_default_settings() {
include $this->path( 'includes/config/default-config.php' );
/**
* @var array $settings defined in manifest file
*/
$this->settings = apply_filters( 'jet-data-importer/default-config', $config );
}
public function add_external_config( $config = array() ) {
$this->has_external = true;
$this->external_config = array_merge( $this->external_config, $config );
}
/**
* Maybe rewrite settings from active theme
*
* @return void
*/
public function set_theme_settings() {
if ( empty( $this->external_config ) ) {
$this->maybe_get_remote_skins();
return;
}
$allowed_settings = array_keys( $this->settings );
/**
* List of settings that should be rewritten from 3rd party source instead of merging
*/
$rewrite = apply_filters( 'jet-data-importer/settings/rewrite-keys', array(
'success-links',
'advanced_import',
) );
foreach ( $allowed_settings as $type ) {
if ( isset( $this->external_config[ $type ] ) ) {
if ( in_array( $type, $rewrite ) ) {
$this->settings[ $type ] = $this->external_config[ $type ];
} else {
$this->settings[ $type ] = wp_parse_args(
$this->external_config[ $type ],
$this->settings[ $type ]
);
}
if ( 'advanced_import' === $type && isset( $this->settings[ $type ]['from_path'] ) ) {
$this->settings[ $type ] = $this->get_remote_skins( $this->settings[ $type ]['from_path'] );
}
}
}
}
/**
* If 3-rd party config not passed - check maybe we need to get default remote config.
*
* @return [type] [description]
*/
public function maybe_get_remote_skins() {
if ( ! isset( $this->settings['advanced_import'] ) ) {
return;
}
if ( ! isset( $this->settings['advanced_import']['from_path'] ) ) {
return;
}
$this->settings['advanced_import'] = $this->get_remote_skins(
$this->settings['advanced_import']['from_path']
);
}
/**
* Get remote skins if config provides URL for scins API
*
* @param string $url API URL to get skins from.
* @return array
*/
public function get_remote_skins( $url ) {
$transient = 'jet_wizard_skins';
$data = get_site_transient( $transient );
if ( $this->has_external ) {
$data = false;
}
if ( ! $data ) {
$response = wp_remote_get( $url, array(
'timeout' => 60,
'sslverify' => false,
) );
$data = wp_remote_retrieve_body( $response );
$data = json_decode( $data, true );
if ( empty( $data ) ) {
$data = array();
}
if ( ! $this->has_external ) {
set_site_transient( $transient, $data, 2 * DAY_IN_SECONDS );
}
}
$result = array();
if ( ! isset( $data['advanced'] ) ) {
return $result;
}
foreach ( $data['advanced'] as $slug => $skin ) {
$result[ $slug ] = array(
'label' => $skin['name'],
'full' => $skin['full_xml'],
'lite' => $skin['lite_xml'],
'thumb' => $skin['thumb'],
'demo_url' => $skin['demo'],
);
}
return $result;
}
/**
* Get setting by name
*
* @param array $keys Settings key to get.
* @return void
*/
public function get_setting( $keys = array() ) {
if ( empty( $keys ) || ! is_array( $keys ) ) {
return false;
}
$temp_result = $this->settings;
foreach ( $keys as $key ) {
if ( ! isset( $temp_result[ $key ] ) ) {
continue;
}
$temp_result = $temp_result[ $key ];
}
return $temp_result;
}
/**
* Include import files
*/
public function load_import() {
$this->load_wp_importer();
require $this->path( 'includes/import/class-jet-data-importer-interface.php' );
jdi_interface();
}
/**
* Load export-related files
*
* @return void
*/
public function load_export() {
if ( ! is_admin() ) {
return;
}
require $this->path( 'includes/export/class-jet-data-export-interface.php' );
}
/**
* Returns path to file or dir inside plugin folder
*
* @param string $path Path inside plugin dir.
* @return string
*/
public function path( $path = null ) {
if ( ! $this->path ) {
$this->path = trailingslashit( plugin_dir_path( __FILE__ ) );
}
return $this->path . $path;
}
/**
* Returns url to file or dir inside plugin folder
*
* @param string $path Path inside plugin dir.
* @return string
*/
public function url( $path = null ) {
if ( ! $this->url ) {
$this->url = trailingslashit( plugin_dir_url( __FILE__ ) );
}
return $this->url . $path;
}
/**
* Prepare assets URL depending from CHERRY_DEBUG value
*
* @param string $path Base file path.
* @return string
*/
public function assets_url( $path ) {
return $this->url( 'assets/' . $path );
}
/**
* Register plugin script and styles
*
* @return void
*/
public function register_assets() {
wp_register_style(
'jet-data-import',
$this->assets_url( 'css/jet-data-import.css' ),
array(),
'1.2.1'
);
wp_register_script(
'jet-data-import',
$this->assets_url( 'js/jet-data-import.js' ),
array(),
'1.2.1',
true
);
wp_register_script(
'jet-data-export',
$this->assets_url( 'js/jet-data-export.js' ),
array(),
'1.2.1',
true
);
wp_localize_script( 'jet-data-import', 'JetDataImportVars', array(
'nonce' => wp_create_nonce( 'jet-data-import' ),
'autorun' => $this->import_autorun(),
'uploadTitle' => esc_html__( 'Select or upload file with demo content', 'jet-data-importer' ),
'uploadBtn' => esc_html__( 'Select', 'jet-data-importer' ),
'file' => ( isset( $_REQUEST['file'] ) ) ? esc_attr( $_REQUEST['file'] ) : false,
'skin' => ( isset( $_REQUEST['skin'] ) ) ? esc_attr( $_REQUEST['skin'] ) : 'default',
'xml_type' => ( isset( $_REQUEST['xml_type'] ) ) ? esc_attr( $_REQUEST['xml_type'] ) : 'lite',
'tab' => jdi_interface()->slug,
'error' => esc_html__( 'Data processing error, please try again!', 'jet-data-importer' ),
'advURLMask' => $this->page_url( array( 'tab' => 'import', 'step' => 2, 'file' => '<-file->' ) ),
) );
wp_localize_script( 'jet-data-export', 'JetDataExportVars', array(
'nonce' => wp_create_nonce( 'jet-data-export' ),
) );
}
/**
* Generate import page URL.
*
* @param array $args Arguments array.
* @return string
*/
public function page_url( $args = array() ) {
$default = array(
'page' => $this->slug,
);
if ( ! empty( $_REQUEST['referrer'] ) ) {
$default['referrer'] = esc_attr( $_REQUEST['referrer'] );
}
if ( empty( $default['referrer'] ) && $this->get_server_ref() ) {
$default['referrer'] = $this->get_server_ref();
}
$args = array_merge( $default, $args );
return add_query_arg( $args, esc_url( admin_url( 'admin.php' ) ) );
}
/**
* Try to get referrer from server vars
*
* @return string|bool false
*/
public function get_server_ref() {
if ( empty( $_SERVER['HTTP_REFERER'] ) ) {
return false;
}
$parts = parse_url( $_SERVER['HTTP_REFERER'] );
if ( ! $parts || empty( $parts['query'] ) ) {
return false;
}
parse_str( $parts['query'], $query );
if ( empty( $query ) || empty( $query['referrer'] ) ) {
return false;
}
return esc_attr( $query['referrer'] );
}
/**
* Check if import autorun is allowed.
*
* @return boolean
*/
public function import_autorun() {
if ( isset( $_GET['type'] ) && 'replace' === $_GET['type'] ) {
return false;
}
if ( isset( $_GET['file'] ) ) {
return esc_attr( $_GET['file'] );
} else {
return false;
}
}
/**
* Enqueue globally required assets
*
* @return void
*/
public function enqueue_assets( $hook ) {
if ( isset( $_GET['page'] ) && $this->slug === $_GET['page'] ) {
wp_enqueue_style( 'jet-data-import' );
wp_enqueue_media();
}
}
/**
* Loads default WordPress importer
*
* @return void
*/
public function load_wp_importer() {
if ( ! class_exists( 'WP_Importer' ) ) {
require ABSPATH . '/wp-admin/includes/class-wp-importer.php';
}
}
/**
* Return importer instance.
*
* @return object
*/
public function importer() {
return $this->importer;
}
/**
* Return exporter instance
*
* @return object
*/
public function exporter() {
return $this->exporter;
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
}
/**
* Returns instance of Jet_Data_Importer
*
* @return object
*/
function jdi() {
return Jet_Data_Importer::get_instance();
}
jdi();
/**
* Register configuration from 3rd party theme or plugin.
* Should be called on 'init' hook with priority 9 or earlier.
*
* @param array $config Array of settings to register.
* @return void
*/
function jet_data_importer_register_config( $config = array() ) {
jdi()->add_external_config( $config );
}

View File

@@ -0,0 +1,470 @@
msgid ""
msgstr ""
"Project-Id-Version: Jet Data Importer\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-23 11:49+0200\n"
"PO-Revision-Date: 2018-11-23 11:49+0200\n"
"Last-Translator: \n"
"Language-Team: Cherry Team <support@cherryframework.com>\n"
"Language: ru\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: __;_e;_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;"
"esc_attr__;esc_attr_e;esc_attr_x:1,2c;_ex:1,2c;_n:1,2;_nx:4c,1,2;_n_noop:1,2;"
"_nx_noop:4c,1,2\n"
"esc_attr__;_x: 1,2c;_n:1,2\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Generator: Poedit 2.1.1\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n"
"X-Poedit-SearchPath-0: .\n"
#: includes/class-jet-data-importer-tools.php:77
msgid "Importing sample data"
msgstr "Импортирование демо-контента"
#: includes/class-jet-data-importer-tools.php:80
msgid "Regenerating thumbnails"
msgstr "Регенерация миниатюр"
#: includes/class-jet-data-importer-tools.php:83
msgid "Congratulations! Youre all Set!"
msgstr "Поздравляем! Все готово!"
#: includes/class-jet-data-importer-tools.php:86
msgid "Select source to import"
msgstr "Выберите источник для импорта"
#: includes/config/default-config.php:28
msgid "Export all content with Jet Data Export tool"
msgstr "Экспортировать весь контент с помощью инструмента Jet Data Export"
#: includes/config/default-config.php:35 templates/import-after.php:16
msgid "View your site"
msgstr "Посмотреть ваш сайт"
#: includes/config/default-config.php:39
msgid "Take a look at your site"
msgstr "Посмотреть ваш сайт"
#: includes/config/default-config.php:43
msgid "Start editing"
msgstr "Начать редактирование"
#: includes/config/default-config.php:47
msgid "Proceed to editing pages"
msgstr "Перейти к редактированию страниц"
#: includes/config/default-config.php:51
msgid "Check documentation"
msgstr "Проверить документацию"
#: includes/config/default-config.php:55
msgid "Get more info from documentation"
msgstr "Получить дополнительную информацию из документации"
#: includes/config/default-config.php:59
msgid "Knowledge Base"
msgstr "База знаний"
#: includes/config/default-config.php:63
msgid "Access the vast knowledge base"
msgstr "Доступ к огромной базе знаний"
#: includes/config/default-config.php:67
msgid "Community"
msgstr "Сообщество"
#: includes/config/default-config.php:71
msgid "Join community to stay tuned to the latest news"
msgstr "Присоединиться к сообществу, чтобы быть в курсе последних новостей"
#: includes/export/class-jet-data-export-interface.php:47
#: templates/export.php:8
msgid "Export"
msgstr "Экспортировать"
#: includes/import/class-jet-data-importer-interface.php:127
msgid "Password is empty"
msgstr "Поле с паролем пусто"
#: includes/import/class-jet-data-importer-interface.php:140
msgid "Content successfully removed"
msgstr "Контент успешно удален"
#: includes/import/class-jet-data-importer-interface.php:147
msgid "Entered password is invalid"
msgstr "Введен неверный пароль"
#: includes/import/class-jet-data-importer-interface.php:191
#, php-format
msgid "%1$s: %2$s required, yours - %3$s"
msgstr "%1$s: %2$s требуется, ваш - %3$s"
#: includes/import/class-jet-data-importer-interface.php:217
msgid "Some parameters from your server don't meet the requirements:"
msgstr "Некоторые параметры вашего сервера не отвечают требованиям:"
#: includes/import/class-jet-data-importer-interface.php:250
msgid "Import"
msgstr "Импортировать"
#: includes/import/class-jet-data-importer-interface.php:332
msgid "Error! Import file not found. Please contact our support team."
msgstr "Ошибка! Файл импорта не найден. Обратитесь в нашу службу поддержки."
#: includes/import/class-jet-data-importer-interface.php:423
#: includes/import/class-jet-data-importer-interface.php:431
msgid "You don't have permissions to do this"
msgstr "Эта опция недоступна"
#: includes/import/class-jet-data-importer-interface.php:459
#, php-format
msgid "%s is missing in request"
msgstr "%s отсутствует в запросе"
#: includes/import/class-jet-data-importer-interface.php:518
msgid "Chunk number is missing in request"
msgstr "Большое количество данных пропущено в запросе"
#: includes/import/class-jet-data-importer-interface.php:748
msgid "Upload XML file with demo content"
msgstr "Загрузить XML-файл с демо-контентом"
#: includes/import/class-jet-data-importer-interface.php:752
msgid "We found 1 XML file with demo content in your theme, install it?"
msgstr "Мы нашли 1 XML-файл с демо-контентом в вашей теме, установить его?"
#: includes/import/class-jet-data-importer-interface.php:757
#, php-format
msgid ""
"We found %s XML files in your theme. Please select one of them to install"
msgstr ""
"Мы нашли %s XML-файлов в вашей теме. Выберите один из них, чтобы установить"
#: includes/import/class-jet-data-importer-interface.php:839
msgid "Upload File"
msgstr "Загрузить файл"
#: includes/import/class-jet-data-importer-interface.php:895
msgid ""
"You don't have permissions to replace content, please re-enter with "
"admiistrator account"
msgstr ""
"Вы не можете заменить содержание, пожалуйста войдите с аккаунта "
"администратора"
#: includes/import/class-jet-data-importer-interface.php:918
msgid "XML file not passed"
msgstr "XML-файл не был принят"
#: includes/import/class-jet-wxr-importer.php:673
msgid "Cannot import auto-draft posts"
msgstr "Невозможно импортировать авто-эскизы публикаций"
#: includes/import/class-jet-wxr-importer.php:1124
msgid "Sidebar does not exist in theme (using Inactive)"
msgstr "Боковая панель не существует в теме (с использованием Inactive)"
#: includes/import/class-jet-wxr-importer.php:1149
msgid "Site does not support widget"
msgstr "Сайт не поддерживает виджет"
#: includes/import/class-jet-wxr-importer.php:1185
msgid "Widget already exists"
msgstr "Виджет уже существует"
#: includes/import/class-jet-wxr-importer.php:1246
msgid "Imported"
msgstr "Импортировано"
#: includes/import/class-jet-wxr-importer.php:1249
msgid "Imported to Inactive"
msgstr "Импортировано в Inactive"
#: includes/import/class-jet-wxr-importer.php:1256
msgid "No Title"
msgstr "Без названия"
#: includes/import/class-jet-wxr-importer.php:1401
#, php-format
msgid "Failed to import \"%s\": Invalid post type %s"
msgstr "Не удалось импортировать «%s»: недопустимый тип публикации %s"
#: includes/import/class-jet-wxr-importer.php:1412
#, php-format
msgid "%s \"%s\" already exists."
msgstr "%s \"%s\" уже существуют."
#: includes/import/class-jet-wxr-importer.php:1492
#, php-format
msgid "Skipping attachment \"%s\", fetching attachments disabled"
msgstr "Пропустить вложение «%s», отключить привязку вложений"
#: includes/import/class-jet-wxr-importer.php:1508
#, php-format
msgid "Failed to import \"%s\" (%s)"
msgstr "Не удалось импортировать «%s» (%s)"
#: includes/import/class-jet-wxr-importer.php:1545
#: includes/import/class-jet-wxr-importer.php:1851
#, php-format
msgid "Imported \"%s\" (%s)"
msgstr "Импортированы «%s» (%s)"
#: includes/import/class-jet-wxr-importer.php:1550
#, php-format
msgid "Post %d remapped to %d"
msgstr "Публикация %d переназначена в %d"
#: includes/import/class-jet-wxr-importer.php:1687
#, php-format
msgid "Failed to import user \"%s\""
msgstr "Не удалось импортировать пользователя «%s»"
#: includes/import/class-jet-wxr-importer.php:1709
#, php-format
msgid "Imported user \"%s\""
msgstr "Импортирован пользователь «%s»"
#: includes/import/class-jet-wxr-importer.php:1714
#, php-format
msgid "User %d remapped to %d"
msgstr "Пользователь%d переназначен на %d"
#: includes/import/class-jet-wxr-importer.php:1815
#, php-format
msgid "Failed to import %s %s"
msgstr "Не удалось импортировать %s %s"
#: includes/import/class-jet-wxr-importer.php:1856
#, php-format
msgid "Term %d remapped to %d"
msgstr "Категория %d переназначена на %d"
#: includes/import/class-jet-wxr-importer.php:2278
msgid "Invalid file type"
msgstr "Неверный тип файла"
#: includes/import/class-jet-wxr-importer.php:2358
msgid "Zero size file downloaded"
msgstr "Загружен файл, не содержащий данных"
#: includes/import/class-jet-wxr-importer.php:2367
#, php-format
msgid "Remote file is too large, limit is %s"
msgstr "Удаленный файл слишком большой, ограничение %s"
#: includes/import/class-jet-wxr-importer.php:2536
msgid "Could not open the file for parsing"
msgstr "Не удалось открыть файл для разбора"
#: jet-data-importer.php:196 jet-data-importer.php:197
#: jet-data-importer.php:221
msgid "Demo Content "
msgstr "Демо-контент "
#: jet-data-importer.php:208
msgid "Settings"
msgstr "Настройки"
#: jet-data-importer.php:662
msgid "Select or upload file with demo content"
msgstr "Выберите или загрузите файл с демо-контентом"
#: jet-data-importer.php:663
msgid "Select"
msgstr "Выбрать"
#: jet-data-importer.php:668
msgid "Data processing error, please try again!"
msgstr "Ошибка обработки данных, повторите попытку!"
#: templates/advanced-popup.php:8
msgid "Attention!"
msgstr "Внимание!"
#: templates/advanced-popup.php:9 templates/wizard-after-install.php:26
msgid ""
"We are ready to install demo data. Do you want to append demo content to "
"your existing content or completely rewrite it?"
msgstr ""
"Мы готовы установить демо-контент. Вы хотите добавить демо-контент к уже "
"существующему контенту, или полностью заменить его?"
#: templates/advanced-popup.php:15 templates/wizard-after-install.php:34
msgid "Append demo content to my existing content"
msgstr "Добавить демо-контент к текущему"
#: templates/advanced-popup.php:22 templates/wizard-after-install.php:46
msgid "Replace my existing content with demo content"
msgstr "Заменить мой текущий контент демо-контентом"
#: templates/advanced-popup.php:28
msgid "NOTE:"
msgstr "Внимание:"
#: templates/advanced-popup.php:29
msgid ""
"This option will remove all your existing content - posts, pages, "
"attachments, terms and comments"
msgstr ""
"Эта опция удалит все существующее содержимое - публикации, страницы, "
"вложения, категории и комментарии"
#: templates/advanced-popup.php:33
msgid "Start Install"
msgstr "Начать установку"
#: templates/import-advanced.php:40
msgid "Recommended Plugins:"
msgstr "Рекомендуемые плагины:"
#: templates/import-advanced.php:56
msgid "Optimize Demo Content"
msgstr "Оптимизировать демо-контент"
#: templates/import-advanced.php:58
msgid ""
"Please select this option to install light version of demo content. "
"Recommended for slow severs and shared web hosts"
msgstr ""
"Выберите этот вариант, чтобы установить облегченную версию демо-контента. "
"Рекомендуется для медленных серверов и совместных веб-узлов"
#: templates/import-advanced.php:63
msgid "Install Demo"
msgstr "Установить демо"
#: templates/import-advanced.php:66
msgid "View Demo"
msgstr "Просмотреть демо"
#: templates/import-after.php:8
msgid "Dont know from where to start? Let us help you!"
msgstr "Не знаете с чего начать? Позвольте нам помочь вам!"
#: templates/import-after.php:20
msgid "See what you get"
msgstr "Посмотрите, что получается"
#: templates/import-before.php:23
msgid "or"
msgstr "или"
#: templates/import-before.php:30
msgid "Start import"
msgstr "Начать импорт"
#: templates/import.php:23
msgid "Import Summary"
msgstr "Общие данные импорта"
#: templates/import.php:24
msgid "Completed"
msgstr "Завершено"
#: templates/import.php:25
msgid "Progress"
msgstr "Прогресс"
#: templates/import.php:33
msgid "Posts"
msgstr "Публикации"
#: templates/import.php:34
msgid "Authors"
msgstr "Авторы"
#: templates/import.php:35
msgid "Comments"
msgstr "Комментарии"
#: templates/import.php:36
msgid "Media"
msgstr "Медиа"
#: templates/import.php:37
msgid "Terms"
msgstr "Категории"
#: templates/import.php:38
msgid "Tables"
msgstr "Таблицы"
#: templates/page-settings.php:8
msgid "Cache handler:"
msgstr "Обработчик кэша"
#: templates/page-settings.php:20
msgid "Save"
msgstr "Сохранить"
#: templates/regenerate.php:9
msgid "Starting process, please wait few seconds..."
msgstr "Запуск процесса, подождите несколько секунд ..."
#: templates/remove-content-form.php:9
msgid ""
"Please, enter your WordPress user password to confirm and start content "
"replacing."
msgstr ""
"Пожалуйста, введите пароль пользователя WordPress, чтобы подтвердить и "
"начать замену контента."
#: templates/remove-content-form.php:12
msgid ""
"NOTE: All your content will be replaced (posts, pages, comments, attachments "
"and terms)"
msgstr ""
"Внимание: весь ваш контент будет заменен (публикации, страницы, комментарии, "
"вложения и категории)"
#: templates/remove-content-form.php:16
msgid "Please, enter your password"
msgstr "Пожалуйста, введите пароль"
#: templates/remove-content-form.php:18
msgid "Import Content"
msgstr "Импортировать контент"
#: templates/wizard-after-install.php:24
msgid "We're almost there!"
msgstr "Мы почти на месте!"
#: templates/wizard-after-install.php:37
msgid ""
"If you have chosen this option, the sample data will be added to the current "
"content of your theme."
msgstr ""
"Если вы выбрали этот вариант, демо-контент будет добавлен к текущему "
"контенту вашей темы."
#: templates/wizard-after-install.php:49
msgid ""
"NB! If you want to install theme demo content, you agree that your current "
"data will be replaced by the new demo content (sample data). If you want to "
"save the current content of your theme, please choose Skip Data Installation."
msgstr ""
"Внимание! Если вы хотите установить демо-контент темы, вы соглашаетесь с "
"тем, что ваш текущий контент будет заменен новым (демонстрационным). Если вы "
"хотите сохранить текущий контент своей темы, выберите «Пропустить установку "
"демо-контента»."
#: templates/wizard-after-install.php:60
msgid "Skip demo content installation"
msgstr "Пропустить установку демо-контента"
#: templates/wizard-after-install.php:63
msgid ""
"If you have chosen this option, the sample data will not be installed on "
"your theme and your current content will stay as it is."
msgstr ""
"Если вы выбрали этот вариант, демо-контент не будет установлен в вашу тему, "
"и ваш текущий контент останется прежним."
#: templates/wizard-after-install.php:76
msgid "Next"
msgstr "Далее"

View File

@@ -0,0 +1,451 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Jet Data Importer\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-23 11:48+0200\n"
"PO-Revision-Date: 2018-05-09 17:23+0200\n"
"Last-Translator: \n"
"Language-Team: Cherry Team <support@cherryframework.com>\n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: __;_e;_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;"
"esc_attr__;esc_attr_e;esc_attr_x:1,2c;_ex:1,2c;_n:1,2;_nx:4c,1,2;_n_noop:1,2;"
"_nx_noop:4c,1,2\n"
"esc_attr__;_x: 1,2c;_n:1,2\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Generator: Poedit 2.1.1\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SearchPath-0: .\n"
"X-Poedit-SearchPathExcluded-0: cherry-framework\n"
"X-Poedit-SearchPathExcluded-1: node_modules\n"
#: includes/class-jet-data-importer-tools.php:77
msgid "Importing sample data"
msgstr ""
#: includes/class-jet-data-importer-tools.php:80
msgid "Regenerating thumbnails"
msgstr ""
#: includes/class-jet-data-importer-tools.php:83
msgid "Congratulations! Youre all Set!"
msgstr ""
#: includes/class-jet-data-importer-tools.php:86
msgid "Select source to import"
msgstr ""
#: includes/config/default-config.php:28
msgid "Export all content with Jet Data Export tool"
msgstr ""
#: includes/config/default-config.php:35 templates/import-after.php:16
msgid "View your site"
msgstr ""
#: includes/config/default-config.php:39
msgid "Take a look at your site"
msgstr ""
#: includes/config/default-config.php:43
msgid "Start editing"
msgstr ""
#: includes/config/default-config.php:47
msgid "Proceed to editing pages"
msgstr ""
#: includes/config/default-config.php:51
msgid "Check documentation"
msgstr ""
#: includes/config/default-config.php:55
msgid "Get more info from documentation"
msgstr ""
#: includes/config/default-config.php:59
msgid "Knowledge Base"
msgstr ""
#: includes/config/default-config.php:63
msgid "Access the vast knowledge base"
msgstr ""
#: includes/config/default-config.php:67
msgid "Community"
msgstr ""
#: includes/config/default-config.php:71
msgid "Join community to stay tuned to the latest news"
msgstr ""
#: includes/export/class-jet-data-export-interface.php:47
#: templates/export.php:8
msgid "Export"
msgstr ""
#: includes/import/class-jet-data-importer-interface.php:127
msgid "Password is empty"
msgstr ""
#: includes/import/class-jet-data-importer-interface.php:140
msgid "Content successfully removed"
msgstr ""
#: includes/import/class-jet-data-importer-interface.php:147
msgid "Entered password is invalid"
msgstr ""
#: includes/import/class-jet-data-importer-interface.php:191
#, php-format
msgid "%1$s: %2$s required, yours - %3$s"
msgstr ""
#: includes/import/class-jet-data-importer-interface.php:217
msgid "Some parameters from your server don't meet the requirements:"
msgstr ""
#: includes/import/class-jet-data-importer-interface.php:250
msgid "Import"
msgstr ""
#: includes/import/class-jet-data-importer-interface.php:332
msgid "Error! Import file not found. Please contact our support team."
msgstr ""
#: includes/import/class-jet-data-importer-interface.php:423
#: includes/import/class-jet-data-importer-interface.php:431
msgid "You don't have permissions to do this"
msgstr ""
#: includes/import/class-jet-data-importer-interface.php:459
#, php-format
msgid "%s is missing in request"
msgstr ""
#: includes/import/class-jet-data-importer-interface.php:518
msgid "Chunk number is missing in request"
msgstr ""
#: includes/import/class-jet-data-importer-interface.php:748
msgid "Upload XML file with demo content"
msgstr ""
#: includes/import/class-jet-data-importer-interface.php:752
msgid "We found 1 XML file with demo content in your theme, install it?"
msgstr ""
#: includes/import/class-jet-data-importer-interface.php:757
#, php-format
msgid ""
"We found %s XML files in your theme. Please select one of them to install"
msgstr ""
#: includes/import/class-jet-data-importer-interface.php:839
msgid "Upload File"
msgstr ""
#: includes/import/class-jet-data-importer-interface.php:895
msgid ""
"You don't have permissions to replace content, please re-enter with "
"admiistrator account"
msgstr ""
#: includes/import/class-jet-data-importer-interface.php:918
msgid "XML file not passed"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:673
msgid "Cannot import auto-draft posts"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1124
msgid "Sidebar does not exist in theme (using Inactive)"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1149
msgid "Site does not support widget"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1185
msgid "Widget already exists"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1246
msgid "Imported"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1249
msgid "Imported to Inactive"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1256
msgid "No Title"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1401
#, php-format
msgid "Failed to import \"%s\": Invalid post type %s"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1412
#, php-format
msgid "%s \"%s\" already exists."
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1492
#, php-format
msgid "Skipping attachment \"%s\", fetching attachments disabled"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1508
#, php-format
msgid "Failed to import \"%s\" (%s)"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1545
#: includes/import/class-jet-wxr-importer.php:1851
#, php-format
msgid "Imported \"%s\" (%s)"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1550
#, php-format
msgid "Post %d remapped to %d"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1687
#, php-format
msgid "Failed to import user \"%s\""
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1709
#, php-format
msgid "Imported user \"%s\""
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1714
#, php-format
msgid "User %d remapped to %d"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1815
#, php-format
msgid "Failed to import %s %s"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:1856
#, php-format
msgid "Term %d remapped to %d"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:2278
msgid "Invalid file type"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:2358
msgid "Zero size file downloaded"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:2367
#, php-format
msgid "Remote file is too large, limit is %s"
msgstr ""
#: includes/import/class-jet-wxr-importer.php:2536
msgid "Could not open the file for parsing"
msgstr ""
#: jet-data-importer.php:196 jet-data-importer.php:197
#: jet-data-importer.php:221
msgid "Demo Content "
msgstr ""
#: jet-data-importer.php:208
msgid "Settings"
msgstr ""
#: jet-data-importer.php:662
msgid "Select or upload file with demo content"
msgstr ""
#: jet-data-importer.php:663
msgid "Select"
msgstr ""
#: jet-data-importer.php:668
msgid "Data processing error, please try again!"
msgstr ""
#: templates/advanced-popup.php:8
msgid "Attention!"
msgstr ""
#: templates/advanced-popup.php:9 templates/wizard-after-install.php:26
msgid ""
"We are ready to install demo data. Do you want to append demo content to "
"your existing content or completely rewrite it?"
msgstr ""
#: templates/advanced-popup.php:15 templates/wizard-after-install.php:34
msgid "Append demo content to my existing content"
msgstr ""
#: templates/advanced-popup.php:22 templates/wizard-after-install.php:46
msgid "Replace my existing content with demo content"
msgstr ""
#: templates/advanced-popup.php:28
msgid "NOTE:"
msgstr ""
#: templates/advanced-popup.php:29
msgid ""
"This option will remove all your existing content - posts, pages, "
"attachments, terms and comments"
msgstr ""
#: templates/advanced-popup.php:33
msgid "Start Install"
msgstr ""
#: templates/import-advanced.php:40
msgid "Recommended Plugins:"
msgstr ""
#: templates/import-advanced.php:56
msgid "Optimize Demo Content"
msgstr ""
#: templates/import-advanced.php:58
msgid ""
"Please select this option to install light version of demo content. "
"Recommended for slow severs and shared web hosts"
msgstr ""
#: templates/import-advanced.php:63
msgid "Install Demo"
msgstr ""
#: templates/import-advanced.php:66
msgid "View Demo"
msgstr ""
#: templates/import-after.php:8
msgid "Dont know from where to start? Let us help you!"
msgstr ""
#: templates/import-after.php:20
msgid "See what you get"
msgstr ""
#: templates/import-before.php:23
msgid "or"
msgstr ""
#: templates/import-before.php:30
msgid "Start import"
msgstr ""
#: templates/import.php:23
msgid "Import Summary"
msgstr ""
#: templates/import.php:24
msgid "Completed"
msgstr ""
#: templates/import.php:25
msgid "Progress"
msgstr ""
#: templates/import.php:33
msgid "Posts"
msgstr ""
#: templates/import.php:34
msgid "Authors"
msgstr ""
#: templates/import.php:35
msgid "Comments"
msgstr ""
#: templates/import.php:36
msgid "Media"
msgstr ""
#: templates/import.php:37
msgid "Terms"
msgstr ""
#: templates/import.php:38
msgid "Tables"
msgstr ""
#: templates/page-settings.php:8
msgid "Cache handler:"
msgstr ""
#: templates/page-settings.php:20
msgid "Save"
msgstr ""
#: templates/regenerate.php:9
msgid "Starting process, please wait few seconds..."
msgstr ""
#: templates/remove-content-form.php:9
msgid ""
"Please, enter your WordPress user password to confirm and start content "
"replacing."
msgstr ""
#: templates/remove-content-form.php:12
msgid ""
"NOTE: All your content will be replaced (posts, pages, comments, attachments "
"and terms)"
msgstr ""
#: templates/remove-content-form.php:16
msgid "Please, enter your password"
msgstr ""
#: templates/remove-content-form.php:18
msgid "Import Content"
msgstr ""
#: templates/wizard-after-install.php:24
msgid "We're almost there!"
msgstr ""
#: templates/wizard-after-install.php:37
msgid ""
"If you have chosen this option, the sample data will be added to the current "
"content of your theme."
msgstr ""
#: templates/wizard-after-install.php:49
msgid ""
"NB! If you want to install theme demo content, you agree that your current "
"data will be replaced by the new demo content (sample data). If you want to "
"save the current content of your theme, please choose Skip Data Installation."
msgstr ""
#: templates/wizard-after-install.php:60
msgid "Skip demo content installation"
msgstr ""
#: templates/wizard-after-install.php:63
msgid ""
"If you have chosen this option, the sample data will not be installed on "
"your theme and your current content will stay as it is."
msgstr ""
#: templates/wizard-after-install.php:76
msgid "Next"
msgstr ""

View File

@@ -0,0 +1,38 @@
<?php
/**
* Template part for displaying advanced popup
*/
?>
<div class="cdi-advanced-popup popup-hidden">
<div class="cdi-advanced-popup__content">
<h3><?php esc_html_e( 'Attention!', 'jet-data-importer' ); ?></h3>
<?php esc_html_e( 'We are ready to install demo data. Do you want to append demo content to your existing content or completely rewrite it?', 'jet-data-importer' ); ?>
<div class="cdi-advanced-popup__select">
<label class="cdi-advanced-popup__item">
<input type="radio" name="install-type" value="append" checked>
<span class="cdi-advanced-popup__item-mask"></span>
<span class="cdi-advanced-popup__item-label"><?php
esc_html_e( 'Append demo content to my existing content', 'jet-data-importer' );
?></span>
</label>
<label class="cdi-advanced-popup__item">
<input type="radio" name="install-type" value="replace">
<span class="cdi-advanced-popup__item-mask"></span>
<span class="cdi-advanced-popup__item-label"><?php
esc_html_e( 'Replace my existing content with demo content', 'jet-data-importer' );
?></span>
</label>
</div>
<div class="cdi-advanced-popup__warning cdi-hide">
<b><?php esc_html_e( 'NOTE:', 'jet-data-importer' ); ?></b>
<?php esc_html_e( 'This option will remove all your existing content - posts, pages, attachments, terms and comments', 'jet-data-importer' ); ?>
</div>
<div class="cdi-advanced-popup__action">
<button class="cdi-btn primary" data-action="confirm-install"><span class="text"><?php
esc_html_e( 'Start Install', 'jet-data-importer' );
?></span><span class="cdi-loader-wrapper-alt"><span class="cdi-loader-alt"></span></span></button>
</div>
<button class="cdi-advanced-popup__close"><span class="dashicons dashicons-no"></span></button>
</div>
</div>

View File

@@ -0,0 +1,11 @@
<?php wp_enqueue_script( 'jet-data-export' ); ?>
<div class="cdi-wrap">
<div class="cdi-message"><?php
echo jdi()->get_setting( array( 'export', 'message' ) );
?></div>
<a href="<?php echo jdi_export_interface()->get_export_url(); ?>" class="cdi-btn primary" id="jet-export">
<span class="dashicons dashicons-upload"></span>
<?php _e( 'Export', 'jet-data-importer' ); ?>
</a>
<div class="cdi-loader cdi-hidden"></div>
</div>

View File

@@ -0,0 +1,70 @@
<?php
/**
* Advanced import template
*/
$item = ! empty( jdi_interface()->data['advanced-item'] ) ? jdi_interface()->data['advanced-item'] : false;
$skin = ! empty( jdi_interface()->data['advanced-slug'] ) ? jdi_interface()->data['advanced-slug'] : false;
if ( ! $item || ! $skin ) {
return;
}
$thumb = ! empty( $item['thumb'] ) ? esc_url( $item['thumb'] ) : false;
$label = ! empty( $item['label'] ) ? $item['label'] : false;
$demo_url = ! empty( $item['demo_url'] ) ? esc_url( $item['demo_url'] ) : false;
$plugins = ! empty( $item['plugins'] ) ? $item['plugins'] : false;
$xml_full = ! empty( $item['full'] ) ? $item['full'] : false;
$xml_min = ! empty( $item['lite'] ) ? $item['lite'] : false;
$full_path = jdi_tools()->secure_path( $xml_full );
$min_path = jdi_tools()->secure_path( $xml_min );
$allow_types = jdi()->get_setting( array( 'import', 'allow_types' ) );
?>
<div class="advanced-item"
data-full="<?php echo $full_path; ?>"
data-lite="<?php echo $min_path; ?>"
data-skin="<?php echo $skin; ?>"
>
<div class="advanced-item__thumb">
<?php
if ( $thumb ) {
printf( '<a href="%3$s"><img src="%1$s" alt="%2$s"></a>', $thumb, $label, $demo_url );
}
?>
</div>
<div class="advanced-item__content">
<h3 class="advanced-item__title"><?php echo $label; ?></h3>
<?php if ( ! empty( $plugins ) ) : ?>
<div class="advanced-item__recommended-plugins"><?php
esc_html_e( 'Recommended Plugins:', 'jet-data-importer' );
?></div>
<div class="advanced-item__plugins-list"><?php
foreach ( $plugins as $slug => $name ) {
$plugin = sprintf( '%1$s/%1$s.php', $slug );
printf(
'<span class="advanced-item__plugin %2$s">%1$s</span>',
$name,
is_plugin_active( $plugin ) ? 'is-active' : 'is-inactive'
);
}
?></div>
<?php endif; ?>
<?php if ( $allow_types ) : ?>
<div class="advanced-item__install-type">
<label class="advanced-item__type-checkbox">
<input type="checkbox"><?php esc_html_e( 'Optimize Demo Content', 'jet-data-importer' ); ?>
</label>
<?php esc_html_e( 'Please select this option to install light version of demo content. Recommended for slow severs and shared web hosts', 'jet-data-importer' ); ?>
</div>
<?php endif; ?>
<div class="advanced-item__install">
<button class="cdi-btn primary" data-action="start-install"><span class="text"><?php
esc_html_e( 'Install Demo', 'jet-data-importer' );
?></span><span class="cdi-loader-wrapper-alt"><span class="cdi-loader-alt"></span></span></button>
<a href="<?php echo $demo_url; ?>" target="_blank" class="cdi-btn"><?php
esc_html_e( 'View Demo', 'jet-data-importer' );
?></a>
</div>
</div>
</div>

View File

@@ -0,0 +1,42 @@
<?php
/**
* Starter import template
*/
?>
<div>
<div class="cdi-success-mesage"><?php
_e( 'Dont know from where to start? Let us help you!', 'jet-data-importer' );
?></div>
<div class="cdi-success-links"><?php
$buttons = jdi()->get_setting( array( 'success-links' ) );
$buttons = apply_filters( 'jet-data-importer/success-buttons', $buttons );
$format = '<a href="%4$s" class="cdi-btn %2$s" target="%3$s">%1$s</a>';
$defaults = array(
'label' => __( 'View your site', 'jet-data-importer' ),
'type' => 'primary',
'target' => '_self',
'icon' => 'dashicons-admin-home',
'desc' => __( 'See what you get', 'jet-data-importer' ),
'url' => home_url( '/' ),
);
if ( ! empty( $buttons ) ) {
echo '<div class="cdi-after-actions">';
foreach ( $buttons as $button ) {
$button = wp_parse_args( $button, $defaults );
?>
<div class="cdi-after-actions__row">
<div class="cdi-after-actions__desc">
<span class="dashicons <?php echo $button['icon']; ?>"></span>
<span><?php echo $button['desc']; ?></span>
</div>
<?php printf( $format, $button['label'], $button['type'], $button['target'], $button['url'] ); ?>
</div>
<?php
}
echo '</div>';
}
?></div>
</div>

View File

@@ -0,0 +1,33 @@
<?php
/**
* Starter import template
*/
?>
<div>
<?php
/**
* Hook before importer messages output.
*
* @hooked Jet_Data_Importer_Interface::check_server_params - 10;
*/
do_action( 'cherry-data-importer/before-messages' );
?>
<?php echo jdi_interface()->get_welcome_message(); ?>
<?php if ( jdi_interface()->is_advanced_import() ) : ?>
<?php jdi_interface()->advanced_import(); ?>
<?php else : ?>
<div class="cdi-actions">
<?php echo jdi_interface()->get_import_files_select( '<div class="cdi-file-select">', '</div>' ); ?>
<?php if ( 1 <= jdi_interface()->get_xml_count() && jdi()->get_setting( array( 'xml', 'use_upload' ) ) ) {
echo '<span class="cdi-delimiter">' . __( 'or', 'jet-data-importer' ) . '</span>';
} ?>
<?php echo jdi_interface()->get_import_file_input( '<div class="cdi-file-upload">', '</div>' ); ?>
</div>
<input type="hidden" name="referrer" value="<?php echo jdi_tools()->get_page_url(); ?>">
<button id="jet-import-start" class="cdi-btn primary">
<span class="dashicons dashicons-download"></span>
<?php esc_html_e( 'Start import', 'jet-data-importer' ); ?>
</button>
<?php endif; ?>
</div>

View File

@@ -0,0 +1,72 @@
<?php
/**
* Main import template
*/
?>
<div class="cdi-content">
<?php jdi_slider()->slider_assets(); ?>
<?php jdi_interface()->remove_content_form(); ?>
<?php
if ( isset( $_GET['type'] ) && 'append' === $_GET['type'] ) {
jdi_slider()->render();
}
?>
<div id="jet-import-progress" class="cdi-progress">
<span class="cdi-progress__bar">
<span class="cdi-progress__label"><span></span></span>
</span>
<span class="cdi-progress__sub-label"></span>
</div>
<table class="cdi-install-summary">
<thead>
<tr>
<th><?php esc_html_e( 'Import Summary', 'jet-data-importer' ); ?></th>
<th class="completed-cell"><?php esc_html_e( 'Completed', 'jet-data-importer' ); ?></th>
<th colspan="3"><?php esc_html_e( 'Progress', 'jet-data-importer' ); ?></th>
</tr>
</theead>
<tbody>
<?php
$summary = jdi_cache()->get( 'import_summary' );
$labels = array(
'posts' => esc_html__( 'Posts', 'jet-data-importer' ),
'authors' => esc_html__( 'Authors', 'jet-data-importer' ),
'comments' => esc_html__( 'Comments', 'jet-data-importer' ),
'media' => esc_html__( 'Media', 'jet-data-importer' ),
'terms' => esc_html__( 'Terms', 'jet-data-importer' ),
'tables' => esc_html__( 'Tables', 'jet-data-importer' ),
);
foreach ( $summary as $type => $total ) {
if ( 0 === $total ) {
continue;
}
?>
<tr data-item="<?php echo $type; ?>" data-total="<?php echo $total; ?>">
<td><?php echo $labels[ $type ]; ?></td>
<td class="completed-cell">
<span class="cdi-install-summary__done">0</span>
/
<span class="cdi-install-summary__total"><?php echo $total; ?></span>
</td>
<td class="cdi-complete-val">
<span class="cdi-install-summary__percent">0</span>%
</td>
<td class="cdi-complete-progress">
<div class="cdi-progress progress-tiny"><span class="cdi-progress__bar"><span></span></span></div>
</td>
<td class="cdi-complete-status">
<div class="cdi-progress-status"></div>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.

View File

@@ -0,0 +1,7 @@
<?php
/**
* Page footer template
*/
?>
</div>
</div>

View File

@@ -0,0 +1,10 @@
<?php
/**
* Page heading template
*/
$ref_class = isset( $_GET['referrer'] ) ? 'ref-' . sanitize_html_class( $_GET['referrer'], 'default' ) : 'default';
?>
<div class="wrap">
<div class="cdi-kit <?php echo $ref_class; ?>">

View File

@@ -0,0 +1,22 @@
<?php
$cache_handler = get_option( 'jdi_cache_handler', 'session' );
?>
<div class="cdi-wrap">
<form method="post">
<label><?php _e( 'Cache handler:', 'jet-data-importer' ); ?></label><br>
<select name="jdi_cache_handler" style="min-height: 34px; margin: 5px 0 0 0; width: 300px;"><?php
foreach ( array( 'session', 'file' ) as $val ) {
printf(
'<option value="%1$s" %2$s>%3$s</option>',
$val,
selected( $cache_handler, $val, false ),
ucfirst( $val )
);
}
?></select>
<br><br>
<button type="submit" class="cdi-btn primary"><?php _e( 'Save', 'jet-data-importer' ); ?></button>
</form>
</div>

View File

@@ -0,0 +1,13 @@
<?php
/**
* Regenerate thumbnails template
*/
?>
<div class="cdi-content">
<div id="jet-import-progress" class="cdi-progress">
<span class="cdi-progress__placeholder"><?php
esc_html_e( 'Starting process, please wait few seconds...', 'jet-data-importer' );
?></span>
<span class="cdi-progress__bar"><span class="cdi-progress__label"><span></span></span></span>
</div>
</div>

View File

@@ -0,0 +1,23 @@
<?php
/**
* Remove content form template
*/
?>
<div class="cdi-remove-form">
<div class="cdi-remove-form__message">
<?php
esc_html_e( 'Please, enter your WordPress user password to confirm and start content replacing.', 'jet-data-importer' );
?>
<span class="cdi-remove-form__note"><?php
esc_html_e( 'NOTE: All your content will be replaced (posts, pages, comments, attachments and terms)', 'jet-data-importer' );
?></span>
</div>
<div class="cdi-remove-form__controls">
<input type="password" class="cdi-remove-form__input" placeholder="<?php esc_html_e( 'Please, enter your password', 'jet-data-importer' ); ?>">
<button class="cdi-btn primary" data-action="remove-content"><span class="text"><?php
esc_html_e( 'Import Content', 'jet-data-importer' );
?></span><span class="cdi-loader-wrapper-alt"><span class="cdi-loader-alt"></span></span></button>
</div>
<div class="cdi-remove-form__notices cdi-hide">
</div>
</div>

View File

@@ -0,0 +1,78 @@
<?php
/**
* Template part for displaying advanced popup
*/
if ( function_exists( 'jet_plugins_wizard_interface' ) ) {
$skin = jet_plugins_wizard_interface()->get_skin_data( 'slug' );
$referrer = 'jet-plugins-wizard';
} elseif ( function_exists( 'tm_wizard_interface' ) ) {
$skin = tm_wizard_interface()->get_skin_data( 'slug' );
$referrer = 'tm-wizard';
} elseif ( function_exists( 'cherry_plugin_wizard_interface' ) ) {
$skin = cherry_plugin_wizard_interface()->get_skin_data( 'slug' );
$referrer = 'cherry-plugin-wizard';
}
$type = ! empty( $_GET['type'] ) ? esc_attr( $_GET['type'] ) : 'lite';
$file = jdi()->get_setting( array( 'advanced_import', $skin, $type ) );
$file = jdi_tools()->secure_path( $file );
?>
<h2><?php esc_html_e( 'We\'re almost there!', 'jet-data-importer' ); ?></h2>
<?php esc_html_e( 'We are ready to install demo data. Do you want to append demo content to your existing content or completely rewrite it?', 'jet-data-importer' ); ?>
<form method="get" action="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>">
<div class="tm-wizard-type__select">
<label class="tm-wizard-type__item">
<input type="radio" name="type" value="append" checked>
<span class="tm-wizard-type__item-mask"></span>
<span class="tm-wizard-type__item-label">
<span class="tm-wizard-type__item-label-title"><?php
esc_html_e( 'Append demo content to my existing content', 'jet-data-importer' );
?></span>
<span class="tm-wizard-type__item-label-desc"><?php
esc_html_e( 'If you have chosen this option, the sample data will be added to the current content of your theme.', 'jet-data-importer' );
?></span>
</span>
</label>
<label class="tm-wizard-type__item">
<input type="radio" name="type" value="replace">
<span class="tm-wizard-type__item-mask"></span>
<span class="tm-wizard-type__item-label">
<span class="tm-wizard-type__item-label-title"><?php
esc_html_e( 'Replace my existing content with demo content', 'jet-data-importer' );
?></span>
<span class="tm-wizard-type__item-label-desc"><?php
esc_html_e( 'NB! If you want to install theme demo content, you agree that your current data will be replaced by the new demo content (sample data). If you want to save the current content of your theme, please choose Skip Data Installation.', 'jet-data-importer' );
?></span>
</span>
</span>
</label>
<label class="tm-wizard-type__item">
<input type="radio" name="type" value="skip">
<span class="tm-wizard-type__item-mask"></span>
<span class="tm-wizard-type__item-label">
<span class="tm-wizard-type__item-label-title"><?php
esc_html_e( 'Skip demo content installation', 'jet-data-importer' );
?></span>
<span class="tm-wizard-type__item-label-desc"><?php
esc_html_e( 'If you have chosen this option, the sample data will not be installed on your theme and your current content will stay as it is.', 'jet-data-importer' );
?></span>
</span>
</label>
</div>
<input type="hidden" name="tab" value="import">
<input type="hidden" name="step" value="2">
<input type="hidden" name="file" value="<?php echo $file; ?>">
<input type="hidden" name="page" value="<?php echo jdi()->slug; ?>">
<input type="hidden" name="referrer" value="<?php echo $referrer; ?>">
<input type="hidden" name="skin" value="<?php echo $skin; ?>">
<input type="hidden" name="xml_type" value="<?php echo $type; ?>">
<button class="btn btn-primary" data-wizard="confirm-install" data-loader="true" data-href=""><span class="text"><?php
esc_html_e( 'Next', 'jet-data-importer' );
?></span><span class="tm-wizard-loader"><span class="tm-wizard-loader__spinner"></span></span></button>
</form>