| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elementor source |
| 4 |
* |
| 5 |
* @package WPFunnels\Batch\Elementor |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace WPFunnels\Batch\Elementor; |
| 9 |
|
| 10 |
use Elementor\TemplateLibrary\Source_Local; |
| 11 |
|
| 12 |
/** |
| 13 |
* Elementor source |
| 14 |
* |
| 15 |
* @since 1.0.0 |
| 16 |
*/ |
| 17 |
class Wpfnl_Elementor_Source extends Source_Local { |
| 18 |
|
| 19 |
|
| 20 |
/** |
| 21 |
* Import single template |
| 22 |
* |
| 23 |
* @param string|int $step_id Funnel step id. |
| 24 |
* |
| 25 |
* @return array|int|void|\WP_Error |
| 26 |
* |
| 27 |
* @since 1.0.0 |
| 28 |
*/ |
| 29 |
public function import_single_template( $step_id ) { |
| 30 |
$_elementor_data = get_post_meta( $step_id, '_elementor_data', true ); |
| 31 |
$content = ''; |
| 32 |
if ( $_elementor_data ) { |
| 33 |
if ( is_array( $_elementor_data ) ) { |
| 34 |
$content = $_elementor_data; |
| 35 |
} else { |
| 36 |
$_elementor_data = add_magic_quotes( json_decode( $_elementor_data, true ) ); |
| 37 |
$content = $_elementor_data; |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
if ( is_array( $content ) ) { |
| 42 |
$content = $this->process_export_import_content( $content, 'on_import' ); |
| 43 |
update_metadata( 'post', $step_id, '_elementor_data', $content ); |
| 44 |
$this->clear_cache(); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Clear cache |
| 50 |
*/ |
| 51 |
public function clear_cache() { |
| 52 |
// Clear 'Elementor' file cache. |
| 53 |
if ( class_exists( '\Elementor\Plugin' ) ) { |
| 54 |
\Elementor\Plugin::$instance->files_manager->clear_cache(); |
| 55 |
} |
| 56 |
} |
| 57 |
} |
| 58 |
|