class-advanced-import-admin.php
5 years ago
class-elementor-import.php
5 years ago
class-reset.php
5 years ago
index.php
5 years ago
class-elementor-import.php
116 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | exit; |
| 4 | } |
| 5 | |
| 6 | /** |
| 7 | * The elementor import functionality of the plugin. |
| 8 | * |
| 9 | * @package Advanced_Import |
| 10 | * @subpackage Advanced_Import/admin/Advanced_Import_Elementor |
| 11 | * @author Addons Press <addonspress.com> |
| 12 | */ |
| 13 | if ( ! class_exists( 'Advanced_Import_Elementor' ) ) { |
| 14 | /** |
| 15 | * Advanced_Import_Elementor |
| 16 | */ |
| 17 | class Advanced_Import_Elementor { |
| 18 | /** |
| 19 | * Main Advanced_Import_Elementor Instance |
| 20 | * Initialize the class and set its properties. |
| 21 | * |
| 22 | * @since 1.0.0 |
| 23 | * @return object $instance Advanced_Import_Elementor Instance |
| 24 | */ |
| 25 | public static function instance() { |
| 26 | |
| 27 | // Store the instance locally to avoid private static replication. |
| 28 | static $instance = null; |
| 29 | |
| 30 | // Only run these methods if they haven't been ran previously. |
| 31 | if ( null === $instance ) { |
| 32 | $instance = new self(); |
| 33 | } |
| 34 | |
| 35 | // Always return the instance. |
| 36 | return $instance; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Change post id related to elementor to new id |
| 41 | * |
| 42 | * @param array $item current array of demo list. |
| 43 | * @param string $key |
| 44 | * @return void |
| 45 | */ |
| 46 | public function elementor_id_import( &$item, $key ) { |
| 47 | if ( $key == 'id' && ! empty( $item ) && is_numeric( $item ) ) { |
| 48 | // check if this has been imported before |
| 49 | $new_meta_val = advanced_import_admin()->imported_post_id( $item ); |
| 50 | if ( $new_meta_val ) { |
| 51 | $item = $new_meta_val; |
| 52 | } |
| 53 | } |
| 54 | if ( $key == 'page' && ! empty( $item ) ) { |
| 55 | |
| 56 | if ( false !== strpos( $item, 'p.' ) ) { |
| 57 | $new_id = str_replace( 'p.', '', $item ); |
| 58 | // check if this has been imported before |
| 59 | $new_meta_val = advanced_import_admin()->imported_post_id( $new_id ); |
| 60 | if ( $new_meta_val ) { |
| 61 | $item = 'p.' . $new_meta_val; |
| 62 | } |
| 63 | } elseif ( is_numeric( $item ) ) { |
| 64 | // check if this has been imported before |
| 65 | $new_meta_val = advanced_import_admin()->imported_post_id( $item ); |
| 66 | if ( $new_meta_val ) { |
| 67 | $item = $new_meta_val; |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | if ( $key == 'post_id' && ! empty( $item ) && is_numeric( $item ) ) { |
| 72 | // check if this has been imported before |
| 73 | $new_meta_val = advanced_import_admin()->imported_post_id( $item ); |
| 74 | if ( $new_meta_val ) { |
| 75 | $item = $new_meta_val; |
| 76 | } |
| 77 | } |
| 78 | if ( $key == 'url' && ! empty( $item ) && strstr( $item, 'ocalhost' ) ) { |
| 79 | // check if this has been imported before |
| 80 | $new_meta_val = advanced_import_admin()->imported_post_id( $item ); |
| 81 | if ( $new_meta_val ) { |
| 82 | $item = $new_meta_val; |
| 83 | } |
| 84 | } |
| 85 | if ( ( $key == 'shortcode' || $key == 'editor' ) && ! empty( $item ) ) { |
| 86 | // we have to fix the [contact-form-7 id=133] shortcode issue. |
| 87 | $item = advanced_import_admin()->parse_shortcode_meta_content( $item ); |
| 88 | |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | public function elementor_post( $post_id = false ) { |
| 93 | |
| 94 | // regenerate the CSS for this Elementor post |
| 95 | if ( class_exists( 'Elementor\Core\Files\CSS\Post' ) ) { |
| 96 | $post_css = new Elementor\Core\Files\CSS\Post( $post_id ); |
| 97 | $post_css->update(); |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | |
| 104 | /** |
| 105 | * Begins execution of the plugin. |
| 106 | * |
| 107 | * Since everything within the plugin is registered via hooks, |
| 108 | * then kicking off the plugin from this point in the file does |
| 109 | * not affect the page life cycle. |
| 110 | * |
| 111 | * @since 1.0.0 |
| 112 | */ |
| 113 | function advanced_import_elementor() { |
| 114 | return Advanced_Import_Elementor::instance(); |
| 115 | } |
| 116 |