Version Description
Release Date - 27 April 2016
- Added filter to enable image regeneration,
- Added filter to change the plugin intro text,
- Added action to execute custom code before widget import,
- Disabled author imports.
Download this release
Release Info
| Developer | capuderg |
| Plugin | |
| Version | 1.0.3 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.2 to 1.0.3
- inc/class-ocdi-helpers.php +4 -1
- inc/class-ocdi-widget-importer.php +3 -3
- languages/one-click-demo-import.pot +33 -37
- one-click-demo-import.php +52 -19
- readme.txt +37 -2
- vendor/humanmade/WordPress-Importer/class-wxr-importer.php +177 -3
inc/class-ocdi-helpers.php
CHANGED
|
@@ -221,7 +221,10 @@ class OCDI_Helpers {
|
|
| 221 |
// By this point, the $wp_filesystem global should be working, so let's use it to create a file.
|
| 222 |
global $wp_filesystem;
|
| 223 |
|
| 224 |
-
$existing_data =
|
|
|
|
|
|
|
|
|
|
| 225 |
|
| 226 |
// Style separator.
|
| 227 |
$separator = PHP_EOL . '---' . $separator_text . '---' . PHP_EOL;
|
| 221 |
// By this point, the $wp_filesystem global should be working, so let's use it to create a file.
|
| 222 |
global $wp_filesystem;
|
| 223 |
|
| 224 |
+
$existing_data = '';
|
| 225 |
+
if ( file_exists( $file_path ) ) {
|
| 226 |
+
$existing_data = $wp_filesystem->get_contents( $file_path );
|
| 227 |
+
}
|
| 228 |
|
| 229 |
// Style separator.
|
| 230 |
$separator = PHP_EOL . '---' . $separator_text . '---' . PHP_EOL;
|
inc/class-ocdi-widget-importer.php
CHANGED
|
@@ -78,7 +78,7 @@ class OCDI_Widget_Importer {
|
|
| 78 |
}
|
| 79 |
|
| 80 |
// Hook before import.
|
| 81 |
-
do_action( 'pt-ocdi/
|
| 82 |
$data = apply_filters( 'pt-ocdi/before_widgets_import_data', $data );
|
| 83 |
|
| 84 |
// Get all available widgets site supports.
|
|
@@ -224,7 +224,7 @@ class OCDI_Widget_Importer {
|
|
| 224 |
'widget_id_num' => $new_instance_id_number,
|
| 225 |
'widget_id_num_old' => $instance_id_number,
|
| 226 |
);
|
| 227 |
-
do_action( 'pt-ocdi/
|
| 228 |
|
| 229 |
// Success message.
|
| 230 |
if ( $sidebar_available ) {
|
|
@@ -247,7 +247,7 @@ class OCDI_Widget_Importer {
|
|
| 247 |
}
|
| 248 |
|
| 249 |
// Hook after import.
|
| 250 |
-
do_action( 'pt-ocdi/
|
| 251 |
|
| 252 |
// Return results.
|
| 253 |
return apply_filters( 'pt-ocdi/widget_import_results', $results );
|
| 78 |
}
|
| 79 |
|
| 80 |
// Hook before import.
|
| 81 |
+
do_action( 'pt-ocdi/widget_importer_before_widgets_import' );
|
| 82 |
$data = apply_filters( 'pt-ocdi/before_widgets_import_data', $data );
|
| 83 |
|
| 84 |
// Get all available widgets site supports.
|
| 224 |
'widget_id_num' => $new_instance_id_number,
|
| 225 |
'widget_id_num_old' => $instance_id_number,
|
| 226 |
);
|
| 227 |
+
do_action( 'pt-ocdi/widget_importer_after_single_widget_import', $after_widget_import );
|
| 228 |
|
| 229 |
// Success message.
|
| 230 |
if ( $sidebar_available ) {
|
| 247 |
}
|
| 248 |
|
| 249 |
// Hook after import.
|
| 250 |
+
do_action( 'pt-ocdi/widget_importer_after_widgets_import' );
|
| 251 |
|
| 252 |
// Return results.
|
| 253 |
return apply_filters( 'pt-ocdi/widget_import_results', $results );
|
languages/one-click-demo-import.pot
CHANGED
|
@@ -34,69 +34,69 @@ msgid ""
|
|
| 34 |
"%s."
|
| 35 |
msgstr ""
|
| 36 |
|
| 37 |
-
#: inc/class-ocdi-helpers.php:187 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 "Files info:%1$sSite URL = %2$s%1$sData file = %3$s%1$sWidget file = %4$s"
|
| 97 |
msgstr ""
|
| 98 |
|
| 99 |
-
#: inc/class-ocdi-helpers.php:
|
| 100 |
msgid "not defined!"
|
| 101 |
msgstr ""
|
| 102 |
|
|
@@ -146,7 +146,7 @@ msgid ""
|
|
| 146 |
"might experience server timeout errors.%s"
|
| 147 |
msgstr ""
|
| 148 |
|
| 149 |
-
#: one-click-demo-import.php:
|
| 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 "
|
|
@@ -154,69 +154,69 @@ msgid ""
|
|
| 154 |
"data, the following things might happen:"
|
| 155 |
msgstr ""
|
| 156 |
|
| 157 |
-
#: one-click-demo-import.php:
|
| 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 |
-
#: one-click-demo-import.php:
|
| 164 |
msgid "Posts, pages, images, widgets and menus will get imported."
|
| 165 |
msgstr ""
|
| 166 |
|
| 167 |
-
#: one-click-demo-import.php:
|
| 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 |
-
#: one-click-demo-import.php:
|
| 174 |
msgid "Before you begin, make sure all the required plugins are activated."
|
| 175 |
msgstr ""
|
| 176 |
|
| 177 |
-
#: one-click-demo-import.php:
|
| 178 |
msgid ""
|
| 179 |
"There are no predefined import files available in this theme. Please upload "
|
| 180 |
"the import files manually!"
|
| 181 |
msgstr ""
|
| 182 |
|
| 183 |
-
#: one-click-demo-import.php:
|
| 184 |
msgid "Choose a XML file for content import:"
|
| 185 |
msgstr ""
|
| 186 |
|
| 187 |
-
#: one-click-demo-import.php:
|
| 188 |
msgid "optional"
|
| 189 |
msgstr ""
|
| 190 |
|
| 191 |
-
#: one-click-demo-import.php:
|
| 192 |
msgid "Choose a WIE or JSON file for widget import:"
|
| 193 |
msgstr ""
|
| 194 |
|
| 195 |
-
#: one-click-demo-import.php:
|
| 196 |
msgid "Import Demo Data"
|
| 197 |
msgstr ""
|
| 198 |
|
| 199 |
-
#: one-click-demo-import.php:
|
| 200 |
msgid "Importing now, please wait!"
|
| 201 |
msgstr ""
|
| 202 |
|
| 203 |
-
#: one-click-demo-import.php:
|
| 204 |
msgid "Manually uploaded files"
|
| 205 |
msgstr ""
|
| 206 |
|
| 207 |
-
#: one-click-demo-import.php:
|
| 208 |
msgid "Downloaded files"
|
| 209 |
msgstr ""
|
| 210 |
|
| 211 |
-
#: one-click-demo-import.php:
|
| 212 |
msgid "The import files for: %s were successfully downloaded!"
|
| 213 |
msgstr ""
|
| 214 |
|
| 215 |
-
#: one-click-demo-import.php:
|
| 216 |
msgid "No import files specified!"
|
| 217 |
msgstr ""
|
| 218 |
|
| 219 |
-
#: one-click-demo-import.php:
|
| 220 |
msgid ""
|
| 221 |
"%1$s%3$sThat's it, all done!%4$s%2$sThe demo import has finished. Please "
|
| 222 |
"check your page and make sure that everything has imported correctly. If it "
|
|
@@ -224,25 +224,21 @@ msgid ""
|
|
| 224 |
"it has done its job.%5$s"
|
| 225 |
msgstr ""
|
| 226 |
|
| 227 |
-
#: one-click-demo-import.php:
|
| 228 |
msgid ""
|
| 229 |
"%1$sThe demo import has finished, but there were some import "
|
| 230 |
"errors.%2$sMore details about the errors can be found in this %3$s%5$slog "
|
| 231 |
"file%6$s%4$s%7$s"
|
| 232 |
msgstr ""
|
| 233 |
|
| 234 |
-
#: one-click-demo-import.php:
|
| 235 |
msgid "Importing content"
|
| 236 |
msgstr ""
|
| 237 |
|
| 238 |
-
#: one-click-demo-import.php:
|
| 239 |
msgid "Importing widgets"
|
| 240 |
msgstr ""
|
| 241 |
|
| 242 |
-
#: one-click-demo-import.php:419
|
| 243 |
-
msgid "After import setup"
|
| 244 |
-
msgstr ""
|
| 245 |
-
|
| 246 |
#. Author URI of the plugin/theme
|
| 247 |
msgid "http://www.proteusthemes.com"
|
| 248 |
msgstr ""
|
| 34 |
"%s."
|
| 35 |
msgstr ""
|
| 36 |
|
| 37 |
+
#: inc/class-ocdi-helpers.php:187 inc/class-ocdi-helpers.php:236
|
| 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:276
|
| 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:301
|
| 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:309
|
| 56 |
msgid "Your WordPress login credentials don't allow to use WP_Filesystem!"
|
| 57 |
msgstr ""
|
| 58 |
|
| 59 |
+
#: inc/class-ocdi-helpers.php:326
|
| 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:398
|
| 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:433
|
| 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:435 inc/class-ocdi-helpers.php:456
|
| 79 |
+
#: inc/class-ocdi-helpers.php:464
|
| 80 |
msgid "Upload files"
|
| 81 |
msgstr ""
|
| 82 |
|
| 83 |
+
#: inc/class-ocdi-helpers.php:452
|
| 84 |
msgid "Widget file was not uploaded. Error: %s"
|
| 85 |
msgstr ""
|
| 86 |
|
| 87 |
+
#: inc/class-ocdi-helpers.php:462
|
| 88 |
msgid "The import files were successfully uploaded!"
|
| 89 |
msgstr ""
|
| 90 |
|
| 91 |
+
#: inc/class-ocdi-helpers.php:480
|
| 92 |
msgid "MAX EXECUTION TIME = %s"
|
| 93 |
msgstr ""
|
| 94 |
|
| 95 |
+
#: inc/class-ocdi-helpers.php:484
|
| 96 |
msgid "Files info:%1$sSite URL = %2$s%1$sData file = %3$s%1$sWidget file = %4$s"
|
| 97 |
msgstr ""
|
| 98 |
|
| 99 |
+
#: inc/class-ocdi-helpers.php:488
|
| 100 |
msgid "not defined!"
|
| 101 |
msgstr ""
|
| 102 |
|
| 146 |
"might experience server timeout errors.%s"
|
| 147 |
msgstr ""
|
| 148 |
|
| 149 |
+
#: one-click-demo-import.php:128
|
| 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 "
|
| 154 |
"data, the following things might happen:"
|
| 155 |
msgstr ""
|
| 156 |
|
| 157 |
+
#: one-click-demo-import.php:132
|
| 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 |
+
#: one-click-demo-import.php:133
|
| 164 |
msgid "Posts, pages, images, widgets and menus will get imported."
|
| 165 |
msgstr ""
|
| 166 |
|
| 167 |
+
#: one-click-demo-import.php:134
|
| 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 |
+
#: one-click-demo-import.php:139
|
| 174 |
msgid "Before you begin, make sure all the required plugins are activated."
|
| 175 |
msgstr ""
|
| 176 |
|
| 177 |
+
#: one-click-demo-import.php:153
|
| 178 |
msgid ""
|
| 179 |
"There are no predefined import files available in this theme. Please upload "
|
| 180 |
"the import files manually!"
|
| 181 |
msgstr ""
|
| 182 |
|
| 183 |
+
#: one-click-demo-import.php:157
|
| 184 |
msgid "Choose a XML file for content import:"
|
| 185 |
msgstr ""
|
| 186 |
|
| 187 |
+
#: one-click-demo-import.php:160
|
| 188 |
msgid "optional"
|
| 189 |
msgstr ""
|
| 190 |
|
| 191 |
+
#: one-click-demo-import.php:160
|
| 192 |
msgid "Choose a WIE or JSON file for widget import:"
|
| 193 |
msgstr ""
|
| 194 |
|
| 195 |
+
#: one-click-demo-import.php:176
|
| 196 |
msgid "Import Demo Data"
|
| 197 |
msgstr ""
|
| 198 |
|
| 199 |
+
#: one-click-demo-import.php:201
|
| 200 |
msgid "Importing now, please wait!"
|
| 201 |
msgstr ""
|
| 202 |
|
| 203 |
+
#: one-click-demo-import.php:248
|
| 204 |
msgid "Manually uploaded files"
|
| 205 |
msgstr ""
|
| 206 |
|
| 207 |
+
#: one-click-demo-import.php:265 one-click-demo-import.php:276
|
| 208 |
msgid "Downloaded files"
|
| 209 |
msgstr ""
|
| 210 |
|
| 211 |
+
#: one-click-demo-import.php:272
|
| 212 |
msgid "The import files for: %s were successfully downloaded!"
|
| 213 |
msgstr ""
|
| 214 |
|
| 215 |
+
#: one-click-demo-import.php:282
|
| 216 |
msgid "No import files specified!"
|
| 217 |
msgstr ""
|
| 218 |
|
| 219 |
+
#: one-click-demo-import.php:321
|
| 220 |
msgid ""
|
| 221 |
"%1$s%3$sThat's it, all done!%4$s%2$sThe demo import has finished. Please "
|
| 222 |
"check your page and make sure that everything has imported correctly. If it "
|
| 224 |
"it has done its job.%5$s"
|
| 225 |
msgstr ""
|
| 226 |
|
| 227 |
+
#: one-click-demo-import.php:332
|
| 228 |
msgid ""
|
| 229 |
"%1$sThe demo import has finished, but there were some import "
|
| 230 |
"errors.%2$sMore details about the errors can be found in this %3$s%5$slog "
|
| 231 |
"file%6$s%4$s%7$s"
|
| 232 |
msgstr ""
|
| 233 |
|
| 234 |
+
#: one-click-demo-import.php:383
|
| 235 |
msgid "Importing content"
|
| 236 |
msgstr ""
|
| 237 |
|
| 238 |
+
#: one-click-demo-import.php:419 one-click-demo-import.php:431
|
| 239 |
msgid "Importing widgets"
|
| 240 |
msgstr ""
|
| 241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
#. Author URI of the plugin/theme
|
| 243 |
msgid "http://www.proteusthemes.com"
|
| 244 |
msgstr ""
|
one-click-demo-import.php
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
Plugin Name: One Click Demo Import
|
| 5 |
Plugin URI: http://www.proteusthemes.com
|
| 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.0.
|
| 8 |
Author: ProteusThemes
|
| 9 |
Author URI: http://www.proteusthemes.com
|
| 10 |
License: GPL3
|
|
@@ -20,7 +20,7 @@ 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.0.
|
| 24 |
|
| 25 |
// Include files.
|
| 26 |
require PT_OCDI_PATH . 'inc/class-ocdi-helpers.php';
|
|
@@ -118,6 +118,9 @@ class PT_One_Click_Demo_Import {
|
|
| 118 |
'</p></div>'
|
| 119 |
);
|
| 120 |
}
|
|
|
|
|
|
|
|
|
|
| 121 |
?>
|
| 122 |
|
| 123 |
<div class="ocdi__intro-text">
|
|
@@ -136,6 +139,14 @@ class PT_One_Click_Demo_Import {
|
|
| 136 |
<p><?php esc_html_e( 'Before you begin, make sure all the required plugins are activated.', 'pt-ocdi' ); ?></p>
|
| 137 |
</div>
|
| 138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
<?php if ( empty( $this->import_files ) ) : ?>
|
| 140 |
<div class="notice notice-info below-h2">
|
| 141 |
<p>
|
|
@@ -200,14 +211,14 @@ class PT_One_Click_Demo_Import {
|
|
| 200 |
* Main AJAX callback function for:
|
| 201 |
* 1. prepare import files (uploaded or predefined via filters)
|
| 202 |
* 2. import content
|
| 203 |
-
* 3.
|
| 204 |
-
* 4.
|
|
|
|
| 205 |
*/
|
| 206 |
public function import_demo_data_ajax_callback() {
|
| 207 |
|
| 208 |
-
//
|
| 209 |
-
|
| 210 |
-
add_filter( 'intermediate_image_sizes_advanced', create_function( '', 'return null;' ) );
|
| 211 |
|
| 212 |
// Verify if the AJAX call is valid (checks nonce and current_user_can).
|
| 213 |
OCDI_Helpers::verify_ajax_call();
|
|
@@ -278,19 +289,30 @@ class PT_One_Click_Demo_Import {
|
|
| 278 |
$frontend_error_messages .= $this->import_content( $selected_import_files['content'] );
|
| 279 |
|
| 280 |
/**
|
| 281 |
-
* 3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
*/
|
| 283 |
-
if ( ! empty( $selected_import_files['widgets'] ) ) {
|
| 284 |
$this->import_widgets( $selected_import_files['widgets'] );
|
| 285 |
}
|
| 286 |
|
| 287 |
/**
|
| 288 |
-
*
|
| 289 |
*/
|
| 290 |
-
|
|
|
|
| 291 |
|
| 292 |
// Run the after_import action to setup other settings.
|
| 293 |
-
$this->
|
| 294 |
}
|
| 295 |
|
| 296 |
// Display final messages (success or error messages).
|
|
@@ -336,6 +358,18 @@ class PT_One_Click_Demo_Import {
|
|
| 336 |
// Increase PHP max execution time.
|
| 337 |
set_time_limit( apply_filters( 'pt-ocdi/set_time_limit_for_demo_data_import', 300 ) );
|
| 338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 339 |
// Import content.
|
| 340 |
if ( ! empty( $import_file_path ) ) {
|
| 341 |
ob_start();
|
|
@@ -400,23 +434,22 @@ class PT_One_Click_Demo_Import {
|
|
| 400 |
|
| 401 |
|
| 402 |
/**
|
| 403 |
-
* Setup other things
|
| 404 |
*
|
| 405 |
-
* @param
|
|
|
|
| 406 |
*/
|
| 407 |
-
private function
|
| 408 |
|
| 409 |
-
// Enable users to add custom code to the end of the import process.
|
| 410 |
-
// Append any output to the log file.
|
| 411 |
ob_start();
|
| 412 |
-
do_action(
|
| 413 |
$message = ob_get_clean();
|
| 414 |
|
| 415 |
// Add this message to log file.
|
| 416 |
$log_added = OCDI_Helpers::append_to_file(
|
| 417 |
$message,
|
| 418 |
$this->log_file_path,
|
| 419 |
-
|
| 420 |
);
|
| 421 |
}
|
| 422 |
|
| 4 |
Plugin Name: One Click Demo Import
|
| 5 |
Plugin URI: http://www.proteusthemes.com
|
| 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.0.3
|
| 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.0.3' );
|
| 24 |
|
| 25 |
// Include files.
|
| 26 |
require PT_OCDI_PATH . 'inc/class-ocdi-helpers.php';
|
| 118 |
'</p></div>'
|
| 119 |
);
|
| 120 |
}
|
| 121 |
+
|
| 122 |
+
// Start output buffer for displaying the plugin intro text.
|
| 123 |
+
ob_start();
|
| 124 |
?>
|
| 125 |
|
| 126 |
<div class="ocdi__intro-text">
|
| 139 |
<p><?php esc_html_e( 'Before you begin, make sure all the required plugins are activated.', 'pt-ocdi' ); ?></p>
|
| 140 |
</div>
|
| 141 |
|
| 142 |
+
<?php
|
| 143 |
+
$plugin_intro_text = ob_get_clean();
|
| 144 |
+
|
| 145 |
+
// Display the plugin intro text (can be replaced with custom text through the filter below).
|
| 146 |
+
echo wp_kses_post( apply_filters( 'pt-ocdi/plugin_intro_text', $plugin_intro_text ) );
|
| 147 |
+
?>
|
| 148 |
+
|
| 149 |
+
|
| 150 |
<?php if ( empty( $this->import_files ) ) : ?>
|
| 151 |
<div class="notice notice-info below-h2">
|
| 152 |
<p>
|
| 211 |
* Main AJAX callback function for:
|
| 212 |
* 1. prepare import files (uploaded or predefined via filters)
|
| 213 |
* 2. import content
|
| 214 |
+
* 3. before widgets import setup (optional)
|
| 215 |
+
* 4. import widgets (optional)
|
| 216 |
+
* 5. after import setup (optional)
|
| 217 |
*/
|
| 218 |
public function import_demo_data_ajax_callback() {
|
| 219 |
|
| 220 |
+
// Try to update PHP memory limit (so that it does not run out of it).
|
| 221 |
+
ini_set( 'memory_limit', apply_filters( 'pt-ocdi/import_memory_limit', '350M' ) );
|
|
|
|
| 222 |
|
| 223 |
// Verify if the AJAX call is valid (checks nonce and current_user_can).
|
| 224 |
OCDI_Helpers::verify_ajax_call();
|
| 289 |
$frontend_error_messages .= $this->import_content( $selected_import_files['content'] );
|
| 290 |
|
| 291 |
/**
|
| 292 |
+
* 3. Before widgets import setup.
|
| 293 |
+
*/
|
| 294 |
+
$action = 'pt-ocdi/before_widgets_import';
|
| 295 |
+
if ( ( false !== has_action( $action ) ) && empty( $frontend_error_messages ) ) {
|
| 296 |
+
|
| 297 |
+
// Run the before_widgets_import action to setup other settings.
|
| 298 |
+
$this->do_import_action( $action, $this->import_files[ $selected_index ] );
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
/**
|
| 302 |
+
* 4. Import widgets.
|
| 303 |
*/
|
| 304 |
+
if ( ! empty( $selected_import_files['widgets'] ) && empty( $frontend_error_messages ) ) {
|
| 305 |
$this->import_widgets( $selected_import_files['widgets'] );
|
| 306 |
}
|
| 307 |
|
| 308 |
/**
|
| 309 |
+
* 5. After import setup.
|
| 310 |
*/
|
| 311 |
+
$action = 'pt-ocdi/after_import';
|
| 312 |
+
if ( ( false !== has_action( $action ) ) && empty( $frontend_error_messages ) ) {
|
| 313 |
|
| 314 |
// Run the after_import action to setup other settings.
|
| 315 |
+
$this->do_import_action( $action, $this->import_files[ $selected_index ] );
|
| 316 |
}
|
| 317 |
|
| 318 |
// Display final messages (success or error messages).
|
| 358 |
// Increase PHP max execution time.
|
| 359 |
set_time_limit( apply_filters( 'pt-ocdi/set_time_limit_for_demo_data_import', 300 ) );
|
| 360 |
|
| 361 |
+
// Disable import of authors.
|
| 362 |
+
add_filter( 'wxr_importer.pre_process.user', '__return_false' );
|
| 363 |
+
|
| 364 |
+
// Disables generation of multiple image sizes (thumbnails) in the content import step.
|
| 365 |
+
if ( ! apply_filters( 'pt-ocdi/regenerate_thumbnails_in_content_import', false ) ) {
|
| 366 |
+
add_filter( 'intermediate_image_sizes_advanced',
|
| 367 |
+
function() {
|
| 368 |
+
return null;
|
| 369 |
+
}
|
| 370 |
+
);
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
// Import content.
|
| 374 |
if ( ! empty( $import_file_path ) ) {
|
| 375 |
ob_start();
|
| 434 |
|
| 435 |
|
| 436 |
/**
|
| 437 |
+
* Setup other things in the passed wp action.
|
| 438 |
*
|
| 439 |
+
* @param string $action the action name to be executed.
|
| 440 |
+
* @param array $selected_import with information about the selected import.
|
| 441 |
*/
|
| 442 |
+
private function do_import_action( $action, $selected_import ) {
|
| 443 |
|
|
|
|
|
|
|
| 444 |
ob_start();
|
| 445 |
+
do_action( $action, $selected_import );
|
| 446 |
$message = ob_get_clean();
|
| 447 |
|
| 448 |
// Add this message to log file.
|
| 449 |
$log_added = OCDI_Helpers::append_to_file(
|
| 450 |
$message,
|
| 451 |
$this->log_file_path,
|
| 452 |
+
$action
|
| 453 |
);
|
| 454 |
}
|
| 455 |
|
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.
|
| 6 |
-
Stable tag: 1.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.
|
|
@@ -88,6 +88,32 @@ function ocdi_after_import( $selected_import ) {
|
|
| 88 |
add_action( 'pt-ocdi/after_import', 'ocdi_after_import' );
|
| 89 |
`
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
= I can't activate the plugin, because of a fatal error, what can I do? =
|
| 92 |
|
| 93 |
You want to activate the plugin, but this error shows up:
|
|
@@ -98,6 +124,15 @@ This happens, because your hosting server is using a very old version of PHP. Th
|
|
| 98 |
|
| 99 |
== Changelog ==
|
| 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
= 1.0.2 =
|
| 102 |
|
| 103 |
*Release Date - 15 April 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.5
|
| 6 |
+
Stable tag: 1.0.3
|
| 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.
|
| 88 |
add_action( 'pt-ocdi/after_import', 'ocdi_after_import' );
|
| 89 |
`
|
| 90 |
|
| 91 |
+
= Can I add some code before the widgets get imported? =
|
| 92 |
+
|
| 93 |
+
Of course you can, use the `pt-ocdi/before_widgets_import` filter. You can also target different predefined demo imports like in the example above. Here is a simple example code of the `pt-ocdi/before_widgets_import` filter:
|
| 94 |
+
|
| 95 |
+
`
|
| 96 |
+
function ocdi_before_widgets_import( $selected_import ) {
|
| 97 |
+
echo "Add your code here that will be executed before the widgets get imported!";
|
| 98 |
+
}
|
| 99 |
+
add_action( 'pt-ocdi/before_widgets_import', 'ocdi_before_widgets_import' );
|
| 100 |
+
`
|
| 101 |
+
|
| 102 |
+
= I'm a theme author and I want to change the plugin intro text, how can I do that? =
|
| 103 |
+
|
| 104 |
+
You can change the plugin intro text by using the `pt-ocdi/plugin_intro_text` filter:
|
| 105 |
+
|
| 106 |
+
`
|
| 107 |
+
function ocdi_plugin_intro_text( $default_text ) {
|
| 108 |
+
$default_text .= '<div class="ocdi__intro-text">This is a custom text added to this plugin intro text.</div>';
|
| 109 |
+
|
| 110 |
+
return $default_text;
|
| 111 |
+
}
|
| 112 |
+
add_action( 'pt-ocdi/plugin_intro_text', 'ocdi_plugin_intro_text' );
|
| 113 |
+
`
|
| 114 |
+
|
| 115 |
+
To add some text in a separate "box", you should wrap your text in a div with a class of 'ocdi__intro-text', like in the code example above.
|
| 116 |
+
|
| 117 |
= I can't activate the plugin, because of a fatal error, what can I do? =
|
| 118 |
|
| 119 |
You want to activate the plugin, but this error shows up:
|
| 124 |
|
| 125 |
== Changelog ==
|
| 126 |
|
| 127 |
+
= 1.0.3 =
|
| 128 |
+
|
| 129 |
+
*Release Date - 27 April 2016*
|
| 130 |
+
|
| 131 |
+
* Added filter to enable image regeneration,
|
| 132 |
+
* Added filter to change the plugin intro text,
|
| 133 |
+
* Added action to execute custom code before widget import,
|
| 134 |
+
* Disabled author imports.
|
| 135 |
+
|
| 136 |
= 1.0.2 =
|
| 137 |
|
| 138 |
*Release Date - 15 April 2016*
|
vendor/humanmade/WordPress-Importer/class-wxr-importer.php
CHANGED
|
@@ -73,6 +73,7 @@ class WXR_Importer extends WP_Importer {
|
|
| 73 |
* @var bool $update_attachment_guids Should attachment GUIDs be updated to the new URL? (True updates the GUID, which keeps compatibility with v1, false doesn't update, and allows deduplication and reimporting. Default is false.)
|
| 74 |
* @var bool $fetch_attachments Fetch attachments from the remote server. (True fetches and creates attachment posts, false skips attachments. Default is false.)
|
| 75 |
* @var bool $aggressive_url_search Should we search/replace for URLs aggressively? (True searches all posts' content for old URLs and replaces, false checks for `<img class="wp-image-*">` only. Default is false.)
|
|
|
|
| 76 |
* }
|
| 77 |
*/
|
| 78 |
public function __construct( $options = array() ) {
|
|
@@ -97,6 +98,7 @@ class WXR_Importer extends WP_Importer {
|
|
| 97 |
'update_attachment_guids' => false,
|
| 98 |
'fetch_attachments' => false,
|
| 99 |
'aggressive_url_search' => false,
|
|
|
|
| 100 |
) );
|
| 101 |
}
|
| 102 |
|
|
@@ -131,6 +133,122 @@ class WXR_Importer extends WP_Importer {
|
|
| 131 |
return $reader;
|
| 132 |
}
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
/**
|
| 135 |
* The main controller for the actual import stage.
|
| 136 |
*
|
|
@@ -171,7 +289,7 @@ class WXR_Importer extends WP_Importer {
|
|
| 171 |
$reader->next();
|
| 172 |
break;
|
| 173 |
|
| 174 |
-
case 'wp:
|
| 175 |
$node = $reader->expand();
|
| 176 |
|
| 177 |
$parsed = $this->parse_author_node( $node );
|
|
@@ -268,7 +386,7 @@ class WXR_Importer extends WP_Importer {
|
|
| 268 |
$reader->next();
|
| 269 |
break;
|
| 270 |
|
| 271 |
-
case 'wp:
|
| 272 |
$node = $reader->expand();
|
| 273 |
|
| 274 |
$parsed = $this->parse_author_node( $node );
|
|
@@ -665,7 +783,10 @@ class WXR_Importer extends WP_Importer {
|
|
| 665 |
|
| 666 |
// Map the author, or mark it as one we need to fix
|
| 667 |
$author = sanitize_user( $data['post_author'], true );
|
| 668 |
-
if (
|
|
|
|
|
|
|
|
|
|
| 669 |
$data['post_author'] = $this->mapping['user_slug'][ $author ];
|
| 670 |
}
|
| 671 |
else {
|
|
@@ -734,6 +855,17 @@ class WXR_Importer extends WP_Importer {
|
|
| 734 |
$post_type_object->labels->singular_name
|
| 735 |
) );
|
| 736 |
$this->logger->debug( $post_id->get_error_message() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 737 |
return false;
|
| 738 |
}
|
| 739 |
|
|
@@ -1215,6 +1347,16 @@ class WXR_Importer extends WP_Importer {
|
|
| 1215 |
add_comment_meta( $comment_id, wp_slash( $meta_item['key'] ), wp_slash( $value ) );
|
| 1216 |
}
|
| 1217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1218 |
$num_comments++;
|
| 1219 |
}
|
| 1220 |
|
|
@@ -1375,6 +1517,14 @@ class WXR_Importer extends WP_Importer {
|
|
| 1375 |
$userdata['user_login']
|
| 1376 |
) );
|
| 1377 |
$this->logger->debug( $user_id->get_error_message() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1378 |
return false;
|
| 1379 |
}
|
| 1380 |
|
|
@@ -1394,6 +1544,13 @@ class WXR_Importer extends WP_Importer {
|
|
| 1394 |
) );
|
| 1395 |
|
| 1396 |
// TODO: Implement meta handling once WXR includes it
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1397 |
}
|
| 1398 |
|
| 1399 |
protected function parse_term_node( $node, $type = 'term' ) {
|
|
@@ -1523,6 +1680,15 @@ class WXR_Importer extends WP_Importer {
|
|
| 1523 |
) );
|
| 1524 |
$this->logger->debug( $result->get_error_message() );
|
| 1525 |
do_action( 'wp_import_insert_term_failed', $result, $data );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1526 |
return false;
|
| 1527 |
}
|
| 1528 |
|
|
@@ -1543,6 +1709,14 @@ class WXR_Importer extends WP_Importer {
|
|
| 1543 |
) );
|
| 1544 |
|
| 1545 |
do_action( 'wp_import_insert_term', $term_id, $data );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1546 |
}
|
| 1547 |
|
| 1548 |
/**
|
| 73 |
* @var bool $update_attachment_guids Should attachment GUIDs be updated to the new URL? (True updates the GUID, which keeps compatibility with v1, false doesn't update, and allows deduplication and reimporting. Default is false.)
|
| 74 |
* @var bool $fetch_attachments Fetch attachments from the remote server. (True fetches and creates attachment posts, false skips attachments. Default is false.)
|
| 75 |
* @var bool $aggressive_url_search Should we search/replace for URLs aggressively? (True searches all posts' content for old URLs and replaces, false checks for `<img class="wp-image-*">` only. Default is false.)
|
| 76 |
+
* @var int $default_author User ID to use if author is missing or invalid. (Default is null, which leaves posts unassigned.)
|
| 77 |
* }
|
| 78 |
*/
|
| 79 |
public function __construct( $options = array() ) {
|
| 98 |
'update_attachment_guids' => false,
|
| 99 |
'fetch_attachments' => false,
|
| 100 |
'aggressive_url_search' => false,
|
| 101 |
+
'default_author' => null,
|
| 102 |
) );
|
| 103 |
}
|
| 104 |
|
| 133 |
return $reader;
|
| 134 |
}
|
| 135 |
|
| 136 |
+
/**
|
| 137 |
+
* The main controller for the actual import stage.
|
| 138 |
+
*
|
| 139 |
+
* @param string $file Path to the WXR file for importing
|
| 140 |
+
*/
|
| 141 |
+
public function get_preliminary_information( $file ) {
|
| 142 |
+
// Let's run the actual importer now, woot
|
| 143 |
+
$reader = $this->get_reader( $file );
|
| 144 |
+
if ( is_wp_error( $reader ) ) {
|
| 145 |
+
return $reader;
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
// Set the version to compatibility mode first
|
| 149 |
+
$this->version = '1.0';
|
| 150 |
+
|
| 151 |
+
// Start parsing!
|
| 152 |
+
$data = new WXR_Import_Info();
|
| 153 |
+
while ( $reader->read() ) {
|
| 154 |
+
// Only deal with element opens
|
| 155 |
+
if ( $reader->nodeType !== XMLReader::ELEMENT ) {
|
| 156 |
+
continue;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
switch ( $reader->name ) {
|
| 160 |
+
case 'wp:wxr_version':
|
| 161 |
+
// Upgrade to the correct version
|
| 162 |
+
$this->version = $reader->readString();
|
| 163 |
+
|
| 164 |
+
if ( version_compare( $this->version, self::MAX_WXR_VERSION, '>' ) ) {
|
| 165 |
+
$this->logger->warning( sprintf(
|
| 166 |
+
__( 'This WXR file (version %s) is newer than the importer (version %s) and may not be supported. Please consider updating.', 'wordpress-importer' ),
|
| 167 |
+
$this->version,
|
| 168 |
+
self::MAX_WXR_VERSION
|
| 169 |
+
) );
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
// Handled everything in this node, move on to the next
|
| 173 |
+
$reader->next();
|
| 174 |
+
break;
|
| 175 |
+
|
| 176 |
+
case 'generator':
|
| 177 |
+
$data->generator = $reader->readString();
|
| 178 |
+
$reader->next();
|
| 179 |
+
break;
|
| 180 |
+
|
| 181 |
+
case 'title':
|
| 182 |
+
$data->title = $reader->readString();
|
| 183 |
+
$reader->next();
|
| 184 |
+
break;
|
| 185 |
+
|
| 186 |
+
case 'wp:base_site_url':
|
| 187 |
+
$data->siteurl = $reader->readString();
|
| 188 |
+
$reader->next();
|
| 189 |
+
break;
|
| 190 |
+
|
| 191 |
+
case 'wp:base_blog_url':
|
| 192 |
+
$data->home = $reader->readString();
|
| 193 |
+
$reader->next();
|
| 194 |
+
break;
|
| 195 |
+
|
| 196 |
+
case 'wp:author':
|
| 197 |
+
$node = $reader->expand();
|
| 198 |
+
|
| 199 |
+
$parsed = $this->parse_author_node( $node );
|
| 200 |
+
if ( is_wp_error( $parsed ) ) {
|
| 201 |
+
$this->log_error( $parsed );
|
| 202 |
+
|
| 203 |
+
// Skip the rest of this post
|
| 204 |
+
$reader->next();
|
| 205 |
+
break;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
$data->users[] = $parsed;
|
| 209 |
+
|
| 210 |
+
// Handled everything in this node, move on to the next
|
| 211 |
+
$reader->next();
|
| 212 |
+
break;
|
| 213 |
+
|
| 214 |
+
case 'item':
|
| 215 |
+
$node = $reader->expand();
|
| 216 |
+
$parsed = $this->parse_post_node( $node );
|
| 217 |
+
if ( is_wp_error( $parsed ) ) {
|
| 218 |
+
$this->log_error( $parsed );
|
| 219 |
+
|
| 220 |
+
// Skip the rest of this post
|
| 221 |
+
$reader->next();
|
| 222 |
+
break;
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
if ( $parsed['data']['post_type'] === 'attachment' ) {
|
| 226 |
+
$data->media_count++;
|
| 227 |
+
} else {
|
| 228 |
+
$data->post_count++;
|
| 229 |
+
}
|
| 230 |
+
$data->comment_count += count( $parsed['comments'] );
|
| 231 |
+
|
| 232 |
+
// Handled everything in this node, move on to the next
|
| 233 |
+
$reader->next();
|
| 234 |
+
break;
|
| 235 |
+
|
| 236 |
+
case 'wp:category':
|
| 237 |
+
case 'wp:tag':
|
| 238 |
+
case 'wp:term':
|
| 239 |
+
$data->term_count++;
|
| 240 |
+
|
| 241 |
+
// Handled everything in this node, move on to the next
|
| 242 |
+
$reader->next();
|
| 243 |
+
break;
|
| 244 |
+
}
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
$data->version = $this->version;
|
| 248 |
+
|
| 249 |
+
return $data;
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
/**
|
| 253 |
* The main controller for the actual import stage.
|
| 254 |
*
|
| 289 |
$reader->next();
|
| 290 |
break;
|
| 291 |
|
| 292 |
+
case 'wp:author':
|
| 293 |
$node = $reader->expand();
|
| 294 |
|
| 295 |
$parsed = $this->parse_author_node( $node );
|
| 386 |
$reader->next();
|
| 387 |
break;
|
| 388 |
|
| 389 |
+
case 'wp:author':
|
| 390 |
$node = $reader->expand();
|
| 391 |
|
| 392 |
$parsed = $this->parse_author_node( $node );
|
| 783 |
|
| 784 |
// Map the author, or mark it as one we need to fix
|
| 785 |
$author = sanitize_user( $data['post_author'], true );
|
| 786 |
+
if ( empty( $author ) ) {
|
| 787 |
+
// Missing or invalid author, use default if available.
|
| 788 |
+
$data['post_author'] = $this->options['default_author'];
|
| 789 |
+
} elseif ( isset( $this->mapping['user_slug'][ $author ] ) ) {
|
| 790 |
$data['post_author'] = $this->mapping['user_slug'][ $author ];
|
| 791 |
}
|
| 792 |
else {
|
| 855 |
$post_type_object->labels->singular_name
|
| 856 |
) );
|
| 857 |
$this->logger->debug( $post_id->get_error_message() );
|
| 858 |
+
|
| 859 |
+
/**
|
| 860 |
+
* Post processing failed.
|
| 861 |
+
*
|
| 862 |
+
* @param WP_Error $post_id Error object.
|
| 863 |
+
* @param array $data Raw data imported for the post.
|
| 864 |
+
* @param array $meta Raw meta data, already processed by {@see process_post_meta}.
|
| 865 |
+
* @param array $comments Raw comment data, already processed by {@see process_comments}.
|
| 866 |
+
* @param array $terms Raw term data, already processed.
|
| 867 |
+
*/
|
| 868 |
+
do_action( 'wxr_importer.process_failed.post', $post_id, $data, $meta, $comments, $terms );
|
| 869 |
return false;
|
| 870 |
}
|
| 871 |
|
| 1347 |
add_comment_meta( $comment_id, wp_slash( $meta_item['key'] ), wp_slash( $value ) );
|
| 1348 |
}
|
| 1349 |
|
| 1350 |
+
/**
|
| 1351 |
+
* Post processing completed.
|
| 1352 |
+
*
|
| 1353 |
+
* @param int $post_id New post ID.
|
| 1354 |
+
* @param array $comment Raw data imported for the comment.
|
| 1355 |
+
* @param array $meta Raw meta data, already processed by {@see process_post_meta}.
|
| 1356 |
+
* @param array $post_id Parent post ID.
|
| 1357 |
+
*/
|
| 1358 |
+
do_action( 'wxr_importer.processed.comment', $comment_id, $comment, $meta, $post_id );
|
| 1359 |
+
|
| 1360 |
$num_comments++;
|
| 1361 |
}
|
| 1362 |
|
| 1517 |
$userdata['user_login']
|
| 1518 |
) );
|
| 1519 |
$this->logger->debug( $user_id->get_error_message() );
|
| 1520 |
+
|
| 1521 |
+
/**
|
| 1522 |
+
* User processing failed.
|
| 1523 |
+
*
|
| 1524 |
+
* @param WP_Error $user_id Error object.
|
| 1525 |
+
* @param array $userdata Raw data imported for the user.
|
| 1526 |
+
*/
|
| 1527 |
+
do_action( 'wxr_importer.process_failed.user', $user_id, $userdata );
|
| 1528 |
return false;
|
| 1529 |
}
|
| 1530 |
|
| 1544 |
) );
|
| 1545 |
|
| 1546 |
// TODO: Implement meta handling once WXR includes it
|
| 1547 |
+
/**
|
| 1548 |
+
* User processing completed.
|
| 1549 |
+
*
|
| 1550 |
+
* @param int $user_id New user ID.
|
| 1551 |
+
* @param array $userdata Raw data imported for the user.
|
| 1552 |
+
*/
|
| 1553 |
+
do_action( 'wxr_importer.processed.user', $user_id, $userdata );
|
| 1554 |
}
|
| 1555 |
|
| 1556 |
protected function parse_term_node( $node, $type = 'term' ) {
|
| 1680 |
) );
|
| 1681 |
$this->logger->debug( $result->get_error_message() );
|
| 1682 |
do_action( 'wp_import_insert_term_failed', $result, $data );
|
| 1683 |
+
|
| 1684 |
+
/**
|
| 1685 |
+
* Term processing failed.
|
| 1686 |
+
*
|
| 1687 |
+
* @param WP_Error $result Error object.
|
| 1688 |
+
* @param array $data Raw data imported for the term.
|
| 1689 |
+
* @param array $meta Meta data supplied for the term.
|
| 1690 |
+
*/
|
| 1691 |
+
do_action( 'wxr_importer.process_failed.term', $result, $data, $meta );
|
| 1692 |
return false;
|
| 1693 |
}
|
| 1694 |
|
| 1709 |
) );
|
| 1710 |
|
| 1711 |
do_action( 'wp_import_insert_term', $term_id, $data );
|
| 1712 |
+
|
| 1713 |
+
/**
|
| 1714 |
+
* Term processing completed.
|
| 1715 |
+
*
|
| 1716 |
+
* @param int $term_id New term ID.
|
| 1717 |
+
* @param array $data Raw data imported for the term.
|
| 1718 |
+
*/
|
| 1719 |
+
do_action( 'wxr_importer.processed.term', $term_id, $data );
|
| 1720 |
}
|
| 1721 |
|
| 1722 |
/**
|
