PluginProbe
WP Data Access – App Builder for Tables, Forms, Dashboards, Charts & Maps / 5.5.87
WP Data Access – App Builder for Tables, Forms, Dashboards, Charts & Maps v5.5.87
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 | wp-data-access.php +153 -37 5.5.36 → 5.5.87 View file →
@@ -3,9 +3,9 @@
3 3 /**
4 4 * Plugin Name: WP Data Access
5 5 * Plugin URI: https://wpdataaccess.com/
6 6 * Description: A powerful data-driven App Builder with an intuitive Table Builder, a highly customizable Form Builder and interactive Chart support in 35 languages
7 - * Version: 5.5.36
7 + * Version: 5.5.87
8 8 * Author: Passionate Programmers B.V.
9 9 * Author URI: https://wpdataaccess.com/
10 10 * Text Domain: wp-data-access
11 11 * License: GPL-2.0+
@@ -38,26 +38,28 @@
38 38 if ( !isset( $wpda_freemius ) ) {
39 39 // Create a helper function for easy SDK access.
40 40 require_once dirname( __FILE__ ) . '/vendor/freemius/start.php';
41 41 $wpda_freemius = fs_dynamic_init( array(
42 - 'id' => '6189',
43 - 'slug' => 'wp-data-access',
44 - 'type' => 'plugin',
45 - 'public_key' => 'pk_fc2d1714ca61c930152f6e326b575',
46 - 'is_premium' => false,
47 - 'premium_suffix' => 'Premium',
48 - 'has_addons' => false,
49 - 'has_paid_plans' => true,
50 - 'trial' => array(
42 + 'id' => '6189',
43 + 'slug' => 'wp-data-access',
44 + 'type' => 'plugin',
45 + 'public_key' => 'pk_fc2d1714ca61c930152f6e326b575',
46 + 'is_premium' => false,
47 + 'premium_suffix' => 'Premium',
48 + 'has_addons' => false,
49 + 'has_paid_plans' => true,
50 + 'trial' => array(
51 51 'days' => 14,
52 52 'is_require_payment' => false,
53 53 ),
54 - 'menu' => array(
54 + 'menu' => array(
55 55 'slug' => 'wpda_navi',
56 56 'contact' => false,
57 57 'network' => true,
58 58 ),
59 - 'is_live' => true,
59 + 'has_affiliation' => 'all',
60 + 'is_live' => true,
61 + 'is_org_compliant' => true,
60 62 ) );
61 63 }
62 64 return $wpda_freemius;
63 65 }
@@ -66,21 +68,67 @@
66 68 wpda_freemius();
67 69 // Signal that SDK was initiated.
68 70 do_action( 'wpda_freemius_loaded' );
69 71 /**
70 - * Change plugin settings info
71 - *
72 + * Check if legacy tools are currently used on this server.
73 + * @return bool
74 + */
75 + function wpda_has_legacy_tools_inuse() {
76 + $option_legacy_tools = WPDA::get_option( WPDA::OPTION_PLUGIN_LEGACY_TOOLS );
77 + $has_legacy_tools = false;
78 + if ( !empty( $option_legacy_tools ) && is_array( $option_legacy_tools ) ) {
79 + foreach ( $option_legacy_tools as $tool ) {
80 + if ( isset( $tool[0] ) && $tool[0] === true && isset( $tool[1] ) && $tool[1] > 0 ) {
81 + $has_legacy_tools = true;
82 + break;
83 + }
84 + }
85 + }
86 + return $has_legacy_tools;
87 + }
88 +
89 + /**
90 + * Hook into the plugin_row_meta filter.
72 91 * @param mixed $links Links.
73 92 * @param mixed $file File.
93 + * @param mixed $data Data.
74 94 * @return mixed
75 95 */
76 - function wpda_row_meta( $links, $file ) {
77 - if ( strpos( $file, plugin_basename( __FILE__ ) ) !== false ) {
96 + function wpda_row_meta( $links, $file, $data ) {
97 + if ( plugin_basename( __FILE__ ) == $file ) {
78 98 // Add settings link.
79 99 $settings_url = admin_url( 'options-general.php' ) . '?page=wpdataaccess';
80 - $settings_link = "<a href='{$settings_url}'>Settings</a>";
100 + $settings_link = '<a href="' . esc_url( $settings_url ) . '">Settings</a>';
81 101 array_push( $links, $settings_link );
82 - //phpcs:ignore - 8.1 proof
102 + // phpcs:ignore -- 8.1 proof
103 + // Add comment for legacy users only
104 + if ( wpda_has_legacy_tools_inuse() ) {
105 + if ( isset( $data['new_version'] ) ) {
106 + $new_version = $data['new_version'];
107 + if ( version_compare( $new_version, '6.0', '>=' ) ) {
108 + $notice = '
109 + <p style="margin-top: 10px; margin-bottom: 0; padding: 6px 10px; border-radius: 2px;"
110 + class="update-message notice inline notice-warning notice-alt"
111 + >
112 + <span class="dashicons dashicons-warning" style="color: #f0b849;"></span>
113 + <strong>Warning for legacy users:</strong> Version ' . esc_html( $new_version ) . ' (available now) removes legacy tools.
114 + <strong style="color: #cc1818;">Stay on Version 5.x</strong> to keep using them.
115 + <a href="https://docs.legacy.wpdataaccess.com/docs/deprecating/" target="_blank">Read more →</a>
116 + </p>';
117 + } else {
118 + $notice = '
119 + <p style="margin-top: 10px; margin-bottom: 0; padding: 6px 10px; border-radius: 2px;"
120 + class="update-message notice inline notice-info notice-alt"
121 + >
122 + <span class="dashicons dashicons-info" style="color: #3858e9;"></span>
123 + <strong>Info for legacy users:</strong> Version 6 is coming soon and removes legacy tools.
124 + <strong>Stay on Version 5.x</strong> to keep using them.
125 + <a href="https://docs.legacy.wpdataaccess.com/docs/deprecating/" target="_blank">Read more →</a>
126 + </p>';
127 + }
128 + $links[] = $notice;
129 + }
130 + }
83 131 }
84 132 return $links;
85 133 }
86 134
@@ -87,22 +135,75 @@
87 135 add_filter(
88 136 'plugin_row_meta',
89 137 'wpda_row_meta',
90 138 10,
91 - 2
139 + 3
92 140 );
93 141 /**
142 + * Remove last | character from plugin links.
143 + * @return void
144 + */
145 + function wpda_clean_plugin_row_script() {
146 + if ( !wpda_has_legacy_tools_inuse() ) {
147 + return;
148 + }
149 + ?>
150 + <script type="text/javascript">
151 + jQuery(document).ready(function($) {
152 + var $row = $('tr[data-slug="wp-data-access"] .plugin-version-author-uri');
153 + if ($row.length) {
154 + $row.contents().each(function(index) {
155 + if (this.nodeType === 3 && index === 6) {
156 + this.nodeValue = this.nodeValue.replace(/\|/g, '');
157 + }
158 + });
159 + }
160 + });
161 + </script>
162 + <?php
163 + }
164 +
165 + add_action( 'admin_footer-plugins.php', 'wpda_clean_plugin_row_script' );
166 + /**
167 + * Show legacy tools info widget.
168 + * @return void
169 + */
170 + function wpda_legacy_tools_notice_widget() {
171 + // Add widget for legacy users only
172 + if ( wpda_has_legacy_tools_inuse() ) {
173 + wp_add_dashboard_widget( 'wporg_dashboard_widget', 'WP Data Access - Info for legacy tools users', function () {
174 + ?>
175 + <p>
176 + Version 6 is coming soon and removes legacy tools.
177 + </p>
178 + <p>
179 + <strong>To keep using the legacy tools:</strong><br>
180 + ✓ Stay on the latest Version 5.x<br>
181 + ✓ Disable auto-updates<br>
182 + ✓ Do not update manually to Version 6
183 + </p>
184 + <p>
185 + <a href="https://docs.legacy.wpdataaccess.com/docs/deprecating/" target="_blank">Read more →</a>
186 + </p>
187 + <?php
188 + } );
189 + }
190 + }
191 +
192 + add_action( 'wp_dashboard_setup', 'wpda_legacy_tools_notice_widget' );
193 + /**
94 194 * Activate plugin
95 195 *
96 196 * @author Peter Schulz
97 197 * @since 1.0.0
98 198 */
99 - function activate_wp_data_access() {
199 + function wpda_activate() {
200 + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
100 201 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php';
101 202 WP_Data_Access_Switch::activate();
102 203 }
103 204
104 - register_activation_hook( __FILE__, 'activate_wp_data_access' );
205 + register_activation_hook( __FILE__, 'wpda_activate' );
105 206 /**
106 207 * Deactivate plugin
107 208 *
108 209 * @author Peter Schulz
@@ -107,14 +208,15 @@
107 208 *
108 209 * @author Peter Schulz
109 210 * @since 1.0.0
110 211 */
111 - function deactivate_wp_data_access() {
212 + function wpda_deactivate() {
213 + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
112 214 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php';
113 215 WP_Data_Access_Switch::deactivate();
114 216 }
115 217
116 - register_deactivation_hook( __FILE__, 'deactivate_wp_data_access' );
218 + register_deactivation_hook( __FILE__, 'wpda_deactivate' );
117 219 /**
118 220 * Check if database needs to be updated
119 221 *
120 222 * @author Peter Schulz
@@ -121,9 +223,9 @@
121 223 * @since 1.5.2
122 224 */
123 225 function wpda_update_db_check() {
124 226 if ( get_option( WPDataAccess\WPDA::OPTION_WPDA_VERSION[0] ) !== WPDataAccess\WPDA::OPTION_WPDA_VERSION[1] ) {
125 - activate_wp_data_access();
227 + wpda_activate();
126 228 }
127 229 }
128 230
129 231 add_action( 'plugins_loaded', 'wpda_update_db_check' );
@@ -132,8 +234,9 @@
132 234 *
133 235 * This functions is called when the plugin is uninstalled. The following actions are performed:
134 236 * + Drop plugin tables (unless settings indicate not to)
135 237 * + Delete plugin options from $wpdb->options (unless settings indicate not to)
238 + * + Unscheduled all WP Data Access events
136 239 *
137 240 * Actions are processed on the current blog and are repeated for every blog on a multisite installation. Must be
138 241 * called from the dashboard (WP_UNINSTALL_PLUGIN defined). User must have the proper privileges (activate_plugins).
139 242 *
@@ -142,8 +245,9 @@
142 245 */
143 246 function wpda_uninstall_blog() {
144 247 global $wpdb;
145 248 $drop_tables = get_option( 'wpda_uninstall_tables' );
249 + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
146 250 if ( 'on' === $drop_tables ) {
147 251 // Get all plugin table names (without WP prefix).
148 252 $plugin_tables = WPDataAccess\WPDA::get_wpda_tables();
149 253 foreach ( $plugin_tables as $plugin_table ) {
@@ -148,13 +252,9 @@
148 252 $plugin_tables = WPDataAccess\WPDA::get_wpda_tables();
149 253 foreach ( $plugin_tables as $plugin_table ) {
150 254 // Loop through plugin tables.
151 255 // Drop plugin table.
152 - $wpdb->query( $wpdb->prepare(
153 - 'DROP TABLE IF EXISTS `%1s`',
154 - // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
155 - WPDataAccess\WPDA::remove_backticks( $plugin_table )
156 - ) );
256 + $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS `%1s`', WPDataAccess\WPDA::remove_backticks( $plugin_table ) ) );
157 257 // db call ok; no-cache ok.
158 258 // Get plugin backup tables (if applicable).
159 259 $backup_tables = $wpdb->get_results( $wpdb->prepare( '
160 260 select table_name as table_name from information_schema.tables
@@ -163,13 +263,9 @@
163 263 ', array($wpdb->dbname, "{$plugin_table}_BACKUP_%") ), 'ARRAY_A' );
164 264 // db call ok; no-cache ok.
165 265 foreach ( $backup_tables as $backup_table ) {
166 266 // Drop plugin backup table.
167 - $wpdb->query( $wpdb->prepare(
168 - 'DROP TABLE IF EXISTS `%1s`',
169 - // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
170 - WPDataAccess\WPDA::remove_backticks( $backup_table['table_name'] )
171 - ) );
267 + $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS `%1s`', WPDataAccess\WPDA::remove_backticks( $backup_table['table_name'] ) ) );
172 268 // db call ok; no-cache ok.
173 269 }
174 270 }
175 271 }
@@ -180,10 +276,24 @@
180 276 // db call ok; no-cache ok.
181 277 $wpdb->query( "\n\t\t\t\t\tDELETE FROM {$wpdb->usermeta}\n\t\t\t\t\tWHERE meta_key LIKE 'wpda%'\n\t\t\t\t\t OR meta_key LIKE '%wp-data-access%'\n\t\t\t\t" );
182 278 // db call ok; no-cache ok.
183 279 }
280 + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
184 281 }
185 282
283 + function wpda_unschedule_event( $hook ) {
284 + $crons = _get_cron_array();
285 + foreach ( $crons as $timestamp => $cron ) {
286 + if ( isset( $cron[$hook] ) ) {
287 + foreach ( $cron[$hook] as $event ) {
288 + if ( isset( $event['args'] ) ) {
289 + wp_unschedule_event( $timestamp, $hook, $event['args'] );
290 + }
291 + }
292 + }
293 + }
294 + }
295 +
186 296 /**
187 297 * Uninstall WP Data Access tables, options and meta keys
188 298 *
189 299 * @return void
@@ -191,10 +301,11 @@
191 301 function wpda_uninstall() {
192 302 if ( is_multisite() ) {
193 303 global $wpdb;
194 304 // Uninstall plugin for all blogs one by one (will fail silently for blogs having no plugin tables/options).
305 + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
195 306 $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" );
196 - // db call ok; no-cache ok.
307 + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
197 308 foreach ( $blogids as $blog_id ) {
198 309 // Uninstall blog.
199 310 switch_to_blog( $blog_id );
200 311 wpda_uninstall_blog();
@@ -204,8 +315,12 @@
204 315 // Uninstall on single site installation.
205 316 wpda_uninstall_blog();
206 317 }
207 318 WPDA::wpda_delete_content_folder();
319 + // Unscheduled all WP Data Access events
320 + wpda_unschedule_event( 'wpda_data_backup' );
321 + wpda_unschedule_event( \WPDataAccess\Query_Builder\WPDA_Query_Builder_Scheduler::SCHEDULER_HOOK_NAME );
322 + wpda_unschedule_event( \WPDataAccess\Utilities\WPDA_Export_Scheduler::SCHEDULER_HOOK_NAME );
208 323 }
209 324
210 325 wpda_freemius()->add_action( 'after_uninstall', 'wpda_uninstall' );
211 326 /**
@@ -223,12 +338,13 @@
223 338 *
224 339 * @author Peter Schulz
225 340 * @since 1.0.0
226 341 */
227 - function run_wp_data_access() {
342 + function wpda_run() {
343 + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
228 344 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access.php';
229 345 $wpdataaccess = new WP_Data_Access();
230 346 $wpdataaccess->run();
231 347 }
232 348
233 - run_wp_data_access();
349 + wpda_run();
234 350 }