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

80 lines 1.5 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 ( '/' . self::WPDA_NAMESPACE === $rest_route && ! current_user_can( 'manage_options' ) ) {
29 return new \WP_Error(
30 'rest_cannot_access',
31 __( 'Only authenticated admin users can access the REST API.', 'wp-data-access' ),
32 array(
33 'status' => rest_authorization_required_code(),
34 )
35 );
36 }
37
38 return $access;
39 }
40 );
41
42 }
43
44 /**
45 * Register routes.
46 *
47 * @return void
48 */
49 public function init() {
50
51 // Plugin
52 $plugin = new WPDA_Plugin();
53 $plugin->register_rest_routes();
54
55 // Apps
56 $apps = new WPDA_Apps();
57 $apps->register_rest_routes();
58
59 // Data Explorer
60 $tree = new WPDA_Tree();
61 $tree->register_rest_routes();
62
63 // Data Tables and Data Forms
64 $tables = new WPDA_Table();
65 $tables->register_rest_routes();
66
67 // Admin actions
68 $actions = new WPDA_Actions();
69 $actions->register_rest_routes();
70
71 // Settings
72 $settings = new WPDA_Settings();
73 $settings->register_rest_routes();
74
75 }
76
77 }
78
79 }
80