goechsler / goe_sass

GNU General Public License v2.0
5 stars 1 forks source link

Configuration form processing practice is tiny bit dangerous #2

Open gocom opened 11 years ago

gocom commented 11 years ago

The whole configuration form practice used in goe_sass_admin() is a hack. There are number of plugins that do that, but as a fair warning; that should be considered as a hack and it may break in the future.

In Textpattern 4.6.0 the preference panel will be remodeled and that will at least partially stop working. It will not save the preferences.

Anyways, there are few ways to represent preference fields in Textpattern admin-side:

The former is easier and requires no more than registering the configuration fields. Additionally you can add extra event and input handlers too. Creating a new preference field to the Preferences panel doesn't take much. E.g.

add_privs('prefs.goe_sass', '1,2');
set_pref('goe_sass_path', '', 'goe_sass', PREF_ADVANCED, 'text_input', 80);
set_pref('goe_sass_css_dir', '', 'goe_sass', PREF_ADVANCED, 'text_input', 81);
set_pref('goe_sass_style', '', 'goe_sass', PREF_ADVANCED, 'text_input', 82);
set_pref('goe_sass_syntax', '', 'goe_sass', PREF_ADVANCED, 'text_input', 83);

Where the above creates a new preferences group with four options in it. The add_privs() grants permissions to the said group (permissions are checked starting from 4.6.0). The labels (translations) are picked on from the plugin's Textpack file.

goechsler commented 11 years ago

Thanks for your feedback! I'll tackle this as soon as possible!