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

Version Description

  • 2022-05-26 =
  • Updated : Tested up WordPress 6
  • Fixed : 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.7
Comparing to
See all releases

Code changes from version 1.3.6 to 1.3.7

admin/class-advanced-import-admin.php CHANGED
@@ -1468,42 +1468,10 @@ class Advanced_Import_Admin {
1468
  }
1469
  }
1470
 
1471
- /*check if already exists by post_name*/
1472
- if ( empty( $post_data['post_title'] ) && ! empty( $post_data['post_name'] ) ) {
1473
- global $wpdb;
1474
- $sql = "
1475
- SELECT ID, post_name, post_parent, post_type
1476
- FROM $wpdb->posts
1477
- WHERE post_name = %s
1478
- AND post_type = %s
1479
- ";
1480
- $pages = $wpdb->get_results(
1481
- $wpdb->prepare(
1482
- $sql,
1483
- array(
1484
- $post_data['post_name'],
1485
- $post_type,
1486
- )
1487
- ),
1488
- OBJECT_K
1489
- );
1490
 
1491
- $foundid = 0;
1492
- foreach ( (array) $pages as $page ) {
1493
- if ( $page->post_name == $post_data['post_name'] && empty( $page->post_title ) ) {
1494
- $foundid = $page->ID;
1495
- }
1496
- }
1497
-
1498
- /*if we have found id by post_name, imported_post_id and return*/
1499
- if ( $foundid ) {
1500
- $this->imported_post_id( $post_data['post_id'], $foundid );
1501
- return true;
1502
- }
1503
- }
1504
-
1505
- /*
1506
- check if already exists by post_name and post_title*/
1507
  /*don't use post_exists because it will dupe up on media with same name but different slug*/
1508
  if ( ! empty( $post_data['post_title'] ) && ! empty( $post_data['post_name'] ) ) {
1509
  global $wpdb;
@@ -1526,22 +1494,11 @@ class Advanced_Import_Admin {
1526
  OBJECT_K
1527
  );
1528
 
1529
- $foundid = 0;
1530
  foreach ( (array) $pages as $page ) {
1531
  if ( $page->post_name == $post_data['post_name'] ) {
1532
  $foundid = $page->ID;
1533
  }
1534
  }
1535
-
1536
- /*if we have found id by post_name and post_title, imported_post_id and return*/
1537
- $elementor_library_id = '';
1538
- if ( $foundid && 'elementor_library' != $post_type ) {
1539
- $this->imported_post_id( $post_data['post_id'], $foundid );
1540
- return true;
1541
- }
1542
- if ( $foundid && 'elementor_library' == $post_type ) {
1543
- $elementor_library_id = $foundid;
1544
- }
1545
  }
1546
 
1547
  /*
@@ -1642,6 +1599,7 @@ class Advanced_Import_Admin {
1642
  }
1643
  break;
1644
 
 
1645
  case 'elementor_library':
1646
  if ( empty( $elementor_library_id ) ) {
1647
  break;
@@ -1817,7 +1775,15 @@ class Advanced_Import_Admin {
1817
  $post_data = apply_filters( 'advanced_import_post_data', $post_data );
1818
 
1819
  /*finally insert post data*/
1820
- $post_id = wp_insert_post( $post_data, true );
 
 
 
 
 
 
 
 
1821
  if ( ! is_wp_error( $post_id ) ) {
1822
 
1823
  /*set id on imported_post_id*/
1468
  }
1469
  }
1470
 
1471
+ $foundid = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1472
 
1473
+ /*
1474
+ check if already exists by post_name and post_title*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1475
  /*don't use post_exists because it will dupe up on media with same name but different slug*/
1476
  if ( ! empty( $post_data['post_title'] ) && ! empty( $post_data['post_name'] ) ) {
1477
  global $wpdb;
1494
  OBJECT_K
1495
  );
1496
 
 
1497
  foreach ( (array) $pages as $page ) {
1498
  if ( $page->post_name == $post_data['post_name'] ) {
1499
  $foundid = $page->ID;
1500
  }
1501
  }
 
 
 
 
 
 
 
 
 
 
1502
  }
1503
 
1504
  /*
1599
  }
1600
  break;
1601
 
1602
+ /*TODO*/
1603
  case 'elementor_library':
1604
  if ( empty( $elementor_library_id ) ) {
1605
  break;
1775
  $post_data = apply_filters( 'advanced_import_post_data', $post_data );
1776
 
1777
  /*finally insert post data*/
1778
+
1779
+ if( $foundid > 0 ){
1780
+ $post_data['ID'] = $foundid;
1781
+ /*finally insert post data*/
1782
+ $post_id = wp_update_post( $post_data, true );
1783
+ }
1784
+ else{
1785
+ $post_id = wp_insert_post( $post_data, true );
1786
+ }
1787
  if ( ! is_wp_error( $post_id ) ) {
1788
 
1789
  /*set id on imported_post_id*/
admin/class-elementor-import.php CHANGED
@@ -118,7 +118,7 @@ if ( ! class_exists( 'Advanced_Import_Elementor' ) ) {
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
 
@@ -207,7 +207,7 @@ if ( ! class_exists( 'Advanced_Import_Elementor' ) ) {
207
  }
208
  }
209
 
210
- return wp_json_encode( $elementor_data );
211
  }
212
 
213
  /**
@@ -215,7 +215,7 @@ if ( ! class_exists( 'Advanced_Import_Elementor' ) ) {
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();
118
  *
119
  * @param array $item current array of demo list.
120
  * @param string $key
121
+ * @return array
122
  */
123
  public function elementor_data( $elementor_data ) {
124
 
207
  }
208
  }
209
 
210
+ return $elementor_data;
211
  }
212
 
213
  /**
215
  *
216
  * @param array $item current array of demo list.
217
  * @param string $key
218
+ * @return void
219
  */
220
  public function process_elementor_posts() {
221
  $el_posts = $this->elementor_data_posts();
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.6
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.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__ ) );
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.7
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.7' );
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__ ) );
includes/class-advanced-import-cron.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Advanced Import Cron
4
+ *
5
+ * @package Advanced Import
6
+ * @subpackage Classes/Cron
7
+ * @since 3.2.1
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+ /**
16
+ * Advanced_Import_Cron Class
17
+ *
18
+ * This class handles scheduled events
19
+ *
20
+ * @since 3.2.1
21
+ */
22
+ class Advanced_Import_Cron {
23
+
24
+ /**
25
+ * Init WordPress hook
26
+ *
27
+ * @since 3.2.1
28
+ * @see Advanced_Import_Cron::weekly_events()
29
+ */
30
+ public function __construct() {
31
+ add_filter( 'cron_schedules', array( $this, 'add_schedules' ) );
32
+ add_action( 'wp', array( $this, 'schedule_events' ) );
33
+ }
34
+
35
+ /**
36
+ * Registers new cron schedules
37
+ *
38
+ * @since 3.2.1
39
+ *
40
+ * @param array $schedules
41
+ * @return array
42
+ */
43
+ public function add_schedules( $schedules = array() ) {
44
+ /*Adds once weekly to the existing schedules*/
45
+ $schedules['weekly'] = array(
46
+ 'interval' => 604800,
47
+ 'display' => __( 'Once Weekly', 'advanced-import' ),
48
+ );
49
+
50
+ return $schedules;
51
+ }
52
+
53
+ /**
54
+ * Schedules our events
55
+ *
56
+ * @since 3.2.1
57
+ * @return void
58
+ */
59
+ public function schedule_events() {
60
+ $this->weekly_events();
61
+ $this->daily_events();
62
+ }
63
+
64
+ /**
65
+ * Schedule weekly events
66
+ *
67
+ * @access private
68
+ * @since 3.2.1
69
+ * @return void
70
+ */
71
+ private function weekly_events() {
72
+ if ( ! wp_next_scheduled( 'advanced_import_weekly_scheduled_events' ) ) {
73
+ wp_schedule_event( time(), 'weekly', 'advanced_import_weekly_scheduled_events' );
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Schedule daily events
79
+ *
80
+ * @access private
81
+ * @since 3.2.1
82
+ * @return void
83
+ */
84
+ private function daily_events() {
85
+ if ( ! wp_next_scheduled( 'advanced_import_daily_scheduled_events' ) ) {
86
+ wp_schedule_event( time(), 'daily', 'advanced_import_daily_scheduled_events' );
87
+ }
88
+ }
89
+
90
+ }
91
+ $advanced_import_cron = new Advanced_Import_Cron();
includes/class-advanced-import.php CHANGED
@@ -175,6 +175,7 @@ class Advanced_Import {
175
  * of the plugin.
176
  */
177
  require_once ADVANCED_IMPORT_PATH . 'includes/functions-advanced-import.php';
 
178
 
179
  /**
180
  * The class responsible for defining all actions that occur in the admin area.
175
  * of the plugin.
176
  */
177
  require_once ADVANCED_IMPORT_PATH . 'includes/functions-advanced-import.php';
178
+ require_once ADVANCED_IMPORT_PATH . 'includes/class-advanced-import-cron.php';
179
 
180
  /**
181
  * The class responsible for defining all actions that occur in the admin area.
includes/functions-advanced-import.php CHANGED
@@ -45,3 +45,27 @@ function advanced_import_add_installed_time() {
45
  );
46
  }
47
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  );
46
  }
47
  }
48
+
49
+ function advanced_import_add_log( $entry, $file = 'advanced-import.log', $mode = 'default' ) {
50
+ // Get WordPress uploads directory.
51
+ $upload_dir = wp_upload_dir();
52
+ $upload_dir = $upload_dir['basedir'];
53
+ // If the entry is array, json_encode.
54
+ if ( is_array( $entry ) ) {
55
+ $entry = json_encode( $entry );
56
+ }
57
+ // Write the log file.
58
+ $file = $upload_dir . '/' . $file;
59
+ if ( 'default' === $mode ) {
60
+ if ( file_exists( $file ) ) {
61
+ $mode = 'a';
62
+ } else {
63
+ $mode = 'w';
64
+ }
65
+ }
66
+
67
+ $file = fopen( $file, $mode );
68
+ $bytes = fwrite( $file, $entry . "\n" );
69
+ fclose( $file );
70
+ return $bytes;
71
+ }
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.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,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.6 - 2022-04-27 =
228
  * Updated : Reset plugin via ajax
229
  * Updated : Elementor imports in some cases
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: 6.0
8
  Requires PHP: 5.6.20
9
+ Stable tag: 1.3.7
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.7 - 2022-05-26 =
228
+ * Updated : Tested up WordPress 6
229
+ * Fixed : Elementor imports in some cases
230
+
231
  = 1.3.6 - 2022-04-27 =
232
  * Updated : Reset plugin via ajax
233
  * Updated : Elementor imports in some cases