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

234 lines 9.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: 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.77
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 'is_org_compliant' => true,
61 ) );
62 }
63 return $wpda_freemius;
64 }
65
66 // Init Freemius.
67 wpda_freemius();
68 // Signal that SDK was initiated.
69 do_action( 'wpda_freemius_loaded' );
70 /**
71 * Change plugin settings info
72 *
73 * @param mixed $links Links.
74 * @param mixed $file File.
75 * @return mixed
76 */
77 function wpda_row_meta( $links, $file ) {
78 if ( strpos( $file, plugin_basename( __FILE__ ) ) !== false ) {
79 // Add settings link.
80 $settings_url = admin_url( 'options-general.php' ) . '?page=wpdataaccess';
81 $settings_link = "<a href='{$settings_url}'>Settings</a>";
82 array_push( $links, $settings_link );
83 // phpcs:ignore -- 8.1 proof
84 }
85 return $links;
86 }
87
88 add_filter(
89 'plugin_row_meta',
90 'wpda_row_meta',
91 10,
92 2
93 );
94 /**
95 * Activate plugin
96 *
97 * @author Peter Schulz
98 * @since 1.0.0
99 */
100 function wpda_activate() {
101 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
102 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php';
103 WP_Data_Access_Switch::activate();
104 }
105
106 register_activation_hook( __FILE__, 'wpda_activate' );
107 /**
108 * Deactivate plugin
109 *
110 * @author Peter Schulz
111 * @since 1.0.0
112 */
113 function wpda_deactivate() {
114 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
115 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php';
116 WP_Data_Access_Switch::deactivate();
117 }
118
119 register_deactivation_hook( __FILE__, 'wpda_deactivate' );
120 /**
121 * Check if database needs to be updated
122 *
123 * @author Peter Schulz
124 * @since 1.5.2
125 */
126 function wpda_update_db_check() {
127 if ( get_option( WPDataAccess\WPDA::OPTION_WPDA_VERSION[0] ) !== WPDataAccess\WPDA::OPTION_WPDA_VERSION[1] ) {
128 wpda_activate();
129 }
130 }
131
132 add_action( 'plugins_loaded', 'wpda_update_db_check' );
133 /**
134 * Uninstall blog
135 *
136 * This functions is called when the plugin is uninstalled. The following actions are performed:
137 * + Drop plugin tables (unless settings indicate not to)
138 * + Delete plugin options from $wpdb->options (unless settings indicate not to)
139 * + Unscheduled all WP Data Access events
140 *
141 * Actions are processed on the current blog and are repeated for every blog on a multisite installation. Must be
142 * called from the dashboard (WP_UNINSTALL_PLUGIN defined). User must have the proper privileges (activate_plugins).
143 *
144 * @author Peter Schulz
145 * @since 1.0.0
146 */
147 function wpda_uninstall_blog() {
148 global $wpdb;
149 $drop_tables = get_option( 'wpda_uninstall_tables' );
150 // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
151 if ( 'on' === $drop_tables ) {
152 // Get all plugin table names (without WP prefix).
153 $plugin_tables = WPDataAccess\WPDA::get_wpda_tables();
154 foreach ( $plugin_tables as $plugin_table ) {
155 // Loop through plugin tables.
156 // Drop plugin table.
157 $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS `%1s`', WPDataAccess\WPDA::remove_backticks( $plugin_table ) ) );
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( 'DROP TABLE IF EXISTS `%1s`', WPDataAccess\WPDA::remove_backticks( $backup_table['table_name'] ) ) );
169 // db call ok; no-cache ok.
170 }
171 }
172 }
173 $delete_options = get_option( 'wpda_uninstall_options' );
174 if ( 'on' === $delete_options ) {
175 // Delete all options from wp_options.
176 $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" );
177 // db call ok; no-cache ok.
178 $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" );
179 // db call ok; no-cache ok.
180 }
181 // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
182 }
183
184 /**
185 * Uninstall WP Data Access tables, options and meta keys
186 *
187 * @return void
188 */
189 function wpda_uninstall() {
190 if ( is_multisite() ) {
191 global $wpdb;
192 // Uninstall plugin for all blogs one by one (will fail silently for blogs having no plugin tables/options).
193 // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
194 $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" );
195 // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
196 foreach ( $blogids as $blog_id ) {
197 // Uninstall blog.
198 switch_to_blog( $blog_id );
199 wpda_uninstall_blog();
200 restore_current_blog();
201 }
202 } else {
203 // Uninstall on single site installation.
204 wpda_uninstall_blog();
205 }
206 WPDA::wpda_delete_content_folder();
207 }
208
209 wpda_freemius()->add_action( 'after_uninstall', 'wpda_uninstall' );
210 /**
211 * Add WP Data Access icon to freemius
212 *
213 * @return string
214 */
215 function wpda_freemius_icon() {
216 return dirname( __FILE__ ) . '/vendor/freemius/assets/img/wpda.png';
217 }
218
219 wpda_freemius()->add_filter( 'plugin_icon', 'wpda_freemius_icon' );
220 /**
221 * Start plugin
222 *
223 * @author Peter Schulz
224 * @since 1.0.0
225 */
226 function wpda_run() {
227 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
228 require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access.php';
229 $wpdataaccess = new WP_Data_Access();
230 $wpdataaccess->run();
231 }
232
233 wpda_run();
234 }