PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.85
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.85
5.5.85 5.5.84 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 All 161 releases
← All changes | WPDataAccess/Data_Apps/WPDA_App_Container.php +47 -13 5.5.36 → 5.5.85 View file →
@@ -1,8 +1,10 @@
1 1 <?php
2 2
3 3 namespace WPDataAccess\Data_Apps {
4 4
5 + use WPDataAccess\API\WPDA_API_Core;
6 + use WPDataAccess\API\WPDA_Apps;
5 7 use WPDataAccess\Plugin_Table_Models\WPDA_App_Apps_Model;
6 8 use WPDataAccess\Plugin_Table_Models\WPDA_App_Model;
7 9 use WPDataAccess\WPDA;
8 10
@@ -9,9 +11,12 @@
9 11 class WPDA_App_Container extends WPDA_Container {
10 12
11 13 private $app_id = '';
12 14
13 - public function __construct( $args = array() ) {
15 + public function __construct(
16 + $args = array(),
17 + $shortcode_args = array()
18 + ) {
14 19
15 20 parent::__construct( $args );
16 21
17 22 if ( isset( $args['app_id'] ) ) {
@@ -27,13 +32,15 @@
27 32 ) {
28 33 $this->builders = false;
29 34 }
30 35
36 + $this->shortcode_args = $shortcode_args;
37 +
31 38 }
32 39
33 40 private function get_app_metadata( $app_id ) {
34 41
35 - $app = new \WPDataAccess\API\WPDA_Apps();
42 + $app = new WPDA_Apps();
36 43 $response = $app->get_app_meta( $app_id );
37 44
38 45 if (
39 46 isset( $response->data['code'], $response->data['data'] ) &&
@@ -53,13 +60,18 @@
53 60 if ( ! $this->send_feedback() ) {
54 61 return;
55 62 }
56 63
57 - $this->show_feedback( __( 'Invalid app id', 'wp-data-access' ) );
64 + $this->show_feedback( __( 'Not authorized', 'wp-data-access' ) );
58 65 return;
59 66 }
60 67
61 68 if ( ! $this->user_can_access( $app ) ) {
69 + if ( $this->pwa ) {
70 + esc_html_e( 'Not authorized', 'wp-data-access' );
71 + return;
72 + }
73 +
62 74 if ( ! $this->send_feedback() ) {
63 75 return;
64 76 }
65 77
@@ -89,8 +101,12 @@
89 101 }
90 102
91 103 $app_type_class = '';
92 104 switch ($app[0]['app_type']) {
105 + case '2':
106 + // Map
107 + $app_type_class = 'pp-container-map';
108 + break;
93 109 case '3':
94 110 // Registration form
95 111 $app_type_class = 'pp-container-registration';
96 112 break;
@@ -100,8 +116,13 @@
100 116 break;
101 117 case '6':
102 118 // Chart
103 119 $app_type_class = 'pp-container-chart';
120 + break;
121 + case '7':
122 + // Chart
123 + $app_type_class = 'pp-container-dashboard';
124 + break;
104 125 }
105 126 ?>
106 127
107 128 <div class="wpda-pp-container">
@@ -111,19 +132,32 @@
111 132
112 133 <?php
113 134 if ( null !== $this->filter_field_name && null !== $this->filter_field_value ) {
114 135 ?>
115 - data-filter_field_name="<?php echo $this->filter_field_name; ?>"
116 - data-filter_field_value="<?php echo $this->filter_field_value; ?>"
136 + data-filter_field_name="<?php echo esc_attr( $this->filter_field_name ); ?>"
137 + data-filter_field_value="<?php echo esc_attr( $this->filter_field_value ); ?>"
117 138 <?php
118 139 }
119 140
120 - if ( 0 < count( $this->shortcode_args ) ) {
121 - ?>
122 - data-shortcode_field_name="<?php echo implode( ',', array_keys( $this->shortcode_args ) ); ?>"
123 - data-shortcode_field_value="<?php echo implode( ',', array_values( $this->shortcode_args ) ); ?>"
124 - <?php
125 - }
141 + if ( 0 < count( $this->shortcode_args ) ) {
142 + $field_names = array();
143 + $field_values = array();
144 + foreach ( $this->shortcode_args as $key => $value ) {
145 + // Sanitize field name
146 + $field_names[] = WPDA_API_Core::sanitize_db_identifier( $key );
147 + // Sanitize field value
148 + $sanitized_value = sanitize_text_field( $value );
149 + $sanitized_value = wp_strip_all_tags( $sanitized_value );
150 + $sanitized_value = str_replace( array( '"', "'", '`' ), '', $sanitized_value );
151 + $sanitized_value = str_replace( array( '<', '>' ), '', $sanitized_value );
152 + $sanitized_value = str_replace( '=', '', $sanitized_value );
153 + $field_values[] = $sanitized_value;
154 + }
155 + ?>
156 + data-shortcode_field_name="<?php echo esc_attr( implode( ',', $field_names) ); ?>"
157 + data-shortcode_field_value="<?php echo esc_attr( implode( ',', $field_values ) ); ?>"
158 + <?php
159 + }
126 160 ?>
127 161 ></div>
128 162 </div>
129 163
@@ -147,9 +181,9 @@
147 181 ?>
148 182
149 183 <?php
150 184
151 - $this->add_client( $this->app_id );
185 + $this->add_client('app', $this->app_id );
152 186
153 187 }
154 188
155 189 private function user_can_access( $app ) {
@@ -192,9 +226,9 @@
192 226 ) {
193 227 // Check user login
194 228 $user_login = WPDA::get_current_user_login();
195 229 if ( ! in_array( $user_login, $app_settings['rest_api']['authorized_users'] ) ) {
196 - return false;
230 + return false;
197 231 }
198 232 }
199 233 }
200 234