From 8f0cf330c67947db26be91f4e17e41d31a01c3d3 Mon Sep 17 00:00:00 2001 From: Gregor Capuder Date: Fri, 13 Apr 2018 09:39:02 +0200 Subject: [PATCH 01/14] Update WP content importer composer package --- composer.json | 2 +- composer.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 71e31e7..a426b30 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ } ], "require": { - "proteusthemes/wp-content-importer-v2": "^2.0.4", + "proteusthemes/wp-content-importer-v2": "^2.1.0", "monolog/monolog": "^1.23" } } diff --git a/composer.lock b/composer.lock index d390935..43ea4ef 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "0508241c889185977eb3b463c4446a07", + "content-hash": "4053d754715459ef8ebcad5eac9b5ecc", "packages": [ { "name": "monolog/monolog", @@ -86,16 +86,16 @@ }, { "name": "proteusthemes/wp-content-importer-v2", - "version": "v2.0.4", + "version": "v2.1.0", "source": { "type": "git", "url": "https://github.com/proteusthemes/WordPress-Importer.git", - "reference": "d1e61025f0a662437607d05f4463f6a6a3fb88c5" + "reference": "7414ce1bfb56a8be780c520ed63e99cac7ac403b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/proteusthemes/WordPress-Importer/zipball/d1e61025f0a662437607d05f4463f6a6a3fb88c5", - "reference": "d1e61025f0a662437607d05f4463f6a6a3fb88c5", + "url": "https://api.github.com/repos/proteusthemes/WordPress-Importer/zipball/7414ce1bfb56a8be780c520ed63e99cac7ac403b", + "reference": "7414ce1bfb56a8be780c520ed63e99cac7ac403b", "shasum": "" }, "type": "library", @@ -131,7 +131,7 @@ "wordpress", "wp" ], - "time": "2018-03-19T10:00:06+00:00" + "time": "2018-04-13T07:31:18+00:00" }, { "name": "psr/log", From 21e4a6aeda0a186db02285c14f0574c754896862 Mon Sep 17 00:00:00 2001 From: Gregor Capuder Date: Fri, 13 Apr 2018 09:43:22 +0200 Subject: [PATCH 02/14] Add AJAX callback for returning the total post items in selected content import file --- class-merlin.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/class-merlin.php b/class-merlin.php index a3169cc..6975195 100755 --- a/class-merlin.php +++ b/class-merlin.php @@ -270,6 +270,7 @@ function __construct( $config = array(), $strings = array() ) { add_action( 'admin_footer', array( $this, 'svg_sprite' ) ); add_filter( 'tgmpa_load', array( $this, 'load_tgmpa' ), 10, 1 ); add_action( 'wp_ajax_merlin_content', array( $this, '_ajax_content' ), 10, 0 ); + add_action( 'wp_ajax_merlin_get_total_content_import_items', array( $this, '_ajax_get_total_content_import_items' ), 10, 0 ); add_action( 'wp_ajax_merlin_plugins', array( $this, '_ajax_plugins' ), 10, 0 ); add_action( 'wp_ajax_merlin_child_theme', array( $this, 'generate_child' ), 10, 0 ); add_action( 'wp_ajax_merlin_activate_license', array( $this, '_ajax_activate_license' ), 10, 0 ); @@ -1807,6 +1808,28 @@ function _ajax_content() { } + /** + * AJAX call to retrieve total items (posts, pages, CPT, attachments) for the content import. + */ + public function _ajax_get_total_content_import_items() { + if ( ! check_ajax_referer( 'merlin_nonce', 'wpnonce' ) && empty( $_POST['selected_index'] ) ) { + $this->logger->error( __( 'The content importer AJAX call for retrieving total content import items failed to start, because of incorrect data.', '@@textdomain' ) ); + + wp_send_json_error( + array( + 'error' => 1, + 'message' => esc_html__( 'Invalid data!', '@@textdomain' ), + ) + ); + } + + $selected_import = intval( $_POST['selected_index'] ); + $import_files = $this->get_import_files_paths( $selected_import ); + + wp_send_json_success( $this->importer->get_number_of_posts_to_import( $import_files['content'] ) ); + } + + /** * Get import data from the selected import. * Which data does the selected import have for the import. From 0db546dacadbcc95de8458cc076cff026f8ce372 Mon Sep 17 00:00:00 2001 From: Gregor Capuder Date: Fri, 13 Apr 2018 09:45:46 +0200 Subject: [PATCH 03/14] Return additional data, when content import AJAX call finishes --- class-merlin.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/class-merlin.php b/class-merlin.php index 6975195..aa96c2d 100755 --- a/class-merlin.php +++ b/class-merlin.php @@ -1767,6 +1767,11 @@ function _ajax_content() { 'logs' => $logs, 'errors' => '', ); + + // The content import ended, so we should mark that all posts were imported. + if ( 'content' === $_POST['content'] ) { + $json['num_of_imported_posts'] = 'all'; + } } } } else { From 8c5f1ca7fe1952a83f65269607961301d675b3a0 Mon Sep 17 00:00:00 2001 From: Gregor Capuder Date: Fri, 13 Apr 2018 14:06:53 +0200 Subject: [PATCH 04/14] Add basic progress bar style --- assets/scss/merlin.scss | 4 +++- assets/scss/modules/_progress-bar.scss | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 assets/scss/modules/_progress-bar.scss diff --git a/assets/scss/merlin.scss b/assets/scss/merlin.scss index d04be42..9bc7205 100644 --- a/assets/scss/merlin.scss +++ b/assets/scss/merlin.scss @@ -145,4 +145,6 @@ p.success { @import "modules/checkmark"; -@import "modules/footer"; \ No newline at end of file +@import "modules/footer"; + +@import "modules/progress-bar"; diff --git a/assets/scss/modules/_progress-bar.scss b/assets/scss/modules/_progress-bar.scss new file mode 100644 index 0000000..3593e03 --- /dev/null +++ b/assets/scss/modules/_progress-bar.scss @@ -0,0 +1,19 @@ +.merlin { + &__progress-bar { + height: 5px; + position: relative; + border-radius: 2px; + padding: 5px; + box-shadow: inset 0 -1px 1px rgba(255, 255, 255, 0.3); + + & > span { + display: block; + height: 100%; + width: 0; + border-radius: 2px; + background-color: $green; + position: relative; + overflow: hidden; + } + } +} From 87ca027be804c97f8a9af3e4d2be03e2a0777a88 Mon Sep 17 00:00:00 2001 From: Gregor Capuder Date: Fri, 13 Apr 2018 14:08:18 +0200 Subject: [PATCH 05/14] Add progress bar HTML to the content import step --- class-merlin.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/class-merlin.php b/class-merlin.php index aa96c2d..d5e682c 100755 --- a/class-merlin.php +++ b/class-merlin.php @@ -1150,6 +1150,10 @@ protected function content() { get_import_steps_html( $import_info ); ?> +
+ +
+