Support » Plugin: One Click Demo Import » Impossible to add import option with customizer settings only

  • Resolved ninetienne

    (@ninetienne)


    I tried adding separate demo options, for the demo content and customizer settings, like this:

    
    /**
     * Demos
     */
    function ocdi_import_files() {
    	return array(
    		array(
    			'import_file_name'             => esc_html__( 'Demo Content', 'text-domain' ),
    			'categories'                   => array( 'Demo Content' ),
    			'local_import_file'            => get_template_directory() . '/framework/includes/demo-content/demo-content.xml',
    			'local_import_widget_file'     => get_template_directory() . '/framework/includes/demo-content/widgets.json',
    			),
    		array(
    			'import_file_name'             => esc_html__( 'Demo 1', 'text-domain' ),
    			'categories'                   => array( 'Theme Settings' ),
    			'local_import_customizer_file' => get_template_directory() . '/framework/includes/demo-content/customizer.dat',
    			),
    		array(
    			'import_file_name'             => esc_html__( 'Demo 2', 'text-domain' ),
    			'categories'                   => array( 'Theme Settings' ),
    			'local_import_customizer_file' => get_template_directory() . '/framework/includes/demo-content/customizer.dat',
    			),
    		);
    }
    
    add_filter( 'pt-ocdi/import_files', 'ocdi_import_files' );
    

    But seems like the plugin won’t add a Demo option without local_import_customizer_file.

    It would be nice to allow importing Customizer settings only. Because the user won’t have duplicate content then: they import the demo content once and then can switch between demos, based on the Customizer settings.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Gregor Capuder

    (@capuderg)

    Hi,

    yes, the OCDI plugin has two required parameters: the name and the content import file (XML).

    If you only want to import the customizer settings, you can use the Customizer export/import plugin.

    Maybe in the future release, we can add this functionality, if other users would want that as well… So I would advise you to open a github issue here: https://github.com/proteusthemes/one-click-demo-import/issues and, if others agree, we will add this in the future version.

    Take care!

    Thread Starter ninetienne

    (@ninetienne)

    I think it would make OCDI more flexible, if you removed the required XML file.
    It would allow different use cases (single XML, single customizer DAT, widget settings file, etc. or any combination) all in one place.
    The thing is that, when the user clicks on Import with an option with XML file, demo posts will be duplicate. If we import the customizer file only, then theme mods get overwritten and there’s no duplicate content.
    I’m aware of the Customizer export/import plugin, but would like to have all the demo content import features within one plugin and one settings page.
    Truly hope, this feature will make it into the great OCDI plugin.

    Plugin Author Gregor Capuder

    (@capuderg)

    Hi,

    thanks for opening the GH issue.

    If anyone else would like this change in this plugin, please upvote or add a comment here: https://github.com/proteusthemes/one-click-demo-import/issues/102

    Take care!

    Thread Starter ninetienne

    (@ninetienne)

    Thanks!

    I’ve just thought of another solution to my issue. Is there a way we can set an option after the first demo content import and during the next import check the option and skip the XML import if the option is set to true?

    Any hint is highly appreciated.

    Plugin Author Gregor Capuder

    (@capuderg)

    Hi,

    there is no such option or functionality in the plugin, but you can make a custom solution: hook into the after import action and save the data you need in a custom wordpress option and then skip all content import items, if the option is set on the next demo import…

    I think the first solution is much better.

    Take care!

    Thread Starter ninetienne

    (@ninetienne)

    Thank you very much for the prompt response and your help.

    I know, how to save a custom option after the first demo import.

    But could you please confirm that skipping the demo content import like this will work?

    
    function ocdi_before_content_import( $selected_import ) {
        if ( true === get_option( 'demo_content_already_imported' ) ) {
            return;
        }
    }
    add_action( 'pt-ocdi/before_content_import', 'ocdi_before_content_import' );
    

    Thanks again!

    Plugin Author Gregor Capuder

    (@capuderg)

    Hi,

    no, that would not skip the actual content import.

    A content importer hook would have to be used… I’m not sure which hook (if any) would be best for this use case and I have never tested that, but maybe import_start or you might have to return false on all pre_process filters, like wxr_importer.pre_process.post for example…

    Take care!

    Thread Starter ninetienne

    (@ninetienne)

    I see. Not the best solution, because it will prevent from any import in future.

    I wish there was a hook for that in OCDI.

    Seems like, I’m asking for way too many things 🙁

    Plugin Author Gregor Capuder

    (@capuderg)

    hehe 🙂

    I think the first solution about making the content import optional (not required) is good and if others agree, we will add that in the plugin.

    We will always improve the plugin, if the suggestions/ideas will be good and inline with what we want to do with this plugin (“one click” demo import for the end users).

    So, thanks for the suggestions! 🙂

    It will be awesome to have that feature.

    Plugin Author Gregor Capuder

    (@capuderg)

    Hi,

    nice.

    Could you please add a “thumbsup” reaction or add a comment in the relevant GH issue: https://github.com/proteusthemes/one-click-demo-import/issues/102 ?

    That would be great.

    Take care!

    Plugin Author Gregor Capuder

    (@capuderg)

    Hi,

    the plugin update with this added code was just released, so I will mark this ticket as solved.

    Take care!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Impossible to add import option with customizer settings only’ is closed to new replies.