PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 2.5.0
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v2.5.0
2.5.0 2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 All 34 releases
fluent-booking / vendor / wpfluent / framework / src / WPFluent / Foundation / Concerns / AjaxTrait.php

AjaxTrait.php in Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution 2.5.0, 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 FluentBooking\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