Support » Plugins and Hacks » Hacks » Settings in plugin.

Settings in plugin.

  • If I have to save some settings, will I have to create a new tabele, or can I save the setting by any function in wp_options?

    Thank you !

Viewing 4 replies - 1 through 4 (of 4 total)
  • wp_options, respectively all functions like add_option(), delete_option(), update_option(), etc are suited also for plugin settings.

    I would also recommend organizing all settings for a plugin in a single array and only store this one in the wp options. This way you will get all settings with only one query, even when using get_option();
    And it’s also easier to keep track of it when you want to uninstall the plugin and therefore delete the settings.

    You don’t need to do any of that to save the widgets values, and that’s actually the wrong way to save the values. The functions like update_option() are meant for system-wide values, not individual values for widgets.

    Raed the Widgets API page and look at the update() function. That is what stores the widgets values with no other code needed and no extra DB tables (unless you’re doing something special).

    Loueen was talking about plugins, not widgets in particular. And since you can specify if an option shall be loaded automatically or manually I think the option functions are just fine.

    Oops… Yes that is right. I must have been looking at something else at the same time and gotten confused.

    The *_option() functions are the way to store basic settings. If there’s a huge range of info that needs to be saved you can add in DB tables if the complexity of the data warrents it, but that’s completely up to exactly what you want to store.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Settings in plugin.’ is closed to new replies.