Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GS Custom Settings [v0.6.2]
#7
Note: The code in this reply is no longer relevant
(2015-02-19, 04:43:21)shawn_a Wrote: Looks promising.

It would be nice to be able to interface with this programmatically via a plugin, it would be very easy to write a bridge function to check for and use this instead of writing your own settings manager in my plugin, or using globals etc like, newsmamager does. I could even use this to make a plugin that shims gsconfig with a ui.

We could also add per component extra hooks, to add these to individual components, in 3.4

True that. I was thinking more about providing for theme developers/ webmasters than plugin devs. I did hint to this in the better components thread, and I will try to add this in one of the next releases. Basically, there's not much else to do than add a function similar to this:

PHP Code:
function add_setting($setting) {
   
$path 'path/to/file';
   
$file json_decode($pathTRUE);
   
$properties = array('label','lookup','access','type','options','value','descr');
   
$final $setting;
   for (
$x 0$i count($properties); $i++) { 
      if (!
array_key_exists($properties[$i]))  {// OR if value is not correct
         // set defaults & validation here
         
$final[$properties[$i]] = $someDefault;
      }
   }
   
array_push($file['data'], $final);
   
$file json_encode($file);
   
file_put_contents($path);


I am still torn on one issue though; for which I'd love to have some feedback. Currently the setting lookups are PHP-ified from the setting's label, while in i18n custom fields for example, the user has to write his own lookup ('name'). I did this to eliminate an extra step of 'thinking', but I understand some lookups could get ridiculously long if the label is too descriptive. On the other hand, there's a per-setting description to explain the label... And as a second point, given that the strings are saved in JSON, they could actually contain almost any character without errors... Should I allow such things as
Code:
get_setting('social/I am a really long label?!')
?

(2015-02-19, 05:18:15)Oleg06 Wrote: does not work
What does not work? I tested and it works all fine now.
Reply


Messages In This Thread
GS Custom Settings [v0.6.2] - by Tyblitz - 2015-02-19, 02:53:15
RE: *New* Plugin KO Site Settings - by shawn_a - 2015-02-19, 03:36:17
RE: *New* Plugin KO Site Settings - by Tyblitz - 2015-02-19, 04:22:15
RE: *New* Plugin KO Site Settings - by Oleg06 - 2015-02-19, 03:45:25
RE: *New* Plugin KO Site Settings - by shawn_a - 2015-02-19, 04:43:21
RE: *New* Plugin KO Site Settings - by Tyblitz - 2015-02-19, 05:40:25
RE: *New* Plugin KO Site Settings - by Oleg06 - 2015-02-19, 05:18:15
RE: *New* Plugin KO Site Settings - by shawn_a - 2015-02-19, 06:30:07
RE: *New* Plugin KO Site Settings - by Tyblitz - 2015-02-19, 09:11:27
RE: *New* Plugin KO Site Settings - by shawn_a - 2015-02-19, 06:31:13
RE: GS Custom Settings [v0.4 out] - by datiswous - 2015-05-23, 23:50:13
RE: GS Custom Settings [v0.4 out] - by datiswous - 2015-05-23, 08:48:21
RE: GS Custom Settings [v0.4 out] - by Tyblitz - 2015-05-23, 09:11:49
RE: GS Custom Settings [v0.4 out] - by datiswous - 2015-05-23, 23:24:29
RE: GS Custom Settings [v0.4 out] - by datiswous - 2015-05-24, 09:57:41
RE: GS Custom Settings [v0.4 out] - by Tyblitz - 2015-05-24, 10:22:31
RE: GS Custom Settings [v0.4 out] - by datiswous - 2015-05-24, 11:09:58
RE: GS Custom Settings [v0.4 out] - by Tyblitz - 2015-05-24, 12:05:29
RE: GS Custom Settings [v0.4 out] - by shawn_a - 2015-05-24, 10:54:52
RE: GS Custom Settings [v0.4 out] - by datiswous - 2015-05-24, 12:19:58
RE: GS Custom Settings [v0.4 out] - by Tyblitz - 2015-05-24, 12:48:50
RE: GS Custom Settings [v0.4 out] - by shawn_a - 2015-05-24, 23:35:59
RE: GS Custom Settings [v0.4 out] - by Tyblitz - 2015-05-25, 04:15:11
RE: GS Custom Settings [v0.5 out] - by Oleg06 - 2015-05-25, 07:10:46
RE: GS Custom Settings [v0.5 out] - by Oleg06 - 2015-05-25, 08:04:05
RE: GS Custom Settings [v0.5 out] - by datiswous - 2015-06-09, 21:32:45
RE: GS Custom Settings [v0.5 out] - by Tyblitz - 2015-06-09, 22:03:33
RE: GS Custom Settings [v0.5 out] - by datiswous - 2015-06-10, 23:52:55
RE: GS Custom Settings [v0.5 out] - by shawn_a - 2015-06-11, 00:27:00
RE: GS Custom Settings [v0.5 out] - by Tyblitz - 2015-06-27, 10:06:20
RE: GS Custom Settings [v0.5 out] - by datiswous - 2015-06-29, 09:47:35
RE: GS Custom Settings [v0.5 out] - by Oleg06 - 2015-07-11, 20:34:20
RE: GS Custom Settings [v0.5 out] - by datiswous - 2015-07-13, 05:40:07
RE: GS Custom Settings [v0.5 out] - by mganko - 2015-07-23, 19:58:56
RE: GS Custom Settings [v0.5 out] - by Tyblitz - 2015-07-24, 07:28:01
RE: GS Custom Settings [v0.5 out] - by Oleg06 - 2015-09-06, 07:50:07
RE: GS Custom Settings [v0.5 out] - by Tyblitz - 2015-09-07, 02:37:41
RE: GS Custom Settings [v0.5 out] - by Oleg06 - 2015-09-07, 04:44:03
RE: GS Custom Settings [v0.5 out] - by Tyblitz - 2015-09-07, 19:29:55
RE: GS Custom Settings [v0.5.1 out] - by Tyblitz - 2015-10-05, 02:40:39
RE: GS Custom Settings [v0.6 out] - by Oleg06 - 2015-10-05, 02:53:16
RE: GS Custom Settings [v0.6 out] - by Tyblitz - 2015-10-05, 03:20:44
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-05, 04:27:39
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-05, 04:46:10
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-05, 08:22:14
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-05, 08:39:09
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-05, 10:02:20
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-05, 17:34:28
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-05, 22:13:31
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-06, 01:16:23
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-06, 03:55:14
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-06, 04:21:51
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-08, 07:22:58
RE: GS Custom Settings [v0.6] - by gslexx - 2015-10-09, 07:44:25
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-09, 09:58:30
RE: GS Custom Settings [v0.6] - by gslexx - 2015-10-09, 17:04:56
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-09, 20:15:17
RE: GS Custom Settings [v0.6] - by gslexx - 2015-10-09, 21:29:44
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-10, 03:40:28
RE: GS Custom Settings [v0.6] - by gslexx - 2015-10-10, 04:05:36
RE: GS Custom Settings [v0.6] - by gslexx - 2015-10-10, 19:32:22
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-10, 21:10:24
RE: GS Custom Settings [v0.6] - by 0zz - 2015-10-10, 23:38:04
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-11, 00:19:55
RE: GS Custom Settings [v0.6] - by 0zz - 2015-10-11, 00:52:57
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-11, 02:15:09
RE: GS Custom Settings [v0.6] - by gslexx - 2015-10-11, 04:55:56
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-11, 10:05:29
RE: GS Custom Settings [v0.6] - by gslexx - 2015-10-11, 16:52:28
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-11, 21:25:34
RE: GS Custom Settings [v0.6] - by gslexx - 2015-10-11, 21:45:09
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-11, 22:08:40
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-12, 10:12:26
RE: GS Custom Settings [v0.6] - by 0zz - 2015-10-13, 01:19:38
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-21, 22:09:59
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-22, 03:39:02
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-22, 07:03:35
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-22, 08:46:31
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-22, 09:15:37
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-27, 00:27:01
RE: GS Custom Settings [v0.6] - by datiswous - 2015-10-26, 22:51:49
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-27, 00:27:13
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-27, 09:38:36
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-30, 05:44:21
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-30, 08:56:20
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-27, 21:07:33
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-27, 22:19:48
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-28, 07:13:31
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-28, 08:02:34
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-28, 08:09:17
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-28, 09:35:25
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-28, 09:48:50
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-10-28, 10:01:25
RE: GS Custom Settings [v0.6] - by Oleg06 - 2015-10-28, 19:23:07
RE: GS Custom Settings [v0.6] - by Tyblitz - 2015-11-06, 09:10:06
RE: GS Custom Settings [v0.6.2] - by Tyblitz - 2015-11-06, 09:25:35
RE: GS Custom Settings [v0.6.2] - by Oleg06 - 2015-11-06, 19:07:33
RE: GS Custom Settings [v0.6.2] - by Tyblitz - 2015-11-07, 08:11:50
RE: GS Custom Settings [v0.6.2] - by Oleg06 - 2015-11-07, 09:47:28
RE: GS Custom Settings [v0.6.2] - by Tyblitz - 2015-11-07, 20:15:22
RE: GS Custom Settings [v0.6.2] - by Oleg06 - 2015-11-07, 20:38:24
RE: GS Custom Settings [v0.6.2] - by Oleg06 - 2015-11-18, 06:34:39
RE: GS Custom Settings [v0.6.2] - by Tyblitz - 2015-11-18, 09:53:37
RE: GS Custom Settings [v0.6.2] - by gslexx - 2015-11-18, 17:23:30
RE: GS Custom Settings [v0.6.2] - by Tyblitz - 2015-11-19, 08:34:34
RE: GS Custom Settings [v0.6.2] - by Oleg06 - 2015-11-19, 16:58:08
RE: GS Custom Settings [v0.6.2] - by gslexx - 2015-11-19, 17:07:39
RE: GS Custom Settings [v0.6.2] - by gslexx - 2015-11-24, 04:48:16
RE: GS Custom Settings [v0.6.2] - by Tyblitz - 2015-11-24, 06:09:28
RE: GS Custom Settings [v0.6.2] - by sbre - 2015-12-07, 16:25:38
RE: GS Custom Settings [v0.6.2] - by Tyblitz - 2015-12-08, 08:07:10
RE: GS Custom Settings [v0.6.2] - by Oleg06 - 2016-01-26, 09:46:23
RE: GS Custom Settings [v0.6.2] - by Tyblitz - 2016-01-28, 21:27:46
RE: GS Custom Settings [v0.6.2] - by Oleg06 - 2016-04-27, 19:21:52
RE: GS Custom Settings [v0.6.2] - by Tyblitz - 2016-05-06, 08:18:20
RE: GS Custom Settings [v0.6.2] - by gslexx - 2016-09-26, 07:41:18
RE: GS Custom Settings [v0.6.2] - by Timbow - 2016-09-27, 10:37:54
RE: GS Custom Settings [v0.6.2] - by datiswous - 2016-09-27, 22:01:36
RE: GS Custom Settings [v0.6.2] - by Oleg06 - 2016-09-27, 22:45:42
RE: GS Custom Settings [v0.6.2] - by Timbow - 2016-09-28, 04:39:36
RE: GS Custom Settings [v0.6.2] - by datiswous - 2016-09-28, 05:14:46
RE: GS Custom Settings [v0.6.2] - by Tyblitz - 2016-09-28, 08:13:38
RE: GS Custom Settings [v0.6.2] - by Timbow - 2016-09-28, 22:03:50



Users browsing this thread: 2 Guest(s)