PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.42
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.42
5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 5.5.42 5.5.43 All 159 releases
wp-data-access / WPDataAccess / API / WPDA_API.php

WPDA_API.php in WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards 5.5.42, at WPDataAccess/API/WPDA_API.php

96 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore Standard.Category.SniffName.ErrorCode
2
3 /**
4 * JSON REST API.
5 */
6
7 namespace WPDataAccess\API {
8
9 use WPDataAccess\WPDA;
10
11 /**
12 * JSON REST API main class.
13 */
14 class WPDA_API {
15
16 const WPDA_NAMESPACE = 'wpda';
17 const WPDA_REST_API_TABLE_ACCESS = 'wpda_rest_api_table_access';
18
19 public function hide() {
20
21 add_filter(
22 'rest_authentication_errors',
23 function ( $access ) {
24 $rest_route = isset( $GLOBALS['wp']->query_vars['rest_route'] )
25 ? untrailingslashit( $GLOBALS['wp']->query_vars['rest_route'] )
26 : '';
27
28 if (
29 '/' . self::WPDA_NAMESPACE === $rest_route &&
30 ! current_user_can( 'manage_options' ) &&
31 ! current_user_can( 'manage_sites' )
32 ) {
33 return new \WP_Error(
34 'rest_cannot_access',
35 __( 'Only authenticated admin users can access the REST API.', 'wp-data-access' ),
36 array(
37 'status' => rest_authorization_required_code(),
38 )
39 );
40 }
41
42 return $access;
43 }
44 );
45
46 }
47
48 /**
49 * Register routes.
50 *
51 * @return void
52 */
53 public function init() {
54
55 // Plugin
56 $plugin = new WPDA_Plugin();
57 $plugin->register_rest_routes();
58
59 // Apps
60 $apps = new WPDA_Apps();
61 $apps->register_rest_routes();
62
63 // Data Explorer
64 $tree = new WPDA_Tree();
65 $tree->register_rest_routes();
66
67 // Data Tables and Data Forms
68 $tables = new WPDA_Table();
69 $tables->register_rest_routes();
70
71 // Admin actions
72 $actions = new WPDA_Actions();
73 $actions->register_rest_routes();
74
75 // Settings
76 $settings = new WPDA_Settings();
77 $settings->register_rest_routes();
78
79 // Query Builder
80 $qb = new WPDA_QB();
81 $qb->register_rest_routes();
82
83 // AI Assistant
84 $ai = new WPDA_AI();
85 $ai->register_rest_routes();
86
87 // Scheduled Exports
88 $export = new WPDA_Export();
89 $export->register_rest_routes();
90
91 }
92
93 }
94
95 }
96