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_Container.php +55 -35 5.5.34 → 5.5.85 View file →
@@ -8,8 +8,12 @@
8 8 private $feedback = false;
9 9
10 10 private $fullscreen = false;
11 11
12 + protected $pwa = false;
13 +
14 + private $hideTitleBar = false;
15 +
12 16 protected $builders = true;
13 17
14 18 protected $filter_field_name = null;
15 19
@@ -14,17 +18,23 @@
14 18 protected $filter_field_name = null;
15 19
16 20 protected $filter_field_value = null;
17 21
18 - protected $shortcode_args = null;
22 + protected $shortcode_args = array();
19 23
20 - public function __construct( $args = array(), $shortcode_args = array() ) {
24 + public function __construct( $args = array() ) {
21 25 if ( isset( $args['feedback'] ) ) {
22 26 $this->feedback = true === $args['feedback'] || 'true' === $args['feedback'];
23 27 }
24 - if ( isset( $shortcode_args['fullscreen'] ) ) {
25 - $this->fullscreen = true === $shortcode_args['fullscreen'] || 'true' === $shortcode_args['fullscreen'];
28 + if ( isset( $args['fullscreen'] ) ) {
29 + $this->fullscreen = true === $args['fullscreen'] || 'true' === $args['fullscreen'];
26 30 }
31 + if ( isset( $args['pwa'] ) ) {
32 + $this->pwa = true === $args['pwa'] || 'true' === $args['pwa'];
33 + }
34 + if ( isset( $args['hidetitlebar'] ) ) {
35 + $this->hideTitleBar = true === $args['hidetitlebar'] || 'true' === $args['hidetitlebar'];
36 + }
27 37 if ( isset( $args['filter_field_name'] ) ) {
28 38 $this->filter_field_name = WPDA_API_Core::sanitize_db_identifier( $args['filter_field_name'] );
29 39 }
30 40 if ( isset( $args['filter_field_value'] ) ) {
@@ -29,17 +39,16 @@
29 39 }
30 40 if ( isset( $args['filter_field_value'] ) ) {
31 41 $this->filter_field_value = sanitize_text_field( $args['filter_field_value'] );
32 42 }
33 - $this->shortcode_args = $shortcode_args;
34 43 wp_enqueue_style( 'wpda_apps' );
35 44 wp_enqueue_media();
36 45 }
37 46
38 - protected function add_client( $app_id = null ) {
39 - $mainjs = 'main-' . WPDA::get_option( WPDA::OPTION_WPDA_CLIENT_VERSION ) . '.js';
47 + protected function add_client( $entry_point, $app_id = null ) {
48 + $mainjs = "{$entry_point}-" . WPDA::get_option( WPDA::OPTION_WPDA_CLIENT_VERSION ) . '.js';
40 49 $script_path = plugin_dir_url( __DIR__ ) . "../assets/dist/";
41 - $script_url = "{$script_path}/{$mainjs}";
50 + $script_url = esc_url( "{$script_path}{$mainjs}" );
42 51 $app_site = wpda_freemius()->get_site();
43 52 unset($app_site->public_key);
44 53 unset($app_site->secret_key);
45 54 $app_licenses = wpda_freemius()->get_available_premium_licenses();
@@ -47,71 +56,82 @@
47 56 for ($i = 0; $i < count( $app_licenses ); $i++) {
48 57 unset($app_licenses[$i]->secret_key);
49 58 }
50 59 }
60 + // phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedScript -- loading module
51 61 ?>
52 62
53 63 <script>
54 - if (! window.PP_APP_CONFIG) {
55 - window.PP_APP_CONFIG = {
56 - appDebug: <?php
64 + if (!window.PP_APP_CONFIG) {
65 + window.PP_APP_CONFIG = {
66 + appDebug: <?php
57 67 echo ( 'on' === WPDA::get_option( WPDA::OPTION_PLUGIN_DEBUG ) ? 'true' : 'false' );
58 68 ?>,
59 - appLocales: "<?php
69 + appLocales: "<?php
60 70 echo esc_url( $script_path ) . 'locales/';
61 71 ?>",
62 - appSite: <?php
72 + appSite: <?php
63 73 echo json_encode( $app_site, true );
64 74 ?>,
65 - appLicenses: <?php
75 + appLicenses: <?php
66 76 echo json_encode( array(
67 77 'license' => $app_licenses,
68 78 'local' => wpda_freemius()->can_use_premium_code__premium_only(),
69 79 ), true );
70 80 ?>,
71 - appTarget: "<?php
81 + appTarget: "<?php
72 82 echo ( is_admin() ? 'backend' : 'frontend' );
73 83 ?>",
74 - appIp: "<?php
75 - echo esc_attr( $_SERVER['REMOTE_ADDR'] );
84 + appIp: "<?php
85 + echo ( isset( $_SERVER['REMOTE_ADDR'] ) ? esc_html( sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) ) : '' );
76 86 ?>",
77 - appUser: "<?php
87 + appUser: "<?php
78 88 echo esc_attr( WPDA::get_current_user_login() );
79 89 ?>",
80 - appRoles: <?php
90 + appRoles: <?php
81 91 echo ( false === $this->builders ? json_encode( array() ) : json_encode( WPDA::get_current_user_roles() ) );
82 92 ?>,
83 - appLogin: <?php
93 + appLogin: <?php
84 94 echo ( 'anonymous' !== WPDA::get_current_user_login() ? 'true' : 'false' );
85 95 ?>,
86 - appVars: <?php
96 + appVars: <?php
97 + // phpcs:disable WordPress.Security.NonceVerification.Missing
87 98 echo json_encode( $_POST, true );
99 + // phpcs:enable WordPress.Security.NonceVerification.Missing
88 100 ?>,
89 - }
90 - }
91 - <?php
101 + }
102 + }
103 + <?php
92 104 if ( null !== $app_id ) {
93 105 // Supporting multiple apps on same page with different settings
94 106 ?>
95 - window.PP_APP_CONFIG[<?php
107 + window.PP_APP_CONFIG[<?php
96 108 echo esc_attr( $app_id );
97 109 ?>] = {
98 - appRoles: <?php
110 + appRoles: <?php
99 111 echo ( false === $this->builders ? json_encode( array() ) : json_encode( WPDA::get_current_user_roles() ) );
100 112 ?>,
101 - appFullscreen: <?php
113 + appFullscreen: <?php
102 114 echo ( $this->fullscreen ? 'true' : 'false' );
103 115 ?>,
104 - }
105 - <?php
116 + appPwa: <?php
117 + echo ( $this->pwa ? 'true' : 'false' );
118 + ?>,
119 + hideTitleBar: <?php
120 + echo ( $this->hideTitleBar ? 'true' : 'false' );
121 + ?>,
122 + }
123 + <?php
106 124 }
107 125 ?>
108 126 </script>
127 +
109 128 <script type="module" src="<?php
110 129 echo esc_attr( $script_url );
111 130 ?>"></script>
112 131
113 132 <?php
133 + // phpcs:enable WordPress.WP.EnqueuedResources.NonEnqueuedScript
114 134 }
115 135
116 136 protected function send_feedback() {
117 137 return $this->feedback;
@@ -120,9 +140,9 @@
120 140 protected function show_feedback( $feedback ) {
121 141 ?>
122 142 <div style="padding: 30px 0">
123 143 <div style="font-weight: normal; margin-bottom: 5px">
124 - WP Data Access error in shortcode<?php
144 + WP Data Access error in shortcode <?php
125 145 echo esc_attr( $this->get_shortcode_from_class() );
126 146 ?>:
127 147 </div>
128 148
@@ -136,13 +156,13 @@
136 156 }
137 157
138 158 private function get_shortcode_from_class() {
139 159 if ( strpos( get_class( $this ), 'WPDA_App_Container' ) !== false ) {
140 - return ' wpda_app';
141 - } elseif ( strpos( get_class( $this ), 'WPDA_Apps_List' ) !== false ) {
142 - return ' wpda_apps';
143 - } elseif ( strpos( get_class( $this ), 'WPDA_Explorer_Container' ) !== false ) {
144 - return ' wpda_data_explorer';
160 + return 'wpda_app';
161 + } elseif ( strpos( get_class( $this ), 'WPDA_App_Builder' ) !== false ) {
162 + return 'wpda_app_builder';
163 + } elseif ( strpos( get_class( $this ), 'WPDA_Data_Explorer' ) !== false ) {
164 + return 'wpda_data_explorer';
145 165 }
146 166 return '';
147 167 }
148 168