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