Load/Save settings
- renamed all settings with dot syntax - refactored Menu->settings() - changed schema of settings table to allow longer setting name and value - added getAll() static method on Setting Model to fetch all settings (with proper unserialize of value)
This commit is contained in:
@ -9,20 +9,24 @@ class Settings {
|
||||
}
|
||||
|
||||
function get() {
|
||||
$settings = Setting::find_array();
|
||||
$settings = Setting::getAll();
|
||||
wp_send_json($settings);
|
||||
}
|
||||
|
||||
function set($args) {
|
||||
$save = function($setting) {
|
||||
Setting::createOrUpdate($setting);
|
||||
};
|
||||
$results = array_map($save, $args);
|
||||
|
||||
wp_send_json(in_array(false, $results));
|
||||
}
|
||||
|
||||
function save($data = array()) {
|
||||
// TODO
|
||||
function set($settings = array()) {
|
||||
if(empty($settings)) {
|
||||
wp_send_json(false);
|
||||
} else {
|
||||
foreach($settings as $name => $value) {
|
||||
if(is_array($value)) {
|
||||
$value = serialize($value);
|
||||
}
|
||||
Setting::createOrUpdate(array(
|
||||
'name' => $name,
|
||||
'value' => $value
|
||||
));
|
||||
}
|
||||
wp_send_json(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user