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

Version Description

  • 2021-06-15 =
  • Added : Plugin info user consent
  • Added : 4 new hooks: advanced_import_update_option_['option-name'], advanced_import_update_value_['option-name'] , advanced_import_menu_hook_suffix and advanced_import_current_url
  • Updated : Error handling and Error Message
  • Updated : recommendedPlugins check if isset
  • Fixed : Reset Message
Download this release

Release Info

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

Code changes from version 1.3.1 to 1.3.3

admin/class-advanced-import-admin.php CHANGED
@@ -141,6 +141,16 @@ class Advanced_Import_Admin {
141
  */
142
  private $current_template_url;
143
 
 
 
 
 
 
 
 
 
 
 
144
  /**
145
  * Initialize the class and set its properties.
146
  *
@@ -197,21 +207,21 @@ class Advanced_Import_Admin {
197
  return (bool) apply_filters( 'advanced_import_is_template_available', $is_available, $item );
198
  }
199
 
200
- /**
201
- * Check if template is available to import
202
- *
203
- * @since 1.0.8
204
- * @param array $item current array of demo list.
205
- * @return boolean
206
- */
207
- public function is_pro( $item ) {
208
- $is_pro = false;
209
- if ( isset( $item['is_pro'] ) && $item['is_pro'] ) {
210
- $is_pro = true;
211
- }
212
-
213
- return (bool) apply_filters( 'advanced_import_is_pro', $is_pro, $item );
214
- }
215
 
216
  /**
217
  * Return Template Button
@@ -314,10 +324,12 @@ class Advanced_Import_Admin {
314
  '<ol><li class="warning">' . __( 'It is highly recommended to import demo on fresh WordPress installation to exactly replicate the theme demo. If no important data on your site, you can reset it from Reset Wizard at the top', 'advanced-import' ) . '</li>',
315
  '<li>' . __( 'No existing posts, pages, categories, images, custom post types or any other data will be deleted or modified.', 'advanced-import' ) . '</li>',
316
  '<li>' . __( 'It will install the plugins required for demo and activate them. Also posts, pages, images, widgets, & other data will get imported.', 'advanced-import' ) . '</li>',
 
317
  '<li>' . __( 'Please click on the Import button and wait, it will take some time to import the data.', 'advanced-import' ) . '</li></ol>'
318
  ),
319
  'confirmButtonText' => esc_html__( 'Yes, Import Demo!', 'advanced-import' ),
320
  'cancelButtonText' => esc_html__( 'Cancel', 'advanced-import' ),
 
321
  ),
322
  'confirmReset' => array(
323
  'title' => esc_html__( 'Are you sure?', 'advanced-import' ),
@@ -375,7 +387,7 @@ class Advanced_Import_Admin {
375
  public function import_menu() {
376
  $this->hook_suffix[] = add_theme_page( esc_html__( 'Demo Import ', 'advanced-import' ), esc_html__( 'Demo Import' ), 'manage_options', 'advanced-import', array( $this, 'demo_import_screen' ) );
377
  $this->hook_suffix[] = add_management_page( esc_html__( 'Advanced Import', 'advanced-import' ), esc_html__( 'Advanced Import', 'advanced-import' ), 'manage_options', 'advanced-import-tool', array( $this, 'demo_import_screen' ) );
378
-
379
  }
380
 
381
  /**
@@ -574,7 +586,7 @@ class Advanced_Import_Admin {
574
  /*finally fetch the file from remote*/
575
  $response = wp_remote_get( $demo_file );
576
 
577
- if ( is_array( $response ) && ! empty( $response['body'] ) && $response['response']['code'] == '200' ) {
578
  require_once ABSPATH . 'wp-admin/includes/file.php';
579
  WP_Filesystem();
580
  global $wp_filesystem;
@@ -781,7 +793,7 @@ class Advanced_Import_Admin {
781
  <?php
782
  echo isset( $demo_list['categories'] ) ? esc_attr( implode( ' ', $demo_list['categories'] ) ) : '';
783
  echo isset( $demo_list['type'] ) ? ' ' . esc_attr( $demo_list['type'] ) : '';
784
- echo $this->is_pro($demo_list) ? ' ai-fp-filter-pro' : ' ai-fp-filter-free';
785
  echo $this->is_template_available( $demo_list ) ? '' : ' ai-pro-item'
786
  ?>
787
  "
@@ -798,7 +810,7 @@ class Advanced_Import_Admin {
798
  <h4 class="ai-author-info"><?php esc_html_e( 'Author: ', 'advanced-import' ); ?><?php echo esc_html( isset( $demo_list['author'] ) ? $demo_list['author'] : wp_get_theme()->get( 'Author' ) ); ?></h4>
799
  <div class="ai-details"><?php esc_html_e( 'Details', 'advanced-import' ); ?></div>
800
  <?php
801
- if ( $this->is_pro($demo_list)) {
802
  ?>
803
  <span class="ai-premium-label"><?php esc_html_e( 'Premium', 'advanced-import' ); ?></span>
804
  <?php
@@ -930,7 +942,7 @@ class Advanced_Import_Admin {
930
  </div>
931
  <ul class="ai-plugins-wrap hidden">
932
  <?php
933
- $recommended_plugins = (array) $_POST['recommendedPlugins'];
934
  if ( count( $recommended_plugins ) ) {
935
  foreach ( $recommended_plugins as $index => $recommended_plugin ) {
936
  ?>
@@ -1006,12 +1018,15 @@ class Advanced_Import_Admin {
1006
  */
1007
  private function advanced_import_setup_content_steps() {
1008
 
 
 
1009
  $content = array();
1010
 
1011
  /*check if there is files*/
1012
  $content_data = $this->get_main_content_json();
1013
  foreach ( $content_data as $post_type => $post_data ) {
1014
  if ( count( $post_data ) ) {
 
1015
  $first = current( $post_data );
1016
  $post_type_title = ! empty( $first['type_title'] ) ? $first['type_title'] : ucwords( $post_type ) . 's';
1017
  $content[ $post_type ] = array(
@@ -1052,6 +1067,8 @@ class Advanced_Import_Admin {
1052
  /*check if there is files*/
1053
  $widget_data = $this->get_widgets_json();
1054
  if ( ! empty( $widget_data ) ) {
 
 
1055
  $content['widgets'] = array(
1056
  'title' => esc_html__( 'Widgets', 'advanced-import' ),
1057
  'description' => esc_html__( 'Insert default sidebar widgets as seen in the demo.', 'advanced-import' ),
@@ -1065,6 +1082,7 @@ class Advanced_Import_Admin {
1065
  }
1066
  $options_data = $this->get_theme_options_json();
1067
  if ( ! empty( $options_data ) ) {
 
1068
  $content['settings'] = array(
1069
  'title' => esc_html__( 'Settings', 'advanced-import' ),
1070
  'description' => esc_html__( 'Configure default settings.', 'advanced-import' ),
@@ -1078,6 +1096,7 @@ class Advanced_Import_Admin {
1078
  }
1079
  $content = apply_filters( $this->theme_name . '_theme_view_setup_step_content', $content );
1080
 
 
1081
  return $content;
1082
 
1083
  }
@@ -1411,6 +1430,8 @@ class Advanced_Import_Admin {
1411
  */
1412
  private function process_import_single_post( $post_type, $post_data, $delayed = 0 ) {
1413
 
 
 
1414
  $this->log( esc_html__( 'Processing ', 'advanced-import' ) . $post_type . ' ' . $post_data['post_id'] );
1415
  $original_post_data = $post_data;
1416
 
@@ -2014,7 +2035,7 @@ class Advanced_Import_Admin {
2014
 
2015
  /*finally fetch the file from remote*/
2016
  $response = wp_remote_get( $url );
2017
- if ( is_array( $response ) && ! empty( $response['body'] ) && $response['response']['code'] == '200' ) {
2018
  require_once ABSPATH . 'wp-admin/includes/file.php';
2019
  $headers = $response['headers'];
2020
  WP_Filesystem();
@@ -2176,6 +2197,8 @@ class Advanced_Import_Admin {
2176
  * return mix
2177
  * */
2178
  private function import_content_widgets_data() {
 
 
2179
  $import_widget_data = $this->get_widgets_json();
2180
  $import_widget_positions = $import_widget_data['widget_positions'];
2181
  $import_widget_options = $import_widget_data['widget_options'];
@@ -2200,12 +2223,12 @@ class Advanced_Import_Admin {
2200
 
2201
  $new_options = apply_filters( 'advanced_import_new_options', $new_options );
2202
 
2203
- update_option( 'widget_' . $widget_name, $new_options );
2204
  }
2205
 
2206
  $sidebars_widgets = array_merge( $widget_positions, $import_widget_positions );
2207
  $sidebars_widgets = apply_filters( 'advanced_import_sidebars_widgets', $sidebars_widgets, $this );
2208
- update_option( 'sidebars_widgets', $sidebars_widgets );
2209
 
2210
  return true;
2211
 
@@ -2226,6 +2249,7 @@ class Advanced_Import_Admin {
2226
  * return mix
2227
  * */
2228
  public function import_menu_and_options() {
 
2229
 
2230
  /*final wrap up of delayed posts.*/
2231
  $this->process_delayed_posts( true );
@@ -2269,7 +2293,7 @@ class Advanced_Import_Admin {
2269
  $option = str_replace( $cat_id, $new_cat_id, $option );
2270
  }
2271
  }
2272
- update_option( $option, $value );
2273
  }
2274
  }
2275
 
@@ -2290,7 +2314,7 @@ class Advanced_Import_Admin {
2290
 
2291
  global $wp_rewrite;
2292
  $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
2293
- update_option( 'rewrite_rules', false );
2294
  $wp_rewrite->flush_rules( true );
2295
 
2296
  return true;
141
  */
142
  private $current_template_url;
143
 
144
+ /**
145
+ * Total requests
146
+ *
147
+ * @since 1.3.3
148
+ * @access public
149
+ * @var int $total_request Store total request for progress bar.
150
+ */
151
+ private $total_request;
152
+ private $current_request = 0;
153
+
154
  /**
155
  * Initialize the class and set its properties.
156
  *
207
  return (bool) apply_filters( 'advanced_import_is_template_available', $is_available, $item );
208
  }
209
 
210
+ /**
211
+ * Check if template is available to import
212
+ *
213
+ * @since 1.0.8
214
+ * @param array $item current array of demo list.
215
+ * @return boolean
216
+ */
217
+ public function is_pro( $item ) {
218
+ $is_pro = false;
219
+ if ( isset( $item['is_pro'] ) && $item['is_pro'] ) {
220
+ $is_pro = true;
221
+ }
222
+
223
+ return (bool) apply_filters( 'advanced_import_is_pro', $is_pro, $item );
224
+ }
225
 
226
  /**
227
  * Return Template Button
324
  '<ol><li class="warning">' . __( 'It is highly recommended to import demo on fresh WordPress installation to exactly replicate the theme demo. If no important data on your site, you can reset it from Reset Wizard at the top', 'advanced-import' ) . '</li>',
325
  '<li>' . __( 'No existing posts, pages, categories, images, custom post types or any other data will be deleted or modified.', 'advanced-import' ) . '</li>',
326
  '<li>' . __( 'It will install the plugins required for demo and activate them. Also posts, pages, images, widgets, & other data will get imported.', 'advanced-import' ) . '</li>',
327
+ '<li class="ai-plugin-info">' . __( 'The demo will install following plugin/s:', 'advanced-import' ) . 'ai_replace_plugins' . '</li>' .
328
  '<li>' . __( 'Please click on the Import button and wait, it will take some time to import the data.', 'advanced-import' ) . '</li></ol>'
329
  ),
330
  'confirmButtonText' => esc_html__( 'Yes, Import Demo!', 'advanced-import' ),
331
  'cancelButtonText' => esc_html__( 'Cancel', 'advanced-import' ),
332
+ 'no_plugins' => esc_html__( 'No plugins will be installed.', 'advanced-import' ),
333
  ),
334
  'confirmReset' => array(
335
  'title' => esc_html__( 'Are you sure?', 'advanced-import' ),
387
  public function import_menu() {
388
  $this->hook_suffix[] = add_theme_page( esc_html__( 'Demo Import ', 'advanced-import' ), esc_html__( 'Demo Import' ), 'manage_options', 'advanced-import', array( $this, 'demo_import_screen' ) );
389
  $this->hook_suffix[] = add_management_page( esc_html__( 'Advanced Import', 'advanced-import' ), esc_html__( 'Advanced Import', 'advanced-import' ), 'manage_options', 'advanced-import-tool', array( $this, 'demo_import_screen' ) );
390
+ $this->hook_suffix = apply_filters( 'advanced_import_menu_hook_suffix', $this->hook_suffix );
391
  }
392
 
393
  /**
586
  /*finally fetch the file from remote*/
587
  $response = wp_remote_get( $demo_file );
588
 
589
+ if ( is_array( $response ) && ! is_wp_error( $response ) ) {
590
  require_once ABSPATH . 'wp-admin/includes/file.php';
591
  WP_Filesystem();
592
  global $wp_filesystem;
793
  <?php
794
  echo isset( $demo_list['categories'] ) ? esc_attr( implode( ' ', $demo_list['categories'] ) ) : '';
795
  echo isset( $demo_list['type'] ) ? ' ' . esc_attr( $demo_list['type'] ) : '';
796
+ echo $this->is_pro( $demo_list ) ? ' ai-fp-filter-pro' : ' ai-fp-filter-free';
797
  echo $this->is_template_available( $demo_list ) ? '' : ' ai-pro-item'
798
  ?>
799
  "
810
  <h4 class="ai-author-info"><?php esc_html_e( 'Author: ', 'advanced-import' ); ?><?php echo esc_html( isset( $demo_list['author'] ) ? $demo_list['author'] : wp_get_theme()->get( 'Author' ) ); ?></h4>
811
  <div class="ai-details"><?php esc_html_e( 'Details', 'advanced-import' ); ?></div>
812
  <?php
813
+ if ( $this->is_pro( $demo_list ) ) {
814
  ?>
815
  <span class="ai-premium-label"><?php esc_html_e( 'Premium', 'advanced-import' ); ?></span>
816
  <?php
942
  </div>
943
  <ul class="ai-plugins-wrap hidden">
944
  <?php
945
+ $recommended_plugins = isset( $_POST['recommendedPlugins'] ) ? (array) $_POST['recommendedPlugins'] : array();
946
  if ( count( $recommended_plugins ) ) {
947
  foreach ( $recommended_plugins as $index => $recommended_plugin ) {
948
  ?>
1018
  */
1019
  private function advanced_import_setup_content_steps() {
1020
 
1021
+ $total_content = 0;
1022
+
1023
  $content = array();
1024
 
1025
  /*check if there is files*/
1026
  $content_data = $this->get_main_content_json();
1027
  foreach ( $content_data as $post_type => $post_data ) {
1028
  if ( count( $post_data ) ) {
1029
+ $total_content += count( $post_data );
1030
  $first = current( $post_data );
1031
  $post_type_title = ! empty( $first['type_title'] ) ? $first['type_title'] : ucwords( $post_type ) . 's';
1032
  $content[ $post_type ] = array(
1067
  /*check if there is files*/
1068
  $widget_data = $this->get_widgets_json();
1069
  if ( ! empty( $widget_data ) ) {
1070
+ $total_content += 1;
1071
+
1072
  $content['widgets'] = array(
1073
  'title' => esc_html__( 'Widgets', 'advanced-import' ),
1074
  'description' => esc_html__( 'Insert default sidebar widgets as seen in the demo.', 'advanced-import' ),
1082
  }
1083
  $options_data = $this->get_theme_options_json();
1084
  if ( ! empty( $options_data ) ) {
1085
+ $total_content += 1;
1086
  $content['settings'] = array(
1087
  'title' => esc_html__( 'Settings', 'advanced-import' ),
1088
  'description' => esc_html__( 'Configure default settings.', 'advanced-import' ),
1096
  }
1097
  $content = apply_filters( $this->theme_name . '_theme_view_setup_step_content', $content );
1098
 
1099
+ $this->total_request = $total_content;
1100
  return $content;
1101
 
1102
  }
1430
  */
1431
  private function process_import_single_post( $post_type, $post_data, $delayed = 0 ) {
1432
 
1433
+ $this->current_request = $this->current_request + 1;
1434
+
1435
  $this->log( esc_html__( 'Processing ', 'advanced-import' ) . $post_type . ' ' . $post_data['post_id'] );
1436
  $original_post_data = $post_data;
1437
 
2035
 
2036
  /*finally fetch the file from remote*/
2037
  $response = wp_remote_get( $url );
2038
+ if ( is_array( $response ) && ! is_wp_error( $response ) ) {
2039
  require_once ABSPATH . 'wp-admin/includes/file.php';
2040
  $headers = $response['headers'];
2041
  WP_Filesystem();
2197
  * return mix
2198
  * */
2199
  private function import_content_widgets_data() {
2200
+ $this->current_request = $this->current_request + 1;
2201
+
2202
  $import_widget_data = $this->get_widgets_json();
2203
  $import_widget_positions = $import_widget_data['widget_positions'];
2204
  $import_widget_options = $import_widget_data['widget_options'];
2223
 
2224
  $new_options = apply_filters( 'advanced_import_new_options', $new_options );
2225
 
2226
+ advanced_import_update_option( 'widget_' . $widget_name, $new_options );
2227
  }
2228
 
2229
  $sidebars_widgets = array_merge( $widget_positions, $import_widget_positions );
2230
  $sidebars_widgets = apply_filters( 'advanced_import_sidebars_widgets', $sidebars_widgets, $this );
2231
+ advanced_import_update_option( 'sidebars_widgets', $sidebars_widgets );
2232
 
2233
  return true;
2234
 
2249
  * return mix
2250
  * */
2251
  public function import_menu_and_options() {
2252
+ $this->current_request = $this->current_request + 1;
2253
 
2254
  /*final wrap up of delayed posts.*/
2255
  $this->process_delayed_posts( true );
2293
  $option = str_replace( $cat_id, $new_cat_id, $option );
2294
  }
2295
  }
2296
+ advanced_import_update_option( $option, $value );
2297
  }
2298
  }
2299
 
2314
 
2315
  global $wp_rewrite;
2316
  $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
2317
+ advanced_import_update_option( 'rewrite_rules', false );
2318
  $wp_rewrite->flush_rules( true );
2319
 
2320
  return true;
admin/class-reset.php CHANGED
@@ -66,7 +66,7 @@ class Advanced_Import_Reset_WordPress {
66
  $hide_notice = sanitize_text_field( $_GET['advanced-import-hide-notice'] );
67
 
68
  if ( ! empty( $hide_notice ) && 'reset_notice' == $hide_notice ) {
69
- update_option( 'advanced_import_reset_notice', 1 );
70
  }
71
  }
72
  }
66
  $hide_notice = sanitize_text_field( $_GET['advanced-import-hide-notice'] );
67
 
68
  if ( ! empty( $hide_notice ) && 'reset_notice' == $hide_notice ) {
69
+ advanced_import_update_option( 'advanced_import_reset_notice', 1 );
70
  }
71
  }
72
  }
advanced-import.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
  // If this file is called directly, abort.
3
  if ( ! defined( 'WPINC' ) ) {
4
- echo 'Hi there! I\'m just a plugin, not much I can do when called directly.';
5
- exit;
6
  }
7
  /**
8
  *
@@ -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.1
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.1' );
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__ ) );
@@ -44,8 +44,8 @@ define( 'ADVANCED_IMPORT_TEMP_UPLOADS', $advanced_import_temp_uploads );
44
  * This action is documented in includes/class-advanced-import-activator.php
45
  */
46
  function activate_advanced_import() {
47
- require_once ADVANCED_IMPORT_PATH . 'includes/class-advanced-import-activator.php';
48
- Advanced_Import_Activator::activate();
49
  }
50
 
51
  /**
@@ -53,8 +53,8 @@ function activate_advanced_import() {
53
  * This action is documented in includes/class-advanced-import-deactivator.php
54
  */
55
  function deactivate_advanced_import() {
56
- require_once ADVANCED_IMPORT_PATH . 'includes/class-advanced-import-deactivator.php';
57
- Advanced_Import_Deactivator::deactivate();
58
  }
59
 
60
  register_activation_hook( __FILE__, 'activate_advanced_import' );
@@ -76,6 +76,6 @@ require ADVANCED_IMPORT_PATH . 'includes/class-advanced-import.php';
76
  * @since 1.0.0
77
  */
78
  function advanced_import() {
79
- return Advanced_Import::instance();
80
  }
81
  advanced_import();
1
  <?php
2
  // If this file is called directly, abort.
3
  if ( ! defined( 'WPINC' ) ) {
4
+ echo 'Hi there! I\'m just a plugin, not much I can do when called directly.';
5
+ exit;
6
  }
7
  /**
8
  *
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.3
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.3' );
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__ ) );
44
  * This action is documented in includes/class-advanced-import-activator.php
45
  */
46
  function activate_advanced_import() {
47
+ require_once ADVANCED_IMPORT_PATH . 'includes/class-advanced-import-activator.php';
48
+ Advanced_Import_Activator::activate();
49
  }
50
 
51
  /**
53
  * This action is documented in includes/class-advanced-import-deactivator.php
54
  */
55
  function deactivate_advanced_import() {
56
+ require_once ADVANCED_IMPORT_PATH . 'includes/class-advanced-import-deactivator.php';
57
+ Advanced_Import_Deactivator::deactivate();
58
  }
59
 
60
  register_activation_hook( __FILE__, 'activate_advanced_import' );
76
  * @since 1.0.0
77
  */
78
  function advanced_import() {
79
+ return Advanced_Import::instance();
80
  }
81
  advanced_import();
assets/js/advanced-import-admin.min.js CHANGED
@@ -1 +1 @@
1
- !function(t){let e,n,i,o,a=t(document),r=!1,c=!1;const l=function(t){let e,n,i=window.location.search.substring(1).split("&");for(n=0;n<i.length;n++)if((e=i[n].split("="))[0]===t)return void 0===e[1]||decodeURIComponent(e[1])},u=Swal.mixin({position:"bottom-end",showConfirmButton:!1,allowOutsideClick:!1,allowEscapeKey:!1,toast:!0}),d=function(e){t("#ai-demo-popup").html(e),u.fire({type:"info",html:t("#ai-demo-popup .ai-notification-title").html()}),u.showLoading()},p=function(t=null,e=null,n=null,i=null){let o=advanced_import_object.text.failedImport.text;o+=t||e||n||i?"<br/>"+advanced_import_object.text.failedImport.code:"",o+=t||"",o+=e||"",o+=n||"",o+=i||"",u.fire({type:"error",html:o}),f()},s=function(e=!1){u.fire({type:"info",html:t(".ai-notification-title").html()}),u.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:o,template_type:i}}).done(function(e){d(e),(new function(){let e,n=0,a="",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())):(e.find("span").text(advanced_import_object.text.error),l())}function l(){e&&(e.data("done-item")||(n++,e.attr("data-done-item",1)),e.find(".spinner").remove());let r=!1,u=t("tr.ai-available-content");u.each(function(){let n=t(this);""===a||r?(a=n.data("content"),e=n,function(){if(a){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:a,template_url:o,template_type:i}}).done(c).fail(c):(e.find("span").text(advanced_import_object.text.skip),setTimeout(l,300))}}(),r=!1):n.data("content")===a&&(r=!0)}),n>=u.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()}).fail(function(t,e,n){return p("",t,e,n),!1}),!1}function v(i){return t.ajax({type:"POST",url:advanced_import_object.ajaxurl,data:{action:"plugin_screen",_wpnonce:e.val(),_wp_http_referer:n.val(),recommendedPlugins:i}}).done(function(i){d(i),u.showLoading(),t("#ai-demo-popup .ai-plugins-wrap").find("li").each(function(){return function i(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:n.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(o.attr("data-completed",1),!o.next("li").length)return h(),!1;setTimeout(i(o.next("li")),1e3)}else setTimeout(i(o),1e3)}).fail(function(t,e,n){return p("",t,e,n),!1})}(t(this)),!1})}).fail(function(t,e,n){return p("",t,e,n),!1}),!1}a.ready(function(){a.on("submit","#ai-upload-zip-form",function(i){if(i.preventDefault(),r)return!1;!function(i){if(void 0===window.FormData)return!0;let o=new FormData,a=i.find("#ai-upload-zip-archive"),r=t("#ai-empty-file");if(!a.val())return r.show(),p(r.html()),!1;r.hide(),s();let c=a[0].files[0];e=i.find("input[name=_wpnonce]"),n=i.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",n.val()),a.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):(p(t.data.message),!1)}).fail(function(t,e,n){return p("",t,e,n),!1})}(t(this))}),a.on("click",".ai-item .ai-demo-import",function(a){if(a.preventDefault(),r)return!1;let c=t(this),l=t(this).data("plugins");Swal.fire({title:advanced_import_object.text.confirmImport.title,html:advanced_import_object.text.confirmImport.html,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(a=>{a.value&&(s(c),function(a,r){let c=a.closest(".ai-item");i=c.data("template_type"),o=c.data("template_url"),e=c.find("input[name=_wpnonce]"),n=c.find("input[name=_wp_http_referer]"),"array"===i?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:o,demo_file_type:i}}).done(function(t){return t.success?(v(r),!1):(p("",jqXHR,textStatus,errorThrown),!1)}).fail(function(t,e,n){return p("",t,e,n),!1})}(c,l))})}),a.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"))})}),a.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,u,d={};setTimeout(function(){let e=t(".ai-filter-content-wrapper").isotope({itemSelector:".ai-item",filter:function(){let e=t(this),n=!u||e.text().match(u),i=!c||e.is(c);return n&&i}});function n(){let n=e.isotope("getFilteredItemElements"),i=t(n);t(".ai-filter-btn").each(function(e,n){let o=t(n),a=o.attr("data-filter");if(!a)return;let r=i.filter(a).length;o.find(".ai-count").text(r)})}e.imagesLoaded().progress(function(){e.isotope("layout")}),n(),t(".ai-filter-group").on("click",".ai-filter-btn",function(){let i=t(this),o=i.parents(".ai-filter-group").attr("data-filter-group");i.siblings().removeClass("ai-filter-btn-active"),i.addClass("ai-filter-btn-active"),d[o]=i.attr("data-filter"),c=function(t){let e="";for(let n in t)e+=t[n];return e}(d),setTimeout(function(){e.isotope(),(i.hasClass("ai-fp-filter")||i.hasClass("ai-type-filter"))&&n()},300)});let i=t(".ai-search-filter").keyup(function(t,e){let n;return e=e||100,function(){clearTimeout(n);let i=arguments,o=this;n=setTimeout(function(){t.apply(o,i)},e)}}(function(){u=new RegExp(i.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})}()})}(jQuery);
1
+ !function(t){let e,n,a,o,i=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}),u=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()):d(e.data.message)},d=function(t=null,e=null,n=null,a=null){let o=advanced_import_object.text.failedImport.text;o+=t||e||n||a?"<br/>"+advanced_import_object.text.failedImport.code:"",o+=t||"",o+=e||"",o+=n||"",o+=a||"",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:n.val(),template_url:o,template_type:a}}).done(function(e){if("object"!=typeof e||null===e||e.success){u(e),(new function(){let e,n=0,i="",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()):d(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);""===i||r?(i=n.data("content"),e=n,function(){if(i){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:i,template_url:o,template_type:a}}).done(c).fail(c):(e.find("span").text(advanced_import_object.text.skip),setTimeout(l,300))}}(),r=!1):n.data("content")===i&&(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 d(e.data.errorMessage?e.data.errorMessage:e.data.message)}).fail(function(t,e,n){return d("",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){u(a),s.showLoading(),t("#ai-demo-popup .ai-plugins-wrap").find("li").each(function(){return function a(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:n.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(a(o.next("li")),1e3)}else d(t.data.errorMessage?t.data.errorMessage:t.data.message);else setTimeout(a(o),1e3)}).fail(function(t,e,n){return d("",t,e,n),!1})}(t(this)),!1})}).fail(function(t,e,n){return d("",t,e,n),!1}),!1}i.ready(function(){i.on("submit","#ai-upload-zip-form",function(a){if(a.preventDefault(),r)return!1;!function(a){if(void 0===window.FormData)return!0;let o=new FormData,i=a.find("#ai-upload-zip-archive"),r=t("#ai-empty-file");if(!i.val())return r.show(),d(r.html()),!1;r.hide(),p();let c=i[0].files[0];e=a.find("input[name=_wpnonce]"),n=a.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",n.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):(d(t.data.message),!1)}).fail(function(t,e,n){return d("",t,e,n),!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="",u=advanced_import_object.text.confirmImport.html;l?(l.forEach(function(t,e){t.name&&(s+=" "+t.name,e<l.length-1&&(s+=","))}),u=u.replace("ai_replace_plugins",s)):u=u.replace("ai_replace_plugins",advanced_import_object.text.confirmImport.no_plugins),Swal.fire({title:advanced_import_object.text.confirmImport.title,html:u,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");a=c.data("template_type"),o=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:o,demo_file_type:a}}).done(function(t){return t.success?(v(r),!1):(d("",jqXHR,textStatus,errorThrown),!1)}).fail(function(t,e,n){return d("",t,e,n),!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,u={};setTimeout(function(){let e=t(".ai-filter-content-wrapper").isotope({itemSelector:".ai-item",filter:function(){let e=t(this),n=!s||e.text().match(s),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 o=t(n),i=o.attr("data-filter");if(!i)return;let r=a.filter(i).length;o.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),o=a.parents(".ai-filter-group").attr("data-filter-group");a.siblings().removeClass("ai-filter-btn-active"),a.addClass("ai-filter-btn-active"),u[o]=a.attr("data-filter"),c=function(t){let e="";for(let n in t)e+=t[n];return e}(u),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,o=this;n=setTimeout(function(){t.apply(o,a)},e)}}(function(){s=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/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 $current_url;
12
  }
13
 
14
  function advanced_import_get_current_theme_author() {
@@ -27,3 +27,9 @@ function advanced_import_get_theme_name() {
27
  $current_theme = wp_get_theme();
28
  return $current_theme->get( 'Name' );
29
  }
 
 
 
 
 
 
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() {
27
  $current_theme = wp_get_theme();
28
  return $current_theme->get( 'Name' );
29
  }
30
+
31
+ function advanced_import_update_option( $option, $value = '' ) {
32
+ $option = apply_filters( 'advanced_import_update_option_' . $option, $option, $value );
33
+ $value = apply_filters( 'advanced_import_update_value_' . $option, $value, $option );
34
+ update_option( $option, $value );
35
+ }
readme.txt CHANGED
@@ -4,9 +4,9 @@ Contributors: addonspress, codersantosh, acmeit
4
  Donate link: https://addonspress.com/
5
  Tags: import, advanced import, demo import, theme import, widget import, customizer import
6
  Requires at least: 5.0
7
- Tested up to: 5.6
8
  Requires PHP: 5.6.20
9
- Stable tag: 1.3.1
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -184,12 +184,15 @@ Here are some important list of filter hooks:
184
  - advanced_import_welcome_message
185
  - advanced_import_demo_lists
186
  - advanced_import_is_pro_active
187
- - 'advanced_import_post_data'
188
- - 'advanced_import_replace_post_ids'
189
- - 'advanced_import_replace_term_ids'
190
- - 'advanced_import_new_options'
191
- - 'advanced_import_sidebars_widgets'
192
- - 'advanced_import_complete_message'
 
 
 
193
 
194
  Here are some important list of action hooks:
195
 
@@ -210,10 +213,6 @@ We don't have any starter plugin but we have developed a plugin for [Acme Themes
210
 
211
  Yes, many themes are using this plugin, for an example, you can look on [CosmosWP Theme](https://cosmoswp.com/)
212
 
213
- = Can I deactivate this plugin? =
214
-
215
- Advanced Import is generally one-time use plugin, it is meant to be used for Demo Import or Site Migrate, once you complete your task you can safely deactivate it.
216
-
217
  == Screenshots ==
218
 
219
  1. Import Main Screen
@@ -225,6 +224,16 @@ Advanced Import is generally one-time use plugin, it is meant to be used for Dem
225
 
226
  == Changelog ==
227
 
 
 
 
 
 
 
 
 
 
 
228
  = 1.3.1 - 2021-01-27 =
229
  * Added : Filter list tab active design
230
  * Updated : is_pro check more strictly
4
  Donate link: https://addonspress.com/
5
  Tags: import, advanced import, demo import, theme import, widget import, customizer import
6
  Requires at least: 5.0
7
+ Tested up to: 5.7.2
8
  Requires PHP: 5.6.20
9
+ Stable tag: 1.3.3
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
184
  - advanced_import_welcome_message
185
  - advanced_import_demo_lists
186
  - advanced_import_is_pro_active
187
+ - advanced_import_post_data
188
+ - advanced_import_replace_post_ids
189
+ - advanced_import_replace_term_ids
190
+ - advanced_import_new_options
191
+ - advanced_import_sidebars_widgets
192
+ - advanced_import_complete_message
193
+ - advanced_import_update_option_['option-name']
194
+ - advanced_import_update_value_['option-name']
195
+ - advanced_import_menu_hook_suffix
196
 
197
  Here are some important list of action hooks:
198
 
213
 
214
  Yes, many themes are using this plugin, for an example, you can look on [CosmosWP Theme](https://cosmoswp.com/)
215
 
 
 
 
 
216
  == Screenshots ==
217
 
218
  1. Import Main Screen
224
 
225
  == Changelog ==
226
 
227
+ = 1.3.3 - 2021-06-15 =
228
+ * Added : Plugin info user consent
229
+ * Added : 4 new hooks: advanced_import_update_option_['option-name'], advanced_import_update_value_['option-name'] , advanced_import_menu_hook_suffix and advanced_import_current_url
230
+ * Updated : Error handling and Error Message
231
+ * Updated : recommendedPlugins check if isset
232
+ * Fixed : Reset Message
233
+
234
+ = 1.3.2 - 2021-04-22 =
235
+ * Updated : Latest version test
236
+
237
  = 1.3.1 - 2021-01-27 =
238
  * Added : Filter list tab active design
239
  * Updated : is_pro check more strictly