Files
piratepoet/lib/Router/Settings.php
Jonathan Labreuille 34c237ce8e 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)
2015-10-15 14:22:27 +02:00

33 lines
646 B
PHP

<?php
namespace MailPoet\Router;
use \MailPoet\Models\Setting;
if(!defined('ABSPATH')) exit;
class Settings {
function __construct() {
}
function get() {
$settings = Setting::getAll();
wp_send_json($settings);
}
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);
}
}
}