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() { function init() {
if(!is_admin()) {
add_action('widgets_init', array($this, 'registerWidget')); add_action('widgets_init', array($this, 'registerWidget'));
if(!is_admin()) {
add_action('widgets_init', array($this, 'setupActions')); add_action('widgets_init', array($this, 'setupActions'));
add_action('widgets_init', array($this, 'setupDependencies')); add_action('widgets_init', array($this, 'setupDependencies'));
} }

View File

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