readme.txt (23548B)
1 === One Click Demo Import === 2 Contributors: capuderg, cyman, Prelc, proteusthemes 3 Tags: import, content, demo, data, widgets, settings, redux, theme options 4 Requires at least: 4.0.0 5 Tested up to: 4.9 6 Stable tag: 2.5.1 7 License: GPLv3 or later 8 9 Import your demo content, widgets and theme settings with one click. Theme authors! Enable simple demo import for your theme demo data. 10 11 == Description == 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 > 17 > Setup One Click Demo Imports for your theme and your users will thank you for it! 18 > 19 > [Follow this easy guide on how to setup this plugin for your themes!](http://proteusthemes.github.io/one-click-demo-import/) 20 > 21 > Also [sign up to the newsletter](http://proteusthemes.github.io/one-click-demo-import/#ocdi-newsletter-signup), so we can inform you about any updates, changes or improvements. 22 23 > **Are you a theme user?** 24 > 25 > Contact the author of your theme and [let them know about this plugin](http://proteusthemes.github.io/one-click-demo-import/theme-users.html). Theme authors can make any theme compatible with this plugin in 15 minutes and make it much more user-friendly. 26 > 27 > "[Where can I find the contact of the theme author?](http://proteusthemes.github.io/one-click-demo-import/theme-users.html)" 28 29 This plugin will create a submenu page under Appearance with the title **Import demo data**. 30 31 If the theme you are using does not have any predefined import files, then you will be presented with three file upload inputs. First one is required and you will have to upload a demo content XML file, for the actual demo import. The second one is optional and will ask you for a WIE or JSON file for widgets import. You create that file using the [Widget Importer & Exporter](https://wordpress.org/plugins/widget-importer-exporter/) plugin. The third one is also optional and will import the customizer settings, select the DAT file which you can generate from [Customizer Export/Import](https://wordpress.org/plugins/customizer-export-import/) plugin (the customizer settings will be imported only if the export file was created from the same theme). The final one is optional as well and will import your Redux framework settings. You can generate the export json file with the [Redux framework](https://wordpress.org/plugins/redux-framework/) plugin. 32 33 This plugin is using the improved WP import 2.0 that is still in development and can be found here: https://github.com/humanmade/WordPress-Importer. 34 35 All progress of this plugin's work is logged in a log file in the default WP upload directory, together with the demo import files used in the importing process. 36 37 NOTE: There is no setting to "connect" authors from the demo import file to the existing users in your WP site (like there is in the original WP Importer plugin). All demo content will be imported under the current user. 38 39 **Do you want to contribute?** 40 41 Please refer to the official [GitHub repository](https://github.com/proteusthemes/one-click-demo-import) of this plugin. 42 43 == Installation == 44 45 **From your WordPress dashboard** 46 47 1. Visit 'Plugins > Add New', 48 2. Search for 'One Click Demo Import' and install the plugin, 49 3. Activate 'One Click Demo Import' from your Plugins page. 50 51 **From WordPress.org** 52 53 1. Download 'One Click Demo Import'. 54 2. Upload the 'one-click-demo-import' directory to your '/wp-content/plugins/' directory, using your favorite method (ftp, sftp, scp, etc...) 55 3. Activate 'One Click Demo Import' from your Plugins page. 56 57 **Once the plugin is activated you will find the actual import page in: Appearance -> Import Demo Data.** 58 59 == Frequently Asked Questions == 60 61 = I have activated the plugin. Where is the "Import Demo Data" page? = 62 63 You will find the import page in *wp-admin -> Appearance -> Import Demo Data*. 64 65 = Where are the demo import files and the log files saved? = 66 67 The files used in the demo import will be saved to the default WordPress uploads directory. An example of that directory would be: `../wp-content/uploads/2016/03/`. 68 69 The log file will also be registered in the *wp-admin -> Media* section, so you can access it easily. 70 71 = How to predefine demo imports? = 72 73 This question is for theme authors. To predefine demo imports, you just have to add the following code structure, with your own values to your theme (using the `pt-ocdi/import_files` filter): 74 75 ` 76 function ocdi_import_files() { 77 return array( 78 array( 79 'import_file_name' => 'Demo Import 1', 80 'categories' => array( 'Category 1', 'Category 2' ), 81 'import_file_url' => 'http://www.your_domain.com/ocdi/demo-content.xml', 82 'import_widget_file_url' => 'http://www.your_domain.com/ocdi/widgets.json', 83 'import_customizer_file_url' => 'http://www.your_domain.com/ocdi/customizer.dat', 84 'import_redux' => array( 85 array( 86 'file_url' => 'http://www.your_domain.com/ocdi/redux.json', 87 'option_name' => 'redux_option_name', 88 ), 89 ), 90 'import_preview_image_url' => 'http://www.your_domain.com/ocdi/preview_import_image1.jpg', 91 'import_notice' => __( 'After you import this demo, you will have to setup the slider separately.', 'your-textdomain' ), 92 'preview_url' => 'http://www.your_domain.com/my-demo-1', 93 ), 94 array( 95 'import_file_name' => 'Demo Import 2', 96 'categories' => array( 'New category', 'Old category' ), 97 'import_file_url' => 'http://www.your_domain.com/ocdi/demo-content2.xml', 98 'import_widget_file_url' => 'http://www.your_domain.com/ocdi/widgets2.json', 99 'import_customizer_file_url' => 'http://www.your_domain.com/ocdi/customizer2.dat', 100 'import_redux' => array( 101 array( 102 'file_url' => 'http://www.your_domain.com/ocdi/redux.json', 103 'option_name' => 'redux_option_name', 104 ), 105 array( 106 'file_url' => 'http://www.your_domain.com/ocdi/redux2.json', 107 'option_name' => 'redux_option_name_2', 108 ), 109 ), 110 'import_preview_image_url' => 'http://www.your_domain.com/ocdi/preview_import_image2.jpg', 111 'import_notice' => __( 'A special note for this import.', 'your-textdomain' ), 112 'preview_url' => 'http://www.your_domain.com/my-demo-2', 113 ), 114 ); 115 } 116 add_filter( 'pt-ocdi/import_files', 'ocdi_import_files' ); 117 ` 118 119 You can set content import, widgets, customizer and Redux framework 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. Categories can be assigned to each demo import, so that they can be filtered easily. The preview URL will display the "Preview" button in the predefined demo item, which will open this URL in a new tab and user can view how the demo site looks like. 120 121 = How to automatically assign "Front page", "Posts page" and menu locations after the importer is done? = 122 123 You can do that, with the `pt-ocdi/after_import` action hook. The code would look something like this: 124 125 ` 126 function ocdi_after_import_setup() { 127 // Assign menus to their locations. 128 $main_menu = get_term_by( 'name', 'Main Menu', 'nav_menu' ); 129 130 set_theme_mod( 'nav_menu_locations', array( 131 'main-menu' => $main_menu->term_id, 132 ) 133 ); 134 135 // Assign front page and posts page (blog page). 136 $front_page_id = get_page_by_title( 'Home' ); 137 $blog_page_id = get_page_by_title( 'Blog' ); 138 139 update_option( 'show_on_front', 'page' ); 140 update_option( 'page_on_front', $front_page_id->ID ); 141 update_option( 'page_for_posts', $blog_page_id->ID ); 142 143 } 144 add_action( 'pt-ocdi/after_import', 'ocdi_after_import_setup' ); 145 ` 146 147 = What about using local import files (from theme folder)? = 148 149 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! 150 151 ` 152 function ocdi_import_files() { 153 return array( 154 array( 155 'import_file_name' => 'Demo Import 1', 156 'categories' => array( 'Category 1', 'Category 2' ), 157 'local_import_file' => trailingslashit( get_template_directory() ) . 'ocdi/demo-content.xml', 158 'local_import_widget_file' => trailingslashit( get_template_directory() ) . 'ocdi/widgets.json', 159 'local_import_customizer_file' => trailingslashit( get_template_directory() ) . 'ocdi/customizer.dat', 160 'local_import_redux' => array( 161 array( 162 'file_path' => trailingslashit( get_template_directory() ) . 'ocdi/redux.json', 163 'option_name' => 'redux_option_name', 164 ), 165 ), 166 'import_preview_image_url' => 'http://www.your_domain.com/ocdi/preview_import_image1.jpg', 167 'import_notice' => __( 'After you import this demo, you will have to setup the slider separately.', 'your-textdomain' ), 168 'preview_url' => 'http://www.your_domain.com/my-demo-1', 169 ), 170 array( 171 'import_file_name' => 'Demo Import 2', 172 'categories' => array( 'New category', 'Old category' ), 173 'local_import_file' => trailingslashit( get_template_directory() ) . 'ocdi/demo-content2.xml', 174 'local_import_widget_file' => trailingslashit( get_template_directory() ) . 'ocdi/widgets2.json', 175 'local_import_customizer_file' => trailingslashit( get_template_directory() ) . 'ocdi/customizer2.dat', 176 'local_import_redux' => array( 177 array( 178 'file_path' => trailingslashit( get_template_directory() ) . 'ocdi/redux.json', 179 'option_name' => 'redux_option_name', 180 ), 181 array( 182 'file_path' => trailingslashit( get_template_directory() ) . 'ocdi/redux2.json', 183 'option_name' => 'redux_option_name_2', 184 ), 185 ), 186 'import_preview_image_url' => 'http://www.your_domain.com/ocdi/preview_import_image2.jpg', 187 'import_notice' => __( 'A special note for this import.', 'your-textdomain' ), 188 'preview_url' => 'http://www.your_domain.com/my-demo-2', 189 ), 190 ); 191 } 192 add_filter( 'pt-ocdi/import_files', 'ocdi_import_files' ); 193 ` 194 195 = How to handle different "after import setups" depending on which predefined import was selected? = 196 197 This question might be asked by a theme author wanting to implement different after import setups for multiple predefined demo imports. Lets say we have predefined two demo imports with the following names: 'Demo Import 1' and 'Demo Import 2', the code for after import setup would be (using the `pt-ocdi/after_import` filter): 198 199 ` 200 function ocdi_after_import( $selected_import ) { 201 echo "This will be displayed on all after imports!"; 202 203 if ( 'Demo Import 1' === $selected_import['import_file_name'] ) { 204 echo "This will be displayed only on after import if user selects Demo Import 1"; 205 206 // Set logo in customizer 207 set_theme_mod( 'logo_img', get_template_directory_uri() . '/assets/images/logo1.png' ); 208 } 209 elseif ( 'Demo Import 2' === $selected_import['import_file_name'] ) { 210 echo "This will be displayed only on after import if user selects Demo Import 2"; 211 212 // Set logo in customizer 213 set_theme_mod( 'logo_img', get_template_directory_uri() . '/assets/images/logo2.png' ); 214 } 215 } 216 add_action( 'pt-ocdi/after_import', 'ocdi_after_import' ); 217 ` 218 219 = Can I add some code before the widgets get imported? = 220 221 Of course you can, use the `pt-ocdi/before_widgets_import` action. 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` action: 222 223 ` 224 function ocdi_before_widgets_import( $selected_import ) { 225 echo "Add your code here that will be executed before the widgets get imported!"; 226 } 227 add_action( 'pt-ocdi/before_widgets_import', 'ocdi_before_widgets_import' ); 228 ` 229 230 = How can I import via the WP-CLI? = 231 232 In the 2.4.0 version of this pugin we added two WP-CLI commands: 233 234 * `wp ocdi list` - Which will list any predefined demo imports currently active theme might have, 235 * `wp ocdi import` - which has a few options that you can use to import the things you want (content/widgets/customizer/predefined demos). Let's look at these options below. 236 237 `wp ocdi import` options: 238 239 `wp ocdi import [--content=<file>] [--widgets=<file>] [--customizer=<file>] [--predefined=<index>]` 240 241 * `--content=<file>` - will run the content import with the WP import file specified in the `<file>` parameter, 242 * `--widgets=<file>` - will run the widgets import with the widgets import file specified in the `<file>` parameter, 243 * `--customizer=<file>` - will run the customizer settings import with the customizer import file specified in the `<file>` parameter, 244 * `--predefined=<index>` - will run the theme predefined import with the index of the predefined import in the `<index>` parameter (you can use the `wp ocdi list` command to check which index is used for each predefined demo import) 245 246 The content, widgets and customizer options can be mixed and used at the same time. If the `predefined` option is set, then it will ignore all other options and import the predefined demo data. 247 248 = I'm a theme author and I want to change the plugin intro text, how can I do that? = 249 250 You can change the plugin intro text by using the `pt-ocdi/plugin_intro_text` filter: 251 252 ` 253 function ocdi_plugin_intro_text( $default_text ) { 254 $default_text .= '<div class="ocdi__intro-text">This is a custom text added to this plugin intro text.</div>'; 255 256 return $default_text; 257 } 258 add_filter( 'pt-ocdi/plugin_intro_text', 'ocdi_plugin_intro_text' ); 259 ` 260 261 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. 262 263 = How to disable generation of smaller images (thumbnails) during the content import = 264 265 This will greatly improve the time needed to import the content (images), but only the original sized images will be imported. You can disable it with a filter, so just add this code to your theme function.php file: 266 267 `add_filter( 'pt-ocdi/regenerate_thumbnails_in_content_import', '__return_false' );` 268 269 = How to change the location, title and other parameters of the plugin page? = 270 271 As a theme author you do not like the location of the "Import Demo Data" plugin page in *Appearance -> Import Demo Data*? You can change that with the filter below. Apart from the location, you can also change the title or the page/menu and some other parameters as well. 272 273 ` 274 function ocdi_plugin_page_setup( $default_settings ) { 275 $default_settings['parent_slug'] = 'themes.php'; 276 $default_settings['page_title'] = esc_html__( 'One Click Demo Import' , 'pt-ocdi' ); 277 $default_settings['menu_title'] = esc_html__( 'Import Demo Data' , 'pt-ocdi' ); 278 $default_settings['capability'] = 'import'; 279 $default_settings['menu_slug'] = 'pt-one-click-demo-import'; 280 281 return $default_settings; 282 } 283 add_filter( 'pt-ocdi/plugin_page_setup', 'ocdi_plugin_page_setup' ); 284 ` 285 286 = How to do something before the content import executes? = 287 288 In version 2.0.0 there is a new action hook: `pt-ocdi/before_content_import`, which will let you hook before the content import starts. An example of the code would look like this: 289 290 ` 291 function ocdi_before_content_import( $selected_import ) { 292 if ( 'Demo Import 1' === $selected_import['import_file_name'] ) { 293 // Here you can do stuff for the "Demo Import 1" before the content import starts. 294 echo "before import 1"; 295 } 296 else { 297 // Here you can do stuff for all other imports before the content import starts. 298 echo "before import 2"; 299 } 300 } 301 add_action( 'pt-ocdi/before_content_import', 'ocdi_before_content_import' ); 302 ` 303 304 = How can I enable the `customize_save*` wp action hooks in the customizer import? = 305 306 It's easy, just add this to your theme: 307 308 `add_action( 'pt-ocdi/enable_wp_customize_save_hooks', '__return_true' );` 309 310 This will enable the following WP hooks when importing the customizer data: `customize_save`, `customize_save_*`, `customize_save_after`. 311 312 313 = How to configure the multi grid layout import popup confirmation? = 314 315 If you want to disable the popup confirmation modal window, use this filter: 316 317 `add_filter( 'pt-ocdi/enable_grid_layout_import_popup_confirmation', '__return_false' );` 318 319 If you want to just change some options for the jQuery modal window we use for the popup confirmation, then use this filter: 320 321 ` 322 function my_theme_ocdi_confirmation_dialog_options ( $options ) { 323 return array_merge( $options, array( 324 'width' => 300, 325 'dialogClass' => 'wp-dialog', 326 'resizable' => false, 327 'height' => 'auto', 328 'modal' => true, 329 ) ); 330 } 331 add_filter( 'pt-ocdi/confirmation_dialog_options', 'my_theme_ocdi_confirmation_dialog_options', 10, 1 ); 332 ` 333 334 = How can I disable the ProteusThemes branding notice after successful demo import? = 335 336 You can disable the branding notice with a WP filter. All you need to do is add this bit of code to your theme: 337 338 `add_filter( 'pt-ocdi/disable_pt_branding', '__return_true' );` 339 340 and the notice will not be displayed. 341 342 343 = I can't activate the plugin, because of a fatal error, what can I do? = 344 345 *Update: since version 1.2.0, there is now a admin error notice, stating that the minimal PHP version required for this plugin is 5.3.2.* 346 347 You want to activate the plugin, but this error shows up: 348 349 *Plugin could not be activated because it triggered a fatal error* 350 351 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* or better yet *7.x*. Please contact your hosting company and ask them to update the PHP version for your site. 352 353 = Issues with the import, that we can't fix in the plugin = 354 355 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. 356 357 == Screenshots == 358 359 1. Example of multiple predefined demo imports, that a user can choose from. 360 2. How the import page looks like, when only one demo import is predefined. 361 3. Example of how the import page looks like, when no demo imports are predefined a.k.a manual import. 362 363 == Changelog == 364 365 = 2.5.1 = 366 367 *Release Date - 25 October 2018* 368 369 * Fix missing translation strings 370 371 = 2.5.0 = 372 373 *Release Date - 8 January 2018* 374 375 * Add OCDI as a WordPress import tool in Tools -> Import, 376 * Add switching to the manual import, if the theme has predefined demo imports, 377 * Fix text domain loading 378 379 = 2.4.0 = 380 381 *Release Date - 23 August 2017* 382 383 * Add WP-CLI commands for importing with this plugin, 384 * Fix conflict with WooCommerce importer 385 386 = 2.3.0 = 387 388 *Release Date - 28 May 2017* 389 390 * Add preview button option to the predefined demo import items, 391 * Add custom JS event trigger when the import process is completed, 392 * Add custom filter for plugin page title, 393 * Remove content import as a required import. Now you can make separate imports for customizer, widgets or redux options. 394 * Fix custom menu widgets imports, the menus will now be set correctly. 395 396 = 2.2.1 = 397 398 *Release Date - 3 April 2017* 399 400 * Fix image importing error for server compressed files, 401 * Fix remapping of featured images, 402 * Fix custom post type existing posts check (no more multiple imports for custom post types). 403 404 = 2.2.0 = 405 406 *Release Date - 5 February 2017* 407 408 * Add ProteusThemes branding notice after successful import, 409 * Fix after import error reporting (duplicate errors were shown), 410 * Fix some undefined variables in the plugin, causing PHP notices. 411 412 = 2.1.0 = 413 414 *Release Date - 8 January 2017* 415 416 * Add grid layout import confirmation popup options filter, 417 * Fix term meta data double import, 418 * Fix WooCommerce product attributes import. 419 420 = 2.0.2 = 421 422 *Release Date - 13 December 2016* 423 424 * Fix issue with customizer options import 425 426 = 2.0.1 = 427 428 *Release Date - 12 December 2016* 429 430 * Fix issue with some browsers (Safari and IE) not supporting some FormData methods. 431 432 = 2.0.0 = 433 434 *Release Date - 10 December 2016* 435 436 * Add new layout for multiple predefined demo imports (a grid layout instead of the dropdown selector), 437 * Add support for Redux framework import, 438 * Change the code structure of the plugin (plugin rewrite, namespaces, autoloading), 439 * Now the whole import (content, widgets, customizer, redux) goes through even if something goes wrong in the content import (before content import errors blocked further import), 440 * Add `pt-ocdi/before_content_import` action hook, that theme authors can use to hook into before the content import starts, 441 * Fix frontend error reporting through multiple AJAX calls, 442 * Fix post formats (video/quote/gallery,...) not importing, 443 * Fix customizer import does not save some options (because of the missing WP actions - these can be enabled via a filter, more in the FAQ section). 444 445 = 1.4.0 = 446 447 *Release Date - 29 October 2016* 448 449 * Add support for WP term meta data in content importer, 450 * Fix the issue of having both plugins (OCDI and the new WP importer v2) activated at the same time. 451 452 = 1.3.0 = 453 454 *Release Date - 1 October 2016* 455 456 * Import/plugin page re-design. Updated the plugin page styles to match WordPress (thanks to Oliver Juhas). 457 458 459 = 1.2.0 = 460 461 *Release Date - 9 July 2016* 462 463 * Now also accepts predefined local import files (from theme folder), 464 * Fixes PHP fatal error on plugin activation, for sites using PHP versions older then 5.3.2 (added admin error notice), 465 * Register log file in *wp-admin -> Media*, so that it's easier to access, 466 * No more "[WARNING] Could not find the author for ..." messages in the log file. 467 468 = 1.1.3 = 469 470 *Release Date - 17 June 2016* 471 472 * Updated plugin design, 473 * Changed the plugin page setup filter name from `pt-ocdi/plugin-page-setup` to `pt-ocdi/plugin_page_setup` (mind the underscore characters instead of dashes). 474 475 = 1.1.2 = 476 477 *Release Date - 12 June 2016* 478 479 * An 'import notice' field has been added to the predefined demo import settings. This notice is displayed above the import button (it also accepts HTML), 480 * Now displays proper error message, if the file-system method is not set to "direct", 481 * This plugin is now compatible with the new [Humanmade content importer plugin](https://github.com/humanmade/WordPress-Importer), 482 * Added a filter to the plugin page creation, so that theme authors can now change the location of the plugin page (Demo data import) and some other parameters as well. 483 484 485 = 1.1.1 = 486 487 *Release Date - 22 May 2016* 488 489 * Preview import images can now be defined for multiple predefined import files (check FAQ "How to predefine demo imports?" for more info), 490 * You can now also import customizer settings. 491 492 = 1.1.0 = 493 494 *Release Date - 14 May 2016* 495 496 * Content import now imports in multiple AJAX calls, so there should be no more server timeout errors, 497 * The setting for generation of multiple image sizes in the content import is again enabled by default, 498 * Plugin textdomain was loaded, so that translations can be made. 499 500 = 1.0.3 = 501 502 *Release Date - 27 April 2016* 503 504 * Added filter to enable image regeneration, 505 * Added filter to change the plugin intro text, 506 * Added action to execute custom code before widget import, 507 * Disabled author imports. 508 509 = 1.0.2 = 510 511 *Release Date - 15 April 2016* 512 513 * Monkey fix for WP version 4.5. - disabled generation of multiple image sizes in the content import. 514 515 = 1.0.1 = 516 517 *Release Date - 2 April 2016* 518 519 Small code fixes: 520 521 * Fixed undefined variable bug, 522 * Fixed naming of downloaded files and their filters. 523 524 = 1.0.0 = 525 526 *Release Date - 25 March 2016* 527 528 * Initial release!