mardi 26 janvier 2016

Wordpress PHP - How to update plugin setting value in main file

This is from inside my Wordpress plugin, inside the main file:

function my_plugin_install() {

    $my_site_url = get_site_url();

    $my_options['my_site_url'] = $my_site_url;

    // Save

}

register_activation_hook(__FILE__, 'my_plugin_install');

Currently, the install is successful but the 'my_site_url' option is not saved. I'm assuming because the way I'm using the $my_options array at this point doesn't mean anything. It should save this data to the wp_options table.

I can't seem to get this to save, or even find a way to test this as using "echo" gives Wordpress an error during install. Is there a best method for running a script and updating the database during install?

Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire