PluginProbe
Independent Analytics – WordPress Analytics Plugin / 2.7.1
Independent Analytics – WordPress Analytics Plugin v2.7.1
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 All 120 releases
independent-analytics / IAWP / AJAX / Export_Reports.php
Export_Reports.php
40 lines 982 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IAWP\AJAX;
4
5 use IAWP\Report_Finder;
6 /** @internal */
7 class Export_Reports extends \IAWP\AJAX\AJAX
8 {
9 /**
10 * @inheritDoc
11 */
12 protected function action_required_fields() : array
13 {
14 return ['ids'];
15 }
16 /**
17 * @inheritDoc
18 */
19 protected function action_name() : string
20 {
21 return 'iawp_export_reports';
22 }
23 /**
24 * @inheritDoc
25 */
26 protected function action_callback() : void
27 {
28 $ids = $this->get_field('ids');
29 if (\count($ids) === 0) {
30 \wp_send_json_error([], 400);
31 }
32 $report_finder = new Report_Finder();
33 $reports = $report_finder->by_ids($ids);
34 $reports_array = \array_map(function ($report) {
35 return $report->to_array();
36 }, $reports);
37 \wp_send_json_success(['json' => \json_encode(['plugin_version' => '2.7.1', 'database_version' => '34', 'export_version' => '1', 'reports' => $reports_array])]);
38 }
39 }
40