PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 1.91.6
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v1.91.6
2.1.0 2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 All 42 releases
fluent-boards / vendor / wpfluent / framework / src / WPFluent / Foundation / Concerns / AjaxTrait.php

AjaxTrait.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 1.91.6, at vendor/wpfluent/framework/src/WPFluent/Foundation/Concerns/AjaxTrait.php

64 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBoards\Framework\Foundation\Concerns;
4
5 trait AjaxTrait
6 {
7 /**
8 * Add ajax action
9 *
10 * @param string $action
11 * @param string|Closure $handler
12 * @param int $priority
13 * @param string $scope
14 * @return void
15 */
16 private function addAjaxAction($action, $handler, $priority, $scope)
17 {
18 $hook = $scope == 'admin' ? 'wp_ajax_' : 'wp_ajax_nopriv_';
19
20 $action = $hook.$this->config->get('app.hook_prefix').$action;
21
22 $callback = $this->parseHookHandler($handler);
23
24 add_action($action, $callback, $priority);
25 }
26
27 /**
28 * Add ajax actions including non_prive
29 * @param string $action
30 * @param string|Closure $handler
31 * @param int $priority
32 * @return void
33 */
34 public function addAjaxActions($action, $handler, $priority = 10)
35 {
36 $this->addAjaxAction($action, $handler, $priority, 'admin');
37 $this->addAjaxAction($action, $handler, $priority, 'public');
38 }
39
40 /**
41 * Add ajax action for privilaged user
42 * @param string $action
43 * @param string|Closure $handler
44 * @param int $priority
45 * @return void
46 */
47 public function addAdminAjaxAction($action, $handler, $priority = 10)
48 {
49 $this->addAjaxAction($action, $handler, $priority, 'admin');
50 }
51
52 /**
53 * Add ajax action for non-privilaged user
54 * @param string $action
55 * @param string|Closure $handler
56 * @param int $priority
57 * @return void
58 */
59 public function addPublicAjaxAction($action, $handler, $priority = 10)
60 {
61 $this->addAjaxAction($action, $handler, $priority, 'public');
62 }
63 }
64