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

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