One Click Demo Import - Version 1.3.0

Version Description

Release Date - 1 October 2016

  • Import/plugin page re-design. Updated the plugin page styles to match WordPress (thanks to Oliver Juhas).
Download this release

Release Info

Developer capuderg
Plugin Icon 128x128 One Click Demo Import
Version 1.3.0
Comparing to
See all releases

Code changes from version 1.2.0 to 1.3.0

assets/css/main.css CHANGED
@@ -1,98 +1,107 @@
1
- /* Plugin title */
2
- .ocdi__title span {
3
- line-height: 30px;
 
4
  }
5
 
6
- /* AJAX loader */
7
- .ocdi__ajax-loader {
8
- font-size: 1.5em;
9
- display: none;
10
  }
11
 
12
- .ocdi__ajax-loader .spinner {
13
- display: inline-block;
14
- float: none;
15
- visibility: visible;
16
- margin-bottom: 6px;
17
  }
18
 
19
- /* Plugin intro text */
20
- .ocdi__intro-text {
21
- width: calc( 100% - 46px );
22
- background-color: #f5fafd;
23
- margin: 10px 0;
24
- padding: 10px 20px;
25
- color: #0C518F;
26
- border: 1px solid #cae0f3;
27
- border-left: 5px solid #cae0f3;
28
- clear: both;
29
  }
30
 
31
- .ocdi__intro-text ul {
32
- padding-left: 40px;
33
- list-style-type: square;
 
 
 
 
 
34
  }
35
 
36
  /* Plugin elements */
 
 
 
 
 
37
  .ocdi__demo-import-preview-image-message {
38
  font-style: italic;
39
  }
40
 
41
- #ocdi__demo-import-preview-image,
42
- #ocdi__demo-import-files {
43
- max-width: 100%;
 
 
 
 
 
 
 
 
 
 
44
  }
45
 
46
  /* Plugin multi select import and Plugin file upload containers */
47
- .ocdi__single-file-upload-container,
48
- .ocdi__multi-select-import {
49
- width: calc( 100% - 46px );
 
 
 
50
  background-color: #ffffff;
51
- margin: 10px 0;
52
- padding: 20px;
53
  border: 1px solid #e5e5e5;
54
- border-left: 5px solid #e5e5e5;
55
  }
56
 
57
- .ocdi__single-file-upload-container {
58
  margin: 0;
59
  margin-bottom: -1px;
60
  }
61
 
62
- .ocdi__single-file-upload-container span {
63
- color: #999999;
64
- float: right;
 
65
  }
66
 
67
- .ocdi__single-file-upload-container h3,
68
- .ocdi__multi-select-import h3 {
69
- margin-top: 0;
 
 
70
  }
71
 
72
- .ocdi__single-file-upload-container h3 {
73
- margin-bottom: .5em;
 
74
  }
75
 
76
- @media (min-width: 992px) {
77
- .ocdi__single-file-upload-container,
78
- .ocdi__multi-select-import {
79
- width: 65%;
80
- }
81
- }
82
 
83
- @media (min-width: 1200px) {
84
- .ocdi__single-file-upload-container,
85
- .ocdi__multi-select-import {
86
- width: 50%;
87
- }
88
  }
89
 
90
- /* WP info notice */
91
- .notice-info {
92
- border-left-color: #58acfa;
 
 
93
  }
94
 
95
- /* WP warning notice */
96
- .notice-warning {
97
- border-left-color: #ed9232;
98
- }
 
 
1
+ /* Overriding WordPress native styles */
2
+
3
+ .ocdi h2 {
4
+ text-align: inherit;
5
  }
6
 
7
+ .ocdi h2:first-child,
8
+ .ocdi h3:first-child {
9
+ margin-top: 0;
 
10
  }
11
 
12
+ .ocdi hr {
13
+ margin: 2.62em 0;
 
 
 
14
  }
15
 
16
+ .feature-section + hr {
17
+ margin-top: 0;
 
 
 
 
 
 
 
 
18
  }
19
 
20
+ #wpbody select {
21
+ height: auto;
22
+ padding: .62em;
23
+ line-height: inherit;
24
+ }
25
+
26
+ .ocdi .notice {
27
+ display: block !important;
28
  }
29
 
30
  /* Plugin elements */
31
+
32
+ .ocdi__demo-import-files {
33
+ width: 100%;
34
+ }
35
+
36
  .ocdi__demo-import-preview-image-message {
37
  font-style: italic;
38
  }
39
 
40
+ /* Plugin title */
41
+
42
+ .ocdi__title:before {
43
+ width: auto;
44
+ height: auto;
45
+ font-size: inherit;
46
+ }
47
+
48
+ /* Plugin intro text */
49
+
50
+ .ocdi__intro-text ul {
51
+ padding: 0 4%;
52
+ list-style-type: square;
53
  }
54
 
55
  /* Plugin multi select import and Plugin file upload containers */
56
+
57
+ .ocdi__file-upload,
58
+ .ocdi__multi-select-import,
59
+ .ocdi__demo-import-notice:not(:empty) {
60
+ padding: 4%;
61
+ margin: 1.62em 0;
62
  background-color: #ffffff;
 
 
63
  border: 1px solid #e5e5e5;
 
64
  }
65
 
66
+ .ocdi__file-upload {
67
  margin: 0;
68
  margin-bottom: -1px;
69
  }
70
 
71
+ .ocdi__file-upload span {
72
+ font-size: .81em;
73
+ font-weight: normal;
74
+ opacity: .66;
75
  }
76
 
77
+ .ocdi__demo-import-notice:not(:empty) {
78
+ border: 0;
79
+ border-left: 4px solid #00a0d2;
80
+ -webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
81
+ box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
82
  }
83
 
84
+ [dir="rtl"] .ocdi__demo-import-notice:not(:empty) {
85
+ border: 0;
86
+ border-right: 4px solid #00a0d2;
87
  }
88
 
89
+ /* Plugin button */
 
 
 
 
 
90
 
91
+ .ocdi__button-container {
92
+ margin-top: 1.62em;
 
 
 
93
  }
94
 
95
+ /* AJAX loader */
96
+
97
+ .ocdi__ajax-loader {
98
+ font-size: 1.5em;
99
+ display: none;
100
  }
101
 
102
+ .ocdi__ajax-loader .spinner {
103
+ display: inline-block;
104
+ float: none;
105
+ visibility: visible;
106
+ margin-bottom: 6px;
107
+ }
assets/js/main.js CHANGED
@@ -47,12 +47,12 @@ jQuery( function ( $ ) {
47
  $( '.js-ocdi-ajax-loader' ).hide();
48
  }
49
  else {
50
- $( '.js-ocdi-ajax-response' ).append( '<div class="error below-h2"><p>' + response + '</p></div>' );
51
  $( '.js-ocdi-ajax-loader' ).hide();
52
  }
53
  })
54
  .fail( function( error ) {
55
- $( '.js-ocdi-ajax-response' ).append( '<div class="error below-h2"> Error: ' + error.statusText + ' (' + error.status + ')' + '</div>' );
56
  $( '.js-ocdi-ajax-loader' ).hide();
57
  });
58
  }
@@ -77,4 +77,4 @@ jQuery( function ( $ ) {
77
  $( '.js-ocdi-demo-import-notice' ).html( currentImportNotice );
78
  });
79
 
80
- });
47
  $( '.js-ocdi-ajax-loader' ).hide();
48
  }
49
  else {
50
+ $( '.js-ocdi-ajax-response' ).append( '<div class="notice notice-error is-dismissible"><p>' + response + '</p></div>' );
51
  $( '.js-ocdi-ajax-loader' ).hide();
52
  }
53
  })
54
  .fail( function( error ) {
55
+ $( '.js-ocdi-ajax-response' ).append( '<div class="notice notice-error is-dismissible"><p>Error: ' + error.statusText + ' (' + error.status + ')' + '</p></div>' );
56
  $( '.js-ocdi-ajax-loader' ).hide();
57
  });
58
  }
77
  $( '.js-ocdi-demo-import-notice' ).html( currentImportNotice );
78
  });
79
 
80
+ });
inc/class-ocdi-main.php CHANGED
@@ -97,8 +97,9 @@ class PT_One_Click_Demo_Import {
97
  public function display_plugin_page() {
98
  ?>
99
 
100
- <div class="ocdi wrap">
101
- <h2 class="ocdi__title"><span class="dashicons dashicons-download"></span><?php esc_html_e( 'One Click Demo Import', 'pt-ocdi' ); ?></h2>
 
102
 
103
  <?php
104
 
@@ -106,7 +107,7 @@ class PT_One_Click_Demo_Import {
106
  if ( ini_get( 'safe_mode' ) ) {
107
  printf(
108
  esc_html__( '%sWarning: your server is using %sPHP safe mode%s. This means that you might experience server timeout errors.%s', 'pt-ocdi' ),
109
- '<div class="notice notice-warning"><p>',
110
  '<strong>',
111
  '</strong>',
112
  '</p></div>'
@@ -117,54 +118,73 @@ class PT_One_Click_Demo_Import {
117
  ob_start();
118
  ?>
119
 
 
 
 
 
120
  <div class="ocdi__intro-text">
121
- <p>
122
- <?php esc_html_e( 'Importing demo data (post, pages, images, theme settings, ...) is the easiest way to setup your theme. It will allow you to quickly edit everything instead of creating content from scratch. When you import the data, the following things might happen:', 'pt-ocdi' ); ?>
 
 
123
  </p>
124
 
 
 
 
 
125
  <ul>
126
  <li><?php esc_html_e( 'No existing posts, pages, categories, images, custom post types or any other data will be deleted or modified.', 'pt-ocdi' ); ?></li>
127
  <li><?php esc_html_e( 'Posts, pages, images, widgets and menus will get imported.', 'pt-ocdi' ); ?></li>
128
  <li><?php esc_html_e( 'Please click "Import Demo Data" button only once and wait, it can take a couple of minutes.', 'pt-ocdi' ); ?></li>
129
  </ul>
130
- </div>
131
 
132
- <div class="ocdi__intro-text">
133
- <p><?php esc_html_e( 'Before you begin, make sure all the required plugins are activated.', 'pt-ocdi' ); ?></p>
134
  </div>
135
 
136
  <?php
137
- $plugin_intro_text = ob_get_clean();
138
 
139
- // Display the plugin intro text (can be replaced with custom text through the filter below).
140
- echo wp_kses_post( apply_filters( 'pt-ocdi/plugin_intro_text', $plugin_intro_text ) );
141
  ?>
142
 
143
 
144
  <?php if ( empty( $this->import_files ) ) : ?>
145
- <div class="notice notice-info below-h2">
146
- <p>
147
- <?php esc_html_e( 'There are no predefined import files available in this theme. Please upload the import files manually!', 'pt-ocdi' ); ?>
148
- </p>
149
  </div>
150
- <div>
151
- <div class="ocdi__single-file-upload-container">
 
 
 
 
152
  <h3><label for="content-file-upload"><?php esc_html_e( 'Choose a XML file for content import:', 'pt-ocdi' ); ?></label></h3>
153
  <input id="ocdi__content-file-upload" type="file" name="content-file-upload">
154
  </div>
155
- <div class="ocdi__single-file-upload-container">
 
156
  <h3><label for="widget-file-upload"><?php esc_html_e( 'Choose a WIE or JSON file for widget import:', 'pt-ocdi' ); ?></label> <span><?php esc_html_e( '(*optional)', 'pt-ocdi' ); ?></span></h3>
157
  <input id="ocdi__widget-file-upload" type="file" name="widget-file-upload">
158
  </div>
159
- <div class="ocdi__single-file-upload-container">
 
160
  <h3><label for="customizer-file-upload"><?php esc_html_e( 'Choose a DAT file for customizer import:', 'pt-ocdi' ); ?></label> <span><?php esc_html_e( '(*optional)', 'pt-ocdi' ); ?></span></h3>
161
  <input id="ocdi__customizer-file-upload" type="file" name="customizer-file-upload">
162
  </div>
 
163
  </div>
 
164
  <?php elseif ( 1 < count( $this->import_files ) ) : ?>
 
165
  <div class="ocdi__multi-select-import">
166
- <h3><?php esc_html_e( 'Choose which demo you want to import:', 'pt-ocdi' ); ?></h3>
167
- <select id="ocdi__demo-import-files">
 
 
168
  <?php foreach ( $this->import_files as $index => $import_file ) : ?>
169
  <option value="<?php echo esc_attr( $index ); ?>">
170
  <?php echo esc_html( $import_file['import_file_name'] ); ?>
@@ -184,32 +204,36 @@ class PT_One_Click_Demo_Import {
184
 
185
  if ( $preview_image_is_defined ) :
186
  ?>
187
- <div>
 
 
188
  <p><?php esc_html_e( 'Import preview:', 'pt-ocdi' ); ?></p>
189
- <p class="ocdi__demo-import-preview-image-message js-ocdi-preview-image-message">
190
- <?php
191
  if ( ! isset( $this->import_files[0]['import_preview_image_url'] ) ) {
192
  esc_html_e( 'No preview image defined for this import.', 'pt-ocdi' );
193
  }
194
  // Leave the img tag below and the p tag above available for later changes via JS.
195
- ?>
196
- </p>
197
  <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'] ) : ''; ?>">
 
198
  </div>
 
199
  <?php endif; ?>
 
200
  </div>
 
201
  <?php endif; ?>
202
 
203
- <div class="ocdi__demo-import-notice js-ocdi-demo-import-notice">
204
- <?php
205
  if ( is_array( $this->import_files ) && ! empty( $this->import_files[0]['import_notice'] ) ) {
206
  echo wp_kses_post( $this->import_files[0]['import_notice'] );
207
  }
208
- ?>
209
- </div>
210
 
211
- <p>
212
- <button class="ocdi__button button-primary js-ocdi-import-data"><?php esc_html_e( 'Import Demo Data', 'pt-ocdi' ); ?></button>
213
  </p>
214
 
215
  <p class="ocdi__ajax-loader js-ocdi-ajax-loader">
@@ -217,6 +241,7 @@ class PT_One_Click_Demo_Import {
217
  </p>
218
 
219
  <div class="ocdi__response js-ocdi-ajax-response"></div>
 
220
  </div>
221
 
222
  <?php
97
  public function display_plugin_page() {
98
  ?>
99
 
100
+ <div class="ocdi wrap about-wrap">
101
+
102
+ <h1 class="ocdi__title dashicons-before dashicons-download"><?php esc_html_e( 'One Click Demo Import', 'pt-ocdi' ); ?></h1>
103
 
104
  <?php
105
 
107
  if ( ini_get( 'safe_mode' ) ) {
108
  printf(
109
  esc_html__( '%sWarning: your server is using %sPHP safe mode%s. This means that you might experience server timeout errors.%s', 'pt-ocdi' ),
110
+ '<div class="notice notice-warning is-dismissible"><p>',
111
  '<strong>',
112
  '</strong>',
113
  '</p></div>'
118
  ob_start();
119
  ?>
120
 
121
+ <div class="ocdi__intro-notice notice notice-warning is-dismissible">
122
+ <p><?php esc_html_e( 'Before you begin, make sure all the required plugins are activated.', 'pt-ocdi' ); ?></p>
123
+ </div>
124
+
125
  <div class="ocdi__intro-text">
126
+
127
+ <p class="about-description">
128
+ <?php esc_html_e( 'Importing demo data (post, pages, images, theme settings, ...) is the easiest way to setup your theme.', 'pt-ocdi' ); ?>
129
+ <?php esc_html_e( 'It will allow you to quickly edit everything instead of creating content from scratch.', 'pt-ocdi' ); ?>
130
  </p>
131
 
132
+ <hr>
133
+
134
+ <p><?php esc_html_e( 'When you import the data, the following things might happen:', 'pt-ocdi' ); ?></p>
135
+
136
  <ul>
137
  <li><?php esc_html_e( 'No existing posts, pages, categories, images, custom post types or any other data will be deleted or modified.', 'pt-ocdi' ); ?></li>
138
  <li><?php esc_html_e( 'Posts, pages, images, widgets and menus will get imported.', 'pt-ocdi' ); ?></li>
139
  <li><?php esc_html_e( 'Please click "Import Demo Data" button only once and wait, it can take a couple of minutes.', 'pt-ocdi' ); ?></li>
140
  </ul>
 
141
 
142
+ <hr>
143
+
144
  </div>
145
 
146
  <?php
147
+ $plugin_intro_text = ob_get_clean();
148
 
149
+ // Display the plugin intro text (can be replaced with custom text through the filter below).
150
+ echo wp_kses_post( apply_filters( 'pt-ocdi/plugin_intro_text', $plugin_intro_text ) );
151
  ?>
152
 
153
 
154
  <?php if ( empty( $this->import_files ) ) : ?>
155
+
156
+ <div class="notice notice-info is-dismissible">
157
+ <p><?php esc_html_e( 'There are no predefined import files available in this theme. Please upload the import files manually!', 'pt-ocdi' ); ?></p>
 
158
  </div>
159
+
160
+ <div class="ocdi__file-upload-container">
161
+
162
+ <h2><?php esc_html_e( 'Manual demo files upload', 'pt-ocdi' ); ?></h2>
163
+
164
+ <div class="ocdi__file-upload">
165
  <h3><label for="content-file-upload"><?php esc_html_e( 'Choose a XML file for content import:', 'pt-ocdi' ); ?></label></h3>
166
  <input id="ocdi__content-file-upload" type="file" name="content-file-upload">
167
  </div>
168
+
169
+ <div class="ocdi__file-upload">
170
  <h3><label for="widget-file-upload"><?php esc_html_e( 'Choose a WIE or JSON file for widget import:', 'pt-ocdi' ); ?></label> <span><?php esc_html_e( '(*optional)', 'pt-ocdi' ); ?></span></h3>
171
  <input id="ocdi__widget-file-upload" type="file" name="widget-file-upload">
172
  </div>
173
+
174
+ <div class="ocdi__file-upload">
175
  <h3><label for="customizer-file-upload"><?php esc_html_e( 'Choose a DAT file for customizer import:', 'pt-ocdi' ); ?></label> <span><?php esc_html_e( '(*optional)', 'pt-ocdi' ); ?></span></h3>
176
  <input id="ocdi__customizer-file-upload" type="file" name="customizer-file-upload">
177
  </div>
178
+
179
  </div>
180
+
181
  <?php elseif ( 1 < count( $this->import_files ) ) : ?>
182
+
183
  <div class="ocdi__multi-select-import">
184
+
185
+ <h2><?php esc_html_e( 'Choose which demo you want to import:', 'pt-ocdi' ); ?></h2>
186
+
187
+ <select id="ocdi__demo-import-files" class="ocdi__demo-import-files">
188
  <?php foreach ( $this->import_files as $index => $import_file ) : ?>
189
  <option value="<?php echo esc_attr( $index ); ?>">
190
  <?php echo esc_html( $import_file['import_file_name'] ); ?>
204
 
205
  if ( $preview_image_is_defined ) :
206
  ?>
207
+
208
+ <div class="ocdi__demo-import-preview-container">
209
+
210
  <p><?php esc_html_e( 'Import preview:', 'pt-ocdi' ); ?></p>
211
+
212
+ <p class="ocdi__demo-import-preview-image-message js-ocdi-preview-image-message"><?php
213
  if ( ! isset( $this->import_files[0]['import_preview_image_url'] ) ) {
214
  esc_html_e( 'No preview image defined for this import.', 'pt-ocdi' );
215
  }
216
  // Leave the img tag below and the p tag above available for later changes via JS.
217
+ ?></p>
218
+
219
  <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'] ) : ''; ?>">
220
+
221
  </div>
222
+
223
  <?php endif; ?>
224
+
225
  </div>
226
+
227
  <?php endif; ?>
228
 
229
+ <div class="ocdi__demo-import-notice js-ocdi-demo-import-notice"><?php
 
230
  if ( is_array( $this->import_files ) && ! empty( $this->import_files[0]['import_notice'] ) ) {
231
  echo wp_kses_post( $this->import_files[0]['import_notice'] );
232
  }
233
+ ?></div>
 
234
 
235
+ <p class="ocdi__button-container">
236
+ <button class="ocdi__button button button-hero button-primary js-ocdi-import-data"><?php esc_html_e( 'Import Demo Data', 'pt-ocdi' ); ?></button>
237
  </p>
238
 
239
  <p class="ocdi__ajax-loader js-ocdi-ajax-loader">
241
  </p>
242
 
243
  <div class="ocdi__response js-ocdi-ajax-response"></div>
244
+
245
  </div>
246
 
247
  <?php
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.3\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"
@@ -78,7 +78,7 @@ msgid "One Click Demo Import"
78
  msgstr ""
79
 
80
  #: inc/class-ocdi-helpers.php:353 inc/class-ocdi-main.php:84
81
- #: inc/class-ocdi-main.php:212
82
  msgid "Import Demo Data"
83
  msgstr ""
84
 
@@ -140,95 +140,107 @@ msgstr ""
140
  msgid "not defined!"
141
  msgstr ""
142
 
143
- #: inc/class-ocdi-main.php:108
144
  msgid ""
145
  "%sWarning: your server is using %sPHP safe mode%s. This means that you "
146
  "might experience server timeout errors.%s"
147
  msgstr ""
148
 
149
  #: inc/class-ocdi-main.php:122
 
 
 
 
150
  msgid ""
151
  "Importing demo data (post, pages, images, theme settings, ...) is the "
152
- "easiest way to setup your theme. It will allow you to quickly edit "
153
- "everything instead of creating content from scratch. When you import the "
154
- "data, the following things might happen:"
155
  msgstr ""
156
 
157
- #: inc/class-ocdi-main.php:126
 
 
 
 
 
 
 
 
 
 
158
  msgid ""
159
  "No existing posts, pages, categories, images, custom post types or any "
160
  "other data will be deleted or modified."
161
  msgstr ""
162
 
163
- #: inc/class-ocdi-main.php:127
164
  msgid "Posts, pages, images, widgets and menus will get imported."
165
  msgstr ""
166
 
167
- #: inc/class-ocdi-main.php:128
168
  msgid ""
169
  "Please click \"Import Demo Data\" button only once and wait, it can take a "
170
  "couple of minutes."
171
  msgstr ""
172
 
173
- #: inc/class-ocdi-main.php:133
174
- msgid "Before you begin, make sure all the required plugins are activated."
175
- msgstr ""
176
-
177
- #: inc/class-ocdi-main.php:147
178
  msgid ""
179
  "There are no predefined import files available in this theme. Please upload "
180
  "the import files manually!"
181
  msgstr ""
182
 
183
- #: inc/class-ocdi-main.php:152
 
 
 
 
184
  msgid "Choose a XML file for content import:"
185
  msgstr ""
186
 
187
- #: inc/class-ocdi-main.php:156
188
  msgid "Choose a WIE or JSON file for widget import:"
189
  msgstr ""
190
 
191
- #: inc/class-ocdi-main.php:156 inc/class-ocdi-main.php:160
192
  msgid "(*optional)"
193
  msgstr ""
194
 
195
- #: inc/class-ocdi-main.php:160
196
  msgid "Choose a DAT file for customizer import:"
197
  msgstr ""
198
 
199
- #: inc/class-ocdi-main.php:166
200
  msgid "Choose which demo you want to import:"
201
  msgstr ""
202
 
203
- #: inc/class-ocdi-main.php:188
204
  msgid "Import preview:"
205
  msgstr ""
206
 
207
- #: inc/class-ocdi-main.php:192 inc/class-ocdi-main.php:243
208
  msgid "No preview image defined for this import."
209
  msgstr ""
210
 
211
- #: inc/class-ocdi-main.php:216
212
  msgid "Importing, please wait!"
213
  msgstr ""
214
 
215
- #: inc/class-ocdi-main.php:300
216
  msgid "Manually uploaded files"
217
  msgstr ""
218
 
219
- #: inc/class-ocdi-main.php:317 inc/class-ocdi-main.php:328
220
  msgid "Downloaded files"
221
  msgstr ""
222
 
223
- #: inc/class-ocdi-main.php:324
224
  msgid "The import files for: %s were successfully downloaded!"
225
  msgstr ""
226
 
227
- #: inc/class-ocdi-main.php:334
228
  msgid "No import files specified!"
229
  msgstr ""
230
 
231
- #: inc/class-ocdi-main.php:381
232
  msgid ""
233
  "%1$s%3$sThat's it, all done!%4$s%2$sThe demo import has finished. Please "
234
  "check your page and make sure that everything has imported correctly. If it "
@@ -236,34 +248,34 @@ msgid ""
236
  "it has done its job.%5$s"
237
  msgstr ""
238
 
239
- #: inc/class-ocdi-main.php:392
240
  msgid ""
241
  "%1$sThe demo import has finished, but there were some import "
242
  "errors.%2$sMore details about the errors can be found in this %3$s%5$slog "
243
  "file%6$s%4$s%7$s"
244
  msgstr ""
245
 
246
- #: inc/class-ocdi-main.php:446
247
  msgid "Max execution time after content import = "
248
  msgstr ""
249
 
250
- #: inc/class-ocdi-main.php:448
251
  msgid "Importing content"
252
  msgstr ""
253
 
254
- #: inc/class-ocdi-main.php:487 inc/class-ocdi-main.php:499
255
  msgid "Importing widgets"
256
  msgstr ""
257
 
258
- #: inc/class-ocdi-main.php:521 inc/class-ocdi-main.php:529
259
  msgid "Importing customizer settings"
260
  msgstr ""
261
 
262
- #: inc/class-ocdi-main.php:527
263
  msgid "Customizer settings import finished!"
264
  msgstr ""
265
 
266
- #: inc/class-ocdi-main.php:579
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.2.0\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"
78
  msgstr ""
79
 
80
  #: inc/class-ocdi-helpers.php:353 inc/class-ocdi-main.php:84
81
+ #: inc/class-ocdi-main.php:236
82
  msgid "Import Demo Data"
83
  msgstr ""
84
 
140
  msgid "not defined!"
141
  msgstr ""
142
 
143
+ #: inc/class-ocdi-main.php:109
144
  msgid ""
145
  "%sWarning: your server is using %sPHP safe mode%s. This means that you "
146
  "might experience server timeout errors.%s"
147
  msgstr ""
148
 
149
  #: inc/class-ocdi-main.php:122
150
+ msgid "Before you begin, make sure all the required plugins are activated."
151
+ msgstr ""
152
+
153
+ #: inc/class-ocdi-main.php:128
154
  msgid ""
155
  "Importing demo data (post, pages, images, theme settings, ...) is the "
156
+ "easiest way to setup your theme."
 
 
157
  msgstr ""
158
 
159
+ #: inc/class-ocdi-main.php:129
160
+ msgid ""
161
+ "It will allow you to quickly edit everything instead of creating content "
162
+ "from scratch."
163
+ msgstr ""
164
+
165
+ #: inc/class-ocdi-main.php:134
166
+ msgid "When you import the data, the following things might happen:"
167
+ msgstr ""
168
+
169
+ #: inc/class-ocdi-main.php:137
170
  msgid ""
171
  "No existing posts, pages, categories, images, custom post types or any "
172
  "other data will be deleted or modified."
173
  msgstr ""
174
 
175
+ #: inc/class-ocdi-main.php:138
176
  msgid "Posts, pages, images, widgets and menus will get imported."
177
  msgstr ""
178
 
179
+ #: inc/class-ocdi-main.php:139
180
  msgid ""
181
  "Please click \"Import Demo Data\" button only once and wait, it can take a "
182
  "couple of minutes."
183
  msgstr ""
184
 
185
+ #: inc/class-ocdi-main.php:157
 
 
 
 
186
  msgid ""
187
  "There are no predefined import files available in this theme. Please upload "
188
  "the import files manually!"
189
  msgstr ""
190
 
191
+ #: inc/class-ocdi-main.php:162
192
+ msgid "Manual demo files upload"
193
+ msgstr ""
194
+
195
+ #: inc/class-ocdi-main.php:165
196
  msgid "Choose a XML file for content import:"
197
  msgstr ""
198
 
199
+ #: inc/class-ocdi-main.php:170
200
  msgid "Choose a WIE or JSON file for widget import:"
201
  msgstr ""
202
 
203
+ #: inc/class-ocdi-main.php:170 inc/class-ocdi-main.php:175
204
  msgid "(*optional)"
205
  msgstr ""
206
 
207
+ #: inc/class-ocdi-main.php:175
208
  msgid "Choose a DAT file for customizer import:"
209
  msgstr ""
210
 
211
+ #: inc/class-ocdi-main.php:185
212
  msgid "Choose which demo you want to import:"
213
  msgstr ""
214
 
215
+ #: inc/class-ocdi-main.php:210
216
  msgid "Import preview:"
217
  msgstr ""
218
 
219
+ #: inc/class-ocdi-main.php:214 inc/class-ocdi-main.php:268
220
  msgid "No preview image defined for this import."
221
  msgstr ""
222
 
223
+ #: inc/class-ocdi-main.php:240
224
  msgid "Importing, please wait!"
225
  msgstr ""
226
 
227
+ #: inc/class-ocdi-main.php:325
228
  msgid "Manually uploaded files"
229
  msgstr ""
230
 
231
+ #: inc/class-ocdi-main.php:342 inc/class-ocdi-main.php:353
232
  msgid "Downloaded files"
233
  msgstr ""
234
 
235
+ #: inc/class-ocdi-main.php:349
236
  msgid "The import files for: %s were successfully downloaded!"
237
  msgstr ""
238
 
239
+ #: inc/class-ocdi-main.php:359
240
  msgid "No import files specified!"
241
  msgstr ""
242
 
243
+ #: inc/class-ocdi-main.php:406
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
  "it has done its job.%5$s"
249
  msgstr ""
250
 
251
+ #: inc/class-ocdi-main.php:417
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
+ #: inc/class-ocdi-main.php:471
259
  msgid "Max execution time after content import = "
260
  msgstr ""
261
 
262
+ #: inc/class-ocdi-main.php:473
263
  msgid "Importing content"
264
  msgstr ""
265
 
266
+ #: inc/class-ocdi-main.php:512 inc/class-ocdi-main.php:524
267
  msgid "Importing widgets"
268
  msgstr ""
269
 
270
+ #: inc/class-ocdi-main.php:546 inc/class-ocdi-main.php:554
271
  msgid "Importing customizer settings"
272
  msgstr ""
273
 
274
+ #: inc/class-ocdi-main.php:552
275
  msgid "Customizer settings import finished!"
276
  msgstr ""
277
 
278
+ #: inc/class-ocdi-main.php:604
279
  msgid "Completed AJAX call number: "
280
  msgstr ""
281
 
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.2.0
8
  Author: ProteusThemes
9
  Author URI: http://www.proteusthemes.com
10
  License: GPL3
@@ -35,7 +35,7 @@ if ( version_compare( phpversion(), '5.3.2', '<' ) ) {
35
  else {
36
 
37
  // Current version of the plugin.
38
- define( 'PT_OCDI_VERSION', '1.2.0' );
39
 
40
  // Path/URL to root of this plugin, with trailing slash.
41
  define( 'PT_OCDI_PATH', plugin_dir_path( __FILE__ ) );
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.3.0
8
  Author: ProteusThemes
9
  Author URI: http://www.proteusthemes.com
10
  License: GPL3
35
  else {
36
 
37
  // Current version of the plugin.
38
+ define( 'PT_OCDI_VERSION', '1.3.0' );
39
 
40
  // Path/URL to root of this plugin, with trailing slash.
41
  define( 'PT_OCDI_PATH', plugin_dir_path( __FILE__ ) );
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  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.2.0
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,12 @@ Import your demo content, widgets and theme settings with one click. Theme autho
12
 
13
  The best feature of this plugin is, that theme authors can define import files in their themes and so all you (the user of the theme) have to do is click on the "Import Demo Data" button.
14
 
15
- **How do theme author define these files?** The answer is in the FAQ section.
 
 
 
 
 
16
 
17
  This plugin will create a submenu page under Appearance with the title **Import demo data**.
18
 
@@ -88,6 +93,32 @@ add_filter( 'pt-ocdi/import_files', 'ocdi_import_files' );
88
 
89
  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.
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  = What about using local import files (from theme folder)? =
92
 
93
  You have to use the same filter as in above example, but with a slightly different array keys: `local_*`. The values have to be absolute paths (not URLs) to your import files. To use local import files, that reside in your theme folder, please use the below code. Note: make sure your import files are readable!
@@ -199,7 +230,7 @@ You want to activate the plugin, but this error shows up:
199
 
200
  This happens, because your hosting server is using a very old version of PHP. This plugin requires PHP version of at least **5.3.x**, but we recommend version *5.6.x*. Please contact your hosting company and ask them to update the PHP version for your site.
201
 
202
- = Issues with the import, that we can fix in the plugin =
203
 
204
  Please visit this [docs page](https://github.com/proteusthemes/one-click-demo-import/blob/master/docs/import-problems.md), for more answers to issues with importing data.
205
 
@@ -211,6 +242,13 @@ Please visit this [docs page](https://github.com/proteusthemes/one-click-demo-im
211
 
212
  == Changelog ==
213
 
 
 
 
 
 
 
 
214
  = 1.2.0 =
215
 
216
  *Release Date - 9 July 2016*
2
  Contributors: capuderg, cyman
3
  Tags: import, content, demo, data, widgets, settings
4
  Requires at least: 4.0.0
5
+ Tested up to: 4.6
6
+ Stable tag: 1.3.0
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
  The best feature of this plugin is, that theme authors can define import files in their themes and so all you (the user of the theme) have to do is click on the "Import Demo Data" button.
14
 
15
+ > **Are you a theme author?**
16
+ > Setup One Click Demo Imports for your theme and your users will thank you for it!
17
+ >
18
+ > [Follow this easy guide on how to setup this plugin for your themes!](http://proteusthemes.github.io/one-click-demo-import/)
19
+ >
20
+ > Also sign up to the newsletter, so we can inform you about any updates, changes or improvements.
21
 
22
  This plugin will create a submenu page under Appearance with the title **Import demo data**.
23
 
93
 
94
  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.
95
 
96
+ = How to automatically assign "Front page", "Posts page" and menu locations after the importer is done? =
97
+
98
+ You can do that, with the `pt-ocdi/after_import` action hook. The code would look something like this:
99
+
100
+ `
101
+ function ocdi_after_import_setup() {
102
+ // Assign menus to their locations.
103
+ $main_menu = get_term_by( 'name', 'Main Menu', 'nav_menu' );
104
+
105
+ set_theme_mod( 'nav_menu_locations', array(
106
+ 'main-menu' => $main_menu->term_id,
107
+ )
108
+ );
109
+
110
+ // Assign front page and posts page (blog page).
111
+ $front_page_id = get_page_by_title( 'Home' );
112
+ $blog_page_id = get_page_by_title( 'Blog' );
113
+
114
+ update_option( 'show_on_front', 'page' );
115
+ update_option( 'page_on_front', $front_page_id->ID );
116
+ update_option( 'page_for_posts', $blog_page_id->ID );
117
+
118
+ }
119
+ add_action( 'pt-ocdi/after_import', 'ocdi_after_import_setup' );
120
+ `
121
+
122
  = What about using local import files (from theme folder)? =
123
 
124
  You have to use the same filter as in above example, but with a slightly different array keys: `local_*`. The values have to be absolute paths (not URLs) to your import files. To use local import files, that reside in your theme folder, please use the below code. Note: make sure your import files are readable!
230
 
231
  This happens, because your hosting server is using a very old version of PHP. This plugin requires PHP version of at least **5.3.x**, but we recommend version *5.6.x*. Please contact your hosting company and ask them to update the PHP version for your site.
232
 
233
+ = Issues with the import, that we can't fix in the plugin =
234
 
235
  Please visit this [docs page](https://github.com/proteusthemes/one-click-demo-import/blob/master/docs/import-problems.md), for more answers to issues with importing data.
236
 
242
 
243
  == Changelog ==
244
 
245
+ = 1.3.0 =
246
+
247
+ *Release Date - 1 October 2016*
248
+
249
+ * Import/plugin page re-design. Updated the plugin page styles to match WordPress (thanks to Oliver Juhas).
250
+
251
+
252
  = 1.2.0 =
253
 
254
  *Release Date - 9 July 2016*
vendor/humanmade/WordPress-Importer/class-wxr-importer.php CHANGED
@@ -561,7 +561,7 @@ class WXR_Importer extends WP_Importer {
561
  public function set_user_mapping( $mapping ) {
562
  foreach ( $mapping as $map ) {
563
  if ( empty( $map['old_slug'] ) || empty( $map['old_id'] ) || empty( $map['new_id'] ) ) {
564
- $this->logger->warning( __( 'Invalid author mapping', 'wordpress-importer') );
565
  $this->logger->debug( var_export( $map, true ) );
566
  continue;
567
  }
@@ -760,13 +760,13 @@ class WXR_Importer extends WP_Importer {
760
  $post_exists = $this->post_exists( $data );
761
  if ( $post_exists ) {
762
  $this->logger->info( sprintf(
763
- __('%s "%s" already exists.', 'wordpress-importer'),
764
  $post_type_object->labels->singular_name,
765
  $data['post_title']
766
  ) );
767
-
768
  // Even though this post already exists, new comments might need importing
769
- $this->process_comments( $comments, $original_id, $data, $post_exists );
770
 
771
  return false;
772
  }
@@ -791,8 +791,7 @@ class WXR_Importer extends WP_Importer {
791
  $data['post_author'] = $this->options['default_author'];
792
  } elseif ( isset( $this->mapping['user_slug'][ $author ] ) ) {
793
  $data['post_author'] = $this->mapping['user_slug'][ $author ];
794
- }
795
- else {
796
  $meta[] = array( 'key' => '_wxr_import_user_slug', 'value' => $author );
797
  $requires_remapping = true;
798
 
@@ -844,7 +843,7 @@ class WXR_Importer extends WP_Importer {
844
  ) );
845
  return false;
846
  }
847
- $remote_url = ! empty($data['attachment_url']) ? $data['attachment_url'] : $data['guid'];
848
  $post_id = $this->process_attachment( $postdata, $meta, $remote_url );
849
  } else {
850
  $post_id = wp_insert_post( $postdata, true );
@@ -873,7 +872,7 @@ class WXR_Importer extends WP_Importer {
873
  }
874
 
875
  // Ensure stickiness is handled correctly too
876
- if ( $data['is_sticky'] == 1 ) {
877
  stick_post( $post_id );
878
  }
879
 
@@ -906,8 +905,7 @@ class WXR_Importer extends WP_Importer {
906
 
907
  if ( isset( $this->mapping['term'][ $key ] ) ) {
908
  $term_ids[ $taxonomy ][] = (int) $this->mapping['term'][ $key ];
909
- }
910
- else {
911
  $meta[] = array( 'key' => '_wxr_import_term', 'value' => $term );
912
  $requires_remapping = true;
913
  }
@@ -984,7 +982,7 @@ class WXR_Importer extends WP_Importer {
984
  default:
985
  // associated object is missing or not imported yet, we'll retry later
986
  $this->missing_menu_items[] = $item;
987
- $this->logger->debug('Unknown menu item type');
988
  break;
989
  }
990
 
@@ -1059,7 +1057,7 @@ class WXR_Importer extends WP_Importer {
1059
  $this->url_remap[ $remote_url ] = $upload['url'];
1060
 
1061
  // If we have a HTTPS URL, ensure the HTTP URL gets replaced too
1062
- if ( substr( $remote_url, 0, 8 ) === 'https://') {
1063
  $insecure_url = 'http' . substr( $remote_url, 5 );
1064
  $this->url_remap[ $insecure_url ] = $upload['url'];
1065
  }
@@ -1139,7 +1137,7 @@ class WXR_Importer extends WP_Importer {
1139
  $key = apply_filters( 'import_post_meta_key', $meta_item['key'], $post_id, $post );
1140
  $value = false;
1141
 
1142
- if ( '_edit_last' == $key ) {
1143
  $value = intval( $meta_item['value'] );
1144
  if ( ! isset( $this->mapping['user'][ $value ] ) ) {
1145
  // Skip!
@@ -1151,15 +1149,17 @@ class WXR_Importer extends WP_Importer {
1151
 
1152
  if ( $key ) {
1153
  // export gets meta straight from the DB so could have a serialized string
1154
- if ( ! $value )
1155
  $value = maybe_unserialize( $meta_item['value'] );
 
1156
 
1157
  add_post_meta( $post_id, $key, $value );
1158
  do_action( 'import_post_meta', $post_id, $key, $value );
1159
 
1160
  // if the post has a featured image, take note of this in case of remap
1161
- if ( '_thumbnail_id' == $key )
1162
- $this->featured_images[$post_id] = (int) $value;
 
1163
  }
1164
  }
1165
 
@@ -1281,9 +1281,12 @@ class WXR_Importer extends WP_Importer {
1281
 
1282
  // if this is a new post we can skip the comment_exists() check
1283
  // TODO: Check comment_exists for performance
1284
- if ( $post_exists && $exists = $this->comment_exists( $comment ) ) {
1285
- $this->mapping['comment'][ $original_id ] = $exists;
1286
- continue;
 
 
 
1287
  }
1288
 
1289
  // Remove meta from the main array
@@ -1630,7 +1633,8 @@ class WXR_Importer extends WP_Importer {
1630
  $parent_id = isset( $data['parent'] ) ? (int) $data['parent'] : 0;
1631
 
1632
  $mapping_key = sha1( $data['taxonomy'] . ':' . $data['slug'] );
1633
- if ( $existing = $this->term_exists( $data ) ) {
 
1634
  $this->mapping['term'][ $mapping_key ] = $existing;
1635
  $this->mapping['term_id'][ $original_id ] = $existing;
1636
  return false;
@@ -1732,18 +1736,19 @@ class WXR_Importer extends WP_Importer {
1732
 
1733
  // get placeholder file in the upload dir with a unique, sanitized filename
1734
  $upload = wp_upload_bits( $file_name, 0, '', $post['upload_date'] );
1735
- if ( $upload['error'] )
1736
  return new WP_Error( 'upload_dir_error', $upload['error'] );
 
1737
 
1738
  // fetch the remote url and write it to the placeholder file
1739
  $response = wp_remote_get( $url, array(
1740
  'stream' => true,
1741
- 'filename' => $upload['file']
1742
  ) );
1743
 
1744
  // request failed
1745
  if ( is_wp_error( $response ) ) {
1746
- @unlink( $upload['file'] );
1747
  return $response;
1748
  }
1749
 
@@ -1751,11 +1756,11 @@ class WXR_Importer extends WP_Importer {
1751
 
1752
  // make sure the fetch was successful
1753
  if ( $code !== 200 ) {
1754
- @unlink( $upload['file'] );
1755
  return new WP_Error(
1756
  'import_file_error',
1757
  sprintf(
1758
- __('Remote server returned %1$d %2$s for %3$s', 'wordpress-importer'),
1759
  $code,
1760
  get_status_header_desc( $code ),
1761
  $url
@@ -1766,20 +1771,21 @@ class WXR_Importer extends WP_Importer {
1766
  $filesize = filesize( $upload['file'] );
1767
  $headers = wp_remote_retrieve_headers( $response );
1768
 
1769
- if ( isset( $headers['content-length'] ) && $filesize != $headers['content-length'] ) {
1770
- @unlink( $upload['file'] );
1771
- return new WP_Error( 'import_file_error', __('Remote file is incorrect size', 'wordpress-importer') );
1772
  }
1773
 
1774
- if ( 0 == $filesize ) {
1775
- @unlink( $upload['file'] );
1776
- return new WP_Error( 'import_file_error', __('Zero size file downloaded', 'wordpress-importer') );
1777
  }
1778
 
1779
  $max_size = (int) $this->max_attachment_size();
1780
  if ( ! empty( $max_size ) && $filesize > $max_size ) {
1781
- @unlink( $upload['file'] );
1782
- return new WP_Error( 'import_file_error', sprintf(__('Remote file is too large, limit is %s', 'wordpress-importer'), size_format($max_size) ) );
 
1783
  }
1784
 
1785
  return $upload;
@@ -1811,8 +1817,7 @@ class WXR_Importer extends WP_Importer {
1811
  // Have we imported the parent now?
1812
  if ( isset( $this->mapping['post'][ $parent_id ] ) ) {
1813
  $data['post_parent'] = $this->mapping['post'][ $parent_id ];
1814
- }
1815
- else {
1816
  $this->logger->warning( sprintf(
1817
  __( 'Could not find the post parent for "%s" (post #%d)', 'wordpress-importer' ),
1818
  get_the_title( $post_id ),
@@ -1831,8 +1836,7 @@ class WXR_Importer extends WP_Importer {
1831
  // Have we imported the user now?
1832
  if ( isset( $this->mapping['user_slug'][ $author_slug ] ) ) {
1833
  $data['post_author'] = $this->mapping['user_slug'][ $author_slug ];
1834
- }
1835
- else {
1836
  $this->logger->warning( sprintf(
1837
  __( 'Could not find the author for "%s" (post #%d)', 'wordpress-importer' ),
1838
  get_the_title( $post_id ),
@@ -1946,8 +1950,7 @@ class WXR_Importer extends WP_Importer {
1946
  // Have we imported the parent now?
1947
  if ( isset( $this->mapping['comment'][ $parent_id ] ) ) {
1948
  $data['comment_parent'] = $this->mapping['comment'][ $parent_id ];
1949
- }
1950
- else {
1951
  $this->logger->warning( sprintf(
1952
  __( 'Could not find the comment parent for comment #%d', 'wordpress-importer' ),
1953
  $comment_id
@@ -1965,8 +1968,7 @@ class WXR_Importer extends WP_Importer {
1965
  // Have we imported the user now?
1966
  if ( isset( $this->mapping['user'][ $author_id ] ) ) {
1967
  $data['user_id'] = $this->mapping['user'][ $author_id ];
1968
- }
1969
- else {
1970
  $this->logger->warning( sprintf(
1971
  __( 'Could not find the author for comment #%d', 'wordpress-importer' ),
1972
  $comment_id
@@ -2007,13 +2009,16 @@ class WXR_Importer extends WP_Importer {
2007
  protected function replace_attachment_urls_in_content() {
2008
  global $wpdb;
2009
  // make sure we do the longest urls first, in case one is a substring of another
2010
- uksort( $this->url_remap, array(&$this, 'cmpr_strlen') );
2011
 
2012
  foreach ( $this->url_remap as $from_url => $to_url ) {
2013
  // remap urls in post_content
2014
- $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, %s, %s)", $from_url, $to_url) );
 
 
2015
  // remap enclosure urls
2016
- $result = $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, %s, %s) WHERE meta_key='enclosure'", $from_url, $to_url) );
 
2017
  }
2018
  }
2019
 
@@ -2023,11 +2028,13 @@ class WXR_Importer extends WP_Importer {
2023
  function remap_featured_images() {
2024
  // cycle through posts that have a featured image
2025
  foreach ( $this->featured_images as $post_id => $value ) {
2026
- if ( isset( $this->processed_posts[$value] ) ) {
2027
- $new_id = $this->processed_posts[$value];
 
2028
  // only update if there's a difference
2029
- if ( $new_id != $value )
2030
  update_post_meta( $post_id, '_thumbnail_id', $new_id );
 
2031
  }
2032
  }
2033
  }
@@ -2041,8 +2048,10 @@ class WXR_Importer extends WP_Importer {
2041
  public function is_valid_meta_key( $key ) {
2042
  // skip attachment metadata since we'll regenerate it from scratch
2043
  // skip _edit_lock as not relevant for import
2044
- if ( in_array( $key, array( '_wp_attached_file', '_wp_attachment_metadata', '_edit_lock' ) ) )
2045
  return false;
 
 
2046
  return $key;
2047
  }
2048
 
@@ -2068,7 +2077,7 @@ class WXR_Importer extends WP_Importer {
2068
 
2069
  // return the difference in length between two strings
2070
  function cmpr_strlen( $a, $b ) {
2071
- return strlen($b) - strlen($a);
2072
  }
2073
 
2074
  /**
561
  public function set_user_mapping( $mapping ) {
562
  foreach ( $mapping as $map ) {
563
  if ( empty( $map['old_slug'] ) || empty( $map['old_id'] ) || empty( $map['new_id'] ) ) {
564
+ $this->logger->warning( __( 'Invalid author mapping', 'wordpress-importer' ) );
565
  $this->logger->debug( var_export( $map, true ) );
566
  continue;
567
  }
760
  $post_exists = $this->post_exists( $data );
761
  if ( $post_exists ) {
762
  $this->logger->info( sprintf(
763
+ __( '%s "%s" already exists.', 'wordpress-importer' ),
764
  $post_type_object->labels->singular_name,
765
  $data['post_title']
766
  ) );
767
+
768
  // Even though this post already exists, new comments might need importing
769
+ $this->process_comments( $comments, $original_id, $data, $post_exists );
770
 
771
  return false;
772
  }
791
  $data['post_author'] = $this->options['default_author'];
792
  } elseif ( isset( $this->mapping['user_slug'][ $author ] ) ) {
793
  $data['post_author'] = $this->mapping['user_slug'][ $author ];
794
+ } else {
 
795
  $meta[] = array( 'key' => '_wxr_import_user_slug', 'value' => $author );
796
  $requires_remapping = true;
797
 
843
  ) );
844
  return false;
845
  }
846
+ $remote_url = ! empty( $data['attachment_url'] ) ? $data['attachment_url'] : $data['guid'];
847
  $post_id = $this->process_attachment( $postdata, $meta, $remote_url );
848
  } else {
849
  $post_id = wp_insert_post( $postdata, true );
872
  }
873
 
874
  // Ensure stickiness is handled correctly too
875
+ if ( $data['is_sticky'] === '1' ) {
876
  stick_post( $post_id );
877
  }
878
 
905
 
906
  if ( isset( $this->mapping['term'][ $key ] ) ) {
907
  $term_ids[ $taxonomy ][] = (int) $this->mapping['term'][ $key ];
908
+ } else {
 
909
  $meta[] = array( 'key' => '_wxr_import_term', 'value' => $term );
910
  $requires_remapping = true;
911
  }
982
  default:
983
  // associated object is missing or not imported yet, we'll retry later
984
  $this->missing_menu_items[] = $item;
985
+ $this->logger->debug( 'Unknown menu item type' );
986
  break;
987
  }
988
 
1057
  $this->url_remap[ $remote_url ] = $upload['url'];
1058
 
1059
  // If we have a HTTPS URL, ensure the HTTP URL gets replaced too
1060
+ if ( substr( $remote_url, 0, 8 ) === 'https://' ) {
1061
  $insecure_url = 'http' . substr( $remote_url, 5 );
1062
  $this->url_remap[ $insecure_url ] = $upload['url'];
1063
  }
1137
  $key = apply_filters( 'import_post_meta_key', $meta_item['key'], $post_id, $post );
1138
  $value = false;
1139
 
1140
+ if ( '_edit_last' === $key ) {
1141
  $value = intval( $meta_item['value'] );
1142
  if ( ! isset( $this->mapping['user'][ $value ] ) ) {
1143
  // Skip!
1149
 
1150
  if ( $key ) {
1151
  // export gets meta straight from the DB so could have a serialized string
1152
+ if ( ! $value ) {
1153
  $value = maybe_unserialize( $meta_item['value'] );
1154
+ }
1155
 
1156
  add_post_meta( $post_id, $key, $value );
1157
  do_action( 'import_post_meta', $post_id, $key, $value );
1158
 
1159
  // if the post has a featured image, take note of this in case of remap
1160
+ if ( '_thumbnail_id' === $key ) {
1161
+ $this->featured_images[ $post_id ] = (int) $value;
1162
+ }
1163
  }
1164
  }
1165
 
1281
 
1282
  // if this is a new post we can skip the comment_exists() check
1283
  // TODO: Check comment_exists for performance
1284
+ if ( $post_exists ) {
1285
+ $existing = $this->comment_exists( $comment );
1286
+ if ( $existing ) {
1287
+ $this->mapping['comment'][ $original_id ] = $exists;
1288
+ continue;
1289
+ }
1290
  }
1291
 
1292
  // Remove meta from the main array
1633
  $parent_id = isset( $data['parent'] ) ? (int) $data['parent'] : 0;
1634
 
1635
  $mapping_key = sha1( $data['taxonomy'] . ':' . $data['slug'] );
1636
+ $existing = $this->term_exists( $data );
1637
+ if ( $existing ) {
1638
  $this->mapping['term'][ $mapping_key ] = $existing;
1639
  $this->mapping['term_id'][ $original_id ] = $existing;
1640
  return false;
1736
 
1737
  // get placeholder file in the upload dir with a unique, sanitized filename
1738
  $upload = wp_upload_bits( $file_name, 0, '', $post['upload_date'] );
1739
+ if ( $upload['error'] ) {
1740
  return new WP_Error( 'upload_dir_error', $upload['error'] );
1741
+ }
1742
 
1743
  // fetch the remote url and write it to the placeholder file
1744
  $response = wp_remote_get( $url, array(
1745
  'stream' => true,
1746
+ 'filename' => $upload['file'],
1747
  ) );
1748
 
1749
  // request failed
1750
  if ( is_wp_error( $response ) ) {
1751
+ unlink( $upload['file'] );
1752
  return $response;
1753
  }
1754
 
1756
 
1757
  // make sure the fetch was successful
1758
  if ( $code !== 200 ) {
1759
+ unlink( $upload['file'] );
1760
  return new WP_Error(
1761
  'import_file_error',
1762
  sprintf(
1763
+ __( 'Remote server returned %1$d %2$s for %3$s', 'wordpress-importer' ),
1764
  $code,
1765
  get_status_header_desc( $code ),
1766
  $url
1771
  $filesize = filesize( $upload['file'] );
1772
  $headers = wp_remote_retrieve_headers( $response );
1773
 
1774
+ if ( isset( $headers['content-length'] ) && $filesize !== (int) $headers['content-length'] ) {
1775
+ unlink( $upload['file'] );
1776
+ return new WP_Error( 'import_file_error', __( 'Remote file is incorrect size', 'wordpress-importer' ) );
1777
  }
1778
 
1779
+ if ( 0 === $filesize ) {
1780
+ unlink( $upload['file'] );
1781
+ return new WP_Error( 'import_file_error', __( 'Zero size file downloaded', 'wordpress-importer' ) );
1782
  }
1783
 
1784
  $max_size = (int) $this->max_attachment_size();
1785
  if ( ! empty( $max_size ) && $filesize > $max_size ) {
1786
+ unlink( $upload['file'] );
1787
+ $message = sprintf( __( 'Remote file is too large, limit is %s', 'wordpress-importer' ), size_format( $max_size ) );
1788
+ return new WP_Error( 'import_file_error', $message );
1789
  }
1790
 
1791
  return $upload;
1817
  // Have we imported the parent now?
1818
  if ( isset( $this->mapping['post'][ $parent_id ] ) ) {
1819
  $data['post_parent'] = $this->mapping['post'][ $parent_id ];
1820
+ } else {
 
1821
  $this->logger->warning( sprintf(
1822
  __( 'Could not find the post parent for "%s" (post #%d)', 'wordpress-importer' ),
1823
  get_the_title( $post_id ),
1836
  // Have we imported the user now?
1837
  if ( isset( $this->mapping['user_slug'][ $author_slug ] ) ) {
1838
  $data['post_author'] = $this->mapping['user_slug'][ $author_slug ];
1839
+ } else {
 
1840
  $this->logger->warning( sprintf(
1841
  __( 'Could not find the author for "%s" (post #%d)', 'wordpress-importer' ),
1842
  get_the_title( $post_id ),
1950
  // Have we imported the parent now?
1951
  if ( isset( $this->mapping['comment'][ $parent_id ] ) ) {
1952
  $data['comment_parent'] = $this->mapping['comment'][ $parent_id ];
1953
+ } else {
 
1954
  $this->logger->warning( sprintf(
1955
  __( 'Could not find the comment parent for comment #%d', 'wordpress-importer' ),
1956
  $comment_id
1968
  // Have we imported the user now?
1969
  if ( isset( $this->mapping['user'][ $author_id ] ) ) {
1970
  $data['user_id'] = $this->mapping['user'][ $author_id ];
1971
+ } else {
 
1972
  $this->logger->warning( sprintf(
1973
  __( 'Could not find the author for comment #%d', 'wordpress-importer' ),
1974
  $comment_id
2009
  protected function replace_attachment_urls_in_content() {
2010
  global $wpdb;
2011
  // make sure we do the longest urls first, in case one is a substring of another
2012
+ uksort( $this->url_remap, array( $this, 'cmpr_strlen' ) );
2013
 
2014
  foreach ( $this->url_remap as $from_url => $to_url ) {
2015
  // remap urls in post_content
2016
+ $query = $wpdb->prepare( "UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, %s, %s)", $from_url, $to_url );
2017
+ $wpdb->query( $query );
2018
+
2019
  // remap enclosure urls
2020
+ $query = $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, %s, %s) WHERE meta_key='enclosure'", $from_url, $to_url );
2021
+ $result = $wpdb->query( $query );
2022
  }
2023
  }
2024
 
2028
  function remap_featured_images() {
2029
  // cycle through posts that have a featured image
2030
  foreach ( $this->featured_images as $post_id => $value ) {
2031
+ if ( isset( $this->processed_posts[ $value ] ) ) {
2032
+ $new_id = $this->processed_posts[ $value ];
2033
+
2034
  // only update if there's a difference
2035
+ if ( $new_id !== $value ) {
2036
  update_post_meta( $post_id, '_thumbnail_id', $new_id );
2037
+ }
2038
  }
2039
  }
2040
  }
2048
  public function is_valid_meta_key( $key ) {
2049
  // skip attachment metadata since we'll regenerate it from scratch
2050
  // skip _edit_lock as not relevant for import
2051
+ if ( in_array( $key, array( '_wp_attached_file', '_wp_attachment_metadata', '_edit_lock' ) ) ) {
2052
  return false;
2053
+ }
2054
+
2055
  return $key;
2056
  }
2057
 
2077
 
2078
  // return the difference in length between two strings
2079
  function cmpr_strlen( $a, $b ) {
2080
+ return strlen( $b ) - strlen( $a );
2081
  }
2082
 
2083
  /**