PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.73
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.73
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.73, at WPDataAccess/API/WPDA_API.php

95 lines 1.9 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 ! WPDA::current_user_is_admin()
31 ) {
32 return new \WP_Error(
33 'rest_cannot_access',
34 __( 'Only authenticated admin users can access the REST API.', 'wp-data-access' ),
35 array(
36 'status' => rest_authorization_required_code(),
37 )
38 );
39 }
40
41 return $access;
42 }
43 );
44
45 }
46
47 /**
48 * Register routes.
49 *
50 * @return void
51 */
52 public function init() {
53
54 // Plugin
55 $plugin = new WPDA_Plugin();
56 $plugin->register_rest_routes();
57
58 // Apps
59 $apps = new WPDA_Apps();
60 $apps->register_rest_routes();
61
62 // Data Explorer
63 $tree = new WPDA_Tree();
64 $tree->register_rest_routes();
65
66 // Data Tables and Data Forms
67 $tables = new WPDA_Table();
68 $tables->register_rest_routes();
69
70 // Admin actions
71 $actions = new WPDA_Actions();
72 $actions->register_rest_routes();
73
74 // Settings
75 $settings = new WPDA_Settings();
76 $settings->register_rest_routes();
77
78 // Query Builder
79 $qb = new WPDA_QB();
80 $qb->register_rest_routes();
81
82 // AI Assistant
83 $ai = new WPDA_AI();
84 $ai->register_rest_routes();
85
86 // Scheduled Exports
87 $export = new WPDA_Export();
88 $export->register_rest_routes();
89
90 }
91
92 }
93
94 }
95