Files
piratepoet/lib/Router/Settings.php
marco ce730d7c3b Settings router.
Here's a simple settings router. the createOrUpdate method lives
in the model, and by default all models will return true on save
or false if save went wrong.
2015-08-19 23:55:30 +02:00

25 lines
457 B
PHP

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