How to add an export function to a custom Option Theme Page

The easiest way would be to look at the code of Si Contact Form (since it already does what you want) and use the same kind of system. Shortly, you’ll need methods to do the following:

  • Create an XML (or other format) document of your theme options.
  • Save/Export the XML document.
  • Import the XML document (There’s no point in exporting if you can’t import it again).

If you want to use Si Contact Form as an example, the backup routines are in:

Basically, it just outputs a serialized version of your options in a file. You can then upload the file to your admin page, parse the serialized string of options, and restore whatever you need from a backup.

The backup scripts for Si Contact Form are in the si_contact_form_backup_restore() function of this file: http://plugins.svn.wordpress.org/si-contact-form/trunk/si-contact-form.php (Most of the way down the page). It just reads the file, parses the options, and sets them in the database as needed.

Leave a Comment