Skip to content

Commit 858fb20

Browse files
donmhicocapuderg
andauthoredNov 27, 2023
3.2.0 release
* Correct recommended plugins WPForms description * Make the successful import buttons filterable * Fix deprecated notice when importing redux options * Fix check condition * Install PHPUnit Polyfills and fix invalid test url * Update dev dependencies * Update node dev dependencies * Keep track of failed media imports and skip on next AJAX calls * Fix nav block import * Fix search replace overwriting already replaced text * Delete menu import-related transient * Reduce transient expiration to an hour * Replace since {VERSION} with package JSON version * Add replace_ver task in build task * Add loading lazy attribute in import preview image * Update AwesomeMotive/WordPressImporter to 3.0.5 * Fix old action hooks not running * Update basic plugin details * 3.2.0 release --------- Co-authored-by: Gregor Capuder <capuderg@gmail.com>
1 parent e0df067 commit 858fb20

21 files changed

+6778
-3501
lines changed
 

‎assets/css/main.css

+7-186
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎assets/css/main.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎assets/js/main.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎composer.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
}
1616
},
1717
"require": {
18-
"awesomemotive/wp-content-importer-v2": "^3.0.4"
18+
"awesomemotive/wp-content-importer-v2": "^3.0.5"
19+
},
20+
"require-dev": {
21+
"yoast/phpunit-polyfills": "^2.0"
1922
}
2023
}

‎composer.lock

+1,683-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎gulpfile.js

+54-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
/**
22
* Load plugins.
33
*/
4-
var gulp = require( 'gulp' ),
4+
import autoprefixer from 'gulp-autoprefixer';
5+
import debug from 'gulp-debug';
6+
import { createRequire } from "module";
7+
const require = createRequire(import.meta.url);
8+
9+
const gulp = require( 'gulp' ),
510
cached = require( 'gulp-cached' ),
6-
sass = require( 'gulp-sass' ),
7-
prefix = require( 'gulp-autoprefixer' ),
11+
sass = require('gulp-sass')(require('sass')),
812
sourcemaps = require( 'gulp-sourcemaps' ),
913
rename = require( 'gulp-rename' ),
10-
debug = require( 'gulp-debug' ),
1114
uglify = require( 'gulp-uglify' ),
1215
copy = require( 'gulp-copy' ),
1316
readme = require( 'gulp-readme-to-markdown' ),
17+
replace = require( 'gulp-replace' ),
18+
packageJSON = require( './package.json' ),
1419
exec = require( 'child_process' ).exec;
1520

16-
var plugin = {
21+
const plugin = {
1722
name: 'One Click Demo Import',
1823
slug: 'one-click-demo-import',
1924
files: [
@@ -61,7 +66,16 @@ var plugin = {
6166
js: [
6267
'assets/js/*.js',
6368
'!assets/js/*.min.js',
64-
]
69+
],
70+
files_replace_ver: [
71+
"**/*.php",
72+
"**/*.js",
73+
"!**/*.min.js",
74+
"!languages/**",
75+
"!node_modules/**",
76+
"!vendor/**",
77+
"!gulpfile.js",
78+
],
6579
};
6680

6781
/**
@@ -73,7 +87,7 @@ gulp.task( 'css', function () {
7387
.pipe( cached( 'processCSS' ) )
7488
.pipe( sourcemaps.init() )
7589
.pipe( sass( { outputStyle: 'expanded' } ).on( 'error', sass.logError ) )
76-
.pipe( prefix() )
90+
.pipe( autoprefixer() )
7791
.pipe( rename( function ( path ) {
7892
path.dirname = '/assets/css';
7993
path.extname = '.css';
@@ -82,7 +96,7 @@ gulp.task( 'css', function () {
8296
.pipe( gulp.dest( './' ) )
8397
// Minified file.
8498
.pipe( sass( { outputStyle: 'compressed' } ).on( 'error', sass.logError ) )
85-
.pipe( prefix() )
99+
.pipe( autoprefixer() )
86100
.pipe( rename( function ( path ) {
87101
path.dirname = '/assets/css';
88102
path.extname = '.min.css';
@@ -143,10 +157,41 @@ gulp.task( 'copy', function () {
143157
.pipe( debug( { title: '[copy]' } ) );
144158
} );
145159

160+
/**
161+
* Replace plugin version with one from package.json in the main plugin file.
162+
*/
163+
gulp.task( 'replace_plugin_file_ver', function () {
164+
return gulp.src( [ 'one-click-demo-import.php' ] )
165+
.pipe(
166+
// File header.
167+
replace(
168+
/Version: ((\*)|([0-9]+(\.((\*)|([0-9]+(\.((\*)|([0-9]+)))?)))?))/gm,
169+
'Version: ' + packageJSON.version
170+
)
171+
)
172+
.pipe( gulp.dest( './' ) );
173+
} );
174+
175+
/**
176+
* Replace plugin version with one from package.json in @since comments in plugin PHP and JS files.
177+
*/
178+
gulp.task( 'replace_since_ver', function() {
179+
return gulp.src( plugin.files_replace_ver )
180+
.pipe(
181+
replace(
182+
/@since {VERSION}/g,
183+
'@since ' + packageJSON.version
184+
)
185+
)
186+
.pipe( gulp.dest( './' ) );
187+
} );
188+
189+
gulp.task( 'replace_ver', gulp.series( 'replace_plugin_file_ver', 'replace_since_ver' ) );
190+
146191
/**
147192
* Task: build.
148193
*/
149-
gulp.task( 'build', gulp.series( gulp.parallel( 'css', 'js', 'pot' ), 'copy' ) );
194+
gulp.task( 'build', gulp.series( gulp.parallel( 'css', 'js', 'pot' ), 'replace_ver', 'copy' ) );
150195

151196
/**
152197
* Look out for relevant sass/js changes.

‎inc/Helpers.php

+44-4
Original file line numberDiff line numberDiff line change
@@ -704,16 +704,21 @@ public static function apply_filters( $hook, $default_data ) {
704704
* but we needed to make sure backwards compatibility is in place.
705705
* This method should be used for all do_action calls.
706706
*
707+
* @since 3.2.0 Run both `$hook` and `pt-$hook` actions.
708+
*
707709
* @param string $hook The action hook name.
708710
* @param mixed ...$arg Optional. Additional arguments which are passed on to the
709711
* functions hooked to the action. Default empty.
710712
*/
711713
public static function do_action( $hook, ...$arg ) {
712-
if ( has_action( $hook ) ) {
713-
do_action( $hook, ...$arg );
714-
} else if ( has_action( "pt-$hook" ) ) {
715-
do_action( "pt-$hook", ...$arg );
714+
do_action( $hook, ...$arg );
715+
716+
$args = [];
717+
foreach ( $arg as $argument ) {
718+
$args[] = $argument;
716719
}
720+
721+
do_action_deprecated( "pt-$hook", $args, '3.0.0', $hook );
717722
}
718723

719724
/**
@@ -756,4 +761,39 @@ public static function get_plugin_page_setup_data() {
756761
'menu_slug' => 'one-click-demo-import',
757762
) );
758763
}
764+
765+
/**
766+
* Get the failed attachment imports.
767+
*
768+
* @since 3.2.0
769+
*
770+
* @return mixed
771+
*/
772+
public static function get_failed_attachment_imports() {
773+
774+
return get_transient( 'ocdi_importer_data_failed_attachment_imports' );
775+
}
776+
777+
/**
778+
* Set the failed attachment imports.
779+
*
780+
* @since 3.2.0
781+
*
782+
* @param string $attachment_url The attachment URL that was not imported.
783+
*
784+
* @return void
785+
*/
786+
public static function set_failed_attachment_import( $attachment_url ) {
787+
788+
// Get current importer transient.
789+
$failed_media_imports = self::get_failed_attachment_imports();
790+
791+
if ( empty( $failed_media_imports ) || ! is_array( $failed_media_imports ) ) {
792+
$failed_media_imports = [];
793+
}
794+
795+
$failed_media_imports[] = $attachment_url;
796+
797+
set_transient( 'ocdi_importer_data_failed_attachment_imports', $failed_media_imports, HOUR_IN_SECONDS );
798+
}
759799
}

‎inc/Importer.php

+5
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ public function import_content( $import_file_path ) {
152152
* @return array
153153
*/
154154
public function new_ajax_request_maybe( $data ) {
155+
156+
if ( empty( $data ) ) {
157+
return $data;
158+
}
159+
155160
$time = microtime( true ) - $this->microtime;
156161

157162
// We should make a new ajax call, if the time is right.

‎inc/OneClickDemoImport.php

+238-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace OCDI;
99

10+
use WP_Error;
11+
1012
/**
1113
* One Click Demo Import class, so we don't have to worry about namespaces.
1214
*/
@@ -128,25 +130,26 @@ protected function __construct() {
128130
add_action( 'all_admin_notices', array( $this, 'finish_notice_output_capturing' ), PHP_INT_MAX );
129131
add_action( 'admin_init', array( $this, 'redirect_from_old_default_admin_page' ) );
130132
add_action( 'set_object_terms', array( $this, 'add_imported_terms' ), 10, 6 );
133+
add_filter( 'wxr_importer.pre_process.post', [ $this, 'skip_failed_attachment_import' ] );
134+
add_action( 'wxr_importer.process_failed.post', [ $this, 'handle_failed_attachment_import' ], 10, 5 );
135+
add_action( 'wp_import_insert_post', [ $this, 'save_wp_navigation_import_mapping' ], 10, 4 );
136+
add_action( 'ocdi/after_import', [ $this, 'fix_imported_wp_navigation' ] );
131137
}
132138

133-
134139
/**
135140
* Private clone method to prevent cloning of the instance of the *Singleton* instance.
136141
*
137142
* @return void
138143
*/
139144
private function __clone() {}
140145

141-
142146
/**
143147
* Empty unserialize method to prevent unserializing of the *Singleton* instance.
144148
*
145149
* @return void
146150
*/
147151
public function __wakeup() {}
148152

149-
150153
/**
151154
* Creates the plugin page and a submenu item in WP Appearance menu.
152155
*/
@@ -469,6 +472,9 @@ public function after_all_import_data_ajax_callback() {
469472
private function final_response() {
470473
// Delete importer data transient for current import.
471474
delete_transient( 'ocdi_importer_data' );
475+
delete_transient( 'ocdi_importer_data_failed_attachment_imports' );
476+
delete_transient( 'ocdi_import_menu_mapping' );
477+
delete_transient( 'ocdi_import_posts_with_nav_block' );
472478

473479
// Display final messages (success or warning messages).
474480
$response['title'] = esc_html__( 'Import Complete!', 'one-click-demo-import' );
@@ -724,6 +730,155 @@ public function add_imported_terms( $object_id, $terms, $tt_ids, $taxonomy, $app
724730
$this->imported_terms[ $taxonomy ] = array_unique( array_merge( $this->imported_terms[ $taxonomy ], $tt_ids ) );
725731
}
726732

733+
/**
734+
* Returns an empty array if current attachment to be imported is in the failed imports list.
735+
*
736+
* This will skip the current attachment import.
737+
*
738+
* @since 3.2.0
739+
*
740+
* @param array $data Post data to be imported.
741+
*
742+
* @return array
743+
*/
744+
public function skip_failed_attachment_import( $data ) {
745+
// Check if failed import.
746+
if (
747+
! empty( $data ) &&
748+
! empty( $data['post_type'] ) &&
749+
$data['post_type'] === 'attachment' &&
750+
! empty( $data['attachment_url'] )
751+
) {
752+
// Get the previously failed imports.
753+
$failed_media_imports = Helpers::get_failed_attachment_imports();
754+
755+
if ( ! empty( $failed_media_imports ) && in_array( $data['attachment_url'], $failed_media_imports, true ) ) {
756+
// If the current attachment URL is in the failed imports, then skip it.
757+
return [];
758+
}
759+
}
760+
761+
return $data;
762+
}
763+
764+
/**
765+
* Save the failed attachment import.
766+
*
767+
* @since 3.2.0
768+
*
769+
* @param WP_Error $post_id Error object.
770+
* @param array $data Raw data imported for the post.
771+
* @param array $meta Raw meta data, already processed.
772+
* @param array $comments Raw comment data, already processed.
773+
* @param array $terms Raw term data, already processed.
774+
*/
775+
public function handle_failed_attachment_import( $post_id, $data, $meta, $comments, $terms ) {
776+
777+
if ( empty( $data ) || empty( $data['post_type'] ) || $data['post_type'] !== 'attachment' ) {
778+
return;
779+
}
780+
781+
Helpers::set_failed_attachment_import( $data['attachment_url'] );
782+
}
783+
784+
/**
785+
* Save the information needed to process the navigation block.
786+
*
787+
* @since 3.2.0
788+
*
789+
* @param int $post_id The new post ID.
790+
* @param int $original_id The original post ID.
791+
* @param array $postdata The post data used to insert the post.
792+
* @param array $data Post data from the WXR file.
793+
*/
794+
public function save_wp_navigation_import_mapping( $post_id, $original_id, $postdata, $data ) {
795+
796+
if ( empty( $postdata['post_content'] ) ) {
797+
return;
798+
}
799+
800+
if ( $postdata['post_type'] !== 'wp_navigation' ) {
801+
802+
/*
803+
* Save the post ID that has navigation block in transient.
804+
*/
805+
if ( strpos( $postdata['post_content'], '<!-- wp:navigation' ) !== false ) {
806+
// Keep track of POST ID that has navigation block.
807+
$ocdi_post_nav_block = get_transient( 'ocdi_import_posts_with_nav_block' );
808+
809+
if ( empty( $ocdi_post_nav_block ) ) {
810+
$ocdi_post_nav_block = [];
811+
}
812+
813+
$ocdi_post_nav_block[] = $post_id;
814+
815+
set_transient( 'ocdi_import_posts_with_nav_block', $ocdi_post_nav_block, HOUR_IN_SECONDS );
816+
}
817+
} else {
818+
819+
/*
820+
* Save the `wp_navigation` post type mapping of the original menu ID and the new menu ID
821+
* in transient.
822+
*/
823+
$ocdi_menu_mapping = get_transient( 'ocdi_import_menu_mapping' );
824+
825+
if ( empty( $ocdi_menu_mapping ) ) {
826+
$ocdi_menu_mapping = [];
827+
}
828+
829+
// Let's save the mapping of the original menu ID and the new menu ID.
830+
$ocdi_menu_mapping[] = [
831+
'original_menu_id' => $original_id,
832+
'new_menu_id' => $post_id,
833+
];
834+
835+
set_transient( 'ocdi_import_menu_mapping', $ocdi_menu_mapping, HOUR_IN_SECONDS );
836+
}
837+
}
838+
839+
/**
840+
* Fix issue with WP Navigation block.
841+
*
842+
* We did this by looping through all the imported posts with the WP Navigation block
843+
* and replacing the original menu ID with the new menu ID.
844+
*
845+
* @since 3.2.0
846+
*/
847+
public function fix_imported_wp_navigation() {
848+
849+
// Get the `wp_navigation` import mapping.
850+
$nav_import_mapping = get_transient( 'ocdi_import_menu_mapping' );
851+
852+
// Get the post IDs that needs to be updated.
853+
$posts_nav_block = get_transient( 'ocdi_import_posts_with_nav_block' );
854+
855+
if ( empty( $nav_import_mapping ) || empty( $posts_nav_block ) ) {
856+
return;
857+
}
858+
859+
$replace_pairs = [];
860+
861+
foreach ( $nav_import_mapping as $mapping ) {
862+
$replace_pairs[ '<!-- wp:navigation {"ref":' . $mapping['original_menu_id'] . '} /-->' ] = '<!-- wp:navigation {"ref":' . $mapping['new_menu_id'] . '} /-->';
863+
}
864+
865+
// Loop through each the posts that needs to be updated.
866+
foreach ( $posts_nav_block as $post_id ) {
867+
$post_nav_block = get_post( $post_id );
868+
869+
if ( empty( $post_nav_block ) || empty( $post_nav_block->post_content ) ) {
870+
return;
871+
}
872+
873+
wp_update_post(
874+
[
875+
'ID' => $post_id,
876+
'post_content' => strtr( $post_nav_block->post_content, $replace_pairs ),
877+
]
878+
);
879+
}
880+
}
881+
727882
/**
728883
* Update imported terms count.
729884
*/
@@ -733,4 +888,84 @@ private function update_terms_count() {
733888
wp_update_term_count_now( $terms, $tax );
734889
}
735890
}
891+
892+
/**
893+
* Get the import buttons HTML for the successful import page.
894+
*
895+
* @since 3.2.0
896+
*
897+
* @return string
898+
*/
899+
public function get_import_successful_buttons_html() {
900+
901+
/**
902+
* Filter the buttons that are displayed on the successful import page.
903+
*
904+
* @since 3.2.0
905+
*
906+
* @param array $buttons {
907+
* Array of buttons.
908+
*
909+
* @type string $label Button label.
910+
* @type string $class Button class.
911+
* @type string $href Button URL.
912+
* @type string $target Button target. Can be `_blank`, `_parent`, `_top`. Default is `_self`.
913+
* }
914+
*/
915+
$buttons = Helpers::apply_filters(
916+
'ocdi/import_successful_buttons',
917+
[
918+
[
919+
'label' => __( 'Theme Settings' , 'one-click-demo-import' ),
920+
'class' => 'button button-primary button-hero',
921+
'href' => admin_url( 'customize.php' ),
922+
'target' => '_blank',
923+
],
924+
[
925+
'label' => __( 'Visit Site' , 'one-click-demo-import' ),
926+
'class' => 'button button-primary button-hero',
927+
'href' => get_home_url(),
928+
'target' => '_blank',
929+
],
930+
]
931+
);
932+
933+
if ( empty( $buttons ) || ! is_array( $buttons ) ) {
934+
return '';
935+
}
936+
937+
ob_start();
938+
939+
foreach ( $buttons as $button ) {
940+
941+
if ( empty( $button['href'] ) || empty( $button['label'] ) ) {
942+
continue;
943+
}
944+
945+
$target = '_self';
946+
if (
947+
! empty( $button['target'] ) &&
948+
in_array( strtolower( $button['target'] ), [ '_blank', '_parent', '_top' ], true )
949+
) {
950+
$target = $button['target'];
951+
}
952+
953+
$class = 'button button-primary button-hero';
954+
if ( ! empty( $button['class'] ) ) {
955+
$class = $button['class'];
956+
}
957+
958+
printf(
959+
'<a href="%1$s" class="%2$s" target="%3$s">%4$s</a>',
960+
esc_url( $button['href'] ),
961+
esc_attr( $class ),
962+
esc_attr( $target ),
963+
esc_html( $button['label'] )
964+
);
965+
}
966+
967+
$buttons_html = ob_get_clean();
968+
969+
return empty( $buttons_html ) ? '' : $buttons_html;
970+
}
736971
}

‎inc/PluginInstaller.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function get_partner_plugins() {
8383
return array(
8484
array(
8585
'name' => esc_html__( 'WPForms', 'one-click-demo-import' ),
86-
'description' => esc_html__( 'Join 4,000,000+ professionals who build smarter forms and surveys with WPForms.', 'one-click-demo-import' ),
86+
'description' => esc_html__( 'Join 6,000,000+ professionals who build smarter forms and surveys with WPForms.', 'one-click-demo-import' ),
8787
'slug' => 'wpforms-lite',
8888
'required' => false,
8989
'preselected' => true,

‎inc/ReduxImporter.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ public static function import( $import_data ) {
4444

4545
if ( isset( $redux_framework->args['opt_name'] ) ) {
4646
// Import Redux settings.
47-
$redux_framework->set_options( $redux_options_data );
47+
if ( ! empty( $redux_framework->options_class ) && method_exists( $redux_framework->options_class, 'set' ) ) {
48+
$redux_framework->options_class->set( $redux_options_data );
49+
} else {
50+
// Handle backwards compatibility.
51+
$redux_framework->set_options( $redux_options_data );
52+
}
4853

4954
// Add this message to log file.
5055
$log_added = Helpers::append_to_file( /* translators: %s - the name of the Redux option. */

‎languages/one-click-demo-import.pot

+49-49
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
msgid ""
22
msgstr ""
3-
"Project-Id-Version: One Click Demo Import 3.1.2\n"
3+
"Project-Id-Version: One Click Demo Import 3.2.0\n"
44
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/one-click-demo-import\n"
55
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
66
"Language-Team: LANGUAGE <LL@li.org>\n"
77
"MIME-Version: 1.0\n"
88
"Content-Type: text/plain; charset=UTF-8\n"
99
"Content-Transfer-Encoding: 8bit\n"
10-
"POT-Creation-Date: 2022-07-08T11:44:31+00:00\n"
10+
"POT-Creation-Date: 2023-11-23T09:35:25+00:00\n"
1111
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12-
"X-Generator: WP-CLI 2.4.0\n"
12+
"X-Generator: WP-CLI 2.8.1\n"
1313
"X-Domain: one-click-demo-import\n"
1414

1515
#. Plugin Name of the plugin
16-
#: inc/Helpers.php:753
16+
#: inc/Helpers.php:758
1717
#: inc/ViewHelpers.php:19
1818
msgid "One Click Demo Import"
1919
msgstr ""
@@ -301,139 +301,147 @@ msgstr ""
301301
msgid "not defined!"
302302
msgstr ""
303303

304-
#: inc/Helpers.php:754
304+
#: inc/Helpers.php:759
305305
#: views/plugin-page.php:290
306306
msgid "Import Demo Data"
307307
msgstr ""
308308

309-
#: inc/Importer.php:174
309+
#: inc/Importer.php:179
310310
msgid "New AJAX call!"
311311
msgstr ""
312312

313-
#: inc/OneClickDemoImport.php:229
313+
#: inc/OneClickDemoImport.php:232
314314
msgid "No preview image defined for this import."
315315
msgstr ""
316316

317-
#: inc/OneClickDemoImport.php:230
317+
#: inc/OneClickDemoImport.php:233
318318
msgid "Are you sure?"
319319
msgstr ""
320320

321-
#: inc/OneClickDemoImport.php:231
321+
#: inc/OneClickDemoImport.php:234
322322
#: views/plugin-page.php:276
323323
msgid "Cancel"
324324
msgstr ""
325325

326-
#: inc/OneClickDemoImport.php:232
326+
#: inc/OneClickDemoImport.php:235
327327
msgid "Yes, import!"
328328
msgstr ""
329329

330-
#: inc/OneClickDemoImport.php:233
330+
#: inc/OneClickDemoImport.php:236
331331
msgid "Selected demo import:"
332332
msgstr ""
333333

334-
#: inc/OneClickDemoImport.php:234
334+
#: inc/OneClickDemoImport.php:237
335335
msgid "Installing..."
336336
msgstr ""
337337

338-
#: inc/OneClickDemoImport.php:235
338+
#: inc/OneClickDemoImport.php:238
339339
#: inc/WPCLICommands.php:153
340340
msgid "Importing..."
341341
msgstr ""
342342

343-
#: inc/OneClickDemoImport.php:236
343+
#: inc/OneClickDemoImport.php:239
344344
msgid "Successfully Imported!"
345345
msgstr ""
346346

347-
#: inc/OneClickDemoImport.php:237
347+
#: inc/OneClickDemoImport.php:240
348348
#: views/plugin-page.php:270
349349
msgid "Install Plugin"
350350
msgstr ""
351351

352-
#: inc/OneClickDemoImport.php:238
352+
#: inc/OneClickDemoImport.php:241
353353
#: views/plugin-page.php:270
354354
msgid "Installed"
355355
msgstr ""
356356

357-
#: inc/OneClickDemoImport.php:239
357+
#: inc/OneClickDemoImport.php:242
358358
msgid "Import Failed"
359359
msgstr ""
360360

361-
#: inc/OneClickDemoImport.php:240
361+
#: inc/OneClickDemoImport.php:243
362362
msgid "Whoops, there was a problem importing your content."
363363
msgstr ""
364364

365-
#: inc/OneClickDemoImport.php:241
365+
#: inc/OneClickDemoImport.php:244
366366
msgid "Looks like some of the plugins failed to install. Please try again. If this issue persists, please manually install the failing plugins and come back to this step to import the theme demo data."
367367
msgstr ""
368368

369-
#: inc/OneClickDemoImport.php:242
369+
#: inc/OneClickDemoImport.php:245
370370
msgid "Invalid file type detected! Please select an XML file for the Content Import."
371371
msgstr ""
372372

373-
#: inc/OneClickDemoImport.php:243
373+
#: inc/OneClickDemoImport.php:246
374374
msgid "Invalid file type detected! Please select a JSON or WIE file for the Widgets Import."
375375
msgstr ""
376376

377-
#: inc/OneClickDemoImport.php:244
377+
#: inc/OneClickDemoImport.php:247
378378
msgid "Invalid file type detected! Please select a DAT file for the Customizer Import."
379379
msgstr ""
380380

381-
#: inc/OneClickDemoImport.php:245
381+
#: inc/OneClickDemoImport.php:248
382382
msgid "Invalid file type detected! Please select a JSON file for the Redux Import."
383383
msgstr ""
384384

385-
#: inc/OneClickDemoImport.php:262
385+
#: inc/OneClickDemoImport.php:265
386386
msgid "Manual import files are missing! Please select the import files and try again."
387387
msgstr ""
388388

389-
#: inc/OneClickDemoImport.php:277
390-
#: inc/OneClickDemoImport.php:322
389+
#: inc/OneClickDemoImport.php:280
390+
#: inc/OneClickDemoImport.php:325
391391
msgid "Manually uploaded files"
392392
msgstr ""
393393

394-
#: inc/OneClickDemoImport.php:335
395-
#: inc/OneClickDemoImport.php:346
394+
#: inc/OneClickDemoImport.php:338
395+
#: inc/OneClickDemoImport.php:349
396396
msgid "Downloaded files"
397397
msgstr ""
398398

399399
#. translators: %s - the name of the selected import.
400-
#: inc/OneClickDemoImport.php:342
400+
#: inc/OneClickDemoImport.php:345
401401
msgid "The import files for: %s were successfully downloaded!"
402402
msgstr ""
403403

404-
#: inc/OneClickDemoImport.php:351
404+
#: inc/OneClickDemoImport.php:354
405405
msgid "No import files specified!"
406406
msgstr ""
407407

408-
#: inc/OneClickDemoImport.php:474
408+
#: inc/OneClickDemoImport.php:480
409409
#: views/import.php:118
410410
msgid "Import Complete!"
411411
msgstr ""
412412

413-
#: inc/OneClickDemoImport.php:475
413+
#: inc/OneClickDemoImport.php:481
414414
#: views/import.php:121
415415
msgid "Congrats, your demo was imported successfully. You can now begin editing your site."
416416
msgstr ""
417417

418-
#: inc/OneClickDemoImport.php:476
418+
#: inc/OneClickDemoImport.php:482
419419
msgid "Successful Import"
420420
msgstr ""
421421

422-
#: inc/OneClickDemoImport.php:479
422+
#: inc/OneClickDemoImport.php:485
423423
msgid "Your import completed, but some things may not have imported properly."
424424
msgstr ""
425425

426426
#. translators: %s - link to the log file.
427-
#: inc/OneClickDemoImport.php:483
427+
#: inc/OneClickDemoImport.php:489
428428
msgid "<p><a href=\"%s\" target=\"_blank\">View error log</a> for more information.</p>"
429429
msgstr ""
430430

431+
#: inc/OneClickDemoImport.php:919
432+
msgid "Theme Settings"
433+
msgstr ""
434+
435+
#: inc/OneClickDemoImport.php:925
436+
msgid "Visit Site"
437+
msgstr ""
438+
431439
#: inc/PluginInstaller.php:85
432440
msgid "WPForms"
433441
msgstr ""
434442

435443
#: inc/PluginInstaller.php:86
436-
msgid "Join 4,000,000+ professionals who build smarter forms and surveys with WPForms."
444+
msgid "Join 6,000,000+ professionals who build smarter forms and surveys with WPForms."
437445
msgstr ""
438446

439447
#: inc/PluginInstaller.php:92
@@ -509,18 +517,18 @@ msgid "The Redux plugin is not activated, so the Redux import was skipped!"
509517
msgstr ""
510518

511519
#: inc/ReduxImporter.php:32
512-
#: inc/ReduxImporter.php:53
513-
#: inc/ReduxImporter.php:66
520+
#: inc/ReduxImporter.php:58
521+
#: inc/ReduxImporter.php:71
514522
msgid "Importing Redux settings"
515523
msgstr ""
516524

517525
#. translators: %s - the name of the Redux option.
518-
#: inc/ReduxImporter.php:51
526+
#: inc/ReduxImporter.php:56
519527
msgid "Redux settings import for: %s finished successfully!"
520528
msgstr ""
521529

522530
#. translators: %s - the name of the Redux option.
523-
#: inc/ReduxImporter.php:57
531+
#: inc/ReduxImporter.php:62
524532
msgid "The Redux option name: %s, was not found in this WP site, so it was not imported!"
525533
msgstr ""
526534

@@ -677,7 +685,7 @@ msgid "Executing action: %s ..."
677685
msgstr ""
678686

679687
#. translators: %1$s - the PHP version, %2$s and %3$s - strong HTML tags, %4$s - br HTMl tag.
680-
#: one-click-demo-import.php:58
688+
#: one-click-demo-import.php:60
681689
msgid "The %2$sOne Click Demo Import%3$s plugin requires %2$sPHP 5.6+%3$s to run properly. Please contact your hosting company and ask them to update the PHP version of your site to at least PHP 7.4%4$s Your current version of PHP: %2$s%1$s%3$s"
682690
msgstr ""
683691

@@ -764,14 +772,6 @@ msgstr ""
764772
msgid "Importing animation"
765773
msgstr ""
766774

767-
#: views/import.php:129
768-
msgid "Theme Settings"
769-
msgstr ""
770-
771-
#: views/import.php:130
772-
msgid "Visit Site"
773-
msgstr ""
774-
775775
#: views/install-plugins.php:25
776776
msgid "Install Recommended Plugins"
777777
msgstr ""

‎one-click-demo-import.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
Plugin Name: One Click Demo Import
55
Plugin URI: https://wordpress.org/plugins/one-click-demo-import/
66
Description: Import your content, widgets and theme settings with one click. Theme authors! Enable simple demo import for your theme demo data.
7-
Version: 3.1.2
7+
Version: 3.2.0
8+
Requires at least: 5.5
9+
Requires PHP: 5.6
810
Author: OCDI
911
Author URI: https://ocdi.com
1012
License: GPL3

‎package-lock.json

+4,622-3,218
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
{
2+
"version": "3.2.0",
3+
"type": "module",
24
"private": true,
35
"devDependencies": {
46
"gulp": "^4.0.2",
5-
"gulp-autoprefixer": "^7.0.1",
7+
"gulp-autoprefixer": "^9.0.0",
68
"gulp-cached": "^1.1.1",
79
"gulp-copy": "^4.0.1",
8-
"gulp-debug": "^4.0.0",
10+
"gulp-debug": "^5.0.1",
911
"gulp-readme-to-markdown": "^0.2.1",
10-
"gulp-rename": "^1.4.0",
11-
"gulp-sass": "^4.1.0",
12-
"gulp-sourcemaps": "^2.6.5",
12+
"gulp-rename": "^2.0.0",
13+
"gulp-replace": "^1.1.4",
14+
"gulp-sass": "^5.1.0",
15+
"gulp-sourcemaps": "^3.0.0",
1316
"gulp-uglify": "^3.0.2",
1417
"gulp-watch": "^5.0.1",
15-
"load-grunt-tasks": "^3.1.0"
18+
"load-grunt-tasks": "^5.1.0",
19+
"sass": "^1.69.5"
1620
},
1721
"scripts": {
1822
"gulp": "node ./node_modules/gulp/bin/gulp.js"

‎readme.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# One Click Demo Import #
22
**Contributors:** ocdi, smub, jaredatch, capuderg
33
**Tags:** import, content, demo, data, widgets, settings, redux, theme options
4-
**Requires at least:** 5.2
5-
**Tested up to:** 6.0
4+
**Requires at least:** 5.5
5+
**Tested up to:** 6.4
66
**Requires PHP:** 5.6
7-
**Stable tag:** 3.1.2
7+
**Stable tag:** 3.2.0
88
**License:** GPLv3 or later
99

1010
Import your demo content, widgets and theme settings with one click. Theme authors! Enable simple theme demo import for your users.
@@ -367,6 +367,18 @@ Please visit this [docs page](https://github.com/awesomemotive/one-click-demo-im
367367

368368
## Changelog ##
369369

370+
### 3.2.0 ###
371+
372+
*Release Date - 23rd November 2023*
373+
374+
* Added `ocdi/import_successful_buttons` filter hook that allow developers to add custom buttons in the import successful page.
375+
* Added `loading="lazy"` in import preview images for better performance.
376+
* Fixed PHP warning notice when importing non-string term metadata.
377+
* Fixed Navigation block not imported properly.
378+
* Fixed issue with failed media import resulting to infinite loop.
379+
* Fixed PHP deprecated notice when importing Redux Framework options.
380+
* Fixed issue with old action hook, `pt-{$hook}`, not running when the new `{$hook}` is also used.
381+
370382
### 3.1.2 ###
371383

372384
*Release Date - 8th July 2022*

‎readme.txt

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
=== One Click Demo Import ===
22
Contributors: ocdi, smub, jaredatch, capuderg
33
Tags: import, content, demo, data, widgets, settings, redux, theme options
4-
Requires at least: 5.2
5-
Tested up to: 6.0
4+
Requires at least: 5.5
5+
Tested up to: 6.4
66
Requires PHP: 5.6
7-
Stable tag: 3.1.2
7+
Stable tag: 3.2.0
88
License: GPLv3 or later
99

1010
Import your demo content, widgets and theme settings with one click. Theme authors! Enable simple theme demo import for your users.
@@ -59,7 +59,7 @@ You will find the import page in *wp-admin -> Appearance -> Import Demo Data*.
5959

6060
= Where are the demo import files and the log files saved? =
6161

62-
The files used in the demo import will be saved to the default WordPress uploads directory. An example of that directory would be: `../wp-content/uploads/2016/03/`.
62+
The files used in the demo import will be saved to the default WordPress uploads directory. An example of that directory would be: `../wp-content/uploads/2023/03/`.
6363

6464
The log file will also be registered in the *wp-admin -> Media* section, so you can access it easily.
6565

@@ -359,6 +359,17 @@ Please visit this [docs page](https://github.com/awesomemotive/one-click-demo-im
359359

360360
== Changelog ==
361361

362+
= 3.2.0 =
363+
*Release Date - 23rd November 2023*
364+
365+
* Added `ocdi/import_successful_buttons` filter hook that allow developers to add custom buttons in the import successful page.
366+
* Added `loading="lazy"` in import preview images for better performance.
367+
* Fixed PHP warning notice when importing non-string term metadata.
368+
* Fixed Navigation block not imported properly.
369+
* Fixed issue with failed media import resulting to infinite loop.
370+
* Fixed PHP deprecated notice when importing Redux Framework options.
371+
* Fixed issue with old action hook, `pt-{$hook}`, not running when the new `{$hook}` is also used.
372+
362373
= 3.1.2 =
363374

364375
*Release Date - 8th July 2022*

‎tests/bootstrap.php

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php
2+
/**
3+
* PHPUnit bootstrap file
4+
*
5+
* @package One_Click_Demo_Import
6+
*/
7+
8+
require_once dirname( dirname( __FILE__ ) ) . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
29

310
$_tests_dir = getenv( 'WP_TESTS_DIR' );
411
if ( ! $_tests_dir ) {

‎tests/inc/test-downloader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function test_get_content_from_url() {
116116
$this->downloader,
117117
'get_content_from_url',
118118
array(
119-
'http://invalid-url.com'
119+
'http://invalid-url.test'
120120
)
121121
);
122122

‎views/import.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,16 @@
126126
<div class="ocdi__response js-ocdi-ajax-response"></div>
127127
</div>
128128
<div class="ocdi-imported-footer">
129-
<a href="<?php echo esc_url( admin_url( 'customize.php' ) ); ?>" class="button button-primary button-hero"><?php esc_html_e( 'Theme Settings' , 'one-click-demo-import' ); ?></a>
130-
<a href="<?php echo esc_url( get_home_url() ); ?>" class="button button-primary button-hero"><?php esc_html_e( 'Visit Site' , 'one-click-demo-import' ); ?></a>
129+
<?php echo wp_kses(
130+
$this->get_import_successful_buttons_html(),
131+
[
132+
'a' => [
133+
'href' => [],
134+
'class' => [],
135+
'target' => [],
136+
],
137+
]
138+
); ?>
131139
</div>
132140
</div>
133141
</div>

‎views/plugin-page.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<div class="ocdi__theme-about">
7272
<div class="ocdi__theme-about-screenshots">
7373
<?php if ( $theme->get_screenshot() ) : ?>
74-
<div class="screenshot"><img src="<?php echo esc_url( $theme->get_screenshot() ); ?>" alt="<?php esc_attr_e( 'Theme screenshot', 'one-click-demo-import' ); ?>" /></div>
74+
<div class="screenshot"><img src="<?php echo esc_url( $theme->get_screenshot() ); ?>" alt="<?php esc_attr_e( 'Theme screenshot', 'one-click-demo-import' ); ?>" loading="lazy" /></div>
7575
<?php else : ?>
7676
<div class="screenshot blank"></div>
7777
<?php endif; ?>
@@ -336,7 +336,7 @@
336336
<div class="ocdi__gl-item js-ocdi-gl-item" data-categories="<?php echo esc_attr( Helpers::get_demo_import_item_categories( $import_file ) ); ?>" data-name="<?php echo esc_attr( strtolower( $import_file['import_file_name'] ) ); ?>">
337337
<div class="ocdi__gl-item-image-container">
338338
<?php if ( ! empty( $img_src ) ) : ?>
339-
<img class="ocdi__gl-item-image" src="<?php echo esc_url( $img_src ) ?>">
339+
<img class="ocdi__gl-item-image" src="<?php echo esc_url( $img_src ) ?>" loading="lazy">
340340
<?php else : ?>
341341
<div class="ocdi__gl-item-image ocdi__gl-item-image--no-image"><?php esc_html_e( 'No preview image.', 'one-click-demo-import' ); ?></div>
342342
<?php endif; ?>

0 commit comments

Comments
 (0)
Please sign in to comment.