I’m creating a new WordPress template and I have a question:
I’ve added a custom Option Page to my new template (you can see what I’m doing Here and Here) but now I would like to add a new function.
Do you know Si Contact Form? In this plugin the end user can download a backup of all the settings and Upload it on a different website.
I would like to be able to add the same function into my new option page.
I know how to backup my settings logging to phpMyAdmin but sometimes end-user can’t login to phpMyAdmin or simply it’s better that he/she doesn’t login to phpMyAdmin :-).
Have you got any solution to this?
Actually all my custom functions are named:
‘appaqua__zona1c’;’appaqua__zona1x’ and so on… my theme shortname is appaqua.
Please by kind with me, I’m not a professional programmer and I’m really sorry if I used wrong words to explain what I need.
Thank you very much to all!
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
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.