Version Description
Release Date - 22 May 2016
- Preview import images can now be defined for multiple predefined import files (check FAQ "How to predefine demo imports?" for more info),
- You can now also import customizer settings.
Download this release
Release Info
Developer | capuderg |
Plugin | One Click Demo Import |
Version | 1.1.1 |
Comparing to | |
See all releases |
Code changes from version 1.1.0 to 1.1.1
- assets/css/main.css +18 -2
- assets/js/main.js +18 -0
- inc/class-ocdi-customizer-importer.php +194 -0
- inc/class-ocdi-customizer-option.php +24 -0
- inc/class-ocdi-helpers.php +49 -4
- languages/pt-ocdi.pot +81 -39
- one-click-demo-import.php +90 -16
- readme.txt +21 -8
assets/css/main.css
CHANGED
@@ -20,11 +20,11 @@
|
|
20 |
.ocdi__intro-text {
|
21 |
background-color: #f5fafd;
|
22 |
margin:10px 0;
|
23 |
-
padding: 10px;
|
24 |
color: #0C518F;
|
25 |
border: 3px solid #cae0f3;
|
26 |
clear: both;
|
27 |
-
width:
|
28 |
line-height: 18px;
|
29 |
}
|
30 |
|
@@ -34,6 +34,22 @@
|
|
34 |
list-style-type: square;
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
/* WP info notice */
|
38 |
.notice-info {
|
39 |
border-left-color: #58acfa;
|
20 |
.ocdi__intro-text {
|
21 |
background-color: #f5fafd;
|
22 |
margin:10px 0;
|
23 |
+
padding: 10px 0 10px 10px;
|
24 |
color: #0C518F;
|
25 |
border: 3px solid #cae0f3;
|
26 |
clear: both;
|
27 |
+
width: calc( 100% - 16px );
|
28 |
line-height: 18px;
|
29 |
}
|
30 |
|
34 |
list-style-type: square;
|
35 |
}
|
36 |
|
37 |
+
/* Plugin elements */
|
38 |
+
.ocdi__demo-import-preview-image-message {
|
39 |
+
font-style: italic;
|
40 |
+
}
|
41 |
+
|
42 |
+
#ocdi__demo-import-preview-image,
|
43 |
+
#ocdi__demo-import-files {
|
44 |
+
max-width: 100%;
|
45 |
+
}
|
46 |
+
|
47 |
+
@media (min-width: 992px) {
|
48 |
+
#ocdi__demo-import-preview-image {
|
49 |
+
max-width: 50%;
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
/* WP info notice */
|
54 |
.notice-info {
|
55 |
border-left-color: #58acfa;
|
assets/js/main.js
CHANGED
@@ -17,6 +17,9 @@ jQuery( function ( $ ) {
|
|
17 |
if ( $('#ocdi__widget-file-upload').length ) {
|
18 |
data.append( 'widget_file', $('#ocdi__widget-file-upload')[0].files[0] );
|
19 |
}
|
|
|
|
|
|
|
20 |
|
21 |
// AJAX call to import everything (content, widgets, before/after setup)
|
22 |
ajaxCall( data );
|
@@ -54,4 +57,19 @@ jQuery( function ( $ ) {
|
|
54 |
});
|
55 |
}
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
});
|
17 |
if ( $('#ocdi__widget-file-upload').length ) {
|
18 |
data.append( 'widget_file', $('#ocdi__widget-file-upload')[0].files[0] );
|
19 |
}
|
20 |
+
if ( $('#ocdi__customizer-file-upload').length ) {
|
21 |
+
data.append( 'customizer_file', $('#ocdi__customizer-file-upload')[0].files[0] );
|
22 |
+
}
|
23 |
|
24 |
// AJAX call to import everything (content, widgets, before/after setup)
|
25 |
ajaxCall( data );
|
57 |
});
|
58 |
}
|
59 |
|
60 |
+
// Switch preview images on select change event, but only if the img element .js-ocdi-preview-image exists.
|
61 |
+
$( '#ocdi__demo-import-files' ).on( 'change', function(){
|
62 |
+
if ( $( '.js-ocdi-preview-image' ).length ) {
|
63 |
+
|
64 |
+
// Attempt to change the image, else display message for missing image.
|
65 |
+
var currentFilePreviewImage = ocdi.import_files[ this.value ]['import_preview_image_url'] || '';
|
66 |
+
$( '.js-ocdi-preview-image' ).prop( 'src', currentFilePreviewImage );
|
67 |
+
$( '.js-ocdi-preview-image-message' ).html( '' );
|
68 |
+
|
69 |
+
if ( '' === currentFilePreviewImage ) {
|
70 |
+
$( '.js-ocdi-preview-image-message' ).html( ocdi.texts.missing_preview_image );
|
71 |
+
}
|
72 |
+
}
|
73 |
+
});
|
74 |
+
|
75 |
});
|
inc/class-ocdi-customizer-importer.php
ADDED
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class for the customizer importer used in the One Click Demo Import plugin.
|
4 |
+
*
|
5 |
+
* Code is mostly from the Customizer Export/Import plugin.
|
6 |
+
*
|
7 |
+
* @see https://wordpress.org/plugins/customizer-export-import/
|
8 |
+
* @package ocdi
|
9 |
+
*/
|
10 |
+
|
11 |
+
class OCDI_Customizer_Importer {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Imports uploaded mods and calls WordPress core customize_save actions so
|
15 |
+
* themes that hook into them can act before mods are saved to the database.
|
16 |
+
*
|
17 |
+
* Update: WP core customize_save actions were removed, because of some errors.
|
18 |
+
*
|
19 |
+
* @since 1.1.1
|
20 |
+
* @param string $import_file_path Path to the import file.
|
21 |
+
* @return void|WP_Error
|
22 |
+
*/
|
23 |
+
public static function import_customizer_options( $import_file_path ) {
|
24 |
+
|
25 |
+
// Setup global vars.
|
26 |
+
global $wp_customize;
|
27 |
+
|
28 |
+
// Setup internal vars.
|
29 |
+
$template = get_template();
|
30 |
+
|
31 |
+
// Make sure we have an import file.
|
32 |
+
if ( ! file_exists( $import_file_path ) ) {
|
33 |
+
return new WP_Error(
|
34 |
+
'missing_cutomizer_import_file',
|
35 |
+
sprintf(
|
36 |
+
esc_html__( 'The customizer import file is missing! File path: %s', 'pt-ocdi' ),
|
37 |
+
$import_file_path
|
38 |
+
)
|
39 |
+
);
|
40 |
+
}
|
41 |
+
|
42 |
+
// Get the upload data.
|
43 |
+
$raw = OCDI_Helpers::data_from_file( $import_file_path );
|
44 |
+
|
45 |
+
// Make sure we got the data.
|
46 |
+
if ( is_wp_error( $raw ) ) {
|
47 |
+
return $raw;
|
48 |
+
}
|
49 |
+
|
50 |
+
$data = unserialize( $raw );
|
51 |
+
|
52 |
+
// Data checks.
|
53 |
+
if ( ! is_array( $data ) && ( ! isset( $data['template'] ) || ! isset( $data['mods'] ) ) ) {
|
54 |
+
return new WP_Error(
|
55 |
+
'customizer_import_data_error',
|
56 |
+
esc_html__( 'The customizer import file is not in a correct format. Please make sure to use the correct customizer import file.', 'pt-ocdi' )
|
57 |
+
);
|
58 |
+
}
|
59 |
+
if ( $data['template'] !== $template ) {
|
60 |
+
return new WP_Error(
|
61 |
+
'customizer_import_wrong_theme',
|
62 |
+
esc_html__( 'The customizer import file is not suitable for current theme. You can only import customizer settings for the same theme or a child theme.', 'pt-ocdi' )
|
63 |
+
);
|
64 |
+
}
|
65 |
+
|
66 |
+
// Import images.
|
67 |
+
if ( apply_filters( 'pt-ocdi/customizer_import_images', true ) ) {
|
68 |
+
$data['mods'] = self::import_customizer_images( $data['mods'] );
|
69 |
+
}
|
70 |
+
|
71 |
+
// Import custom options.
|
72 |
+
if ( isset( $data['options'] ) ) {
|
73 |
+
|
74 |
+
// Require modified customizer options class.
|
75 |
+
if ( ! class_exists( 'WP_Customize_Setting' ) ) {
|
76 |
+
require_once ABSPATH . 'wp-includes/class-wp-customize-setting.php';
|
77 |
+
}
|
78 |
+
require PT_OCDI_PATH . 'inc/class-ocdi-customizer-option.php';
|
79 |
+
|
80 |
+
foreach ( $data['options'] as $option_key => $option_value ) {
|
81 |
+
$option = new OCDI_Customizer_Option( $wp_customize, $option_key, array(
|
82 |
+
'default' => '',
|
83 |
+
'type' => 'option',
|
84 |
+
'capability' => 'edit_theme_options',
|
85 |
+
) );
|
86 |
+
|
87 |
+
$option->import( $option_value );
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
// Loop through the mods.
|
92 |
+
foreach ( $data['mods'] as $key => $val ) {
|
93 |
+
|
94 |
+
// Save the mod.
|
95 |
+
set_theme_mod( $key, $val );
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Helper function: Customizer import - imports images for settings saved as mods.
|
101 |
+
*
|
102 |
+
* @since 1.1.1
|
103 |
+
* @param array $mods An array of customizer mods.
|
104 |
+
* @return array The mods array with any new import data.
|
105 |
+
*/
|
106 |
+
private static function import_customizer_images( $mods ) {
|
107 |
+
foreach ( $mods as $key => $val ) {
|
108 |
+
if ( self::customizer_is_image_url( $val ) ) {
|
109 |
+
$data = self::customizer_sideload_image( $val );
|
110 |
+
if ( ! is_wp_error( $data ) ) {
|
111 |
+
$mods[ $key ] = $data->url;
|
112 |
+
|
113 |
+
// Handle header image controls.
|
114 |
+
if ( isset( $mods[ $key . '_data' ] ) ) {
|
115 |
+
$mods[ $key . '_data' ] = $data;
|
116 |
+
update_post_meta( $data->attachment_id, '_wp_attachment_is_custom_header', get_stylesheet() );
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
return $mods;
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Helper function: Customizer import
|
127 |
+
* Taken from the core media_sideload_image function and
|
128 |
+
* modified to return an array of data instead of html.
|
129 |
+
*
|
130 |
+
* @since 1.1.1.
|
131 |
+
* @param string $file The image file path.
|
132 |
+
* @return array An array of image data.
|
133 |
+
*/
|
134 |
+
private static function customizer_sideload_image( $file ) {
|
135 |
+
$data = new stdClass();
|
136 |
+
|
137 |
+
if ( ! function_exists( 'media_handle_sideload' ) ) {
|
138 |
+
require_once( ABSPATH . 'wp-admin/includes/media.php' );
|
139 |
+
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
140 |
+
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
141 |
+
}
|
142 |
+
if ( ! empty( $file ) ) {
|
143 |
+
|
144 |
+
// Set variables for storage, fix file filename for query strings.
|
145 |
+
preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
|
146 |
+
$file_array = array();
|
147 |
+
$file_array['name'] = basename( $matches[0] );
|
148 |
+
|
149 |
+
// Download file to temp location.
|
150 |
+
$file_array['tmp_name'] = download_url( $file );
|
151 |
+
|
152 |
+
// If error storing temporarily, return the error.
|
153 |
+
if ( is_wp_error( $file_array['tmp_name'] ) ) {
|
154 |
+
return $file_array['tmp_name'];
|
155 |
+
}
|
156 |
+
|
157 |
+
// Do the validation and storage stuff.
|
158 |
+
$id = media_handle_sideload( $file_array, 0 );
|
159 |
+
|
160 |
+
// If error storing permanently, unlink.
|
161 |
+
if ( is_wp_error( $id ) ) {
|
162 |
+
unlink( $file_array['tmp_name'] );
|
163 |
+
return $id;
|
164 |
+
}
|
165 |
+
|
166 |
+
// Build the object to return.
|
167 |
+
$meta = wp_get_attachment_metadata( $id );
|
168 |
+
$data->attachment_id = $id;
|
169 |
+
$data->url = wp_get_attachment_url( $id );
|
170 |
+
$data->thumbnail_url = wp_get_attachment_thumb_url( $id );
|
171 |
+
$data->height = $meta['height'];
|
172 |
+
$data->width = $meta['width'];
|
173 |
+
}
|
174 |
+
|
175 |
+
return $data;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Checks to see whether a string is an image url or not.
|
180 |
+
*
|
181 |
+
* @since 1.1.1
|
182 |
+
* @param string $string The string to check.
|
183 |
+
* @return bool Whether the string is an image url or not.
|
184 |
+
*/
|
185 |
+
private static function customizer_is_image_url( $string = '' ) {
|
186 |
+
if ( is_string( $string ) ) {
|
187 |
+
if ( preg_match( '/\.(jpg|jpeg|png|gif)/i', $string ) ) {
|
188 |
+
return true;
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
return false;
|
193 |
+
}
|
194 |
+
}
|
inc/class-ocdi-customizer-option.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* A class that extends WP_Customize_Setting so we can access
|
4 |
+
* the protected updated method when importing options.
|
5 |
+
*
|
6 |
+
* Used in the Customizer importer.
|
7 |
+
*
|
8 |
+
* @since 1.1.1
|
9 |
+
* @package ocdi
|
10 |
+
*/
|
11 |
+
|
12 |
+
final class OCDI_Customizer_Option extends WP_Customize_Setting {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Import an option value for this setting.
|
16 |
+
*
|
17 |
+
* @since 1.1.1
|
18 |
+
* @param mixed $value The option value.
|
19 |
+
* @return void
|
20 |
+
*/
|
21 |
+
public function import( $value ) {
|
22 |
+
$this->update( $value );
|
23 |
+
}
|
24 |
+
}
|
inc/class-ocdi-helpers.php
CHANGED
@@ -99,6 +99,29 @@ class OCDI_Helpers {
|
|
99 |
}
|
100 |
}
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
return $downloaded_files;
|
103 |
}
|
104 |
|
@@ -423,8 +446,9 @@ class OCDI_Helpers {
|
|
423 |
);
|
424 |
|
425 |
// Handle demo content and widgets file upload.
|
426 |
-
$content_file_info
|
427 |
-
$widget_file_info
|
|
|
428 |
|
429 |
if ( empty( $content_file_info['file'] ) || isset( $content_file_info['error'] ) ) {
|
430 |
|
@@ -439,6 +463,7 @@ class OCDI_Helpers {
|
|
439 |
// Set uploaded content file.
|
440 |
$selected_import_files['content'] = $content_file_info['file'];
|
441 |
|
|
|
442 |
if ( $widget_file_info && ! isset( $widget_file_info['error'] ) ) {
|
443 |
|
444 |
// Set uploaded widget file.
|
@@ -457,6 +482,25 @@ class OCDI_Helpers {
|
|
457 |
);
|
458 |
}
|
459 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
460 |
// Add this message to log file.
|
461 |
$log_added = self::append_to_file(
|
462 |
__( 'The import files were successfully uploaded!', 'pt-ocdi' ) . self::import_file_info( $selected_import_files ),
|
@@ -481,11 +525,12 @@ class OCDI_Helpers {
|
|
481 |
ini_get( 'max_execution_time' )
|
482 |
) . PHP_EOL .
|
483 |
sprintf(
|
484 |
-
__( 'Files info:%1$sSite URL = %2$s%1$sData file = %3$s%1$sWidget file = %4$s', 'pt-ocdi' ),
|
485 |
PHP_EOL,
|
486 |
get_site_url(),
|
487 |
$selected_import_files['content'],
|
488 |
-
empty( $selected_import_files['widgets'] ) ? esc_html__( 'not defined!', 'pt-ocdi' ) : $selected_import_files['widgets']
|
|
|
489 |
);
|
490 |
}
|
491 |
|
99 |
}
|
100 |
}
|
101 |
|
102 |
+
// Get customizer import file as well. If defined!
|
103 |
+
if ( ! empty( $import_file_info['import_customizer_file_url'] ) ) {
|
104 |
+
|
105 |
+
// Retrieve customizer content from the URL.
|
106 |
+
$demo_import_customizer_content = self::get_content_from_url( $import_file_info['import_customizer_file_url'], $import_file_info['import_file_name'] );
|
107 |
+
|
108 |
+
// Return from this function if there was an error.
|
109 |
+
if ( is_wp_error( $demo_import_customizer_content ) ) {
|
110 |
+
return $demo_import_customizer_content;
|
111 |
+
}
|
112 |
+
|
113 |
+
// Setup filename path to save the customizer content.
|
114 |
+
$import_customizer_file_path = $upload_path . apply_filters( 'pt-ocdi/downloaded_customizer_file_prefix', 'demo-customizer-import-file_' ) . $start_date . apply_filters( 'pt-ocdi/downloaded_customizer_file_suffix_and_file_extension', '.dat' );
|
115 |
+
|
116 |
+
// Write customizer content to the file and return the file path on successful write.
|
117 |
+
$downloaded_files['customizer'] = self::write_to_file( $demo_import_customizer_content, $import_customizer_file_path );
|
118 |
+
|
119 |
+
// Return from this function if there was an error.
|
120 |
+
if ( is_wp_error( $downloaded_files['customizer'] ) ) {
|
121 |
+
return $downloaded_files['customizer'];
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
return $downloaded_files;
|
126 |
}
|
127 |
|
446 |
);
|
447 |
|
448 |
// Handle demo content and widgets file upload.
|
449 |
+
$content_file_info = wp_handle_upload( $_FILES['content_file'], $upload_overrides );
|
450 |
+
$widget_file_info = wp_handle_upload( $_FILES['widget_file'], $upload_overrides );
|
451 |
+
$customizer_file_info = wp_handle_upload( $_FILES['customizer_file'], $upload_overrides );
|
452 |
|
453 |
if ( empty( $content_file_info['file'] ) || isset( $content_file_info['error'] ) ) {
|
454 |
|
463 |
// Set uploaded content file.
|
464 |
$selected_import_files['content'] = $content_file_info['file'];
|
465 |
|
466 |
+
// Process widget import file.
|
467 |
if ( $widget_file_info && ! isset( $widget_file_info['error'] ) ) {
|
468 |
|
469 |
// Set uploaded widget file.
|
482 |
);
|
483 |
}
|
484 |
|
485 |
+
// Process Customizer import file.
|
486 |
+
if ( $customizer_file_info && ! isset( $customizer_file_info['error'] ) ) {
|
487 |
+
|
488 |
+
// Set uploaded widget file.
|
489 |
+
$selected_import_files['customizer'] = $customizer_file_info['file'];
|
490 |
+
}
|
491 |
+
else {
|
492 |
+
|
493 |
+
// Add this error to log file.
|
494 |
+
$log_added = self::append_to_file(
|
495 |
+
sprintf(
|
496 |
+
__( 'Customizer file was not uploaded. Error: %s', 'pt-ocdi' ),
|
497 |
+
$customizer_file_info['error']
|
498 |
+
),
|
499 |
+
$log_file_path,
|
500 |
+
esc_html__( 'Upload files' , 'pt-ocdi' )
|
501 |
+
);
|
502 |
+
}
|
503 |
+
|
504 |
// Add this message to log file.
|
505 |
$log_added = self::append_to_file(
|
506 |
__( 'The import files were successfully uploaded!', 'pt-ocdi' ) . self::import_file_info( $selected_import_files ),
|
525 |
ini_get( 'max_execution_time' )
|
526 |
) . PHP_EOL .
|
527 |
sprintf(
|
528 |
+
__( 'Files info:%1$sSite URL = %2$s%1$sData file = %3$s%1$sWidget file = %4$s%1$sCustomizer file = %5$s', 'pt-ocdi' ),
|
529 |
PHP_EOL,
|
530 |
get_site_url(),
|
531 |
$selected_import_files['content'],
|
532 |
+
empty( $selected_import_files['widgets'] ) ? esc_html__( 'not defined!', 'pt-ocdi' ) : $selected_import_files['widgets'],
|
533 |
+
empty( $selected_import_files['customizer'] ) ? esc_html__( 'not defined!', 'pt-ocdi' ) : $selected_import_files['customizer']
|
534 |
);
|
535 |
}
|
536 |
|
languages/pt-ocdi.pot
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
# This file is distributed under the GPL 2.0.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: One Click Demo Import 1.1.
|
6 |
"Report-Msgid-Bugs-To: http://support.proteusthemes.com/\n"
|
7 |
"POT-Creation-Date: 2016-05-14 09:53:17+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
@@ -24,79 +24,101 @@ msgstr ""
|
|
24 |
"X-Poedit-Bookmarks: \n"
|
25 |
"X-Textdomain-Support: yes\n"
|
26 |
|
27 |
-
#: inc/class-ocdi-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
msgid "URL for %s%s%s file is not defined!"
|
29 |
msgstr ""
|
30 |
|
31 |
-
#: inc/class-ocdi-helpers.php:
|
32 |
msgid ""
|
33 |
"An error occurred while fetching %s%s%s file from the server!%sReason: %s - "
|
34 |
"%s."
|
35 |
msgstr ""
|
36 |
|
37 |
-
#: inc/class-ocdi-helpers.php:
|
38 |
msgid ""
|
39 |
"An error occurred while writing file to your server! Tried to write a file "
|
40 |
"to: %s%s."
|
41 |
msgstr ""
|
42 |
|
43 |
-
#: inc/class-ocdi-helpers.php:
|
44 |
msgid ""
|
45 |
"An error occurred while reading a file from your server! Tried reading file "
|
46 |
"from path: %s%s."
|
47 |
msgstr ""
|
48 |
|
49 |
-
#: inc/class-ocdi-helpers.php:
|
50 |
msgid ""
|
51 |
"An error occurred while retrieving reading/writing permissions to your "
|
52 |
"server (could not retrieve WP filesystem credentials)!"
|
53 |
msgstr ""
|
54 |
|
55 |
-
#: inc/class-ocdi-helpers.php:
|
56 |
msgid "Your WordPress login credentials don't allow to use WP_Filesystem!"
|
57 |
msgstr ""
|
58 |
|
59 |
-
#: inc/class-ocdi-helpers.php:
|
60 |
msgid ""
|
61 |
"This WordPress page does not have %sdirect%s write file access. This plugin "
|
62 |
"needs it in order to save the demo import xml file to the upload directory "
|
63 |
"of your site. You can change this setting with these instructions: %s."
|
64 |
msgstr ""
|
65 |
|
66 |
-
#: inc/class-ocdi-helpers.php:
|
67 |
msgid ""
|
68 |
"%sYour user role isn't high enough. You don't have permission to import "
|
69 |
"demo data.%s"
|
70 |
msgstr ""
|
71 |
|
72 |
-
#: inc/class-ocdi-helpers.php:
|
73 |
msgid ""
|
74 |
"Please upload XML file for content import. If you want to import widgets "
|
75 |
"only, please use Widget Importer & Exporter plugin."
|
76 |
msgstr ""
|
77 |
|
78 |
-
#: inc/class-ocdi-helpers.php:
|
79 |
-
#: inc/class-ocdi-helpers.php:
|
80 |
msgid "Upload files"
|
81 |
msgstr ""
|
82 |
|
83 |
-
#: inc/class-ocdi-helpers.php:
|
84 |
msgid "Widget file was not uploaded. Error: %s"
|
85 |
msgstr ""
|
86 |
|
87 |
-
#: inc/class-ocdi-helpers.php:
|
|
|
|
|
|
|
|
|
88 |
msgid "The import files were successfully uploaded!"
|
89 |
msgstr ""
|
90 |
|
91 |
-
#: inc/class-ocdi-helpers.php:
|
92 |
msgid "MAX EXECUTION TIME = %s"
|
93 |
msgstr ""
|
94 |
|
95 |
-
#: inc/class-ocdi-helpers.php:
|
96 |
-
msgid "
|
|
|
|
|
97 |
msgstr ""
|
98 |
|
99 |
-
#: inc/class-ocdi-helpers.php:
|
100 |
msgid "not defined!"
|
101 |
msgstr ""
|
102 |
|
@@ -164,13 +186,13 @@ msgstr ""
|
|
164 |
msgid "One Click Demo Import"
|
165 |
msgstr ""
|
166 |
|
167 |
-
#: one-click-demo-import.php:
|
168 |
msgid ""
|
169 |
"%sWarning: your server is using %sPHP safe mode%s. This means that you "
|
170 |
"might experience server timeout errors.%s"
|
171 |
msgstr ""
|
172 |
|
173 |
-
#: one-click-demo-import.php:
|
174 |
msgid ""
|
175 |
"Importing demo data (post, pages, images, theme settings, ...) is the "
|
176 |
"easiest way to setup your theme. It will allow you to quickly edit "
|
@@ -178,69 +200,81 @@ msgid ""
|
|
178 |
"data, the following things might happen:"
|
179 |
msgstr ""
|
180 |
|
181 |
-
#: one-click-demo-import.php:
|
182 |
msgid ""
|
183 |
"No existing posts, pages, categories, images, custom post types or any "
|
184 |
"other data will be deleted or modified."
|
185 |
msgstr ""
|
186 |
|
187 |
-
#: one-click-demo-import.php:
|
188 |
msgid "Posts, pages, images, widgets and menus will get imported."
|
189 |
msgstr ""
|
190 |
|
191 |
-
#: one-click-demo-import.php:
|
192 |
msgid ""
|
193 |
"Please click \"Import Demo Data\" button only once and wait, it can take a "
|
194 |
"couple of minutes."
|
195 |
msgstr ""
|
196 |
|
197 |
-
#: one-click-demo-import.php:
|
198 |
msgid "Before you begin, make sure all the required plugins are activated."
|
199 |
msgstr ""
|
200 |
|
201 |
-
#: one-click-demo-import.php:
|
202 |
msgid ""
|
203 |
"There are no predefined import files available in this theme. Please upload "
|
204 |
"the import files manually!"
|
205 |
msgstr ""
|
206 |
|
207 |
-
#: one-click-demo-import.php:
|
208 |
msgid "Choose a XML file for content import:"
|
209 |
msgstr ""
|
210 |
|
211 |
-
#: one-click-demo-import.php:
|
212 |
msgid "optional"
|
213 |
msgstr ""
|
214 |
|
215 |
-
#: one-click-demo-import.php:
|
216 |
msgid "Choose a WIE or JSON file for widget import:"
|
217 |
msgstr ""
|
218 |
|
219 |
-
#: one-click-demo-import.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
msgid "Import Demo Data"
|
221 |
msgstr ""
|
222 |
|
223 |
-
#: one-click-demo-import.php:
|
224 |
msgid "Importing, please wait!"
|
225 |
msgstr ""
|
226 |
|
227 |
-
#: one-click-demo-import.php:
|
228 |
msgid "Manually uploaded files"
|
229 |
msgstr ""
|
230 |
|
231 |
-
#: one-click-demo-import.php:
|
232 |
msgid "Downloaded files"
|
233 |
msgstr ""
|
234 |
|
235 |
-
#: one-click-demo-import.php:
|
236 |
msgid "The import files for: %s were successfully downloaded!"
|
237 |
msgstr ""
|
238 |
|
239 |
-
#: one-click-demo-import.php:
|
240 |
msgid "No import files specified!"
|
241 |
msgstr ""
|
242 |
|
243 |
-
#: one-click-demo-import.php:
|
244 |
msgid ""
|
245 |
"%1$s%3$sThat's it, all done!%4$s%2$sThe demo import has finished. Please "
|
246 |
"check your page and make sure that everything has imported correctly. If it "
|
@@ -248,22 +282,30 @@ msgid ""
|
|
248 |
"it has done its job.%5$s"
|
249 |
msgstr ""
|
250 |
|
251 |
-
#: one-click-demo-import.php:
|
252 |
msgid ""
|
253 |
"%1$sThe demo import has finished, but there were some import "
|
254 |
"errors.%2$sMore details about the errors can be found in this %3$s%5$slog "
|
255 |
"file%6$s%4$s%7$s"
|
256 |
msgstr ""
|
257 |
|
258 |
-
#: one-click-demo-import.php:
|
259 |
msgid "Importing content"
|
260 |
msgstr ""
|
261 |
|
262 |
-
#: one-click-demo-import.php:
|
263 |
msgid "Importing widgets"
|
264 |
msgstr ""
|
265 |
|
266 |
-
#: one-click-demo-import.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
msgid "Completed AJAX call number: "
|
268 |
msgstr ""
|
269 |
|
2 |
# This file is distributed under the GPL 2.0.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: One Click Demo Import 1.1.1\n"
|
6 |
"Report-Msgid-Bugs-To: http://support.proteusthemes.com/\n"
|
7 |
"POT-Creation-Date: 2016-05-14 09:53:17+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
24 |
"X-Poedit-Bookmarks: \n"
|
25 |
"X-Textdomain-Support: yes\n"
|
26 |
|
27 |
+
#: inc/class-ocdi-customizer-importer.php:36
|
28 |
+
msgid "The customizer import file is missing! File path: %s"
|
29 |
+
msgstr ""
|
30 |
+
|
31 |
+
#: inc/class-ocdi-customizer-importer.php:56
|
32 |
+
msgid ""
|
33 |
+
"The customizer import file is not in a correct format. Please make sure to "
|
34 |
+
"use the correct customizer import file."
|
35 |
+
msgstr ""
|
36 |
+
|
37 |
+
#: inc/class-ocdi-customizer-importer.php:62
|
38 |
+
msgid ""
|
39 |
+
"The customizer import file is not suitable for current theme. You can only "
|
40 |
+
"import customizer settings for the same theme or a child theme."
|
41 |
+
msgstr ""
|
42 |
+
|
43 |
+
#: inc/class-ocdi-helpers.php:143
|
44 |
msgid "URL for %s%s%s file is not defined!"
|
45 |
msgstr ""
|
46 |
|
47 |
+
#: inc/class-ocdi-helpers.php:165
|
48 |
msgid ""
|
49 |
"An error occurred while fetching %s%s%s file from the server!%sReason: %s - "
|
50 |
"%s."
|
51 |
msgstr ""
|
52 |
|
53 |
+
#: inc/class-ocdi-helpers.php:210 inc/class-ocdi-helpers.php:259
|
54 |
msgid ""
|
55 |
"An error occurred while writing file to your server! Tried to write a file "
|
56 |
"to: %s%s."
|
57 |
msgstr ""
|
58 |
|
59 |
+
#: inc/class-ocdi-helpers.php:299
|
60 |
msgid ""
|
61 |
"An error occurred while reading a file from your server! Tried reading file "
|
62 |
"from path: %s%s."
|
63 |
msgstr ""
|
64 |
|
65 |
+
#: inc/class-ocdi-helpers.php:324
|
66 |
msgid ""
|
67 |
"An error occurred while retrieving reading/writing permissions to your "
|
68 |
"server (could not retrieve WP filesystem credentials)!"
|
69 |
msgstr ""
|
70 |
|
71 |
+
#: inc/class-ocdi-helpers.php:332
|
72 |
msgid "Your WordPress login credentials don't allow to use WP_Filesystem!"
|
73 |
msgstr ""
|
74 |
|
75 |
+
#: inc/class-ocdi-helpers.php:349
|
76 |
msgid ""
|
77 |
"This WordPress page does not have %sdirect%s write file access. This plugin "
|
78 |
"needs it in order to save the demo import xml file to the upload directory "
|
79 |
"of your site. You can change this setting with these instructions: %s."
|
80 |
msgstr ""
|
81 |
|
82 |
+
#: inc/class-ocdi-helpers.php:421
|
83 |
msgid ""
|
84 |
"%sYour user role isn't high enough. You don't have permission to import "
|
85 |
"demo data.%s"
|
86 |
msgstr ""
|
87 |
|
88 |
+
#: inc/class-ocdi-helpers.php:457
|
89 |
msgid ""
|
90 |
"Please upload XML file for content import. If you want to import widgets "
|
91 |
"only, please use Widget Importer & Exporter plugin."
|
92 |
msgstr ""
|
93 |
|
94 |
+
#: inc/class-ocdi-helpers.php:459 inc/class-ocdi-helpers.php:481
|
95 |
+
#: inc/class-ocdi-helpers.php:500 inc/class-ocdi-helpers.php:508
|
96 |
msgid "Upload files"
|
97 |
msgstr ""
|
98 |
|
99 |
+
#: inc/class-ocdi-helpers.php:477
|
100 |
msgid "Widget file was not uploaded. Error: %s"
|
101 |
msgstr ""
|
102 |
|
103 |
+
#: inc/class-ocdi-helpers.php:496
|
104 |
+
msgid "Customizer file was not uploaded. Error: %s"
|
105 |
+
msgstr ""
|
106 |
+
|
107 |
+
#: inc/class-ocdi-helpers.php:506
|
108 |
msgid "The import files were successfully uploaded!"
|
109 |
msgstr ""
|
110 |
|
111 |
+
#: inc/class-ocdi-helpers.php:524
|
112 |
msgid "MAX EXECUTION TIME = %s"
|
113 |
msgstr ""
|
114 |
|
115 |
+
#: inc/class-ocdi-helpers.php:528
|
116 |
+
msgid ""
|
117 |
+
"Files info:%1$sSite URL = %2$s%1$sData file = %3$s%1$sWidget file = "
|
118 |
+
"%4$s%1$sCustomizer file = %5$s"
|
119 |
msgstr ""
|
120 |
|
121 |
+
#: inc/class-ocdi-helpers.php:532 inc/class-ocdi-helpers.php:533
|
122 |
msgid "not defined!"
|
123 |
msgstr ""
|
124 |
|
186 |
msgid "One Click Demo Import"
|
187 |
msgstr ""
|
188 |
|
189 |
+
#: one-click-demo-import.php:116
|
190 |
msgid ""
|
191 |
"%sWarning: your server is using %sPHP safe mode%s. This means that you "
|
192 |
"might experience server timeout errors.%s"
|
193 |
msgstr ""
|
194 |
|
195 |
+
#: one-click-demo-import.php:130
|
196 |
msgid ""
|
197 |
"Importing demo data (post, pages, images, theme settings, ...) is the "
|
198 |
"easiest way to setup your theme. It will allow you to quickly edit "
|
200 |
"data, the following things might happen:"
|
201 |
msgstr ""
|
202 |
|
203 |
+
#: one-click-demo-import.php:134
|
204 |
msgid ""
|
205 |
"No existing posts, pages, categories, images, custom post types or any "
|
206 |
"other data will be deleted or modified."
|
207 |
msgstr ""
|
208 |
|
209 |
+
#: one-click-demo-import.php:135
|
210 |
msgid "Posts, pages, images, widgets and menus will get imported."
|
211 |
msgstr ""
|
212 |
|
213 |
+
#: one-click-demo-import.php:136
|
214 |
msgid ""
|
215 |
"Please click \"Import Demo Data\" button only once and wait, it can take a "
|
216 |
"couple of minutes."
|
217 |
msgstr ""
|
218 |
|
219 |
+
#: one-click-demo-import.php:141
|
220 |
msgid "Before you begin, make sure all the required plugins are activated."
|
221 |
msgstr ""
|
222 |
|
223 |
+
#: one-click-demo-import.php:155
|
224 |
msgid ""
|
225 |
"There are no predefined import files available in this theme. Please upload "
|
226 |
"the import files manually!"
|
227 |
msgstr ""
|
228 |
|
229 |
+
#: one-click-demo-import.php:159
|
230 |
msgid "Choose a XML file for content import:"
|
231 |
msgstr ""
|
232 |
|
233 |
+
#: one-click-demo-import.php:162 one-click-demo-import.php:165
|
234 |
msgid "optional"
|
235 |
msgstr ""
|
236 |
|
237 |
+
#: one-click-demo-import.php:162
|
238 |
msgid "Choose a WIE or JSON file for widget import:"
|
239 |
msgstr ""
|
240 |
|
241 |
+
#: one-click-demo-import.php:165
|
242 |
+
msgid "Choose a DAT file for customizer import:"
|
243 |
+
msgstr ""
|
244 |
+
|
245 |
+
#: one-click-demo-import.php:192
|
246 |
+
msgid "Import preview:"
|
247 |
+
msgstr ""
|
248 |
+
|
249 |
+
#: one-click-demo-import.php:196 one-click-demo-import.php:240
|
250 |
+
msgid "No preview image defined for this import."
|
251 |
+
msgstr ""
|
252 |
+
|
253 |
+
#: one-click-demo-import.php:209
|
254 |
msgid "Import Demo Data"
|
255 |
msgstr ""
|
256 |
|
257 |
+
#: one-click-demo-import.php:213
|
258 |
msgid "Importing, please wait!"
|
259 |
msgstr ""
|
260 |
|
261 |
+
#: one-click-demo-import.php:297
|
262 |
msgid "Manually uploaded files"
|
263 |
msgstr ""
|
264 |
|
265 |
+
#: one-click-demo-import.php:314 one-click-demo-import.php:325
|
266 |
msgid "Downloaded files"
|
267 |
msgstr ""
|
268 |
|
269 |
+
#: one-click-demo-import.php:321
|
270 |
msgid "The import files for: %s were successfully downloaded!"
|
271 |
msgstr ""
|
272 |
|
273 |
+
#: one-click-demo-import.php:331
|
274 |
msgid "No import files specified!"
|
275 |
msgstr ""
|
276 |
|
277 |
+
#: one-click-demo-import.php:378
|
278 |
msgid ""
|
279 |
"%1$s%3$sThat's it, all done!%4$s%2$sThe demo import has finished. Please "
|
280 |
"check your page and make sure that everything has imported correctly. If it "
|
282 |
"it has done its job.%5$s"
|
283 |
msgstr ""
|
284 |
|
285 |
+
#: one-click-demo-import.php:389
|
286 |
msgid ""
|
287 |
"%1$sThe demo import has finished, but there were some import "
|
288 |
"errors.%2$sMore details about the errors can be found in this %3$s%5$slog "
|
289 |
"file%6$s%4$s%7$s"
|
290 |
msgstr ""
|
291 |
|
292 |
+
#: one-click-demo-import.php:445
|
293 |
msgid "Importing content"
|
294 |
msgstr ""
|
295 |
|
296 |
+
#: one-click-demo-import.php:484 one-click-demo-import.php:496
|
297 |
msgid "Importing widgets"
|
298 |
msgstr ""
|
299 |
|
300 |
+
#: one-click-demo-import.php:518 one-click-demo-import.php:526
|
301 |
+
msgid "Importing customizer settings"
|
302 |
+
msgstr ""
|
303 |
+
|
304 |
+
#: one-click-demo-import.php:524
|
305 |
+
msgid "Customizer settings import finished!"
|
306 |
+
msgstr ""
|
307 |
+
|
308 |
+
#: one-click-demo-import.php:576
|
309 |
msgid "Completed AJAX call number: "
|
310 |
msgstr ""
|
311 |
|
one-click-demo-import.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: One Click Demo Import
|
5 |
Plugin URI: https://wordpress.org/plugins/one-click-demo-import/
|
6 |
Description: Import your content, widgets and theme settings with one click. Theme authors! Enable simple demo import for your theme demo data.
|
7 |
-
Version: 1.1.
|
8 |
Author: ProteusThemes
|
9 |
Author URI: http://www.proteusthemes.com
|
10 |
License: GPL3
|
@@ -20,12 +20,13 @@ define( 'PT_OCDI_PATH', plugin_dir_path( __FILE__ ) );
|
|
20 |
define( 'PT_OCDI_URL', plugin_dir_url( __FILE__ ) );
|
21 |
|
22 |
// Current version of the plugin.
|
23 |
-
define( 'PT_OCDI_VERSION', '1.1.
|
24 |
|
25 |
// Include files.
|
26 |
require PT_OCDI_PATH . 'inc/class-ocdi-helpers.php';
|
27 |
require PT_OCDI_PATH . 'inc/class-ocdi-importer.php';
|
28 |
require PT_OCDI_PATH . 'inc/class-ocdi-widget-importer.php';
|
|
|
29 |
require PT_OCDI_PATH . 'inc/class-ocdi-logger.php';
|
30 |
|
31 |
/**
|
@@ -160,18 +161,49 @@ class PT_One_Click_Demo_Import {
|
|
160 |
<br>
|
161 |
<small><?php esc_html_e( 'optional', 'pt-ocdi' ); ?></small> <label for="widget-file-upload"><?php esc_html_e( 'Choose a WIE or JSON file for widget import:', 'pt-ocdi' ); ?></label>
|
162 |
<input id="ocdi__widget-file-upload" type="file" name="widget-file-upload">
|
|
|
|
|
|
|
163 |
</p>
|
164 |
<?php elseif ( 1 < count( $this->import_files ) ) : ?>
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
<p>
|
177 |
<button class="ocdi__button button-primary js-ocdi-import-data"><?php esc_html_e( 'Import Demo Data', 'pt-ocdi' ); ?></button>
|
@@ -201,8 +233,12 @@ class PT_One_Click_Demo_Import {
|
|
201 |
|
202 |
wp_localize_script( 'ocdi-main-js', 'ocdi',
|
203 |
array(
|
204 |
-
'ajax_url'
|
205 |
-
'ajax_nonce'
|
|
|
|
|
|
|
|
|
206 |
)
|
207 |
);
|
208 |
|
@@ -217,7 +253,8 @@ class PT_One_Click_Demo_Import {
|
|
217 |
* 2. import content
|
218 |
* 3. before widgets import setup (optional)
|
219 |
* 4. import widgets (optional)
|
220 |
-
* 5.
|
|
|
221 |
*/
|
222 |
public function import_demo_data_ajax_callback() {
|
223 |
|
@@ -319,7 +356,14 @@ class PT_One_Click_Demo_Import {
|
|
319 |
}
|
320 |
|
321 |
/**
|
322 |
-
* 5.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
*/
|
324 |
$action = 'pt-ocdi/after_import';
|
325 |
if ( ( false !== has_action( $action ) ) && empty( $this->frontend_error_messages ) ) {
|
@@ -454,6 +498,36 @@ class PT_One_Click_Demo_Import {
|
|
454 |
}
|
455 |
|
456 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
457 |
/**
|
458 |
* Setup other things in the passed wp action.
|
459 |
*
|
4 |
Plugin Name: One Click Demo Import
|
5 |
Plugin URI: https://wordpress.org/plugins/one-click-demo-import/
|
6 |
Description: Import your content, widgets and theme settings with one click. Theme authors! Enable simple demo import for your theme demo data.
|
7 |
+
Version: 1.1.1
|
8 |
Author: ProteusThemes
|
9 |
Author URI: http://www.proteusthemes.com
|
10 |
License: GPL3
|
20 |
define( 'PT_OCDI_URL', plugin_dir_url( __FILE__ ) );
|
21 |
|
22 |
// Current version of the plugin.
|
23 |
+
define( 'PT_OCDI_VERSION', '1.1.1' );
|
24 |
|
25 |
// Include files.
|
26 |
require PT_OCDI_PATH . 'inc/class-ocdi-helpers.php';
|
27 |
require PT_OCDI_PATH . 'inc/class-ocdi-importer.php';
|
28 |
require PT_OCDI_PATH . 'inc/class-ocdi-widget-importer.php';
|
29 |
+
require PT_OCDI_PATH . 'inc/class-ocdi-customizer-importer.php';
|
30 |
require PT_OCDI_PATH . 'inc/class-ocdi-logger.php';
|
31 |
|
32 |
/**
|
161 |
<br>
|
162 |
<small><?php esc_html_e( 'optional', 'pt-ocdi' ); ?></small> <label for="widget-file-upload"><?php esc_html_e( 'Choose a WIE or JSON file for widget import:', 'pt-ocdi' ); ?></label>
|
163 |
<input id="ocdi__widget-file-upload" type="file" name="widget-file-upload">
|
164 |
+
<br>
|
165 |
+
<small><?php esc_html_e( 'optional', 'pt-ocdi' ); ?></small> <label for="customizer-file-upload"><?php esc_html_e( 'Choose a DAT file for customizer import:', 'pt-ocdi' ); ?></label>
|
166 |
+
<input id="ocdi__customizer-file-upload" type="file" name="customizer-file-upload">
|
167 |
</p>
|
168 |
<?php elseif ( 1 < count( $this->import_files ) ) : ?>
|
169 |
+
<p>
|
170 |
+
<select id="ocdi__demo-import-files">
|
171 |
+
<?php foreach ( $this->import_files as $index => $import_file ) : ?>
|
172 |
+
<option value="<?php echo esc_attr( $index ); ?>">
|
173 |
+
<?php echo esc_html( $import_file['import_file_name'] ); ?>
|
174 |
+
</option>
|
175 |
+
<?php endforeach; ?>
|
176 |
+
</select>
|
177 |
+
</p>
|
178 |
+
|
179 |
+
<?php
|
180 |
+
// Check if at least one preview image is defined, so we can prepare the structure for display.
|
181 |
+
$preview_image_is_defined = false;
|
182 |
+
foreach ( $this->import_files as $import_file ) {
|
183 |
+
if ( isset( $import_file['import_preview_image_url'] ) ) {
|
184 |
+
$preview_image_is_defined = true;
|
185 |
+
break;
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
if ( $preview_image_is_defined ) :
|
190 |
+
?>
|
191 |
+
<p>
|
192 |
+
<h3><?php esc_html_e( 'Import preview:', 'pt-ocdi' ); ?></h3>
|
193 |
+
<p class="ocdi__demo-import-preview-image-message js-ocdi-preview-image-message">
|
194 |
+
<?php
|
195 |
+
if ( ! isset( $this->import_files[0]['import_preview_image_url'] ) ) {
|
196 |
+
esc_html_e( 'No preview image defined for this import.', 'pt-ocdi' );
|
197 |
+
}
|
198 |
+
// Leave the img tag below and the p tag above available for later changes via JS.
|
199 |
+
?>
|
200 |
+
</p>
|
201 |
+
<img id="ocdi__demo-import-preview-image" class="js-ocdi-preview-image" src="<?php echo ! empty( $this->import_files[0]['import_preview_image_url'] ) ? esc_url( $this->import_files[0]['import_preview_image_url'] ) : ''; ?>">
|
202 |
+
<p>
|
203 |
+
<?php
|
204 |
+
endif;
|
205 |
+
endif;
|
206 |
+
?>
|
207 |
|
208 |
<p>
|
209 |
<button class="ocdi__button button-primary js-ocdi-import-data"><?php esc_html_e( 'Import Demo Data', 'pt-ocdi' ); ?></button>
|
233 |
|
234 |
wp_localize_script( 'ocdi-main-js', 'ocdi',
|
235 |
array(
|
236 |
+
'ajax_url' => admin_url( 'admin-ajax.php' ),
|
237 |
+
'ajax_nonce' => wp_create_nonce( 'ocdi-ajax-verification' ),
|
238 |
+
'import_files' => $this->import_files,
|
239 |
+
'texts' => array(
|
240 |
+
'missing_preview_image' => esc_html__( 'No preview image defined for this import.', 'pt-ocdi' ),
|
241 |
+
),
|
242 |
)
|
243 |
);
|
244 |
|
253 |
* 2. import content
|
254 |
* 3. before widgets import setup (optional)
|
255 |
* 4. import widgets (optional)
|
256 |
+
* 5. import customizer options (optional)
|
257 |
+
* 6. after import setup (optional)
|
258 |
*/
|
259 |
public function import_demo_data_ajax_callback() {
|
260 |
|
356 |
}
|
357 |
|
358 |
/**
|
359 |
+
* 5. Import customize options.
|
360 |
+
*/
|
361 |
+
if ( ! empty( $this->selected_import_files['customizer'] ) && empty( $this->frontend_error_messages ) ) {
|
362 |
+
$this->import_customizer( $this->selected_import_files['customizer'] );
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* 6. After import setup.
|
367 |
*/
|
368 |
$action = 'pt-ocdi/after_import';
|
369 |
if ( ( false !== has_action( $action ) ) && empty( $this->frontend_error_messages ) ) {
|
498 |
}
|
499 |
|
500 |
|
501 |
+
/**
|
502 |
+
* Import customizer from a DAT file, generated by the Customizer Export/Import plugin.
|
503 |
+
*
|
504 |
+
* @param string $customizer_import_file_path path to the customizer import file.
|
505 |
+
*/
|
506 |
+
private function import_customizer( $customizer_import_file_path ) {
|
507 |
+
|
508 |
+
// Try to import the customizer settings.
|
509 |
+
$results = OCDI_Customizer_Importer::import_customizer_options( $customizer_import_file_path );
|
510 |
+
|
511 |
+
// Check for errors.
|
512 |
+
if ( is_wp_error( $results ) ) {
|
513 |
+
|
514 |
+
// Write error to log file and send an AJAX response with the error.
|
515 |
+
OCDI_Helpers::log_error_and_send_ajax_response(
|
516 |
+
$results->get_error_message(),
|
517 |
+
$this->log_file_path,
|
518 |
+
esc_html__( 'Importing customizer settings', 'pt-ocdi' )
|
519 |
+
);
|
520 |
+
}
|
521 |
+
|
522 |
+
// Add this message to log file.
|
523 |
+
$log_added = OCDI_Helpers::append_to_file(
|
524 |
+
esc_html__( 'Customizer settings import finished!', 'pt-ocdi' ),
|
525 |
+
$this->log_file_path,
|
526 |
+
esc_html__( 'Importing customizer settings' , 'pt-ocdi' )
|
527 |
+
);
|
528 |
+
}
|
529 |
+
|
530 |
+
|
531 |
/**
|
532 |
* Setup other things in the passed wp action.
|
533 |
*
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: capuderg, cyman
|
|
3 |
Tags: import, content, demo, data, widgets, settings
|
4 |
Requires at least: 4.0.0
|
5 |
Tested up to: 4.5
|
6 |
-
Stable tag: 1.1.
|
7 |
License: GPLv3 or later
|
8 |
|
9 |
Import your demo content, widgets and theme settings with one click. Theme authors! Enable simple demo import for your theme demo data.
|
@@ -12,7 +12,7 @@ Import your demo content, widgets and theme settings with one click. Theme autho
|
|
12 |
|
13 |
This plugin will create a submenu page under Appearance with the title **Import demo data**.
|
14 |
|
15 |
-
If the theme you are using does not have any predefined import files, then you will be presented with
|
16 |
|
17 |
This plugin is using the improved WP import that you can find here: https://github.com/humanmade/WordPress-Importer.
|
18 |
|
@@ -50,20 +50,26 @@ This question is for theme authors. To predefine demo imports, you just have to
|
|
50 |
function ocdi_import_files() {
|
51 |
return array(
|
52 |
array(
|
53 |
-
'import_file_name'
|
54 |
-
'import_file_url'
|
55 |
-
'import_widget_file_url'
|
|
|
|
|
56 |
),
|
57 |
array(
|
58 |
-
'import_file_name'
|
59 |
-
'import_file_url'
|
60 |
-
'import_widget_file_url'
|
|
|
|
|
61 |
),
|
62 |
);
|
63 |
}
|
64 |
add_filter( 'pt-ocdi/import_files', 'ocdi_import_files' );
|
65 |
`
|
66 |
|
|
|
|
|
67 |
= How to handle different "after import setups" depending on which predefined import was selected? =
|
68 |
|
69 |
This question might be asked by a theme author wanting to implement different after import setups for multiple predefined demo imports. Lets say we have predefined two demo imports with the following names: 'Demo Import 1' and 'Demo Import 2', the code for after import setup would be (using the `pt-ocdi/after_import` filter):
|
@@ -124,6 +130,13 @@ This happens, because your hosting server is using a very old version of PHP. Th
|
|
124 |
|
125 |
== Changelog ==
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
= 1.1.0 =
|
128 |
|
129 |
*Release Date - 14 May 2016*
|
3 |
Tags: import, content, demo, data, widgets, settings
|
4 |
Requires at least: 4.0.0
|
5 |
Tested up to: 4.5
|
6 |
+
Stable tag: 1.1.1
|
7 |
License: GPLv3 or later
|
8 |
|
9 |
Import your demo content, widgets and theme settings with one click. Theme authors! Enable simple demo import for your theme demo data.
|
12 |
|
13 |
This plugin will create a submenu page under Appearance with the title **Import demo data**.
|
14 |
|
15 |
+
If the theme you are using does not have any predefined import files, then you will be presented with three file upload inputs. First one is required and you will have to upload a demo content XML file, for the actual demo import. The second one is optional and will ask you for a WIE or JSON file for widgets import. You create that file using the [Widget Importer & Exporter](https://wordpress.org/plugins/widget-importer-exporter/) plugin. The third one is also optional and will import the customizer settings, select the DAT file which you can generate from [Customizer Export/Import](https://wordpress.org/plugins/customizer-export-import/) plugin (the customizer settings will be imported only if the export file was created from the same theme).
|
16 |
|
17 |
This plugin is using the improved WP import that you can find here: https://github.com/humanmade/WordPress-Importer.
|
18 |
|
50 |
function ocdi_import_files() {
|
51 |
return array(
|
52 |
array(
|
53 |
+
'import_file_name' => 'Demo Import 1',
|
54 |
+
'import_file_url' => 'http://www.your_domain.com/ocdi/demo-content.xml',
|
55 |
+
'import_widget_file_url' => 'http://www.your_domain.com/ocdi/widgets.json',
|
56 |
+
'import_customizer_file_url' => 'http://www.your_domain.com/ocdi/customizer.dat',
|
57 |
+
'import_preview_image_url' => 'http://www.your_domain.com/ocdi/preview_import_image1.json',
|
58 |
),
|
59 |
array(
|
60 |
+
'import_file_name' => 'Demo Import 2',
|
61 |
+
'import_file_url' => 'http://www.your_domain.com/ocdi/demo-content2.xml',
|
62 |
+
'import_widget_file_url' => 'http://www.your_domain.com/ocdi/widgets2.json',
|
63 |
+
'import_customizer_file_url' => 'http://www.your_domain.com/ocdi/customizer2.dat',
|
64 |
+
'import_preview_image_url' => 'http://www.your_domain.com/ocdi/preview_import_image2.json',
|
65 |
),
|
66 |
);
|
67 |
}
|
68 |
add_filter( 'pt-ocdi/import_files', 'ocdi_import_files' );
|
69 |
`
|
70 |
|
71 |
+
You can set content import, widgets, and customizer import files. You can also define a preview image, which will be used only when multiple demo imports are defined, so that the user will see the difference between imports.
|
72 |
+
|
73 |
= How to handle different "after import setups" depending on which predefined import was selected? =
|
74 |
|
75 |
This question might be asked by a theme author wanting to implement different after import setups for multiple predefined demo imports. Lets say we have predefined two demo imports with the following names: 'Demo Import 1' and 'Demo Import 2', the code for after import setup would be (using the `pt-ocdi/after_import` filter):
|
130 |
|
131 |
== Changelog ==
|
132 |
|
133 |
+
= 1.1.1 =
|
134 |
+
|
135 |
+
*Release Date - 22 May 2016*
|
136 |
+
|
137 |
+
* Preview import images can now be defined for multiple predefined import files (check FAQ "How to predefine demo imports?" for more info),
|
138 |
+
* You can now also import customizer settings.
|
139 |
+
|
140 |
= 1.1.0 =
|
141 |
|
142 |
*Release Date - 14 May 2016*
|