/** * List contributions based on Campaign ID and/or Volunteer ID */ static function listData() { global $wp; $args = array(); if (isset($wp->query_vars['cid']) && !empty($wp->query_vars['cid'])) { $args['campaign'] = $wp->query_vars['cid']; } // Volunteer by ID if (isset($wp->query_vars['vid']) && !empty($wp->query_vars['vid'])) { $args['volunteer'] = $wp->query_vars['vid']; } else { if (isset($_POST['token']) && !empty($_POST['token'])) { if ($volunteer = API_Volunteer::get_volunter_by_token($_POST['token'])) { $args['volunteer'] = $volunteer->get_id(); } } } $contributionList = new self($args); $contributions = array(); if (0 < count($contributionList->get_contributions())) { foreach ($contributionList->get_contributions() as $contribution) { $contributions[] = $contribution->serialize(false); } } echo json_encode($contributions); die; }