fixed widget + test + split get method in sub router

This commit is contained in:
Jonathan Labreuille
2015-08-27 16:06:19 +02:00
committed by marco
parent 703fd17932
commit d81c4e7aa1
2 changed files with 33 additions and 25 deletions

View File

@@ -9,8 +9,9 @@ class Widget {
}
function init() {
if(!is_admin()) {
add_action('widgets_init', array($this, 'registerWidget'));
if(!is_admin()) {
add_action('widgets_init', array($this, 'setupActions'));
add_action('widgets_init', array($this, 'setupDependencies'));
}

View File

@@ -8,9 +8,7 @@ class Subscribers {
function __construct() {
}
function get() {
if(isset($_POST['data'])) {
$data = $_POST['data'];
function get($data = array()) {
$offset = (isset($data['offset']) ? (int)$data['offset'] : 0);
$limit = (isset($data['limit']) ? (int)$data['limit'] : 50);
$search = (isset($data['search']) ? $data['search'] : null);
@@ -26,16 +24,25 @@ class Subscribers {
);
}
// filters
$filters = array(
);
$collection = array(
'count' => $collection->count(),
'filters' => $filters,
'items' => $collection
->offset($offset)
->limit($limit)
->find_array()
);
} else {
$collection = Subscriber::find_array();
wp_send_json($collection);
}
function getAll() {
$collection = Subscriber::find_array();
wp_send_json($collection);
}