PluginProbe
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce / 1.17.4
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce v1.17.4
1.17.9 1.17.8 1.17.7 1.17.6 1.17.5 1.17.4 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.3.0 1.3.1 1.3.11 1.3.12 1.3.13 1.3.14 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 All 143 releases
erp / includes / API / UtilityController.php

UtilityController.php in ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce 1.17.4, at includes/API/UtilityController.php

57 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WeDevs\ERP\API;
4
5 use WP_REST_Response;
6 use WP_REST_Server;
7
8 class UtilityController extends REST_Controller {
9
10 /**
11 * Endpoint namespace.
12 *
13 * @var string
14 */
15 protected $namespace = 'erp/v1';
16
17 /**
18 * Route base.
19 *
20 * @var string
21 */
22 protected $rest_base = 'utility';
23
24 /**
25 * Register the routes for the objects of the controller.
26 */
27 public function register_routes() {
28 register_rest_route( $this->namespace, '/' . $this->rest_base . '/get-active-plugins', [
29 [
30 'methods' => WP_REST_Server::READABLE,
31 'callback' => [ $this, 'get_active_plugins' ],
32 'args' => $this->get_collection_params(),
33 'permission_callback' => function ( $request ) {
34 return current_user_can( 'erp_view_list' );
35 },
36 ],
37 'schema' => [ $this, 'get_public_item_schema' ],
38 ] );
39 }
40
41 /**
42 * Get the list of active plugins
43 *
44 * @since 1.3.0
45 *
46 * @param $request
47 *
48 * @return mixed|WP_REST_Response
49 */
50 public function get_active_plugins( $request ) {
51 $active_plugins = get_option( 'active_plugins' );
52 $response = rest_ensure_response( $active_plugins );
53
54 return $response;
55 }
56 }
57