public static function get_filter_links($form, $include_counts = true) { $form_id = absint($form['id']); $summary = $include_counts ? GFFormsModel::get_form_counts($form_id) : array(); $active_lead_count = rgar($summary, 'total'); $unread_count = rgar($summary, 'unread'); $starred_count = rgar($summary, 'starred'); $spam_count = rgar($summary, 'spam'); $trash_count = rgar($summary, 'trash'); $filter_links = array(array('id' => 'all', 'field_filters' => array(), 'count' => $active_lead_count, 'label' => esc_html_x('All', 'Entry List', 'gravityforms')), array('id' => 'unread', 'field_filters' => array(array('key' => 'is_read', 'value' => false)), 'count' => $unread_count, 'label' => esc_html_x('Unread', 'Entry List', 'gravityforms')), array('id' => 'star', 'field_filters' => array(array('key' => 'is_starred', 'value' => true)), 'count' => $starred_count, 'label' => esc_html_x('Starred', 'Entry List', 'gravityforms'))); if (GFCommon::spam_enabled($form_id)) { $filter_links[] = array('id' => 'spam', 'field_filters' => array(), 'count' => $spam_count, 'label' => esc_html__('Spam', 'gravityforms')); } $filter_links[] = array('id' => 'trash', 'field_filters' => array(), 'count' => $trash_count, 'label' => esc_html__('Trash', 'gravityforms')); /** * ---Provisional and may be subject to change--- * * Allow the row of filter links to be modified. * * Array elements: * selected - bool * filter - string * label - string * * @param array $filter_links The filter links. * */ $filter_links = apply_filters('gform_filter_links_entry_list', $filter_links, $form, $include_counts); return $filter_links; }
public function get_forms($form_ids = null, $schema = "") { $this->authorize("gravityforms_edit_forms"); $status = 200; $response = array(); if (empty($form_ids)) { $forms = RGFormsModel::get_forms(true); foreach ($forms as $form) { $form_id = $form->id; $totals = GFFormsModel::get_form_counts($form_id); $form_info = array("id" => $form_id, "title" => $form->title, "entries" => rgar($totals, "total")); $response[$form_id] = $form_info; } if ($schema == "mtd") { $response = $this->mtd_transform_forms_data($response); } } else { if (is_array($form_ids)) { foreach ($form_ids as $form_id) { $response[$form_id] = GFAPI::get_form($form_id); } } else { $result = GFAPI::get_form($form_ids); if (is_wp_error($result)) { $response = $this->get_error_response($result); $status = $this->get_error_status($result); } elseif (!$result) { $this->die_not_found(); } else { $response = $result; } } } $this->end($status, $response); }
public function get_forms($form_ids = null, $schema = '') { $this->log_debug(__METHOD__ . '(): Running.'); $capability = apply_filters('gform_web_api_capability_get_forms', 'gravityforms_edit_forms'); $this->authorize($capability); $status = 200; $response = array(); if (empty($form_ids)) { $forms = RGFormsModel::get_forms(true); foreach ($forms as $form) { $form_id = $form->id; $totals = GFFormsModel::get_form_counts($form_id); $form_info = array('id' => $form_id, 'title' => $form->title, 'entries' => rgar($totals, 'total')); $response[$form_id] = $form_info; } if ($schema == 'mtd') { $response = $this->mtd_transform_forms_data($response); } } else { if (is_array($form_ids)) { foreach ($form_ids as $form_id) { $response[$form_id] = GFAPI::get_form($form_id); } } else { $result = GFAPI::get_form($form_ids); if (is_wp_error($result)) { $response = $this->get_error_response($result); $status = $this->get_error_status($result); } elseif (!$result) { $this->die_not_found(); } else { $response = $result; } } } $this->end($status, $response); }