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

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