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

235 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.64
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 * + Unscheduled all WP Data Access events
137 *
138 * Actions are processed on the current blog and are repeated for every blog on a multisite installation. Must be
139 * called from the dashboard (WP_UNINSTALL_PLUGIN defined). User must have the proper privileges (activate_plugins).
140 *
141 * @author Peter Schulz
142 * @since 1.0.0
143 */
144 function wpda_uninstall_blog() {
145 global $wpdb;
146 $drop_tables = get_option( 'wpda_uninstall_tables' );
147 if ( 'on' === $drop_tables ) {
148 // Get all plugin table names (without WP prefix).
149 $plugin_tables = WPDataAccess\WPDA::get_wpda_tables();
150 foreach ( $plugin_tables as $plugin_table ) {
151 // Loop through plugin tables.
152 // Drop plugin table.
153 $wpdb->query( $wpdb->prepare(
154 'DROP TABLE IF EXISTS `%1s`',
155 // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
156 WPDataAccess\WPDA::remove_backticks( $plugin_table )
157 ) );
158 // db call ok; no-cache ok.
159 // Get plugin backup tables (if applicable).
160 $backup_tables = $wpdb->get_results( $wpdb->prepare( '
161 select table_name as table_name from information_schema.tables
162 where table_schema = %s
163 and table_name like %s
164 ', array($wpdb->dbname, "{$plugin_table}_BACKUP_%") ), 'ARRAY_A' );
165 // db call ok; no-cache ok.
166 foreach ( $backup_tables as $backup_table ) {
167 // Drop plugin backup table.
168 $wpdb->query( $wpdb->prepare(
169 'DROP TABLE IF EXISTS `%1s`',
170 // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
171 WPDataAccess\WPDA::remove_backticks( $backup_table['table_name'] )
172 ) );
173 // db call ok; no-cache ok.
174 }
175 }
176 }
177 $delete_options = get_option( 'wpda_uninstall_options' );
178 if ( 'on' === $delete_options ) {
179 // Delete all options from wp_options.
180 $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" );
181 // db call ok; no-cache ok.
182 $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" );
183 // db call ok; no-cache ok.
184 }
185 }
186
187 /**
188 * Uninstall WP Data Access tables, options and meta keys
189 *
190 * @return void
191 */
192 function wpda_uninstall() {
193 if ( is_multisite() ) {
194 global $wpdb;
195 // Uninstall plugin for all blogs one by one (will fail silently for blogs having no plugin tables/options).
196 $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" );
197 // db call ok; no-cache ok.
198 foreach ( $blogids as $blog_id ) {
199 // Uninstall blog.
200 switch_to_blog( $blog_id );
201 wpda_uninstall_blog();
202 restore_current_blog();
203 }
204 } else {
205 // Uninstall on single site installation.
206 wpda_uninstall_blog();
207 }
208 WPDA::wpda_delete_content_folder();
209 }
210
211 wpda_freemius()->add_action( 'after_uninstall', 'wpda_uninstall' );
212 /**
213 * Add WP Data Access icon to freemius
214 *
215 * @return string
216 */
217 function wpda_freemius_icon() {
218 return dirname( __FILE__ ) . '/vendor/freemius/assets/img/wpda.png';
219 }
220
221 wpda_freemius()->add_filter( 'plugin_icon', 'wpda_freemius_icon' );
222 /**
223 * Start plugin
224 *
225 * @author Peter Schulz
226 * @since 1.0.0
227 */
228 function run_wp_data_access() {
229 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access.php';
230 $wpdataaccess = new WP_Data_Access();
231 $wpdataaccess->run();
232 }
233
234 run_wp_data_access();
235 }