Advanced Import : One Click Import for WordPress or Theme Demo Data - Version 1.3.6

Version Description

  • 2022-04-27 =
  • Updated : Reset plugin via ajax
  • Updated : Elementor imports in some cases
Download this release

Release Info

Developer addonspress
Plugin Icon 128x128 Advanced Import : One Click Import for WordPress or Theme Demo Data
Version 1.3.6
Comparing to
See all releases

Code changes from version 1.3.5 to 1.3.6

admin/class-advanced-import-admin.php CHANGED
@@ -336,6 +336,7 @@ class Advanced_Import_Admin {
336
  'text' => __( "You won't be able to revert this!", 'advanced-import' ),
337
  'confirmButtonText' => esc_html__( 'Yes, Reset', 'advanced-import' ),
338
  'cancelButtonText' => esc_html__( 'Cancel', 'advanced-import' ),
 
339
  ),
340
  'resetSuccess' => array(
341
  'title' => esc_html__( 'Reset Successful', 'advanced-import' ),
@@ -933,10 +934,8 @@ class Advanced_Import_Admin {
933
 
934
  check_admin_referer( 'advanced-import' );
935
 
936
- /*for safety.*/
937
- delete_transient( 'content.json' );
938
- delete_transient( 'widgets.json' );
939
- delete_transient( 'options.json' );
940
 
941
  do_action( 'advanced_import_before_plugin_screen' );
942
  ?>
@@ -1719,7 +1718,7 @@ class Advanced_Import_Admin {
1719
  }
1720
  }
1721
 
1722
- array_walk_recursive( $post_data['meta'], array( advanced_import_elementor(), 'elementor_id_import' ) );
1723
 
1724
  /*todo gutenberg and page builders*/
1725
 
@@ -1834,6 +1833,8 @@ class Advanced_Import_Admin {
1834
  if ( $inserted_id ) {
1835
  $meta_val = $inserted_id;
1836
  }
 
 
1837
  }
1838
  /*update meta*/
1839
  update_post_meta( $post_id, $meta_key, $meta_val );
@@ -1866,16 +1867,25 @@ class Advanced_Import_Admin {
1866
 
1867
  /*add the term meta.*/
1868
  if ( $term_id && ! empty( $term['meta'] ) && is_array( $term['meta'] ) ) {
 
 
 
 
 
 
 
 
 
1869
  foreach ( $term['meta'] as $meta_key => $meta_val ) {
1870
  // we have to replace certain meta_key/meta_val
1871
  // e.g. thumbnail id from woocommerce product categories.
1872
- switch ( $meta_key ) {
1873
- case 'thumbnail_id':
1874
- if ( $new_meta_val = $this->imported_post_id( $meta_val ) ) {
1875
- /*use this new id.*/
1876
- $meta_val = $new_meta_val;
1877
- }
1878
- break;
1879
  }
1880
  update_term_meta( $term_id, $meta_key, $meta_val );
1881
  }
@@ -2323,6 +2333,9 @@ class Advanced_Import_Admin {
2323
  /*final wrap up of delayed posts.*/
2324
  $this->process_delayed_posts( true );
2325
 
 
 
 
2326
  /*it includes options and menu data*/
2327
  $theme_options = $this->get_theme_options_json();
2328
 
@@ -2398,6 +2411,17 @@ class Advanced_Import_Admin {
2398
  $this->logs[] = esc_html__( 'ERROR!!!! ', 'advanced-import' ) . $message;
2399
  }
2400
 
 
 
 
 
 
 
 
 
 
 
 
2401
  /*
2402
  Callback function to completed
2403
  * Show Completed Message
@@ -2419,10 +2443,9 @@ class Advanced_Import_Admin {
2419
  $wp_filesystem->rmdir( ADVANCED_IMPORT_TEMP, true );
2420
 
2421
  set_theme_mod( 'advanced_import_setup_complete', time() );
 
2422
  /*delete_transient();*/
2423
- delete_transient( 'content.json' );
2424
- delete_transient( 'widgets.json' );
2425
- delete_transient( 'options.json' );
2426
 
2427
  $message = '<div class="ai-notification-title">';
2428
  $message .= '<p>' . esc_html__( 'Your Website is Ready!', 'advanced-import' ) . '</p>';
@@ -2605,7 +2628,7 @@ class Advanced_Import_Admin {
2605
  'content' =>
2606
  '<h2>' . __( '<strong>WordPress Reset</strong>', 'advanced-import' ) . '</h2>' .
2607
  '<p>' . __( 'If no important data on your site. You can reset the WordPress back to default again!', 'advanced-import' ) . '</p>' .
2608
- '<p class="submit"><a href="' . esc_url( $reset_url ) . '" class="button button-primary ai-wp-reset">' . __( 'Run the Reset Wizard', 'advanced-import' ) . '</a></p>',
2609
  )
2610
  );
2611
 
@@ -2614,6 +2637,23 @@ class Advanced_Import_Admin {
2614
  '<p><a href="' . 'https://wordpress.org/plugins/advanced-export/' . '" target="_blank">' . __( 'Advanced Export', 'advanced-import' ) . '</a></p>' .
2615
  '<p><a href="' . 'https://wordpress.org/plugins/advanced-import/' . '" target="_blank">' . __( 'Advanced Import', 'advanced-import' ) . '</a></p>'
2616
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2617
  }
2618
  }
2619
 
336
  'text' => __( "You won't be able to revert this!", 'advanced-import' ),
337
  'confirmButtonText' => esc_html__( 'Yes, Reset', 'advanced-import' ),
338
  'cancelButtonText' => esc_html__( 'Cancel', 'advanced-import' ),
339
+ 'resetting' => esc_html__( 'Resetting! Starting WordPress in Default Mode.', 'advanced-import' ),
340
  ),
341
  'resetSuccess' => array(
342
  'title' => esc_html__( 'Reset Successful', 'advanced-import' ),
934
 
935
  check_admin_referer( 'advanced-import' );
936
 
937
+ /*for safety: delete_transient();*/
938
+ $this->reset_transient();
 
 
939
 
940
  do_action( 'advanced_import_before_plugin_screen' );
941
  ?>
1718
  }
1719
  }
1720
 
1721
+ // array_walk_recursive( $post_data['meta'], array( advanced_import_elementor(), 'elementor_id_import' ) );
1722
 
1723
  /*todo gutenberg and page builders*/
1724
 
1833
  if ( $inserted_id ) {
1834
  $meta_val = $inserted_id;
1835
  }
1836
+ } elseif ( '_elementor_data' == $meta_key ) {
1837
+ advanced_import_elementor()->elementor_data_posts( $post_id, $meta_val );
1838
  }
1839
  /*update meta*/
1840
  update_post_meta( $post_id, $meta_key, $meta_val );
1867
 
1868
  /*add the term meta.*/
1869
  if ( $term_id && ! empty( $term['meta'] ) && is_array( $term['meta'] ) ) {
1870
+
1871
+ $replace_post_ids = apply_filters(
1872
+ 'advanced_import_replace_post_ids',
1873
+ array(
1874
+ 'image_id',
1875
+ 'thumbnail_id',
1876
+ 'author_picture',
1877
+ )
1878
+ );
1879
  foreach ( $term['meta'] as $meta_key => $meta_val ) {
1880
  // we have to replace certain meta_key/meta_val
1881
  // e.g. thumbnail id from woocommerce product categories.
1882
+
1883
+ if ( in_array( $meta_key, $replace_post_ids ) ) {
1884
+
1885
+ if ( $new_meta_val = $this->imported_post_id( $meta_val ) ) {
1886
+ /*use this new id.*/
1887
+ $meta_val = $new_meta_val;
1888
+ }
1889
  }
1890
  update_term_meta( $term_id, $meta_key, $meta_val );
1891
  }
2333
  /*final wrap up of delayed posts.*/
2334
  $this->process_delayed_posts( true );
2335
 
2336
+ /*Elementor posts*/
2337
+ advanced_import_elementor()->process_elementor_posts();
2338
+
2339
  /*it includes options and menu data*/
2340
  $theme_options = $this->get_theme_options_json();
2341
 
2411
  $this->logs[] = esc_html__( 'ERROR!!!! ', 'advanced-import' ) . $message;
2412
  }
2413
 
2414
+ public function reset_transient() {
2415
+ delete_transient( 'content.json' );
2416
+ delete_transient( 'widgets.json' );
2417
+ delete_transient( 'options.json' );
2418
+ delete_transient( 'delayed_posts' );
2419
+ delete_transient( 'imported_term_ids' );
2420
+ delete_transient( 'imported_post_ids' );
2421
+ delete_transient( 'post_orphans' );
2422
+ delete_transient( 'adi_elementor_data_posts' );
2423
+ }
2424
+
2425
  /*
2426
  Callback function to completed
2427
  * Show Completed Message
2443
  $wp_filesystem->rmdir( ADVANCED_IMPORT_TEMP, true );
2444
 
2445
  set_theme_mod( 'advanced_import_setup_complete', time() );
2446
+
2447
  /*delete_transient();*/
2448
+ $this->reset_transient();
 
 
2449
 
2450
  $message = '<div class="ai-notification-title">';
2451
  $message .= '<p>' . esc_html__( 'Your Website is Ready!', 'advanced-import' ) . '</p>';
2628
  'content' =>
2629
  '<h2>' . __( '<strong>WordPress Reset</strong>', 'advanced-import' ) . '</h2>' .
2630
  '<p>' . __( 'If no important data on your site. You can reset the WordPress back to default again!', 'advanced-import' ) . '</p>' .
2631
+ '<p class="submit">' . wp_nonce_field( 'advanced-import-reset', 'advanced-import-reset', true, false ) . '<a href="' . esc_url( $reset_url ) . '" class="button button-primary ai-wp-reset">' . __( 'Run the Reset Wizard', 'advanced-import' ) . '</a></p>',
2632
  )
2633
  );
2634
 
2637
  '<p><a href="' . 'https://wordpress.org/plugins/advanced-export/' . '" target="_blank">' . __( 'Advanced Export', 'advanced-import' ) . '</a></p>' .
2638
  '<p><a href="' . 'https://wordpress.org/plugins/advanced-import/' . '" target="_blank">' . __( 'Advanced Import', 'advanced-import' ) . '</a></p>'
2639
  );
2640
+
2641
+ global $advanced_import_tracking;
2642
+ ob_start();
2643
+ $advanced_import_tracking->admin_notice( true );
2644
+ $has_admin_notice = ob_get_contents();
2645
+ ob_end_clean();
2646
+ if ( $has_admin_notice ) {
2647
+ $has_admin_notice = '<h2>' . __( '<strong>Allow Track</strong>', 'advanced-import' ) . '</h2>' . $has_admin_notice;
2648
+ $screen->add_help_tab(
2649
+ array(
2650
+ 'id' => 'ai_help_tab_track',
2651
+ 'title' => __( 'Allow Track', 'advanced-import' ),
2652
+ 'content' => $has_admin_notice,
2653
+ )
2654
+ );
2655
+ }
2656
+
2657
  }
2658
  }
2659
 
admin/class-advanced-import-tracking.php ADDED
@@ -0,0 +1,529 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Tracking functions for reporting plugin usage to the Engine site for users that have opted in
4
+ *
5
+ * @package Advanced Import
6
+ * @subpackage Admin
7
+ * @since 1.3.6
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+ /**
16
+ * Agent Usage tracking
17
+ *
18
+ * @since 1.3.6
19
+ * @return void
20
+ */
21
+ class Advanced_Import_Tracking {
22
+
23
+ /**
24
+ * @access private
25
+ */
26
+ private $slug = '';
27
+ private $secret_opt_key = '';
28
+ private $last_send_opt_key = '';
29
+ private $hide_notice_opt_key = '';
30
+ private $agents_opt_key = '';
31
+ private $agent_active_opt_key = '';
32
+ private $data;
33
+ private $api_url = '';
34
+ private $remote_url = '';
35
+ private $version = '';
36
+
37
+ /**
38
+ * Get things going
39
+ * allow-tracking is set from $this->get_opt_data()
40
+ * Other from opt key
41
+ *
42
+ * @since 1.3.6
43
+ * @return void
44
+ */
45
+ public function __construct() {
46
+
47
+ /*Changed with the plugin*/
48
+ $this->remote_url = trailingslashit( 'https://tracking.acmeit.org' );
49
+ $this->slug = ADVANCED_IMPORT_PLUGIN_NAME;
50
+ $this->version = '1.0.0';
51
+ /*Changed with the plugin end*/
52
+
53
+ $this->secret_opt_key = 'agent_secret_key';
54
+ $this->last_send_opt_key = 'agent_last_send';
55
+ $this->hide_notice_opt_key = 'agent_hide_notice';
56
+ $this->agent_active_opt_key = 'is_active_this_track';
57
+
58
+ $this->agents_opt_key = 'agent_' . md5( $this->remote_url );/*unique per remote url*/
59
+
60
+ $this->init();
61
+
62
+ }
63
+
64
+ /**
65
+ * Set up WordPress hooks.
66
+ *
67
+ * @since 1.3.6
68
+ * @return void
69
+ */
70
+ public function init() {
71
+
72
+ add_action( 'init', array( $this, 'schedule_send' ) );
73
+ add_action( 'admin_init', array( $this, 'do_agents' ) );
74
+ add_action( 'admin_init', array( $this, 'do_show_tracking_notice' ) );
75
+ add_action( 'admin_notices', array( $this, 'admin_notice' ) );
76
+ }
77
+
78
+ /**
79
+ * Update agents.
80
+ * Run once in the lifetime.
81
+ *
82
+ * @since 1.3.6
83
+ * @return void
84
+ */
85
+ public function do_agents() {
86
+
87
+ $installed_agents = get_option( $this->agents_opt_key, array() );
88
+ if ( isset( $installed_agents[ $this->slug ] ) ) {
89
+ return;
90
+ }
91
+
92
+ $installed_agents[ $this->slug ] = $this->version;
93
+
94
+ $active_agent = $this->get_opt_data( $this->agent_active_opt_key, '' );
95
+
96
+ if ( ! $active_agent ) {
97
+ $active_agent = $this->slug;
98
+ } else {
99
+ if ( is_array( $installed_agents ) && ! empty( $installed_agents ) ) {
100
+ $highest_ver = $this->version;
101
+ foreach ( $installed_agents as $agent => $agent_ver ) {
102
+ if ( version_compare( $agent_ver, $highest_ver ) > 0 ) {
103
+ $highest_ver = $agent_ver;
104
+ $active_agent = $agent;
105
+ }
106
+ }
107
+ }
108
+ }
109
+
110
+ advanced_import_add_installed_time();
111
+
112
+ // register this agent locally.
113
+ $this->update_opt_data( $this->agent_active_opt_key, $active_agent );
114
+
115
+ // register agent data globally.
116
+ update_option( $this->agents_opt_key, $installed_agents );
117
+ }
118
+
119
+ /**
120
+ * Is this active agent
121
+ *
122
+ * @since 1.3.6
123
+ * @return boolean
124
+ */
125
+ private function is_active_agent() {
126
+ if ( $this->slug == $this->get_opt_data( $this->agent_active_opt_key ) ) {
127
+ return true;
128
+ }
129
+ return false;
130
+
131
+ }
132
+
133
+ /**
134
+ * Update secret keyy
135
+ *
136
+ * @since 1.3.6
137
+ * @return void
138
+ */
139
+ private function update_secret_key( $res ) {
140
+ // get secret key from engine.
141
+ $get_secret_key = json_decode( $res, true );
142
+ $secret_key = 'none';
143
+ if ( $get_secret_key && is_array( $get_secret_key ) && isset( $get_secret_key['secret_key'] ) ) {
144
+ $secret_key = $get_secret_key['secret_key'];
145
+ }
146
+ $this->update_opt_data( $this->secret_opt_key, sanitize_text_field( $secret_key ) );
147
+ }
148
+
149
+ /**
150
+ * Authorize this site to send data to engine.
151
+ * get secret key from engine
152
+ * run on agent activation.
153
+ *
154
+ * @since 1.3.6
155
+ * @return void
156
+ */
157
+ public function do_handshake() {
158
+ $secret_key = $this->get_opt_data( $this->secret_opt_key );
159
+
160
+ if ( ! empty( $secret_key ) ) {
161
+ // secret_key already exists.
162
+ // do nothing.
163
+ return;
164
+ }
165
+
166
+ // authenticate with engine.
167
+ $this->api_url = $this->remote_url . 'wp-json/acme-udp-admin/v1/handshake';
168
+
169
+ $get_secret_key = $this->do_post( true, true );
170
+
171
+ $this->update_secret_key( $get_secret_key );
172
+
173
+ }
174
+
175
+ /**
176
+ * Default Options
177
+ *
178
+ * @param null
179
+ * @return array $advanced_import_default_options
180
+ *
181
+ * @since 1.3.6
182
+ */
183
+ private function default_options() {
184
+ return array(
185
+ 'allow-tracking' => false,
186
+ );
187
+ }
188
+
189
+ /**
190
+ * Get option.
191
+ *
192
+ * @since 1.3.6
193
+ * @return array
194
+ */
195
+ private function get_opt_data( $key = '' ) {
196
+ $advanced_import_options = json_decode( get_option( 'advanced_import_settings_options' ), true );
197
+
198
+ $advanced_import_default_options = $this->default_options();
199
+ if ( ! empty( $key ) ) {
200
+ if ( isset( $advanced_import_options[ $key ] ) ) {
201
+ return $advanced_import_options[ $key ];
202
+ }
203
+ return isset( $advanced_import_default_options[ $key ] ) ? $advanced_import_default_options[ $key ] : '';
204
+ } else {
205
+ if ( ! is_array( $advanced_import_options ) ) {
206
+ $advanced_import_options = array();
207
+ }
208
+ return array_merge( $advanced_import_default_options, $advanced_import_options );
209
+ }
210
+ }
211
+
212
+ /**
213
+ * Update options.
214
+ *
215
+ * @since 1.3.6
216
+ * @return array
217
+ */
218
+ private function update_opt_data( $key, $val ) {
219
+ $helper_options = json_decode( get_option( 'advanced_import_settings_options' ), true );
220
+ if ( ! is_array( $helper_options ) ) {
221
+ $helper_options = array();
222
+ }
223
+ $helper_options[ $key ] = $val;
224
+ update_option(
225
+ 'advanced_import_settings_options',
226
+ wp_json_encode( $helper_options )
227
+ );
228
+ }
229
+
230
+ /**
231
+ * Gather data to send to engine.
232
+ *
233
+ * @since 1.3.6
234
+ * @return array
235
+ */
236
+ private function get_data() {
237
+
238
+ if ( ! class_exists( 'WP_Debug_Data' ) ) {
239
+ include_once ABSPATH . 'wp-admin/includes/class-wp-debug-data.php';
240
+ }
241
+ $data = array();
242
+
243
+ if ( method_exists( 'WP_Debug_Data', 'debug_data' ) ) {
244
+ $data['data'] = WP_Debug_Data::debug_data();
245
+ } else {
246
+ $data['data'] = array();
247
+ }
248
+ $data['admin_email'] = get_bloginfo( 'admin_email' );
249
+ $user = get_user_by( 'email', $data['admin_email'] );
250
+ $data['nicename'] = $user->data->user_nicename;
251
+ $data['site_url'] = get_bloginfo( 'url' );
252
+ $data['version'] = get_bloginfo( 'version' );
253
+
254
+ $data['sender'] = $this->slug;
255
+
256
+ return $data;
257
+ }
258
+
259
+ /**
260
+ * Setup the data
261
+ *
262
+ * @access private
263
+ *
264
+ * @since 1.3.6
265
+ * @return void
266
+ */
267
+ private function setup_data() {
268
+ $data = array();
269
+ $data['agent_data'] = maybe_serialize( $this->get_data() );
270
+ $data['secret_key'] = $this->get_opt_data( $this->secret_opt_key );
271
+ $this->data = $data;
272
+ }
273
+
274
+ /**
275
+ * Send the data to the Engine server
276
+ *
277
+ * @access public
278
+ *
279
+ * @param bool $override If we should override the tracking setting.
280
+ * @param bool $is_handshake If it is just handshake to get secret key.
281
+ *
282
+ * @since 1.3.6
283
+ * @return bool
284
+ */
285
+ public function do_post( $override = false, $is_handshake = false ) {
286
+
287
+ if ( ! $this->get_opt_data( 'allow-tracking' ) && ! $override ) {
288
+ return false;
289
+ }
290
+
291
+ /*Send a maximum of once per week*/
292
+ $last_send = $this->get_last_send();
293
+ if ( is_numeric( $last_send ) && $last_send > strtotime( '-1 week' ) && ! $is_handshake ) {
294
+ return false;
295
+ }
296
+
297
+ /*if this agent is not active agent*/
298
+ if ( ! $this->is_active_agent() ) {
299
+ return false;
300
+ }
301
+
302
+ if ( ! $is_handshake ) {
303
+ $this->api_url = $this->remote_url . 'wp-json/acme-udp-admin/v1/process-data';
304
+ $this->update_last_send();
305
+ }
306
+
307
+ $this->setup_data();
308
+ $response = wp_remote_post(
309
+ $this->api_url,
310
+ array(
311
+ 'method' => 'POST',
312
+ 'timeout' => 45,
313
+ 'redirection' => 5,
314
+ 'httpversion' => '1.0',
315
+ 'blocking' => true,
316
+ 'headers' => array(),
317
+ 'body' => $this->data,
318
+ )
319
+ );
320
+
321
+ if ( $is_handshake ) {
322
+ return wp_remote_retrieve_body( $response );
323
+ } else {
324
+ $is_secret_key = json_decode( wp_remote_retrieve_body( $response ), true );
325
+ if ( is_array( $is_secret_key ) && isset( $is_secret_key['secret_key'] ) ) {
326
+ $this->update_secret_key( wp_remote_retrieve_body( $response ) );
327
+ }
328
+ }
329
+
330
+ }
331
+
332
+ /**
333
+ * When saving hide tracking notice.
334
+ *
335
+ * @return void
336
+ */
337
+ public function do_show_tracking_notice() {
338
+
339
+ $this->do_handshake();
340
+
341
+ // listen for our activate button to be clicked
342
+ if ( ! isset( $_GET[ esc_attr( $this->slug ) . '_tracking' ] ) ) {
343
+ return;
344
+ }
345
+
346
+ if ( ! current_user_can( 'manage_options' ) ) {
347
+ return;
348
+ }
349
+
350
+ /*Security check*/
351
+ check_admin_referer( $this->slug );
352
+
353
+ if ( 1 == $_GET[ esc_attr( $this->slug ) . '_tracking' ] ) {
354
+ $this->update_opt_data( 'allow-tracking', true );
355
+ $this->do_post( true );
356
+ } else {
357
+ $this->update_opt_data( 'allow-tracking', false );
358
+ }
359
+
360
+ $this->update_hide_tracking_notice( true );
361
+ }
362
+
363
+ /**
364
+ * Schedule a weekly tracking
365
+ *
366
+ * @since 1.3.6
367
+ * @return void
368
+ */
369
+ public function schedule_send() {
370
+ if ( isset( $_GET['acmeit_verify_user_secret_key_rand_3022'] ) ) {
371
+ die( 'equal' );
372
+ }
373
+ if ( wp_doing_cron() ) {
374
+ add_action( 'advanced_import_weekly_scheduled_events', array( $this, 'do_post' ) );
375
+ }
376
+ }
377
+
378
+ /**
379
+ * Update last send
380
+ *
381
+ * @since 1.3.6
382
+ * @return void
383
+ */
384
+ public function update_last_send() {
385
+
386
+ $this->update_opt_data( $this->last_send_opt_key, time() );
387
+ }
388
+
389
+ /**
390
+ * Get last send
391
+ *
392
+ * @since 1.3.6
393
+ * @return string
394
+ */
395
+ public function get_last_send() {
396
+ return $this->get_opt_data( $this->last_send_opt_key );
397
+
398
+ }
399
+
400
+ /**
401
+ * Update hide notice
402
+ *
403
+ * @since 1.3.6
404
+ * @return void
405
+ */
406
+ public function update_hide_tracking_notice( $val = false ) {
407
+ $this->update_opt_data( $this->hide_notice_opt_key, $val );
408
+ }
409
+
410
+ /**
411
+ * Get hide notice
412
+ *
413
+ * @since 1.3.6
414
+ * @return boolean
415
+ */
416
+ public function get_hide_tracking_notice() {
417
+ return $this->get_opt_data( $this->hide_notice_opt_key );
418
+
419
+ }
420
+
421
+ /**
422
+ * Check if we can show tracking notice to user.
423
+ *
424
+ * @since 1.3.6
425
+ * @return boolean
426
+ */
427
+ public function can_show_notice() {
428
+
429
+ if ( $this->get_opt_data( 'installed_time' ) > strtotime( '-3 day' ) ) {
430
+ return false;
431
+ }
432
+
433
+ if ( $this->get_hide_tracking_notice() ) {
434
+ return false;
435
+ }
436
+ if ( $this->get_opt_data( 'allow-tracking' ) ) {
437
+ return false;
438
+ }
439
+ if ( ! current_user_can( 'manage_options' ) ) {
440
+ return false;
441
+ }
442
+ /*if this agent is not active agent*/
443
+ if ( ! $this->is_active_agent() ) {
444
+ return false;
445
+ }
446
+ return true;
447
+
448
+ }
449
+
450
+ /**
451
+ * Get current admin page URL.
452
+ *
453
+ * Returns an empty string if it cannot generate a URL.
454
+ *
455
+ * @since 1.3.6
456
+ * @return string
457
+ */
458
+ private function get_current_admin_url() {
459
+ $uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
460
+ $uri = preg_replace( '|^.*/wp-admin/|i', '', $uri );
461
+
462
+ if ( ! $uri ) {
463
+ return '';
464
+ }
465
+
466
+ return remove_query_arg( array( '_wpnonce' ), admin_url( $uri ) );
467
+ }
468
+
469
+ /**
470
+ * Display the admin notice to users.
471
+ *
472
+ * @return void
473
+ * @since 1.3.6
474
+ */
475
+ public function admin_notice( $is_help = false ) {
476
+
477
+ if ( ! $this->can_show_notice() ) {
478
+ return;
479
+ }
480
+ global $current_user;
481
+
482
+ $allow_url = wp_nonce_url(
483
+ add_query_arg(
484
+ array(
485
+ esc_attr( $this->slug ) . '_tracking' => 1,
486
+ ),
487
+ $this->get_current_admin_url()
488
+ ),
489
+ $this->slug
490
+ );
491
+ $not_allow_url = wp_nonce_url(
492
+ add_query_arg(
493
+ array(
494
+ esc_attr( $this->slug ) . '_tracking' => 0,
495
+ ),
496
+ $this->get_current_admin_url()
497
+ ),
498
+ $this->slug
499
+ );
500
+ ?>
501
+ <div class="<?php echo $is_help ? '' : 'notice updated '; ?><?php echo esc_attr( $this->slug ); ?>-track-notice">
502
+ <p style="float: left">
503
+ <?php
504
+ printf(
505
+ /* Translators: %1$s current user display name. */
506
+ esc_html__(
507
+ 'Howdy, %1$s! Allow Advanced Import to anonymously track how this plugin is used and help us make the plugin better. No sensitive data is tracked.',
508
+ 'advanced-import'
509
+ ),
510
+ '<strong>' . esc_html( $current_user->display_name ) . '</strong>'
511
+ );
512
+ ?>
513
+ </p>
514
+
515
+
516
+ <a href="<?php echo esc_url( $allow_url ); ?>" class="btn button-primary">
517
+ <span><?php esc_html_e( 'Allow', 'advanced-import' ); ?></span>
518
+ </a>
519
+ <a href="<?php echo esc_url( $not_allow_url ); ?>" class="btn button-link">
520
+ <span><?php esc_html_e( 'Do not allow', 'advanced-import' ); ?></span>
521
+ </a>
522
+
523
+ </div>
524
+
525
+ <?php
526
+ }
527
+ }
528
+ global $advanced_import_tracking;
529
+ $advanced_import_tracking = new Advanced_Import_Tracking();
admin/class-elementor-import.php CHANGED
@@ -97,6 +97,135 @@ if ( ! class_exists( 'Advanced_Import_Elementor' ) ) {
97
  $post_css->update();
98
  }
99
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  }
101
  }
102
 
97
  $post_css->update();
98
  }
99
  }
100
+
101
+ /*
102
+ set and get transient adi_elementor_data_posts
103
+ return mix*/
104
+ public function elementor_data_posts( $el_post_id = false, $meta_val = false ) {
105
+ $el_posts = get_transient( 'adi_elementor_data_posts' );
106
+ if ( ! is_array( $el_posts ) ) {
107
+ $el_posts = array();
108
+ }
109
+ if ( $el_post_id && $meta_val ) {
110
+ $el_posts[ $el_post_id ] = $meta_val;
111
+ set_transient( 'adi_elementor_data_posts', $el_posts, 60 * 60 * 24 );
112
+ }
113
+ return $el_posts;
114
+ }
115
+
116
+ /**
117
+ * Change post and term id related to elementor meta to new id
118
+ *
119
+ * @param array $item current array of demo list.
120
+ * @param string $key
121
+ * @return string
122
+ */
123
+ public function elementor_data( $elementor_data ) {
124
+
125
+ /*$upload_dir = wp_upload_dir();
126
+ $advanced_export_temp = $upload_dir['basedir'] . '/advanced-export-temp-test/';
127
+
128
+ WP_Filesystem();
129
+ global $wp_filesystem;
130
+
131
+ if ( ! file_exists( $advanced_export_temp ) ) {
132
+ $wp_filesystem->mkdir( $advanced_export_temp );
133
+ }
134
+ $file = fopen( $advanced_export_temp . 'content.json', 'a' );//a for append -- could use a+ to create the file if it doesn't exist
135
+ fwrite( $file, "\n" . print_r( $elementor_data, true ) );
136
+ fclose( $file );*/
137
+
138
+ if ( advanced_import_admin()->isJson( $elementor_data ) && is_string( $elementor_data ) && ! is_null( $elementor_data ) ) {
139
+ $elementor_data = json_decode( stripslashes( $elementor_data ), true );
140
+ }
141
+
142
+ /*Terms IDS*/
143
+ $replace_post_ids = apply_filters(
144
+ 'advanced_import_replace_post_ids',
145
+ array(
146
+ 'image_id',
147
+ 'thumbnail_id',
148
+ 'page_id',
149
+ 'post_id',
150
+ )
151
+ );
152
+
153
+ /*Terms IDS*/
154
+ $replace_term_ids = apply_filters(
155
+ 'advanced_import_replace_term_ids',
156
+ array(
157
+ 'acm_authors_list',
158
+ 'categories_selected',
159
+ )
160
+ );
161
+
162
+ // Recursively update elementor data.
163
+ foreach ( $elementor_data as $element_id => $element_data ) {
164
+ if ( ! empty( $element_data['elements'] ) ) {
165
+ foreach ( $element_data['elements'] as $el_key => $el_data ) {
166
+ if ( ! empty( $el_data['elements'] ) ) {
167
+ foreach ( $el_data['elements'] as $el_child_key => $child_el_data ) {
168
+ if ( 'widget' === $child_el_data['elType'] ) {
169
+ $settings = $child_el_data['settings'] ?? array();
170
+
171
+ if ( ! empty( $settings ) ) {
172
+ foreach ( $settings as $el_set_key => $el_set_data ) {
173
+ if ( in_array( $el_set_key, $replace_post_ids ) ) {
174
+ if ( is_numeric( $el_set_data ) ) {
175
+ $el_set_data = advanced_import_admin()->imported_post_id( $el_set_data );
176
+ } elseif ( is_array( $el_set_data ) && ! empty( $el_set_data ) ) {
177
+ $new_set_data = array();
178
+ foreach ( $el_set_data as $el_set_single_data ) {
179
+ if ( is_numeric( $el_set_data ) ) {
180
+ $new_set_data[] = advanced_import_admin()->imported_post_id( $el_set_single_data );
181
+ }
182
+ }
183
+ $el_set_data = $new_set_data;
184
+ }
185
+ }
186
+ if ( in_array( $el_set_key, $replace_term_ids ) ) {
187
+ if ( is_numeric( $el_set_data ) ) {
188
+ $el_set_data = advanced_import_admin()->imported_term_id( $el_set_data );
189
+ } elseif ( is_array( $el_set_data ) && ! empty( $el_set_data ) ) {
190
+ $new_set_data = array();
191
+ foreach ( $el_set_data as $el_set_single_data ) {
192
+ if ( is_numeric( $el_set_single_data ) ) {
193
+ $new_set_data[] = advanced_import_admin()->imported_term_id( $el_set_single_data );
194
+ }
195
+ }
196
+ $el_set_data = $new_set_data;
197
+ }
198
+ }
199
+ $elementor_data[ $element_id ]['elements'][ $el_key ]['elements'][ $el_child_key ]['settings'][ $el_set_key ] = $el_set_data;
200
+
201
+ }
202
+ }
203
+ }
204
+ }
205
+ }
206
+ }
207
+ }
208
+ }
209
+
210
+ return wp_json_encode( $elementor_data );
211
+ }
212
+
213
+ /**
214
+ * Change post and term id related to elementor meta to new id
215
+ *
216
+ * @param array $item current array of demo list.
217
+ * @param string $key
218
+ * @return string
219
+ */
220
+ public function process_elementor_posts() {
221
+ $el_posts = $this->elementor_data_posts();
222
+ if ( is_array( $el_posts ) && ! empty( $el_posts ) ) {
223
+ foreach ( $el_posts as $el_post => $el_data ) {
224
+ $el_data = $this->elementor_data( $el_data );
225
+ update_post_meta( $el_post, '_elementor_data', $el_data );
226
+ }
227
+ }
228
+ }
229
  }
230
  }
231
 
admin/class-reset.php CHANGED
@@ -71,15 +71,13 @@ class Advanced_Import_Reset_WordPress {
71
  * We may add other plugins after testing/reported
72
  */
73
  private function deactivate_plugins() {
74
- if ( $this->can_reset() ) {
75
- include_once ABSPATH . 'wp-admin/includes/plugin.php';
76
- if ( ! function_exists( 'deactivate_plugins' ) ) {
77
- return;
78
- }
79
 
80
- if ( is_plugin_active( 'elementor/elementor.php' ) ) {
81
- deactivate_plugins( 'elementor/elementor.php' );
82
- }
83
  }
84
 
85
  }
@@ -104,10 +102,6 @@ class Advanced_Import_Reset_WordPress {
104
  advanced_import_update_option( 'advanced_import_reset_notice', 1 );
105
  }
106
  }
107
- /*Deactivate troubleshoot plugins before reset*/
108
- if ( $this->can_reset() ) {
109
- $this->deactivate_plugins();
110
- }
111
  }
112
 
113
  /**
@@ -215,7 +209,7 @@ class Advanced_Import_Reset_WordPress {
215
  ?>
216
  <div id="message" class="updated ai-import-message">
217
  <p><?php _e( '<strong>WordPress Reset</strong> &#8211; If no important data on your site. You can reset the WordPress back to default again!', 'advanced-import' ); ?></p>
218
- <p class="submit"><a href="<?php echo esc_url( $reset_url ); ?>" class="button button-primary ai-wp-reset"><?php esc_html_e( 'Run the Reset Wizard', 'advanced-import' ); ?></a> <a class="button-secondary skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'advanced-import-hide-notice', 'reset_notice', $current_url ), 'advanced_import_hide_notice_nonce', '_advanced_import_notice_nonce' ) ); ?>"><?php esc_attr_e( 'Hide this notice', 'advanced-import' ); ?></a></p>
219
  </div>
220
  <?php
221
  } elseif ( isset( $_GET['reset'] ) && 'true' === $_GET['reset'] ) {
@@ -228,6 +222,31 @@ class Advanced_Import_Reset_WordPress {
228
  }
229
  }
230
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
  }
233
 
71
  * We may add other plugins after testing/reported
72
  */
73
  private function deactivate_plugins() {
74
+ include_once ABSPATH . 'wp-admin/includes/plugin.php';
75
+ if ( ! function_exists( 'deactivate_plugins' ) ) {
76
+ return;
77
+ }
 
78
 
79
+ if ( is_plugin_active( 'elementor/elementor.php' ) ) {
80
+ deactivate_plugins( 'elementor/elementor.php' );
 
81
  }
82
 
83
  }
102
  advanced_import_update_option( 'advanced_import_reset_notice', 1 );
103
  }
104
  }
 
 
 
 
105
  }
106
 
107
  /**
209
  ?>
210
  <div id="message" class="updated ai-import-message">
211
  <p><?php _e( '<strong>WordPress Reset</strong> &#8211; If no important data on your site. You can reset the WordPress back to default again!', 'advanced-import' ); ?></p>
212
+ <p class="submit"><?php wp_nonce_field( 'advanced-import-reset', 'advanced-import-reset' ); ?><a href="<?php echo esc_url( $reset_url ); ?>" class="button button-primary ai-wp-reset"><?php esc_html_e( 'Run the Reset Wizard', 'advanced-import' ); ?></a> <a class="button-secondary skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'advanced-import-hide-notice', 'reset_notice', $current_url ), 'advanced_import_hide_notice_nonce', '_advanced_import_notice_nonce' ) ); ?>"><?php esc_attr_e( 'Hide this notice', 'advanced-import' ); ?></a></p>
213
  </div>
214
  <?php
215
  } elseif ( isset( $_GET['reset'] ) && 'true' === $_GET['reset'] ) {
222
  }
223
  }
224
 
225
+ /**
226
+ * Before Reset Ajax callback
227
+ */
228
+ public function before_reset() {
229
+ /*check for security*/
230
+ if ( ! current_user_can( 'upload_files' ) ) {
231
+ wp_send_json_error(
232
+ array(
233
+ 'message' => esc_html__( 'Sorry, you are not allowed to install demo on this site.', 'advanced-import' ),
234
+ )
235
+ );
236
+ }
237
+ check_admin_referer( 'advanced-import-reset' );
238
+
239
+ /*Deactivate troubleshoot plugins before reset*/
240
+ $this->deactivate_plugins();
241
+
242
+ do_action( 'advanced_import_before_reset' );
243
+ wp_send_json_success(
244
+ array(
245
+ 'message' => esc_html__( 'Success', 'advanced-import' ),
246
+ )
247
+ );
248
+ }
249
+
250
 
251
  }
252
 
advanced-import.php CHANGED
@@ -14,7 +14,7 @@ if ( ! defined( 'WPINC' ) ) {
14
  * Plugin Name: Advanced Import
15
  * Plugin URI: https://addonspress.com/item/advanced-import
16
  * Description: Easily import demo data starter site packages or Migrate your site data
17
- * Version: 1.3.5
18
  * Author: AddonsPress
19
  * Author URI: https://addonspress.com/
20
  * License: GPL-2.0+
@@ -24,7 +24,7 @@ if ( ! defined( 'WPINC' ) ) {
24
  */
25
 
26
  /*Define Constants for this plugin*/
27
- define( 'ADVANCED_IMPORT_VERSION', '1.3.5' );
28
  define( 'ADVANCED_IMPORT_PLUGIN_NAME', 'advanced-import' );
29
  define( 'ADVANCED_IMPORT_PATH', plugin_dir_path( __FILE__ ) );
30
  define( 'ADVANCED_IMPORT_URL', plugin_dir_url( __FILE__ ) );
14
  * Plugin Name: Advanced Import
15
  * Plugin URI: https://addonspress.com/item/advanced-import
16
  * Description: Easily import demo data starter site packages or Migrate your site data
17
+ * Version: 1.3.6
18
  * Author: AddonsPress
19
  * Author URI: https://addonspress.com/
20
  * License: GPL-2.0+
24
  */
25
 
26
  /*Define Constants for this plugin*/
27
+ define( 'ADVANCED_IMPORT_VERSION', '1.3.6' );
28
  define( 'ADVANCED_IMPORT_PLUGIN_NAME', 'advanced-import' );
29
  define( 'ADVANCED_IMPORT_PATH', plugin_dir_path( __FILE__ ) );
30
  define( 'ADVANCED_IMPORT_URL', plugin_dir_url( __FILE__ ) );
assets/js/advanced-import-admin.min.js CHANGED
@@ -1 +1 @@
1
- !function(t){let e,a,n,o,i=t(document),r=!1,c=!1;const l=function(t){let e,a,n=window.location.search.substring(1).split("&");for(a=0;a<n.length;a++)if((e=n[a].split("="))[0]===t)return void 0===e[1]||decodeURIComponent(e[1])},s=Swal.mixin({position:"bottom-end",showConfirmButton:!1,allowOutsideClick:!1,allowEscapeKey:!1,toast:!0}),d=function(e){"object"!=typeof e||null===e||e.success?(t("#ai-demo-popup").html(e),s.fire({type:"info",html:t("#ai-demo-popup .ai-notification-title").html()}),s.showLoading()):u(e.data.message)},u=function(t=null,e=null,a=null,n=null){let o=advanced_import_object.text.failedImport.text;o+=t||e||a||n?"<br/>"+advanced_import_object.text.failedImport.code:"",o+=t||"",o+=e||"",o+=a||"",o+=n||"",s.fire({type:"error",html:o}),f()},p=function(e=!1){s.fire({type:"info",html:t(".ai-notification-title").html()}),s.showLoading(),r=!0,m(e)},f=function(){r=!1,_()},m=function(t){return!!t&&(!c&&((c=t).append('<span class="ai-update dashicons dashicons-update"></span>'),c.attr("disabled",!0),void c.closest(".ai-item").addClass("ai-action-importing")))},_=function(){if(!c)return!1;c.children(".ai-update").remove(),c.attr("disabled",!1),c.closest(".ai-item").removeClass("ai-action-importing"),c=!1};function h(){return t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"content_screen",_wpnonce:e.val(),_wp_http_referer:a.val(),template_url:o,template_type:n}}).done(function(e){if("object"!=typeof e||null===e||e.success){d(e),(new function(){let e,a=0,i="",r="";function c(a){"object"==typeof a&&void 0!==a.message?(e.find("span").text(a.message),void 0!==a.url?a.hash===r?(e.find("span").text(advanced_import_object.text.failed),l()):(r=a.hash,t.ajax({type:"POST",url:a.url,data:a}).done(c).fail(c)):(a.done,l())):"object"!=typeof a||null===a||a.success?(e.find("span").text(advanced_import_object.text.error),l()):u(a.data.errorMessage?a.data.errorMessage:a.data.message)}function l(){e&&(e.data("done-item")||(a++,e.attr("data-done-item",1)),e.find(".spinner").remove());let r=!1,s=t("tr.ai-available-content");s.each(function(){let a=t(this);""===i||r?(i=a.data("content"),e=a,function(){if(i){let a=e.find("input:checkbox");a.is(":checked")?t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"import_content",wpnonce:advanced_import_object.wpnonce,content:i,template_url:o,template_type:n}}).done(c).fail(c):(e.find("span").text(advanced_import_object.text.skip),setTimeout(l,300))}}(),r=!1):a.data("content")===i&&(r=!0)}),a>=s.length&&complete()}return{init:function(){let e=t(".ai-pages");e.addClass("installing"),e.find("input").prop("disabled",!0),complete=function(){return t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"complete_screen"}}).done(function(e){return t("#ai-demo-popup").html(e),Swal.fire({title:"Success",html:t("#ai-demo-popup .ai-notification-title").html(),type:"success",allowOutsideClick:!1,showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:advanced_import_object.text.successImport.confirmButtonText,cancelButtonText:advanced_import_object.text.successImport.cancelButtonText}).then(e=>{e.value&&window.open(t("#ai-demo-popup .ai-actions-buttons a").attr("href"),"_blank")}),f(),!1}).fail(function(t,e,a){console.log(t+" :: "+e+" :: "+a)}),!1},l()}}}).init()}else u(e.data.errorMessage?e.data.errorMessage:e.data.message)}).fail(function(t,e,a){return u("",t,e,a),!1}),!1}function v(n){return t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"plugin_screen",_wpnonce:e.val(),_wp_http_referer:a.val(),recommendedPlugins:n}}).done(function(n){d(n),s.showLoading(),t("#ai-demo-popup .ai-plugins-wrap").find("li").each(function(){return function n(o){if("ai-no-recommended-plugins"===o.attr("id"))return h(),!1;t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"install_plugin",_wpnonce:e.val(),_wp_http_referer:a.val(),slug:o.data("slug"),plugin:o.data("slug")+"/"+o.data("main_file")}}).done(function(t){if("object"==typeof t&&void 0!==t.success)if(t.success){if(o.attr("data-completed",1),!o.next("li").length)return h(),!1;setTimeout(n(o.next("li")),1e3)}else{let e="";t.data.errorMessage&&(e=t.data.errorMessage+"<br/>",e+=advanced_import_object.text.failedImport.pluginError+"<br/>",t.data.plugin&&(e+=advanced_import_object.text.failedImport.plugin+t.data.plugin+"<br/>"),t.data.slug&&(e+=advanced_import_object.text.failedImport.slug+t.data.slug+"<br/>")),u(e||t.data.message)}else setTimeout(n(o),1e3)}).fail(function(t,e,a){return u("",t,e,a),!1})}(t(this)),!1})}).fail(function(t,e,a){return u("",t,e,a),!1}),!1}i.ready(function(){i.on("submit","#ai-upload-zip-form",function(n){if(n.preventDefault(),r)return!1;!function(n){if(void 0===window.FormData)return!0;let o=new FormData,i=n.find("#ai-upload-zip-archive"),r=t("#ai-empty-file");if(!i.val())return r.show(),u(r.html()),!1;r.hide(),p();let c=i[0].files[0];e=n.find("input[name=_wpnonce]"),a=n.find("input[name=_wp_http_referer]"),o.append("ai-upload-zip-archive",c),o.append("action","advanced_import_ajax_setup"),o.append("_wpnonce",e.val()),o.append("_wp_http_referer",a.val()),i.val(""),t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:o,cache:!1,contentType:!1,processData:!1}).done(function(t){return"object"!=typeof t&&(t=JSON.parse(t)),t.success?(h(),!1):(u(t.data.message),!1)}).fail(function(t,e,a){return u("",t,e,a),!1})}(t(this))}),i.on("click",".ai-item .ai-demo-import",function(i){if(i.preventDefault(),r)return!1;let c=t(this),l=t(this).data("plugins"),s="",d=advanced_import_object.text.confirmImport.html;l?(l.forEach(function(t,e){t.name&&(s+=" "+t.name,e<l.length-1&&(s+=","))}),d=d.replace("ai_replace_plugins",s)):d=d.replace("ai_replace_plugins",advanced_import_object.text.confirmImport.no_plugins),Swal.fire({title:advanced_import_object.text.confirmImport.title,html:d,width:"64rem",customClass:{content:"ai-confirm-import-content"},allowOutsideClick:!1,showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:advanced_import_object.text.confirmImport.confirmButtonText,cancelButtonText:advanced_import_object.text.confirmImport.cancelButtonText}).then(i=>{i.value&&(p(c),function(i,r){let c=i.closest(".ai-item");n=c.data("template_type"),o=c.data("template_url"),e=c.find("input[name=_wpnonce]"),a=c.find("input[name=_wp_http_referer]"),"array"===n?v(r):t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"demo_download_and_unzip",_wpnonce:e.val(),_wp_http_referer:a.val(),demo_file:o,demo_file_type:n}}).done(function(t){return t.success?(v(r),!1):(u(t.data.errorMessage?t.data.errorMessage:t.data.message,jqXHR,textStatus,errorThrown),!1)}).fail(function(t,e,a){return u("",t,e,a),!1})}(c,l))})}),i.on("click",".ai-wp-reset",function(e){e.preventDefault(),Swal.fire({title:advanced_import_object.text.confirmReset.title,text:advanced_import_object.text.confirmReset.text,type:"warning",allowOutsideClick:!1,showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:advanced_import_object.text.confirmReset.confirmButtonText,cancelButtonText:advanced_import_object.text.confirmReset.cancelButtonText}).then(e=>{e.value&&(window.location.href=t(".ai-wp-reset").attr("href"))})}),i.on("click",".ai-filter-tabs li",function(e){if(e.preventDefault(),r)return!1;t(this).hasClass("ai-form-file-import")?(t(".ai-filter-content").addClass("hidden"),t(".ai-form").removeClass("hidden")):(t(".ai-form").addClass("hidden"),t(".ai-filter-content").removeClass("hidden"))});let c,s,d={};setTimeout(function(){let e=t(".ai-filter-content-wrapper").isotope({itemSelector:".ai-item",filter:function(){let e=t(this),a=!s||e.text().match(s),n=!c||e.is(c);return a&&n}});function a(){let a=e.isotope("getFilteredItemElements"),n=t(a);t(".ai-filter-btn").each(function(e,a){let o=t(a),i=o.attr("data-filter");if(!i)return;let r=n.filter(i).length;o.find(".ai-count").text(r)})}e.imagesLoaded().progress(function(){e.isotope("layout")}),a(),t(".ai-filter-group").on("click",".ai-filter-btn",function(){let n=t(this),o=n.parents(".ai-filter-group").attr("data-filter-group");n.siblings().removeClass("ai-filter-btn-active"),n.addClass("ai-filter-btn-active"),d[o]=n.attr("data-filter"),c=function(t){let e="";for(let a in t)e+=t[a];return e}(d),setTimeout(function(){e.isotope(),(n.hasClass("ai-fp-filter")||n.hasClass("ai-type-filter"))&&a()},300)});let n=t(".ai-search-filter").keyup(function(t,e){let a;return e=e||100,function(){clearTimeout(a);let n=arguments,o=this;a=setTimeout(function(){t.apply(o,n)},e)}}(function(){s=new RegExp(n.val(),"gi"),e.isotope(),a()}))},1),function(){let t=l("reset"),e=l("from");"true"===t&&"ai-reset-wp"===e&&Swal.fire({title:advanced_import_object.text.resetSuccess.title,type:"success",allowOutsideClick:!1,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:advanced_import_object.text.resetSuccess.confirmButtonText})}()}),setTimeout(function(){let t=window.location.href;if(new RegExp("[?|&]reset=[0-9a-zA-Z_+-|.,;]*").test(t)){let t=new URL(location);t.searchParams.delete("reset"),t.searchParams.delete("from"),history.replaceState(null,null,t)}},1500)}(jQuery);
1
+ !function(t){let e,n,a,i,o=t(document),r=!1,c=!1;const l=function(t){let e,n,a=window.location.search.substring(1).split("&");for(n=0;n<a.length;n++)if((e=a[n].split("="))[0]===t)return void 0===e[1]||decodeURIComponent(e[1])},s=Swal.mixin({position:"bottom-end",showConfirmButton:!1,allowOutsideClick:!1,allowEscapeKey:!1,toast:!0}),d=function(e){"object"!=typeof e||null===e||e.success?(t("#ai-demo-popup").html(e),s.fire({type:"info",html:t("#ai-demo-popup .ai-notification-title").html()}),s.showLoading()):u(e.data.message)},u=function(t=null,e=null,n=null,a=null){let i=advanced_import_object.text.failedImport.text;i+=t||e||n||a?"<br/>"+advanced_import_object.text.failedImport.code:"",i+=t||"",i+=e||"",i+=n||"",i+=a||"",s.fire({type:"error",html:i}),f()},p=function(e=!1){s.fire({type:"info",html:t(".ai-notification-title").html()}),s.showLoading(),r=!0,m(e)},f=function(){r=!1,_()},m=function(t){return!!t&&(!c&&((c=t).append('<span class="ai-update dashicons dashicons-update"></span>'),c.attr("disabled",!0),void c.closest(".ai-item").addClass("ai-action-importing")))},_=function(){if(!c)return!1;c.children(".ai-update").remove(),c.attr("disabled",!1),c.closest(".ai-item").removeClass("ai-action-importing"),c=!1};function h(){return t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"content_screen",_wpnonce:e.val(),_wp_http_referer:n.val(),template_url:i,template_type:a}}).done(function(e){if("object"!=typeof e||null===e||e.success){d(e),(new function(){let e,n=0,o="",r="";function c(n){"object"==typeof n&&void 0!==n.message?(e.find("span").text(n.message),void 0!==n.url?n.hash===r?(e.find("span").text(advanced_import_object.text.failed),l()):(r=n.hash,t.ajax({type:"POST",url:n.url,data:n}).done(c).fail(c)):(n.done,l())):"object"!=typeof n||null===n||n.success?(e.find("span").text(advanced_import_object.text.error),l()):u(n.data.errorMessage?n.data.errorMessage:n.data.message)}function l(){e&&(e.data("done-item")||(n++,e.attr("data-done-item",1)),e.find(".spinner").remove());let r=!1,s=t("tr.ai-available-content");s.each(function(){let n=t(this);""===o||r?(o=n.data("content"),e=n,function(){if(o){let n=e.find("input:checkbox");n.is(":checked")?t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"import_content",wpnonce:advanced_import_object.wpnonce,content:o,template_url:i,template_type:a}}).done(c).fail(c):(e.find("span").text(advanced_import_object.text.skip),setTimeout(l,300))}}(),r=!1):n.data("content")===o&&(r=!0)}),n>=s.length&&complete()}return{init:function(){let e=t(".ai-pages");e.addClass("installing"),e.find("input").prop("disabled",!0),complete=function(){return t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"complete_screen"}}).done(function(e){return t("#ai-demo-popup").html(e),Swal.fire({title:"Success",html:t("#ai-demo-popup .ai-notification-title").html(),type:"success",allowOutsideClick:!1,showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:advanced_import_object.text.successImport.confirmButtonText,cancelButtonText:advanced_import_object.text.successImport.cancelButtonText}).then(e=>{e.value&&window.open(t("#ai-demo-popup .ai-actions-buttons a").attr("href"),"_blank")}),f(),!1}).fail(function(t,e,n){console.log(t+" :: "+e+" :: "+n)}),!1},l()}}}).init()}else u(e.data.errorMessage?e.data.errorMessage:e.data.message)}).fail(function(t,e,n){return u("",t,e,n),!1}),!1}function v(a){return t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"plugin_screen",_wpnonce:e.val(),_wp_http_referer:n.val(),recommendedPlugins:a}}).done(function(a){d(a),s.showLoading(),t("#ai-demo-popup .ai-plugins-wrap").find("li").each(function(){return function a(i){if("ai-no-recommended-plugins"===i.attr("id"))return h(),!1;t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"install_plugin",_wpnonce:e.val(),_wp_http_referer:n.val(),slug:i.data("slug"),plugin:i.data("slug")+"/"+i.data("main_file")}}).done(function(t){if("object"==typeof t&&void 0!==t.success)if(t.success){if(i.attr("data-completed",1),!i.next("li").length)return h(),!1;setTimeout(a(i.next("li")),1e3)}else{let e="";t.data.errorMessage&&(e=t.data.errorMessage+"<br/>",e+=advanced_import_object.text.failedImport.pluginError+"<br/>",t.data.plugin&&(e+=advanced_import_object.text.failedImport.plugin+t.data.plugin+"<br/>"),t.data.slug&&(e+=advanced_import_object.text.failedImport.slug+t.data.slug+"<br/>")),u(e||t.data.message)}else setTimeout(a(i),1e3)}).fail(function(t,e,n){return u("",t,e,n),!1})}(t(this)),!1})}).fail(function(t,e,n){return u("",t,e,n),!1}),!1}o.ready(function(){o.on("submit","#ai-upload-zip-form",function(a){if(a.preventDefault(),r)return!1;!function(a){if(void 0===window.FormData)return!0;let i=new FormData,o=a.find("#ai-upload-zip-archive"),r=t("#ai-empty-file");if(!o.val())return r.show(),u(r.html()),!1;r.hide(),p();let c=o[0].files[0];e=a.find("input[name=_wpnonce]"),n=a.find("input[name=_wp_http_referer]"),i.append("ai-upload-zip-archive",c),i.append("action","advanced_import_ajax_setup"),i.append("_wpnonce",e.val()),i.append("_wp_http_referer",n.val()),o.val(""),t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:i,cache:!1,contentType:!1,processData:!1}).done(function(t){return"object"!=typeof t&&(t=JSON.parse(t)),t.success?(h(),!1):(u(t.data.message),!1)}).fail(function(t,e,n){return u("",t,e,n),!1})}(t(this))}),o.on("click",".ai-item .ai-demo-import",function(o){if(o.preventDefault(),r)return!1;let c=t(this),l=t(this).data("plugins"),s="",d=advanced_import_object.text.confirmImport.html;l?(l.forEach(function(t,e){t.name&&(s+=" "+t.name,e<l.length-1&&(s+=","))}),d=d.replace("ai_replace_plugins",s)):d=d.replace("ai_replace_plugins",advanced_import_object.text.confirmImport.no_plugins),Swal.fire({title:advanced_import_object.text.confirmImport.title,html:d,width:"64rem",customClass:{content:"ai-confirm-import-content"},allowOutsideClick:!1,showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:advanced_import_object.text.confirmImport.confirmButtonText,cancelButtonText:advanced_import_object.text.confirmImport.cancelButtonText}).then(o=>{o.value&&(p(c),function(o,r){let c=o.closest(".ai-item");a=c.data("template_type"),i=c.data("template_url"),e=c.find("input[name=_wpnonce]"),n=c.find("input[name=_wp_http_referer]"),"array"===a?v(r):t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"demo_download_and_unzip",_wpnonce:e.val(),_wp_http_referer:n.val(),demo_file:i,demo_file_type:a}}).done(function(t){return t.success?(v(r),!1):(u(t.data.errorMessage?t.data.errorMessage:t.data.message,jqXHR,textStatus,errorThrown),!1)}).fail(function(t,e,n){return u("",t,e,n),!1})}(c,l))})}),o.on("click",".ai-wp-reset",function(e){e.preventDefault();let n=t(this);Swal.fire({title:advanced_import_object.text.confirmReset.title,text:advanced_import_object.text.confirmReset.text,type:"warning",allowOutsideClick:!1,showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:advanced_import_object.text.confirmReset.confirmButtonText,cancelButtonText:advanced_import_object.text.confirmReset.cancelButtonText}).then(e=>{e.value&&t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"advanced_import_before_reset",_wpnonce:n.siblings("input[name=advanced-import-reset]").val(),_wp_http_referer:n.siblings("input[name=_wp_http_referer]").val()},beforeSend:function(t){s.fire({type:"info",html:advanced_import_object.text.confirmReset.resetting}),s.showLoading()}}).done(function(e){if(!e.success)return u(e.data.message),!1;window.location.href=t(".ai-wp-reset").attr("href")}).fail(function(t,e,n){u("",t,e,n)})})}),o.on("click",".ai-filter-tabs li",function(e){if(e.preventDefault(),r)return!1;t(this).hasClass("ai-form-file-import")?(t(".ai-filter-content").addClass("hidden"),t(".ai-form").removeClass("hidden")):(t(".ai-form").addClass("hidden"),t(".ai-filter-content").removeClass("hidden"))});let c,d,f={};setTimeout(function(){let e=t(".ai-filter-content-wrapper").isotope({itemSelector:".ai-item",filter:function(){let e=t(this),n=!d||e.text().match(d),a=!c||e.is(c);return n&&a}});function n(){let n=e.isotope("getFilteredItemElements"),a=t(n);t(".ai-filter-btn").each(function(e,n){let i=t(n),o=i.attr("data-filter");if(!o)return;let r=a.filter(o).length;i.find(".ai-count").text(r)})}e.imagesLoaded().progress(function(){e.isotope("layout")}),n(),t(".ai-filter-group").on("click",".ai-filter-btn",function(){let a=t(this),i=a.parents(".ai-filter-group").attr("data-filter-group");a.siblings().removeClass("ai-filter-btn-active"),a.addClass("ai-filter-btn-active"),f[i]=a.attr("data-filter"),c=function(t){let e="";for(let n in t)e+=t[n];return e}(f),setTimeout(function(){e.isotope(),(a.hasClass("ai-fp-filter")||a.hasClass("ai-type-filter"))&&n()},300)});let a=t(".ai-search-filter").keyup(function(t,e){let n;return e=e||100,function(){clearTimeout(n);let a=arguments,i=this;n=setTimeout(function(){t.apply(i,a)},e)}}(function(){d=new RegExp(a.val(),"gi"),e.isotope(),n()}))},1),function(){let t=l("reset"),e=l("from");"true"===t&&"ai-reset-wp"===e&&Swal.fire({title:advanced_import_object.text.resetSuccess.title,type:"success",allowOutsideClick:!1,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:advanced_import_object.text.resetSuccess.confirmButtonText})}()}),setTimeout(function(){let t=window.location.href;if(new RegExp("[?|&]reset=[0-9a-zA-Z_+-|.,;]*").test(t)){let t=new URL(location);t.searchParams.delete("reset"),t.searchParams.delete("from"),history.replaceState(null,null,t)}},1500)}(jQuery);
includes/class-advanced-import-activator.php CHANGED
@@ -31,6 +31,7 @@ class Advanced_Import_Activator {
31
  */
32
  public static function activate() {
33
 
 
34
  }
35
 
36
  }
31
  */
32
  public static function activate() {
33
 
34
+ advanced_import_add_installed_time();
35
  }
36
 
37
  }
includes/class-advanced-import.php CHANGED
@@ -179,6 +179,7 @@ class Advanced_Import {
179
  /**
180
  * The class responsible for defining all actions that occur in the admin area.
181
  */
 
182
  require_once ADVANCED_IMPORT_PATH . 'admin/class-advanced-import-admin.php';
183
  require_once ADVANCED_IMPORT_PATH . 'admin/class-elementor-import.php';
184
 
@@ -248,6 +249,7 @@ class Advanced_Import {
248
  $this->loader->add_action( 'wp_loaded', advanced_import_reset_wordpress(), 'hide_reset_notice', -1 );
249
  $this->loader->add_action( 'admin_init', advanced_import_reset_wordpress(), 'reset_wizard_actions', -1 );
250
  $this->loader->add_action( 'admin_notices', advanced_import_reset_wordpress(), 'reset_wizard_notice', -1 );
 
251
 
252
  }
253
 
179
  /**
180
  * The class responsible for defining all actions that occur in the admin area.
181
  */
182
+ require_once ADVANCED_IMPORT_PATH . 'admin/class-advanced-import-tracking.php';
183
  require_once ADVANCED_IMPORT_PATH . 'admin/class-advanced-import-admin.php';
184
  require_once ADVANCED_IMPORT_PATH . 'admin/class-elementor-import.php';
185
 
249
  $this->loader->add_action( 'wp_loaded', advanced_import_reset_wordpress(), 'hide_reset_notice', -1 );
250
  $this->loader->add_action( 'admin_init', advanced_import_reset_wordpress(), 'reset_wizard_actions', -1 );
251
  $this->loader->add_action( 'admin_notices', advanced_import_reset_wordpress(), 'reset_wizard_notice', -1 );
252
+ $this->loader->add_action( 'wp_ajax_advanced_import_before_reset', advanced_import_reset_wordpress(), 'before_reset' );
253
 
254
  }
255
 
includes/functions-advanced-import.php CHANGED
@@ -8,7 +8,7 @@ function advanced_import_allowed_html( $input ) {
8
  function advanced_import_current_url() {
9
  global $pagenow;
10
  $current_url = $pagenow == 'tools.php' ? admin_url( 'tools.php?page=advanced-import-tool' ) : admin_url( 'themes.php?page=advanced-import' );
11
- return apply_filters('advanced_import_current_url', $current_url, $pagenow );
12
  }
13
 
14
  function advanced_import_get_current_theme_author() {
@@ -33,3 +33,15 @@ function advanced_import_update_option( $option, $value = '' ) {
33
  $value = apply_filters( 'advanced_import_update_value_' . $option, $value, $option );
34
  update_option( $option, $value );
35
  }
 
 
 
 
 
 
 
 
 
 
 
 
8
  function advanced_import_current_url() {
9
  global $pagenow;
10
  $current_url = $pagenow == 'tools.php' ? admin_url( 'tools.php?page=advanced-import-tool' ) : admin_url( 'themes.php?page=advanced-import' );
11
+ return apply_filters( 'advanced_import_current_url', $current_url, $pagenow );
12
  }
13
 
14
  function advanced_import_get_current_theme_author() {
33
  $value = apply_filters( 'advanced_import_update_value_' . $option, $value, $option );
34
  update_option( $option, $value );
35
  }
36
+
37
+
38
+ function advanced_import_add_installed_time() {
39
+ $helper_options = json_decode( get_option( 'advanced_import_settings_options' ), true );
40
+ if ( ! isset( $helper_options['installed_time'] ) || ! $helper_options['installed_time'] ) {
41
+ $helper_options['installed_time'] = time();
42
+ update_option(
43
+ 'advanced_import_settings_options',
44
+ wp_json_encode( $helper_options )
45
+ );
46
+ }
47
+ }
readme.txt CHANGED
@@ -6,7 +6,7 @@ Tags: import, advanced import, demo import, theme import, widget import, customi
6
  Requires at least: 5.0
7
  Tested up to: 5.9
8
  Requires PHP: 5.6.20
9
- Stable tag: 1.3.5
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -224,6 +224,10 @@ Yes, many themes are using this plugin, for an example, you can look on [CosmosW
224
 
225
  == Changelog ==
226
 
 
 
 
 
227
  = 1.3.5 - 2022-02-04 =
228
  * Added : Plugin Errors Details
229
  * Updated : Latest version test
6
  Requires at least: 5.0
7
  Tested up to: 5.9
8
  Requires PHP: 5.6.20
9
+ Stable tag: 1.3.6
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
224
 
225
  == Changelog ==
226
 
227
+ = 1.3.6 - 2022-04-27 =
228
+ * Updated : Reset plugin via ajax
229
+ * Updated : Elementor imports in some cases
230
+
231
  = 1.3.5 - 2022-02-04 =
232
  * Added : Plugin Errors Details
233
  * Updated : Latest version test