| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elementor importer |
| 4 |
* |
| 5 |
* @package CARTFLOWS |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Elementor\TemplateLibrary; |
| 9 |
|
| 10 |
use Elementor\Core\Base\Document; |
| 11 |
use Elementor\DB; |
| 12 |
use Elementor\Core\Settings\Page\Manager as PageSettingsManager; |
| 13 |
use Elementor\Core\Settings\Manager as SettingsManager; |
| 14 |
use Elementor\Core\Settings\Page\Model; |
| 15 |
use Elementor\Editor; |
| 16 |
use Elementor\Plugin; |
| 17 |
use Elementor\Settings; |
| 18 |
use Elementor\Utils; |
| 19 |
|
| 20 |
if ( ! defined( 'ABSPATH' ) ) { |
| 21 |
exit; // Exit if accessed directly. |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Elementor template library local source. |
| 26 |
* |
| 27 |
* Elementor template library local source handler class is responsible for |
| 28 |
* handling local Elementor templates saved by the user locally on his site. |
| 29 |
* |
| 30 |
* @since 1.0.0 |
| 31 |
*/ |
| 32 |
class CartFlows_Importer_Elementor extends Source_Local { |
| 33 |
|
| 34 |
/** |
| 35 |
* Import single template |
| 36 |
* |
| 37 |
* @param int $post_id post ID. |
| 38 |
*/ |
| 39 |
public function import_single_template( $post_id ) { |
| 40 |
|
| 41 |
$rest_content = get_post_meta( $post_id, '_elementor_data', true ); |
| 42 |
|
| 43 |
if ( empty( $rest_content ) ) { |
| 44 |
$data = __( 'Invalid content.', 'cartflows' ); |
| 45 |
wcf()->logger->import_log( '(✕) ' . $data ); |
| 46 |
} |
| 47 |
|
| 48 |
$rest_content = add_magic_quotes( $rest_content ); |
| 49 |
$content = json_decode( $rest_content, true ); |
| 50 |
|
| 51 |
if ( ! is_array( $content ) ) { |
| 52 |
$data = __( 'Invalid content. Expected an array.', 'cartflows' ); |
| 53 |
wcf()->logger->import_log( '(✕) ' . $data ); |
| 54 |
wcf()->logger->import_log( $content ); |
| 55 |
} else { |
| 56 |
|
| 57 |
wcf()->logger->import_log( '(✓) Processing Request..' ); |
| 58 |
wcf()->logger->import_log( '(✓) Data ' . json_encode( $content ) ); |
| 59 |
|
| 60 |
// Import the data. |
| 61 |
$content = $this->process_export_import_content( $content, 'on_import' ); |
| 62 |
|
| 63 |
// Update content. |
| 64 |
update_metadata( 'post', $post_id, '_elementor_data', $content ); |
| 65 |
|
| 66 |
wcf()->logger->import_log( '(✓) Process Complete' ); |
| 67 |
} |
| 68 |
|
| 69 |
} |
| 70 |
} |
| 71 |
|