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