PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.40
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.40
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 5.5.45 All 158 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.5.40, at wp-data-access.php

234 lines 8.3 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: 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.40
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 if ( !function_exists( 'wpda_freemius' ) ) {
29 // Load WPDataAccess namespace.
30 require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
31 /**
32 * Create a helper function for easy SDK access
33 *
34 * @return Freemius
35 */
36 function wpda_freemius() {
37 global $wpda_freemius;
38 if ( !isset( $wpda_freemius ) ) {
39 // Create a helper function for easy SDK access.
40 require_once dirname( __FILE__ ) . '/vendor/freemius/start.php';
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(
51 'days' => 14,
52 'is_require_payment' => false,
53 ),
54 'menu' => array(
55 'slug' => 'wpda_navi',
56 'contact' => false,
57 'network' => true,
58 ),
59 'is_live' => true,
60 ) );
61 }
62 return $wpda_freemius;
63 }
64
65 // Init Freemius.
66 wpda_freemius();
67 // Signal that SDK was initiated.
68 do_action( 'wpda_freemius_loaded' );
69 /**
70 * Change plugin settings info
71 *
72 * @param mixed $links Links.
73 * @param mixed $file File.
74 * @return mixed
75 */
76 function wpda_row_meta( $links, $file ) {
77 if ( strpos( $file, plugin_basename( __FILE__ ) ) !== false ) {
78 // Add settings link.
79 $settings_url = admin_url( 'options-general.php' ) . '?page=wpdataaccess';
80 $settings_link = "<a href='{$settings_url}'>Settings</a>";
81 array_push( $links, $settings_link );
82 //phpcs:ignore - 8.1 proof
83 }
84 return $links;
85 }
86
87 add_filter(
88 'plugin_row_meta',
89 'wpda_row_meta',
90 10,
91 2
92 );
93 /**
94 * Activate plugin
95 *
96 * @author Peter Schulz
97 * @since 1.0.0
98 */
99 function activate_wp_data_access() {
100 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php';
101 WP_Data_Access_Switch::activate();
102 }
103
104 register_activation_hook( __FILE__, 'activate_wp_data_access' );
105 /**
106 * Deactivate plugin
107 *
108 * @author Peter Schulz
109 * @since 1.0.0
110 */
111 function deactivate_wp_data_access() {
112 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php';
113 WP_Data_Access_Switch::deactivate();
114 }
115
116 register_deactivation_hook( __FILE__, 'deactivate_wp_data_access' );
117 /**
118 * Check if database needs to be updated
119 *
120 * @author Peter Schulz
121 * @since 1.5.2
122 */
123 function wpda_update_db_check() {
124 if ( get_option( WPDataAccess\WPDA::OPTION_WPDA_VERSION[0] ) !== WPDataAccess\WPDA::OPTION_WPDA_VERSION[1] ) {
125 activate_wp_data_access();
126 }
127 }
128
129 add_action( 'plugins_loaded', 'wpda_update_db_check' );
130 /**
131 * Uninstall blog
132 *
133 * This functions is called when the plugin is uninstalled. The following actions are performed:
134 * + Drop plugin tables (unless settings indicate not to)
135 * + Delete plugin options from $wpdb->options (unless settings indicate not to)
136 *
137 * Actions are processed on the current blog and are repeated for every blog on a multisite installation. Must be
138 * called from the dashboard (WP_UNINSTALL_PLUGIN defined). User must have the proper privileges (activate_plugins).
139 *
140 * @author Peter Schulz
141 * @since 1.0.0
142 */
143 function wpda_uninstall_blog() {
144 global $wpdb;
145 $drop_tables = get_option( 'wpda_uninstall_tables' );
146 if ( 'on' === $drop_tables ) {
147 // Get all plugin table names (without WP prefix).
148 $plugin_tables = WPDataAccess\WPDA::get_wpda_tables();
149 foreach ( $plugin_tables as $plugin_table ) {
150 // Loop through plugin tables.
151 // 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 ) );
157 // db call ok; no-cache ok.
158 // Get plugin backup tables (if applicable).
159 $backup_tables = $wpdb->get_results( $wpdb->prepare( '
160 select table_name as table_name from information_schema.tables
161 where table_schema = %s
162 and table_name like %s
163 ', array($wpdb->dbname, "{$plugin_table}_BACKUP_%") ), 'ARRAY_A' );
164 // db call ok; no-cache ok.
165 foreach ( $backup_tables as $backup_table ) {
166 // 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 ) );
172 // db call ok; no-cache ok.
173 }
174 }
175 }
176 $delete_options = get_option( 'wpda_uninstall_options' );
177 if ( 'on' === $delete_options ) {
178 // Delete all options from wp_options.
179 $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" );
180 // db call ok; no-cache ok.
181 $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 // db call ok; no-cache ok.
183 }
184 }
185
186 /**
187 * Uninstall WP Data Access tables, options and meta keys
188 *
189 * @return void
190 */
191 function wpda_uninstall() {
192 if ( is_multisite() ) {
193 global $wpdb;
194 // Uninstall plugin for all blogs one by one (will fail silently for blogs having no plugin tables/options).
195 $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" );
196 // db call ok; no-cache ok.
197 foreach ( $blogids as $blog_id ) {
198 // Uninstall blog.
199 switch_to_blog( $blog_id );
200 wpda_uninstall_blog();
201 restore_current_blog();
202 }
203 } else {
204 // Uninstall on single site installation.
205 wpda_uninstall_blog();
206 }
207 WPDA::wpda_delete_content_folder();
208 }
209
210 wpda_freemius()->add_action( 'after_uninstall', 'wpda_uninstall' );
211 /**
212 * Add WP Data Access icon to freemius
213 *
214 * @return string
215 */
216 function wpda_freemius_icon() {
217 return dirname( __FILE__ ) . '/vendor/freemius/assets/img/wpda.png';
218 }
219
220 wpda_freemius()->add_filter( 'plugin_icon', 'wpda_freemius_icon' );
221 /**
222 * Start plugin
223 *
224 * @author Peter Schulz
225 * @since 1.0.0
226 */
227 function run_wp_data_access() {
228 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access.php';
229 $wpdataaccess = new WP_Data_Access();
230 $wpdataaccess->run();
231 }
232
233 run_wp_data_access();
234 }