PluginProbe
Independent Analytics – WordPress Analytics Plugin / 2.8.9
Independent Analytics – WordPress Analytics Plugin v2.8.9
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 / Sort_Reports.php
Sort_Reports.php
41 lines 1.1 KB
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\Capability_Manager;
6 use IAWP\Illuminate_Builder;
7 use IAWP\Query;
8 /** @internal */
9 class Sort_Reports extends \IAWP\AJAX\AJAX
10 {
11 /**
12 * @return array
13 */
14 protected function action_required_fields() : array
15 {
16 return ['ids', 'type'];
17 }
18 /**
19 * @return string
20 */
21 protected function action_name() : string
22 {
23 return 'iawp_sort_reports';
24 }
25 /**
26 * @return void
27 */
28 protected function action_callback() : void
29 {
30 $reports_table = Query::get_table_name(Query::REPORTS);
31 if (!Capability_Manager::can_edit()) {
32 \wp_send_json_error([], 400);
33 }
34 Illuminate_Builder::get_builder()->from($reports_table)->where('type', '=', $this->get_field('type'))->update(['position' => null]);
35 foreach ($this->get_field('ids') as $index => $id) {
36 Illuminate_Builder::get_builder()->from($reports_table)->where('type', '=', $this->get_field('type'))->where('report_id', '=', $id)->update(['position' => $index]);
37 }
38 \wp_send_json_success();
39 }
40 }
41