Support » Plugins » Hacks » Import/export from plugin – best practices?

  • I’m redeveloping a plugin and would like to make it easier for people to migrate the options and tables my plugin uses from one site to another, or to keep backups for themselves of these things.

    Is there any general guidelines for this, or perhaps an existing plugin you can think of that implements this functionality well? I’ve not had any great luck finding this. Is there some reason this is not advised, or just not a popular option? Or I’m just looking in the wrong place!

    I’m wondering things like if there is a standard sort of UI for import/export from a plugin, or if plugins hook into WP’s own import/export for their personal settings and tables, etc.

    Not looking for someone to do the work for me – but just for a point in the right direction. Thanks for any ideas.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’ve been thinking of something along the same lines; using json_encode to take a plugin’s array of settings and export them into a file and use json_decode to do the reverse. As far as I know there’s no best practice or plugin that currently does this, though a suggestion has dropped up in WordPress Ideas for this. The closest I’ve ever found to a plugin that gets near this is the Widget Settings Importer/Exporter plugin, which might provide some code you could use as a starting point. The (undocumented I believe) export_wp function in /wp-admin/includes/export.php shows how WordPress does exporting.


    Hard to believe I’m on the cutting edge of seeking such a function. Perhaps someone should develop a framework plugin that other plugins could utilize to add this functionality. Seems like a fair amount of overhead for each plugin to implement it separately/differently (though, it doesn’t seem like anyone is really doing this now).

    Thanks Gary; that gives me some ideas to chew on.

    I like the idea of a framework. I might even try and implement this once I’ve got the latest batch of updates to my plugins up, running and released. It might not be trivial though.

    Just taking one of my plugins as an example … there’s a single settings array in the wp_options table; this would be relatively trivial to serialise out to a file in JSON. But then there’s also settings in wp_postmeta and wp_usermeta, which are best practise as far as where to store certain settings within WordPress, but which make the task (potentially) less suited for a framework and more tailored to an individual plugin.

    But this is all off of the top of my head. It’s certainly given me something to think about and I can just about see how a framework, with plugin hooks for feeding options into the framework might work. With heavy emphasis on the word might!


Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Import/export from plugin – best practices?’ is closed to new replies.