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

240 lines 7.7 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: 4.3.1
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 use WPDataAccess\Dashboard\WPDA_Dashboard ;
21 use WPDataAccess\WPDA ;
22 if ( !defined( 'WPINC' ) ) {
23 die;
24 }
25 if ( !defined( 'ABSPATH' ) ) {
26 exit;
27 }
28 // Add freemius to WP Data Access
29
30 if ( function_exists( 'wpda_freemius' ) ) {
31 wpda_freemius()->set_basename( false, __FILE__ );
32 } else {
33 // Load WPDataAccess namespace.
34 require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
35 // Create a helper function for easy SDK access
36 function wpda_freemius()
37 {
38 global $wpda_freemius ;
39
40 if ( !isset( $wpda_freemius ) ) {
41 // Include Freemius SDK
42 require_once dirname( __FILE__ ) . '/freemius/start.php';
43 $wpda_freemius = fs_dynamic_init( array(
44 'id' => '6189',
45 'slug' => 'wp-data-access',
46 'type' => 'plugin',
47 'public_key' => 'pk_fc2d1714ca61c930152f6e326b575',
48 'is_premium' => false,
49 'premium_suffix' => 'Premium',
50 'has_addons' => false,
51 'has_paid_plans' => true,
52 'trial' => array(
53 'days' => 14,
54 'is_require_payment' => false,
55 ),
56 'menu' => array(
57 'slug' => 'wpda',
58 'contact' => false,
59 'network' => true,
60 ),
61 'is_live' => true,
62 ) );
63 }
64
65 return $wpda_freemius;
66 }
67
68 // Init Freemius
69 wpda_freemius();
70 // Signal that SDK was initiated
71 do_action( 'wpda_freemius_loaded' );
72 // Change plugin settings info
73 function wpda_row_meta( $links, $file )
74 {
75
76 if ( strpos( $file, plugin_basename( __FILE__ ) ) !== false ) {
77 // Add settings link
78 $settings_url = admin_url( 'options-general.php?page=wpdataaccess' );
79 $settings_link = "<a href='{$settings_url}'>Settings</a>";
80 array_push( $links, $settings_link );
81 }
82
83 return $links;
84 }
85
86 add_filter(
87 'plugin_row_meta',
88 'wpda_row_meta',
89 10,
90 2
91 );
92 /**
93 * Activate plugin
94 *
95 * @author Peter Schulz
96 * @since 1.0.0
97 */
98 function activate_wp_data_access()
99 {
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 {
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 {
126 if ( WPDataAccess\WPDA::OPTION_WPDA_VERSION[1] !== get_option( WPDataAccess\WPDA::OPTION_WPDA_VERSION[0] ) ) {
127 activate_wp_data_access();
128 }
129 }
130
131 add_action( 'plugins_loaded', 'wpda_update_db_check' );
132 /**
133 * Uninstall blog
134 *
135 * This functions is called when the plugin is uninstalled. The following actions are performed:
136 * + Drop plugin tables (unless settings indicate not to)
137 * + Delete plugin options from $wpdb->options (unless settings indicate not to)
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 {
147 global $wpdb ;
148 $drop_tables = get_option( 'wpda_uninstall_tables' );
149
150 if ( 'on' === $drop_tables ) {
151 // Get all plugin table names (without WP prefix)
152 $plugin_tables = WPDataAccess\WPDA::get_wpda_tables();
153 foreach ( $plugin_tables as $plugin_table ) {
154 // Loop through plugin tables
155 // Drop plugin table
156 $wpdb->query( "DROP TABLE IF EXISTS {$plugin_table}" );
157 // Get plugin backup tables (if applicable)
158 $query = "select table_name as table_name from information_schema.tables " . "where table_schema = '{$wpdb->dbname}' " . " and table_name like '{$plugin_table}_BACKUP_%'";
159 $backup_tables = $wpdb->get_results( $query, 'ARRAY_A' );
160 foreach ( $backup_tables as $backup_table ) {
161 // Drop plugin backup table
162 $wpdb->query( "DROP TABLE IF EXISTS {$backup_table['table_name']}" );
163 }
164 }
165 }
166
167 $delete_options = get_option( 'wpda_uninstall_options' );
168
169 if ( 'on' === $delete_options ) {
170 // Delete all options from wp_options.
171 $wpdb->query( "\n\t\t\tDELETE FROM {$wpdb->options}\n\t\t\tWHERE option_name LIKE 'wpda_%'\n\t\t" );
172 // db call ok; no-cache ok.
173 }
174
175 }
176
177 function wpda_uninstall()
178 {
179
180 if ( is_multisite() ) {
181 global $wpdb ;
182 // Uninstall plugin for alll blogs one by one (will fail silently for blogs having no plugin tables/options).
183 $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" );
184 // db call ok; no-cache ok.
185 foreach ( $blogids as $blog_id ) {
186 // Uninstall blog.
187 switch_to_blog( $blog_id );
188 wpda_uninstall_blog();
189 restore_current_blog();
190 }
191 } else {
192 // Uninstall on single site installation.
193 wpda_uninstall_blog();
194 }
195
196 WPDA::wpda_delete_content_folder();
197 }
198
199 wpda_freemius()->add_action( 'after_uninstall', 'wpda_uninstall' );
200 // Add WP Data Access icon to freemius
201 function wpda_freemius_icon()
202 {
203 return dirname( __FILE__ ) . '/freemius/assets/img/wpda.png';
204 }
205
206 wpda_freemius()->add_filter( 'plugin_icon', 'wpda_freemius_icon' );
207 // Handle freemius menu items
208 function wpda_freemius_menu_visible( $is_visible, $submenu_id )
209 {
210 // support, account, contact, pricing
211 if ( 'dashboard' === WPDA::get_option( WPDA::OPTION_PLUGIN_NAVIGATION ) ) {
212 if ( $submenu_id === 'support' || $submenu_id === 'account' ) {
213 $is_visible = false;
214 }
215 }
216 return $is_visible;
217 }
218
219 wpda_freemius()->add_filter(
220 'is_submenu_visible',
221 'wpda_freemius_menu_visible',
222 10,
223 2
224 );
225 /**
226 * Start plugin
227 *
228 * @author Peter Schulz
229 * @since 1.0.0
230 */
231 function run_wp_data_access()
232 {
233 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access.php';
234 $wpdataaccess = new WP_Data_Access();
235 $wpdataaccess->run();
236 }
237
238 run_wp_data_access();
239 }
240