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

241 lines 7.9 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: Local and remote data administration, publication and app development tool available directly from the WordPress dashboard.
7 * Version: 5.1.2
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 // Create a helper function for easy SDK access
35 function wpda_freemius()
36 {
37 global $wpda_freemius ;
38
39 if ( !isset( $wpda_freemius ) ) {
40 // Include Freemius SDK
41 require_once dirname( __FILE__ ) . '/freemius/start.php';
42 $wpda_freemius = fs_dynamic_init( array(
43 'id' => '6189',
44 'slug' => 'wp-data-access',
45 'type' => 'plugin',
46 'public_key' => 'pk_fc2d1714ca61c930152f6e326b575',
47 'is_premium' => false,
48 'premium_suffix' => 'Premium',
49 'has_addons' => false,
50 'has_paid_plans' => true,
51 'trial' => array(
52 'days' => 14,
53 'is_require_payment' => false,
54 ),
55 'menu' => array(
56 'slug' => 'wpda',
57 'contact' => false,
58 'network' => true,
59 ),
60 'is_live' => true,
61 ) );
62 }
63
64 return $wpda_freemius;
65 }
66
67 // Init Freemius
68 wpda_freemius();
69 // Signal that SDK was initiated
70 do_action( 'wpda_freemius_loaded' );
71 // Change plugin settings info
72 function wpda_row_meta( $links, $file )
73 {
74
75 if ( strpos( $file, plugin_basename( __FILE__ ) ) !== false ) {
76 // Add settings link
77 $settings_url = admin_url( 'options-general.php' ) . '?page=wpdataaccess';
78 $settings_link = "<a href='{$settings_url}'>Settings</a>";
79 array_push( $links, $settings_link );
80 }
81
82 return $links;
83 }
84
85 add_filter(
86 'plugin_row_meta',
87 'wpda_row_meta',
88 10,
89 2
90 );
91 /**
92 * Activate plugin
93 *
94 * @author Peter Schulz
95 * @since 1.0.0
96 */
97 function activate_wp_data_access()
98 {
99 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php';
100 WP_Data_Access_Switch::activate();
101 }
102
103 register_activation_hook( __FILE__, 'activate_wp_data_access' );
104 /**
105 * Deactivate plugin
106 *
107 * @author Peter Schulz
108 * @since 1.0.0
109 */
110 function deactivate_wp_data_access()
111 {
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 {
125 if ( WPDataAccess\WPDA::OPTION_WPDA_VERSION[1] !== get_option( WPDataAccess\WPDA::OPTION_WPDA_VERSION[0] ) ) {
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 *
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 {
146 global $wpdb ;
147 $drop_tables = get_option( 'wpda_uninstall_tables' );
148
149 if ( 'on' === $drop_tables ) {
150 // Get all plugin table names (without WP prefix)
151 $plugin_tables = WPDataAccess\WPDA::get_wpda_tables();
152 foreach ( $plugin_tables as $plugin_table ) {
153 // Loop through plugin tables
154 // Drop plugin table
155 $wpdb->query( "DROP TABLE IF EXISTS {$plugin_table}" );
156 // Get plugin backup tables (if applicable)
157 $query = "select table_name as table_name from information_schema.tables " . "where table_schema = '{$wpdb->dbname}' " . " and table_name like '{$plugin_table}_BACKUP_%'";
158 $backup_tables = $wpdb->get_results( $query, 'ARRAY_A' );
159 foreach ( $backup_tables as $backup_table ) {
160 // Drop plugin backup table
161 $wpdb->query( "DROP TABLE IF EXISTS {$backup_table['table_name']}" );
162 }
163 }
164 }
165
166 $delete_options = get_option( 'wpda_uninstall_options' );
167
168 if ( 'on' === $delete_options ) {
169 // Delete all options from wp_options.
170 $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" );
171 // db call ok; no-cache ok.
172 $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" );
173 // db call ok; no-cache ok.
174 }
175
176 }
177
178 function wpda_uninstall()
179 {
180
181 if ( is_multisite() ) {
182 global $wpdb ;
183 // Uninstall plugin for alll blogs one by one (will fail silently for blogs having no plugin tables/options).
184 $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" );
185 // db call ok; no-cache ok.
186 foreach ( $blogids as $blog_id ) {
187 // Uninstall blog.
188 switch_to_blog( $blog_id );
189 wpda_uninstall_blog();
190 restore_current_blog();
191 }
192 } else {
193 // Uninstall on single site installation.
194 wpda_uninstall_blog();
195 }
196
197 WPDA::wpda_delete_content_folder();
198 }
199
200 wpda_freemius()->add_action( 'after_uninstall', 'wpda_uninstall' );
201 // Add WP Data Access icon to freemius
202 function wpda_freemius_icon()
203 {
204 return dirname( __FILE__ ) . '/freemius/assets/img/wpda.png';
205 }
206
207 wpda_freemius()->add_filter( 'plugin_icon', 'wpda_freemius_icon' );
208 // Handle freemius menu items
209 function wpda_freemius_menu_visible( $is_visible, $submenu_id )
210 {
211 // support, account, contact, pricing
212 if ( 'dashboard' === WPDA::get_option( WPDA::OPTION_PLUGIN_NAVIGATION ) ) {
213 if ( $submenu_id === 'support' || $submenu_id === 'account' ) {
214 $is_visible = false;
215 }
216 }
217 return $is_visible;
218 }
219
220 wpda_freemius()->add_filter(
221 'is_submenu_visible',
222 'wpda_freemius_menu_visible',
223 10,
224 2
225 );
226 /**
227 * Start plugin
228 *
229 * @author Peter Schulz
230 * @since 1.0.0
231 */
232 function run_wp_data_access()
233 {
234 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access.php';
235 $wpdataaccess = new WP_Data_Access();
236 $wpdataaccess->run();
237 }
238
239 run_wp_data_access();
240 }
241