Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

using twice or as many as times in theme or in plugins

Open webangon opened this issue 12 years ago • 2 comments

Hi How can I create instances of this framework? Let I have this framework in theme now I will again use this in plugin.How can I do this?Again let I have to use this in other plugins as well. How the settings work?I mean does it create new settings with different names?

webangon avatar Nov 20 '14 08:11 webangon

How can I create instances of this framework?

You can't create multiple instances, only one instance is created automatically when you include the framework/bootstrap.php file

Let I have this framework in theme now I will again use this in plugin. How can I do this?

You can include the framework/bootstrap.php file multiple times, but it will have effect only when included first time. It detects, if it's already loaded then it does nothing.

For example you can have the framework as a plugin, but also include it from the theme functions.php (like it is now). In this case, only the plugin version will be active, that from the theme will be ignored

Again let I have to use this in other plugins as well. How the settings work? I mean does it create new settings with different names?

It stores the settings in the same place, in the fw_options option. On every settings save, it will array_merge old settings with new values

If you want an option to be unique for your theme, use the theme id in the option id

$theme_id = fw()->theme->manifest->get_id();

$options = array(
    'shared_option' => array('type' => 'text'),
    $theme_id .'_theme_unique_option' => array('type' => 'text'),
);

If you have some suggestions, please let us know.

ghost avatar Nov 20 '14 08:11 ghost

thank you

webangon avatar Nov 20 '14 09:11 webangon