Plugin / One Click Demo Import

ProteusThemes

Frequently Asked Questions (FAQ)

You will find the import page in wp-admin -> Appearance -> Import Demo Data.
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/. The log file will also be registered in the wp-admin -> Media section, so you can access it easily.
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): function ocdi_import_files() { return array( array( 'import_file_name' => 'Demo Import 1', 'categories' => array( 'Category 1', 'Category 2' ), 'import_file_url' => 'http://www.your_domain.com/ocdi/demo-content.xml', 'import_widget_file_url' => 'http://www.your_domain.com/ocdi/widgets.json', 'import_customizer_file_url' => 'http://www.your_domain.com/ocdi/customizer.dat', 'import_redux' => array( array( 'file_url' => 'http://www.your_domain.com/ocdi/redux.json', 'option_name' => 'redux_option_name', ), ), 'import_preview_image_url' => 'http://www.your_domain.com/ocdi/preview_import_image1.jpg', 'import_notice' => __( 'After you import this demo, you will have to setup the slider separately.', 'your-textdomain' ), 'preview_url' => 'http://www.your_domain.com/my-demo-1', ), array( 'import_file_name' => 'Demo Import 2', 'categories' => array( 'New category', 'Old category' ), 'import_file_url' => 'http://www.your_domain.com/ocdi/demo-content2.xml', 'import_widget_file_url' => 'http://www.your_domain.com/ocdi/widgets2.json', 'import_customizer_file_url' => 'http://www.your_domain.com/ocdi/customizer2.dat', 'import_redux' => array( array( 'file_url' => 'http://www.your_domain.com/ocdi/redux.json', 'option_name' => 'redux_option_name', ), array( 'file_url' => 'http://www.your_domain.com/ocdi/redux2.json', 'option_name' => 'redux_option_name_2', ), ), 'import_preview_image_url' => 'http://www.your_domain.com/ocdi/preview_import_image2.jpg', 'import_notice' => __( 'A special note for this import.', 'your-textdomain' ), 'preview_url' => 'http://www.your_domain.com/my-demo-2', ), ); } add_filter( 'pt-ocdi/import_files', 'ocdi_import_files' ); 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.
You can do that, with the pt-ocdi/after_import action hook. The code would look something like this: function ocdi_after_import_setup() { // Assign menus to their locations. $main_menu = get_term_by( 'name', 'Main Menu', 'nav_menu' ); set_theme_mod( 'nav_menu_locations', array( 'main-menu' => $main_menu->term_id, // replace 'main-menu' here with the menu location identifier from register_nav_menu() function ) ); // Assign front page and posts page (blog page). $front_page_id = get_page_by_title( 'Home' ); $blog_page_id = get_page_by_title( 'Blog' ); update_option( 'show_on_front', 'page' ); update_option( 'page_on_front', $front_page_id->ID ); update_option( 'page_for_posts', $blog_page_id->ID ); } add_action( 'pt-ocdi/after_import', 'ocdi_after_import_setup' );
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! function ocdi_import_files() { return array( array( 'import_file_name' => 'Demo Import 1', 'categories' => array( 'Category 1', 'Category 2' ), 'local_import_file' => trailingslashit( get_template_directory() ) . 'ocdi/demo-content.xml', 'local_import_widget_file' => trailingslashit( get_template_directory() ) . 'ocdi/widgets.json', 'local_import_customizer_file' => trailingslashit( get_template_directory() ) . 'ocdi/customizer.dat', 'local_import_redux' => array( array( 'file_path' => trailingslashit( get_template_directory() ) . 'ocdi/redux.json', 'option_name' => 'redux_option_name', ), ), 'import_preview_image_url' => 'http://www.your_domain.com/ocdi/preview_import_image1.jpg', 'import_notice' => __( 'After you import this demo, you will have to setup the slider separately.', 'your-textdomain' ), 'preview_url' => 'http://www.your_domain.com/my-demo-1', ), array( 'import_file_name' => 'Demo Import 2', 'categories' => array( 'New category', 'Old category' ), 'local_import_file' => trailingslashit( get_template_directory() ) . 'ocdi/demo-content2.xml', 'local_import_widget_file' => trailingslashit( get_template_directory() ) . 'ocdi/widgets2.json', 'local_import_customizer_file' => trailingslashit( get_template_directory() ) . 'ocdi/customizer2.dat', 'local_import_redux' => array( array( 'file_path' => trailingslashit( get_template_directory() ) . 'ocdi/redux.json', 'option_name' => 'redux_option_name', ), array( 'file_path' => trailingslashit( get_template_directory() ) . 'ocdi/redux2.json', 'option_name' => 'redux_option_name_2', ), ), 'import_preview_image_url' => 'http://www.your_domain.com/ocdi/preview_import_image2.jpg', 'import_notice' => __( 'A special note for this import.', 'your-textdomain' ), 'preview_url' => 'http://www.your_domain.com/my-demo-2', ), ); } add_filter( 'pt-ocdi/import_files', 'ocdi_import_files' );
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): function ocdi_after_import( $selected_import ) { echo "This will be displayed on all after imports!"; if ( 'Demo Import 1' === $selected_import['import_file_name'] ) { echo "This will be displayed only on after import if user selects Demo Import 1"; // Set logo in customizer set_theme_mod( 'logo_img', get_template_directory_uri() . '/assets/images/logo1.png' ); } elseif ( 'Demo Import 2' === $selected_import['import_file_name'] ) { echo "This will be displayed only on after import if user selects Demo Import 2"; // Set logo in customizer set_theme_mod( 'logo_img', get_template_directory_uri() . '/assets/images/logo2.png' ); } } add_action( 'pt-ocdi/after_import', 'ocdi_after_import' );
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: function ocdi_before_widgets_import( $selected_import ) { echo "Add your code here that will be executed before the widgets get imported!"; } add_action( 'pt-ocdi/before_widgets_import', 'ocdi_before_widgets_import' );
In the 2.4.0 version of this pugin we added two WP-CLI commands: wp ocdi list – Which will list any predefined demo imports currently active theme might have, 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. wp ocdi import options: wp ocdi import [–content=] [–widgets=] [–customizer=] [–predefined=] --content= – will run the content import with the WP import file specified in the parameter, --widgets= – will run the widgets import with the widgets import file specified in the parameter, --customizer= – will run the customizer settings import with the customizer import file specified in the parameter, --predefined= – will run the theme predefined import with the index of the predefined import in the parameter (you can use the wp ocdi list command to check which index is used for each predefined demo import) 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.
You can change the plugin intro text by using the pt-ocdi/plugin_intro_text filter: function ocdi_plugin_intro_text( $default_text ) { $default_text .= '
This is a custom text added to this plugin intro text.
'; return $default_text; } add_filter( 'pt-ocdi/plugin_intro_text', 'ocdi_plugin_intro_text' ); 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.
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: add_filter( 'pt-ocdi/regenerate_thumbnails_in_content_import', '__return_false' );
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. function ocdi_plugin_page_setup( $default_settings ) { $default_settings['parent_slug'] = 'themes.php'; $default_settings['page_title'] = esc_html__( 'One Click Demo Import' , 'pt-ocdi' ); $default_settings['menu_title'] = esc_html__( 'Import Demo Data' , 'pt-ocdi' ); $default_settings['capability'] = 'import'; $default_settings['menu_slug'] = 'pt-one-click-demo-import'; return $default_settings; } add_filter( 'pt-ocdi/plugin_page_setup', 'ocdi_plugin_page_setup' );
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: function ocdi_before_content_import( $selected_import ) { if ( 'Demo Import 1' === $selected_import['import_file_name'] ) { // Here you can do stuff for the "Demo Import 1" before the content import starts. echo "before import 1"; } else { // Here you can do stuff for all other imports before the content import starts. echo "before import 2"; } } add_action( 'pt-ocdi/before_content_import', 'ocdi_before_content_import' );
It’s easy, just add this to your theme: add_action( 'pt-ocdi/enable_wp_customize_save_hooks', '__return_true' ); This will enable the following WP hooks when importing the customizer data: customize_save, customize_save_*, customize_save_after.
If you want to disable the popup confirmation modal window, use this filter: add_filter( 'pt-ocdi/enable_grid_layout_import_popup_confirmation', '__return_false' ); If you want to just change some options for the jQuery modal window we use for the popup confirmation, then use this filter: function my_theme_ocdi_confirmation_dialog_options ( $options ) { return array_merge( $options, array( 'width' => 300, 'dialogClass' => 'wp-dialog', 'resizable' => false, 'height' => 'auto', 'modal' => true, ) ); } add_filter( 'pt-ocdi/confirmation_dialog_options', 'my_theme_ocdi_confirmation_dialog_options', 10, 1 );
You can disable the branding notice with a WP filter. All you need to do is add this bit of code to your theme: add_filter( 'pt-ocdi/disable_pt_branding', '__return_true' ); and the notice will not be displayed.
If you want to host your import content files on Amazon S3, but you want them to be publicly available, rather through an own API as presigned URL’s (which expires) you can use the filter pt-ocdi/pre_download_import_files in which you can pass your own URL’s, for example: ` add_filter( ‘pt-ocdi/pre_download_import_files’, function( $import_file_info ){ // In this example `get_my_custom_urls` is supposedly making a `wp_remote_get` request, getting the urls from an API server where you're creating the presigned urls, [example here](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/s3-presigned-url.html). // This request should return an array containing all the 3 links - `import_file_url`, `import_widget_file_url`, `import_customizer_file_url` $request = get_my_custom_urls( $import_file_info ); if ( !is_wp_error( $request ) ) { if ( isset($request['data']) && is_array($request['data']) ) { if( isset($request['data']['import_file_url']) && $import_file_url = $request['data']['import_file_url'] ){ $import_file_info['import_file_url'] = $import_file_url; } if( isset($request['data']['import_widget_file_url']) && $import_widget_file_url = $request['data']['import_widget_file_url'] ){ $import_file_info['import_widget_file_url'] = $import_widget_file_url; } if( isset($request['data']['import_customizer_file_url']) && $import_customizer_file_url = $request['data']['import_customizer_file_url'] ){ $import_file_info['import_customizer_file_url'] = $import_customizer_file_url; } } } return $import_file_info; } ); `
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. You want to activate the plugin, but this error shows up: Plugin could not be activated because it triggered a fatal error 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.
Please visit this docs page, for more answers to issues with importing data.

Ratings

4.7
52 reviews

Rating breakdown

Details Information

Version

2.5.2

First Released

23 Mar, 2016

Total Downloads

4,080,462

Wordpress Version

4.0.0 or higher

Tested up to:

5.2.4

Require PHP Version:

-

Tags

Contributors

Languages

The plugin hasn't been transalated in any language other than English.

DIRECTORY DISCLAIMER

The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.

The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.

Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.

While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.

wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.

Keep Leading Your Followers!
Share it for them.