PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.3.7
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.3.7
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 / wp-data-access.php

wp-data-access.php in WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards 5.3.7, at wp-data-access.php

257 lines 8.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: WP Data Access
5 * Plugin URI: https://wpdataaccess.com/
6 * Description: The best WordPress table plugin with an intuitive table builder and a highly customizable form builder to support data entry
7 * Version: 5.3.7
8 * Author: Passionate Programmers B.V.
9 * Author URI: https://wpdataaccess.com/
10 * Text Domain: wp-data-access
11 * License: GPL-2.0+
12 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
13 * Domain Path: /languages
14 *
15 *
16 * @package plugin
17 * @author Peter Schulz
18 * @since 1.0.0
19 */
20 use WPDataAccess\WPDA ;
21 if ( !defined( 'WPINC' ) ) {
22 die;
23 }
24 if ( !defined( 'ABSPATH' ) ) {
25 exit;
26 }
27 // Add freemius to WP Data Access.
28
29 if ( function_exists( 'wpda_freemius' ) ) {
30 wpda_freemius()->set_basename( false, __FILE__ );
31 } else {
32 // Load WPDataAccess namespace.
33 require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
34 /**
35 * Create a helper function for easy SDK access
36 *
37 * @return Freemius
38 */
39 function wpda_freemius()
40 {
41 global $wpda_freemius ;
42
43 if ( !isset( $wpda_freemius ) ) {
44 // Include Freemius SDK.
45 require_once dirname( __FILE__ ) . '/freemius/start.php';
46 $wpda_freemius = fs_dynamic_init( array(
47 'id' => '6189',
48 'slug' => 'wp-data-access',
49 'type' => 'plugin',
50 'public_key' => 'pk_fc2d1714ca61c930152f6e326b575',
51 'is_premium' => false,
52 'premium_suffix' => 'Premium',
53 'has_addons' => false,
54 'has_paid_plans' => true,
55 'trial' => array(
56 'days' => 14,
57 'is_require_payment' => false,
58 ),
59 'menu' => array(
60 'slug' => 'wpda',
61 'contact' => false,
62 'network' => true,
63 ),
64 'is_live' => true,
65 ) );
66 }
67
68 return $wpda_freemius;
69 }
70
71 // Init Freemius.
72 wpda_freemius();
73 // Signal that SDK was initiated.
74 do_action( 'wpda_freemius_loaded' );
75 /**
76 * Change plugin settings info
77 *
78 * @param mixed $links Links.
79 * @param mixed $file File.
80 * @return mixed
81 */
82 function wpda_row_meta( $links, $file )
83 {
84
85 if ( strpos( $file, plugin_basename( __FILE__ ) ) !== false ) {
86 // Add settings link.
87 $settings_url = admin_url( 'options-general.php' ) . '?page=wpdataaccess';
88 $settings_link = "<a href='{$settings_url}'>Settings</a>";
89 array_push( $links, $settings_link );
90 //phpcs:ignore - 8.1 proof
91 }
92
93 return $links;
94 }
95
96 add_filter(
97 'plugin_row_meta',
98 'wpda_row_meta',
99 10,
100 2
101 );
102 /**
103 * Activate plugin
104 *
105 * @author Peter Schulz
106 * @since 1.0.0
107 */
108 function activate_wp_data_access()
109 {
110 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php';
111 WP_Data_Access_Switch::activate();
112 }
113
114 register_activation_hook( __FILE__, 'activate_wp_data_access' );
115 /**
116 * Deactivate plugin
117 *
118 * @author Peter Schulz
119 * @since 1.0.0
120 */
121 function deactivate_wp_data_access()
122 {
123 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php';
124 WP_Data_Access_Switch::deactivate();
125 }
126
127 register_deactivation_hook( __FILE__, 'deactivate_wp_data_access' );
128 /**
129 * Check if database needs to be updated
130 *
131 * @author Peter Schulz
132 * @since 1.5.2
133 */
134 function wpda_update_db_check()
135 {
136 if ( get_option( WPDataAccess\WPDA::OPTION_WPDA_VERSION[0] ) !== WPDataAccess\WPDA::OPTION_WPDA_VERSION[1] ) {
137 activate_wp_data_access();
138 }
139 }
140
141 add_action( 'plugins_loaded', 'wpda_update_db_check' );
142 /**
143 * Uninstall blog
144 *
145 * This functions is called when the plugin is uninstalled. The following actions are performed:
146 * + Drop plugin tables (unless settings indicate not to)
147 * + Delete plugin options from $wpdb->options (unless settings indicate not to)
148 *
149 * Actions are processed on the current blog and are repeated for every blog on a multisite installation. Must be
150 * called from the dashboard (WP_UNINSTALL_PLUGIN defined). User must have the proper privileges (activate_plugins).
151 *
152 * @author Peter Schulz
153 * @since 1.0.0
154 */
155 function wpda_uninstall_blog()
156 {
157 global $wpdb ;
158 $drop_tables = get_option( 'wpda_uninstall_tables' );
159
160 if ( 'on' === $drop_tables ) {
161 // Get all plugin table names (without WP prefix).
162 $plugin_tables = WPDataAccess\WPDA::get_wpda_tables();
163 foreach ( $plugin_tables as $plugin_table ) {
164 // Loop through plugin tables.
165 // Drop plugin table.
166 $wpdb->query( $wpdb->prepare(
167 'DROP TABLE IF EXISTS `%1s`',
168 // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
169 WPDataAccess\WPDA::remove_backticks( $plugin_table )
170 ) );
171 // db call ok; no-cache ok.
172 // Get plugin backup tables (if applicable).
173 $backup_tables = $wpdb->get_results( $wpdb->prepare( '
174 select table_name as table_name from information_schema.tables
175 where table_schema = %s
176 and table_name like %s
177 ', array( $wpdb->dbname, "{$plugin_table}_BACKUP_%" ) ), 'ARRAY_A' );
178 // db call ok; no-cache ok.
179 foreach ( $backup_tables as $backup_table ) {
180 // Drop plugin backup table.
181 $wpdb->query( $wpdb->prepare(
182 'DROP TABLE IF EXISTS `%1s`',
183 // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
184 WPDataAccess\WPDA::remove_backticks( $backup_table['table_name'] )
185 ) );
186 // db call ok; no-cache ok.
187 }
188 }
189 }
190
191 $delete_options = get_option( 'wpda_uninstall_options' );
192
193 if ( 'on' === $delete_options ) {
194 // Delete all options from wp_options.
195 $wpdb->query( "\n\t\t\t\t\tDELETE FROM {$wpdb->options}\n\t\t\t\t\tWHERE option_name LIKE 'wpda%'\n\t\t\t\t" );
196 // db call ok; no-cache ok.
197 $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" );
198 // db call ok; no-cache ok.
199 }
200
201 }
202
203 /**
204 * Uninstall WP Data Access tables, options and meta keys
205 *
206 * @return void
207 */
208 function wpda_uninstall()
209 {
210
211 if ( is_multisite() ) {
212 global $wpdb ;
213 // Uninstall plugin for all blogs one by one (will fail silently for blogs having no plugin tables/options).
214 $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" );
215 // db call ok; no-cache ok.
216 foreach ( $blogids as $blog_id ) {
217 // Uninstall blog.
218 switch_to_blog( $blog_id );
219 wpda_uninstall_blog();
220 restore_current_blog();
221 }
222 } else {
223 // Uninstall on single site installation.
224 wpda_uninstall_blog();
225 }
226
227 WPDA::wpda_delete_content_folder();
228 }
229
230 wpda_freemius()->add_action( 'after_uninstall', 'wpda_uninstall' );
231 /**
232 * Add WP Data Access icon to freemius
233 *
234 * @return string
235 */
236 function wpda_freemius_icon()
237 {
238 return dirname( __FILE__ ) . '/freemius/assets/img/wpda.png';
239 }
240
241 wpda_freemius()->add_filter( 'plugin_icon', 'wpda_freemius_icon' );
242 /**
243 * Start plugin
244 *
245 * @author Peter Schulz
246 * @since 1.0.0
247 */
248 function run_wp_data_access()
249 {
250 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access.php';
251 $wpdataaccess = new WP_Data_Access();
252 $wpdataaccess->run();
253 }
254
255 run_wp_data_access();
256 }
257