| @@ -6,14 +6,16 @@ | ||
| 6 | 6 | use BitCode\BitForm\Core\Capability\Request; |
| 7 | 7 | use BitCode\BitForm\Core\Integration\Integrations; |
| 8 | 8 | use BitCode\BitForm\Frontend\Ajax\FrontendAjax; |
| 9 | 9 | |
| 10 | -class AjaxService { | |
| 11 | - public function __construct() { | |
| 10 | +class AjaxService | |
| 11 | +{ | |
| 12 | + public function __construct() | |
| 13 | + { | |
| 12 | 14 | if (Request::Check('ajax')) { |
| 13 | 15 | $this->loadPublicAjax(); |
| 14 | 16 | } |
| 15 | - if (Request::Check('admin')) { | |
| 17 | + if (Request::Check('admin') && (current_user_can('manage_bitform') || current_user_can('manage_options'))) { | |
| 16 | 18 | $this->loadAdminAjax(); |
| 17 | 19 | $this->loadIntegrationsAjax(); |
| 18 | 20 | } |
| 19 | 21 | } |
| @@ -22,9 +24,10 @@ | ||
| 22 | 24 | * Helps to register admin side ajax |
| 23 | 25 | * |
| 24 | 26 | * @return null |
| 25 | 27 | */ |
| 26 | - public function loadAdminAjax() { | |
| 28 | + public function loadAdminAjax() | |
| 29 | + { | |
| 27 | 30 | (new AdminAjax())->register(); |
| 28 | 31 | } |
| 29 | 32 | |
| 30 | 33 | /** |
| @@ -31,9 +34,10 @@ | ||
| 31 | 34 | * Helps to register frontend ajax |
| 32 | 35 | * |
| 33 | 36 | * @return null |
| 34 | 37 | */ |
| 35 | - protected function loadPublicAjax() { | |
| 38 | + protected function loadPublicAjax() | |
| 39 | + { | |
| 36 | 40 | (new FrontendAjax())->register(); |
| 37 | 41 | } |
| 38 | 42 | |
| 39 | 43 | /** |
| @@ -40,8 +44,9 @@ | ||
| 40 | 44 | * Helps to register integration ajax |
| 41 | 45 | * |
| 42 | 46 | * @return null |
| 43 | 47 | */ |
| 44 | - public function loadIntegrationsAjax() { | |
| 45 | - (new Integrations())->registerAjax(); | |
| 48 | + public function loadIntegrationsAjax() | |
| 49 | + { | |
| 50 | + (Integrations::getInstance())->registerAjax(); | |
| 46 | 51 | } |
| 47 | 52 | } |