• dnp_theme

    (@dnp_theme)


    Hi Kevin.

    I am trying to import my widgets when my theme activates. Some points:

    – I have the widgets_settings.json inside my theme folders
    – this thing happens when I also import some sample content, similar function as with widgets and that one works perfect
    – I want to import all widgets by default from my json file
    – so far I know I need the parse_import_data(), ajax_import_widget_data() and get_new_widget_name() functions
    – I changed ajax_import_widget_data( $file ) and inside $import_file = $file;
    – I’ve setup a new function on my theme hooked to theme activation action

    if (file_exists($widgets_file)) {
    	require_once( get_template_directory() . '/inc/sample-data/widgets-settings-importexport/widget-data.php' );
    
    	$wp_import = new Widget_Data();
    	$data = $wp_import->ajax_import_widget_data($widgets_file);
    	$wp_import->parse_import_data($data);
    
    	$wp_import->init();
        }

    To this point, nothing works, if you can give me a hint on this I would highly appreciate it.

    Thanks

  • The topic ‘Do the import on theme activation’ is closed to new replies.