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

271 lines 9.1 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.16
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 // if ( wpda_freemius()->can_use_premium_code__premium_only() ) {
76 // /**
77 // * Add support for Angular preflight (required for Data Forms)
78 // */
79 // if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'OPTIONS' === $_SERVER['REQUEST_METHOD'] ) {
80 // header( 'Access-Control-Allow-Origin: *' );
81 // header( 'Access-Control-Allow-Credentials: true' );
82 // header( 'Access-Control-Allow-Methods: POST, GET, OPTIONS' );
83 // header( 'Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept' );
84 // header( 'Access-Control-Max-Age: 86400' );
85 // header( 'Cache-Control: public, max-age=86400' );
86 // header( 'Vary: origin' );
87 // }
88 // }
89 /**
90 * Change plugin settings info
91 *
92 * @param mixed $links Links.
93 * @param mixed $file File.
94 * @return mixed
95 */
96 function wpda_row_meta( $links, $file )
97 {
98
99 if ( strpos( $file, plugin_basename( __FILE__ ) ) !== false ) {
100 // Add settings link.
101 $settings_url = admin_url( 'options-general.php' ) . '?page=wpdataaccess';
102 $settings_link = "<a href='{$settings_url}'>Settings</a>";
103 array_push( $links, $settings_link );
104 //phpcs:ignore - 8.1 proof
105 }
106
107 return $links;
108 }
109
110 add_filter(
111 'plugin_row_meta',
112 'wpda_row_meta',
113 10,
114 2
115 );
116 /**
117 * Activate plugin
118 *
119 * @author Peter Schulz
120 * @since 1.0.0
121 */
122 function activate_wp_data_access()
123 {
124 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php';
125 WP_Data_Access_Switch::activate();
126 }
127
128 register_activation_hook( __FILE__, 'activate_wp_data_access' );
129 /**
130 * Deactivate plugin
131 *
132 * @author Peter Schulz
133 * @since 1.0.0
134 */
135 function deactivate_wp_data_access()
136 {
137 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php';
138 WP_Data_Access_Switch::deactivate();
139 }
140
141 register_deactivation_hook( __FILE__, 'deactivate_wp_data_access' );
142 /**
143 * Check if database needs to be updated
144 *
145 * @author Peter Schulz
146 * @since 1.5.2
147 */
148 function wpda_update_db_check()
149 {
150 if ( get_option( WPDataAccess\WPDA::OPTION_WPDA_VERSION[0] ) !== WPDataAccess\WPDA::OPTION_WPDA_VERSION[1] ) {
151 activate_wp_data_access();
152 }
153 }
154
155 add_action( 'plugins_loaded', 'wpda_update_db_check' );
156 /**
157 * Uninstall blog
158 *
159 * This functions is called when the plugin is uninstalled. The following actions are performed:
160 * + Drop plugin tables (unless settings indicate not to)
161 * + Delete plugin options from $wpdb->options (unless settings indicate not to)
162 *
163 * Actions are processed on the current blog and are repeated for every blog on a multisite installation. Must be
164 * called from the dashboard (WP_UNINSTALL_PLUGIN defined). User must have the proper privileges (activate_plugins).
165 *
166 * @author Peter Schulz
167 * @since 1.0.0
168 */
169 function wpda_uninstall_blog()
170 {
171 global $wpdb ;
172 $drop_tables = get_option( 'wpda_uninstall_tables' );
173
174 if ( 'on' === $drop_tables ) {
175 // Get all plugin table names (without WP prefix).
176 $plugin_tables = WPDataAccess\WPDA::get_wpda_tables();
177 foreach ( $plugin_tables as $plugin_table ) {
178 // Loop through plugin tables.
179 // Drop plugin table.
180 $wpdb->query( $wpdb->prepare(
181 'DROP TABLE IF EXISTS `%1s`',
182 // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
183 WPDataAccess\WPDA::remove_backticks( $plugin_table )
184 ) );
185 // db call ok; no-cache ok.
186 // Get plugin backup tables (if applicable).
187 $backup_tables = $wpdb->get_results( $wpdb->prepare( '
188 select table_name as table_name from information_schema.tables
189 where table_schema = %s
190 and table_name like %s
191 ', array( $wpdb->dbname, "{$plugin_table}_BACKUP_%" ) ), 'ARRAY_A' );
192 // db call ok; no-cache ok.
193 foreach ( $backup_tables as $backup_table ) {
194 // Drop plugin backup table.
195 $wpdb->query( $wpdb->prepare(
196 'DROP TABLE IF EXISTS `%1s`',
197 // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
198 WPDataAccess\WPDA::remove_backticks( $backup_table['table_name'] )
199 ) );
200 // db call ok; no-cache ok.
201 }
202 }
203 }
204
205 $delete_options = get_option( 'wpda_uninstall_options' );
206
207 if ( 'on' === $delete_options ) {
208 // Delete all options from wp_options.
209 $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" );
210 // db call ok; no-cache ok.
211 $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" );
212 // db call ok; no-cache ok.
213 }
214
215 }
216
217 /**
218 * Uninstall WP Data Access tables, options and meta keys
219 *
220 * @return void
221 */
222 function wpda_uninstall()
223 {
224
225 if ( is_multisite() ) {
226 global $wpdb ;
227 // Uninstall plugin for all blogs one by one (will fail silently for blogs having no plugin tables/options).
228 $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" );
229 // db call ok; no-cache ok.
230 foreach ( $blogids as $blog_id ) {
231 // Uninstall blog.
232 switch_to_blog( $blog_id );
233 wpda_uninstall_blog();
234 restore_current_blog();
235 }
236 } else {
237 // Uninstall on single site installation.
238 wpda_uninstall_blog();
239 }
240
241 WPDA::wpda_delete_content_folder();
242 }
243
244 wpda_freemius()->add_action( 'after_uninstall', 'wpda_uninstall' );
245 /**
246 * Add WP Data Access icon to freemius
247 *
248 * @return string
249 */
250 function wpda_freemius_icon()
251 {
252 return dirname( __FILE__ ) . '/freemius/assets/img/wpda.png';
253 }
254
255 wpda_freemius()->add_filter( 'plugin_icon', 'wpda_freemius_icon' );
256 /**
257 * Start plugin
258 *
259 * @author Peter Schulz
260 * @since 1.0.0
261 */
262 function run_wp_data_access()
263 {
264 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access.php';
265 $wpdataaccess = new WP_Data_Access();
266 $wpdataaccess->run();
267 }
268
269 run_wp_data_access();
270 }
271