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

257 lines 8.0 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: 3.6.0
8 * Author: Passionate Programmers
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 if ( !defined( 'WPINC' ) ) {
21 die;
22 }
23 const SETTINGS_URL = 'options-general.php?page=wpdataaccess' ;
24 function wpda_row_meta( $links, $file )
25 {
26
27 if ( strpos( $file, plugin_basename( __FILE__ ) ) !== false ) {
28 // Add settings link
29 $settings_url = esc_url( get_admin_url() . SETTINGS_URL );
30 $settings_link = "<a href='{$settings_url}'>Settings</a>";
31 array_push( $links, $settings_link );
32 }
33
34 return $links;
35 }
36
37 add_filter(
38 'plugin_row_meta',
39 'wpda_row_meta',
40 10,
41 2
42 );
43 // Load WPDataAccess namespace.
44 require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
45 /**
46 * Activate plugin
47 *
48 * @author Peter Schulz
49 * @since 1.0.0
50 */
51 function activate_wp_data_access()
52 {
53
54 if ( current_user_can( 'activate_plugins' ) ) {
55 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php';
56 WP_Data_Access_Switch::activate();
57 }
58
59 }
60
61 register_activation_hook( __FILE__, 'activate_wp_data_access' );
62 /**
63 * Deactivate plugin
64 *
65 * @author Peter Schulz
66 * @since 1.0.0
67 */
68 function deactivate_wp_data_access()
69 {
70
71 if ( current_user_can( 'activate_plugins' ) ) {
72 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php';
73 WP_Data_Access_Switch::deactivate();
74 }
75
76 }
77
78 register_deactivation_hook( __FILE__, 'deactivate_wp_data_access' );
79 /**
80 * Check if database needs to be updated
81 *
82 * @author Peter Schulz
83 * @since 1.5.2
84 */
85 function wpda_update_db_check()
86 {
87 if ( WPDataAccess\WPDA::OPTION_WPDA_VERSION[1] !== get_option( WPDataAccess\WPDA::OPTION_WPDA_VERSION[0] ) ) {
88 activate_wp_data_access();
89 }
90 }
91
92 add_action( 'plugins_loaded', 'wpda_update_db_check' );
93 // Add freemius to WP Data Access
94
95 if ( function_exists( 'wpda_fremius' ) ) {
96 wpda_fremius()->set_basename( false, __FILE__ );
97 } else {
98
99 if ( !function_exists( 'wpda_fremius' ) ) {
100 // Create a helper function for easy SDK access
101 function wpda_fremius()
102 {
103 global $wpda_fremius ;
104
105 if ( !isset( $wpda_fremius ) ) {
106 // Include Freemius SDK
107 require_once dirname( __FILE__ ) . '/freemius/start.php';
108 $wpda_fremius = fs_dynamic_init( array(
109 'id' => '6189',
110 'slug' => 'wp-data-access',
111 'type' => 'plugin',
112 'public_key' => 'pk_fc2d1714ca61c930152f6e326b575',
113 'is_premium' => false,
114 'premium_suffix' => 'Premium',
115 'has_addons' => false,
116 'has_paid_plans' => true,
117 'trial' => array(
118 'days' => 14,
119 'is_require_payment' => false,
120 ),
121 'menu' => array(
122 'slug' => 'wpda',
123 'network' => true,
124 ),
125 'is_live' => true,
126 ) );
127 }
128
129 return $wpda_fremius;
130 }
131
132 // Init Freemius
133 wpda_fremius();
134 // Signal that SDK was initiated
135 do_action( 'wpda_fremius_loaded' );
136 // Send user to support page
137 function wpda_support_forum_url( $wp_org_support_forum_url )
138 {
139 if ( wpda_fremius()->is_premium() ) {
140 // Use different support page for premium version
141 return 'https://users.freemius.com/store/2612';
142 }
143 return 'https://wordpress.org/support/plugin/wp-data-access/';
144 }
145
146 wpda_fremius()->add_filter( 'support_forum_url', 'wpda_support_forum_url' );
147 // Add WP Data Access icon to freemius
148 function wpda_freemius_icon()
149 {
150 return dirname( __FILE__ ) . '/freemius/assets/img/wpda.png';
151 }
152
153 wpda_fremius()->add_filter( 'plugin_icon', 'wpda_freemius_icon' );
154 // Handle freemius menu items
155 function wpda_freemius_menu_visible( $is_visible, $submenu_id )
156 {
157 // support, account, contact, pricing
158 if ( $submenu_id === 'contact' ) {
159 $is_visible = false;
160 }
161 if ( wpda_fremius()->is_premium() && $submenu_id === 'contact' ) {
162 $is_visible = true;
163 }
164 return $is_visible;
165 }
166
167 wpda_fremius()->add_filter(
168 'is_submenu_visible',
169 'wpda_freemius_menu_visible',
170 10,
171 2
172 );
173 /**
174 * Start plugin
175 *
176 * @author Peter Schulz
177 * @since 1.0.0
178 */
179 function run_wp_data_access()
180 {
181 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access.php';
182 $wpdataaccess = new WP_Data_Access();
183 $wpdataaccess->run();
184 }
185
186 run_wp_data_access();
187 }
188
189 }
190
191 /**
192 * Uninstall blog
193 *
194 * This functions is called when the plugin is uninstalled. The following actions are performed:
195 * + Drop plugin tables (unless settings indicate not to)
196 * + Delete plugin options from $wpdb->options (unless settings indicate not to)
197 *
198 * Actions are processed on the current blog and are repeated for every blog on a multisite installation. Must be
199 * called from the dashboard (WP_UNINSTALL_PLUGIN defined). User must have the proper privileges (activate_plugins).
200 *
201 * @author Peter Schulz
202 * @since 1.0.0
203 */
204 function wpda_uninstall_blog()
205 {
206 global $wpdb ;
207 $drop_tables = get_option( 'wpda_uninstall_tables' );
208
209 if ( !$drop_tables || 'on' === $drop_tables ) {
210 // Get all plugin table names (without WP prefix)
211 $plugin_tables = WPDataAccess\WPDA::get_wpda_tables();
212 foreach ( $plugin_tables as $plugin_table ) {
213 // Loop through plugin tables
214 // Drop plugin table
215 $wpdb->query( "DROP TABLE IF EXISTS {$plugin_table}" );
216 // Get plugin backup tables (if applicable)
217 $query = "select table_name from information_schema.tables " . "where table_schema = '{$wpdb->dbname}' " . " and table_name like '{$plugin_table}_BACKUP_%'";
218 $backup_tables = $wpdb->get_results( $query, 'ARRAY_A' );
219 foreach ( $backup_tables as $backup_table ) {
220 // Drop plugin backup table
221 $wpdb->query( "DROP TABLE IF EXISTS {$backup_table['table_name']}" );
222 }
223 }
224 }
225
226 $delete_options = get_option( 'wpda_uninstall_options' );
227
228 if ( !$delete_options || 'on' === $delete_options ) {
229 // Delete all options from wp_options.
230 $wpdb->query( "\n\t\t\t\tDELETE FROM {$wpdb->options}\n\t\t\t\tWHERE option_name LIKE 'wpda_%'\n\t\t\t" );
231 // db call ok; no-cache ok.
232 }
233
234 }
235
236 function wpda_uninstall()
237 {
238
239 if ( is_multisite() ) {
240 global $wpdb ;
241 // Uninstall plugin for alll blogs one by one (will fail silently for blogs having no plugin tables/options).
242 $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" );
243 // db call ok; no-cache ok.
244 foreach ( $blogids as $blog_id ) {
245 // Uninstall blog.
246 switch_to_blog( $blog_id );
247 wpda_uninstall_blog();
248 restore_current_blog();
249 }
250 } else {
251 // Uninstall on single site installation.
252 wpda_uninstall_blog();
253 }
254
255 }
256
257 wpda_fremius()->add_action( 'after_uninstall', 'wpda_uninstall' );