| @@ -2,10 +2,10 @@ | ||
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | 4 | * Plugin Name: WP Data Access |
| 5 | 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.76 | |
| 6 | + * Description: Local and remote data administration, publication and app development tool available directly from the WordPress dashboard. | |
| 7 | + * Version: 5.2 | |
| 8 | 8 | * Author: Passionate Programmers B.V. |
| 9 | 9 | * Author URI: https://wpdataaccess.com/ |
| 10 | 10 | * Text Domain: wp-data-access |
| 11 | 11 | * License: GPL-2.0+ |
| @@ -16,9 +16,9 @@ | ||
| 16 | 16 | * @package plugin |
| 17 | 17 | * @author Peter Schulz |
| 18 | 18 | * @since 1.0.0 |
| 19 | 19 | */ |
| 20 | -use WPDataAccess\WPDA; | |
| 20 | +use WPDataAccess\WPDA ; | |
| 21 | 21 | if ( !defined( 'WPINC' ) ) { |
| 22 | 22 | die; |
| 23 | 23 | } |
| 24 | 24 | if ( !defined( 'ABSPATH' ) ) { |
| @@ -24,9 +24,12 @@ | ||
| 24 | 24 | if ( !defined( 'ABSPATH' ) ) { |
| 25 | 25 | exit; |
| 26 | 26 | } |
| 27 | 27 | // Add freemius to WP Data Access. |
| 28 | -if ( !function_exists( 'wpda_freemius' ) ) { | |
| 28 | + | |
| 29 | +if ( function_exists( 'wpda_freemius' ) ) { | |
| 30 | + wpda_freemius()->set_basename( false, __FILE__ ); | |
| 31 | +} else { | |
| 29 | 32 | // Load WPDataAccess namespace. |
| 30 | 33 | require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; |
| 31 | 34 | /** |
| 32 | 35 | * Create a helper function for easy SDK access |
| @@ -32,38 +35,40 @@ | ||
| 32 | 35 | * Create a helper function for easy SDK access |
| 33 | 36 | * |
| 34 | 37 | * @return Freemius |
| 35 | 38 | */ |
| 36 | - function wpda_freemius() { | |
| 37 | - global $wpda_freemius; | |
| 39 | + function wpda_freemius() | |
| 40 | + { | |
| 41 | + global $wpda_freemius ; | |
| 42 | + | |
| 38 | 43 | if ( !isset( $wpda_freemius ) ) { |
| 39 | - // Create a helper function for easy SDK access. | |
| 40 | - require_once dirname( __FILE__ ) . '/vendor/freemius/start.php'; | |
| 44 | + // Include Freemius SDK. | |
| 45 | + require_once dirname( __FILE__ ) . '/freemius/start.php'; | |
| 41 | 46 | $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, | |
| 47 | + 'id' => '6189', | |
| 48 | + 'slug' => 'wp-data-access', | |
| 49 | + 'type' => 'plugin', | |
| 50 | + 'public_key' => 'pk_fc2d1714ca61c930152f6e326b575', | |
| 51 | + 'is_premium' => false, | |
| 52 | + 'premium_suffix' => 'Premium', | |
| 53 | + 'has_addons' => false, | |
| 54 | + 'has_paid_plans' => true, | |
| 55 | + 'trial' => array( | |
| 56 | + 'days' => 14, | |
| 57 | + 'is_require_payment' => false, | |
| 58 | + ), | |
| 59 | + 'menu' => array( | |
| 60 | + 'slug' => 'wpda', | |
| 61 | + 'contact' => false, | |
| 62 | + 'network' => true, | |
| 63 | + ), | |
| 64 | + 'is_live' => true, | |
| 61 | 65 | ) ); |
| 62 | 66 | } |
| 67 | + | |
| 63 | 68 | return $wpda_freemius; |
| 64 | 69 | } |
| 65 | - | |
| 70 | + | |
| 66 | 71 | // Init Freemius. |
| 67 | 72 | wpda_freemius(); |
| 68 | 73 | // Signal that SDK was initiated. |
| 69 | 74 | do_action( 'wpda_freemius_loaded' ); |
| @@ -73,19 +78,21 @@ | ||
| 73 | 78 | * @param mixed $links Links. |
| 74 | 79 | * @param mixed $file File. |
| 75 | 80 | * @return mixed |
| 76 | 81 | */ |
| 77 | - function wpda_row_meta( $links, $file ) { | |
| 82 | + function wpda_row_meta( $links, $file ) | |
| 83 | + { | |
| 84 | + | |
| 78 | 85 | if ( strpos( $file, plugin_basename( __FILE__ ) ) !== false ) { |
| 79 | 86 | // Add settings link. |
| 80 | 87 | $settings_url = admin_url( 'options-general.php' ) . '?page=wpdataaccess'; |
| 81 | 88 | $settings_link = "<a href='{$settings_url}'>Settings</a>"; |
| 82 | 89 | array_push( $links, $settings_link ); |
| 83 | - //phpcs:ignore - 8.1 proof | |
| 84 | 90 | } |
| 91 | + | |
| 85 | 92 | return $links; |
| 86 | 93 | } |
| 87 | - | |
| 94 | + | |
| 88 | 95 | add_filter( |
| 89 | 96 | 'plugin_row_meta', |
| 90 | 97 | 'wpda_row_meta', |
| 91 | 98 | 10, |
| @@ -96,13 +103,14 @@ | ||
| 96 | 103 | * |
| 97 | 104 | * @author Peter Schulz |
| 98 | 105 | * @since 1.0.0 |
| 99 | 106 | */ |
| 100 | - function activate_wp_data_access() { | |
| 107 | + function activate_wp_data_access() | |
| 108 | + { | |
| 101 | 109 | require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php'; |
| 102 | 110 | WP_Data_Access_Switch::activate(); |
| 103 | 111 | } |
| 104 | - | |
| 112 | + | |
| 105 | 113 | register_activation_hook( __FILE__, 'activate_wp_data_access' ); |
| 106 | 114 | /** |
| 107 | 115 | * Deactivate plugin |
| 108 | 116 | * |
| @@ -108,13 +116,14 @@ | ||
| 108 | 116 | * |
| 109 | 117 | * @author Peter Schulz |
| 110 | 118 | * @since 1.0.0 |
| 111 | 119 | */ |
| 112 | - function deactivate_wp_data_access() { | |
| 120 | + function deactivate_wp_data_access() | |
| 121 | + { | |
| 113 | 122 | require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access-switch.php'; |
| 114 | 123 | WP_Data_Access_Switch::deactivate(); |
| 115 | 124 | } |
| 116 | - | |
| 125 | + | |
| 117 | 126 | register_deactivation_hook( __FILE__, 'deactivate_wp_data_access' ); |
| 118 | 127 | /** |
| 119 | 128 | * Check if database needs to be updated |
| 120 | 129 | * |
| @@ -120,14 +129,15 @@ | ||
| 120 | 129 | * |
| 121 | 130 | * @author Peter Schulz |
| 122 | 131 | * @since 1.5.2 |
| 123 | 132 | */ |
| 124 | - function wpda_update_db_check() { | |
| 133 | + function wpda_update_db_check() | |
| 134 | + { | |
| 125 | 135 | if ( get_option( WPDataAccess\WPDA::OPTION_WPDA_VERSION[0] ) !== WPDataAccess\WPDA::OPTION_WPDA_VERSION[1] ) { |
| 126 | 136 | activate_wp_data_access(); |
| 127 | 137 | } |
| 128 | 138 | } |
| 129 | - | |
| 139 | + | |
| 130 | 140 | add_action( 'plugins_loaded', 'wpda_update_db_check' ); |
| 131 | 141 | /** |
| 132 | 142 | * Uninstall blog |
| 133 | 143 | * |
| @@ -133,9 +143,8 @@ | ||
| 133 | 143 | * |
| 134 | 144 | * This functions is called when the plugin is uninstalled. The following actions are performed: |
| 135 | 145 | * + Drop plugin tables (unless settings indicate not to) |
| 136 | 146 | * + Delete plugin options from $wpdb->options (unless settings indicate not to) |
| 137 | - * + Unscheduled all WP Data Access events | |
| 138 | 147 | * |
| 139 | 148 | * Actions are processed on the current blog and are repeated for every blog on a multisite installation. Must be |
| 140 | 149 | * called from the dashboard (WP_UNINSTALL_PLUGIN defined). User must have the proper privileges (activate_plugins). |
| 141 | 150 | * |
| @@ -141,11 +150,13 @@ | ||
| 141 | 150 | * |
| 142 | 151 | * @author Peter Schulz |
| 143 | 152 | * @since 1.0.0 |
| 144 | 153 | */ |
| 145 | - function wpda_uninstall_blog() { | |
| 146 | - global $wpdb; | |
| 154 | + function wpda_uninstall_blog() | |
| 155 | + { | |
| 156 | + global $wpdb ; | |
| 147 | 157 | $drop_tables = get_option( 'wpda_uninstall_tables' ); |
| 158 | + | |
| 148 | 159 | if ( 'on' === $drop_tables ) { |
| 149 | 160 | // Get all plugin table names (without WP prefix). |
| 150 | 161 | $plugin_tables = WPDataAccess\WPDA::get_wpda_tables(); |
| 151 | 162 | foreach ( $plugin_tables as $plugin_table ) { |
| @@ -150,13 +161,13 @@ | ||
| 150 | 161 | $plugin_tables = WPDataAccess\WPDA::get_wpda_tables(); |
| 151 | 162 | foreach ( $plugin_tables as $plugin_table ) { |
| 152 | 163 | // Loop through plugin tables. |
| 153 | 164 | // Drop plugin table. |
| 154 | - $wpdb->query( $wpdb->prepare( | |
| 165 | + $wpdb->query( $wpdb->prepare( | |
| 155 | 166 | 'DROP TABLE IF EXISTS `%1s`', |
| 156 | 167 | // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange |
| 157 | 168 | WPDataAccess\WPDA::remove_backticks( $plugin_table ) |
| 158 | - ) ); | |
| 169 | + ) ); | |
| 159 | 170 | // db call ok; no-cache ok. |
| 160 | 171 | // Get plugin backup tables (if applicable). |
| 161 | 172 | $backup_tables = $wpdb->get_results( $wpdb->prepare( ' |
| 162 | 173 | select table_name as table_name from information_schema.tables |
| @@ -161,22 +172,24 @@ | ||
| 161 | 172 | $backup_tables = $wpdb->get_results( $wpdb->prepare( ' |
| 162 | 173 | select table_name as table_name from information_schema.tables |
| 163 | 174 | where table_schema = %s |
| 164 | 175 | and table_name like %s |
| 165 | - ', array($wpdb->dbname, "{$plugin_table}_BACKUP_%") ), 'ARRAY_A' ); | |
| 176 | + ', array( $wpdb->dbname, "{$plugin_table}_BACKUP_%" ) ), 'ARRAY_A' ); | |
| 166 | 177 | // db call ok; no-cache ok. |
| 167 | 178 | foreach ( $backup_tables as $backup_table ) { |
| 168 | 179 | // Drop plugin backup table. |
| 169 | - $wpdb->query( $wpdb->prepare( | |
| 180 | + $wpdb->query( $wpdb->prepare( | |
| 170 | 181 | 'DROP TABLE IF EXISTS `%1s`', |
| 171 | 182 | // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange |
| 172 | 183 | WPDataAccess\WPDA::remove_backticks( $backup_table['table_name'] ) |
| 173 | - ) ); | |
| 184 | + ) ); | |
| 174 | 185 | // db call ok; no-cache ok. |
| 175 | 186 | } |
| 176 | 187 | } |
| 177 | 188 | } |
| 189 | + | |
| 178 | 190 | $delete_options = get_option( 'wpda_uninstall_options' ); |
| 191 | + | |
| 179 | 192 | if ( 'on' === $delete_options ) { |
| 180 | 193 | // Delete all options from wp_options. |
| 181 | 194 | $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" ); |
| 182 | 195 | // db call ok; no-cache ok. |
| @@ -182,19 +195,22 @@ | ||
| 182 | 195 | // db call ok; no-cache ok. |
| 183 | 196 | $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" ); |
| 184 | 197 | // db call ok; no-cache ok. |
| 185 | 198 | } |
| 199 | + | |
| 186 | 200 | } |
| 187 | - | |
| 201 | + | |
| 188 | 202 | /** |
| 189 | 203 | * Uninstall WP Data Access tables, options and meta keys |
| 190 | 204 | * |
| 191 | 205 | * @return void |
| 192 | 206 | */ |
| 193 | - function wpda_uninstall() { | |
| 207 | + function wpda_uninstall() | |
| 208 | + { | |
| 209 | + | |
| 194 | 210 | if ( is_multisite() ) { |
| 195 | - global $wpdb; | |
| 196 | - // Uninstall plugin for all blogs one by one (will fail silently for blogs having no plugin tables/options). | |
| 211 | + global $wpdb ; | |
| 212 | + // Uninstall plugin for alll blogs one by one (will fail silently for blogs having no plugin tables/options). | |
| 197 | 213 | $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" ); |
| 198 | 214 | // db call ok; no-cache ok. |
| 199 | 215 | foreach ( $blogids as $blog_id ) { |
| 200 | 216 | // Uninstall blog. |
| @@ -205,11 +221,12 @@ | ||
| 205 | 221 | } else { |
| 206 | 222 | // Uninstall on single site installation. |
| 207 | 223 | wpda_uninstall_blog(); |
| 208 | 224 | } |
| 225 | + | |
| 209 | 226 | WPDA::wpda_delete_content_folder(); |
| 210 | 227 | } |
| 211 | - | |
| 228 | + | |
| 212 | 229 | wpda_freemius()->add_action( 'after_uninstall', 'wpda_uninstall' ); |
| 213 | 230 | /** |
| 214 | 231 | * Add WP Data Access icon to freemius |
| 215 | 232 | * |
| @@ -214,23 +231,49 @@ | ||
| 214 | 231 | * Add WP Data Access icon to freemius |
| 215 | 232 | * |
| 216 | 233 | * @return string |
| 217 | 234 | */ |
| 218 | - function wpda_freemius_icon() { | |
| 219 | - return dirname( __FILE__ ) . '/vendor/freemius/assets/img/wpda.png'; | |
| 235 | + function wpda_freemius_icon() | |
| 236 | + { | |
| 237 | + return dirname( __FILE__ ) . '/freemius/assets/img/wpda.png'; | |
| 220 | 238 | } |
| 221 | - | |
| 239 | + | |
| 222 | 240 | wpda_freemius()->add_filter( 'plugin_icon', 'wpda_freemius_icon' ); |
| 223 | 241 | /** |
| 242 | + * Handle freemius menu items | |
| 243 | + * | |
| 244 | + * @param boolean $is_visible Visibility. | |
| 245 | + * @param string $submenu_id Sub menu ID. | |
| 246 | + * @return false|mixed | |
| 247 | + */ | |
| 248 | + function wpda_freemius_menu_visible( $is_visible, $submenu_id ) | |
| 249 | + { | |
| 250 | + // Support, account, contact, pricing. | |
| 251 | + if ( 'dashboard' === WPDA::get_option( WPDA::OPTION_PLUGIN_NAVIGATION ) ) { | |
| 252 | + if ( 'support' === $submenu_id || 'account' === $submenu_id ) { | |
| 253 | + $is_visible = false; | |
| 254 | + } | |
| 255 | + } | |
| 256 | + return $is_visible; | |
| 257 | + } | |
| 258 | + | |
| 259 | + wpda_freemius()->add_filter( | |
| 260 | + 'is_submenu_visible', | |
| 261 | + 'wpda_freemius_menu_visible', | |
| 262 | + 10, | |
| 263 | + 2 | |
| 264 | + ); | |
| 265 | + /** | |
| 224 | 266 | * Start plugin |
| 225 | 267 | * |
| 226 | 268 | * @author Peter Schulz |
| 227 | 269 | * @since 1.0.0 |
| 228 | 270 | */ |
| 229 | - function run_wp_data_access() { | |
| 271 | + function run_wp_data_access() | |
| 272 | + { | |
| 230 | 273 | require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access.php'; |
| 231 | 274 | $wpdataaccess = new WP_Data_Access(); |
| 232 | 275 | $wpdataaccess->run(); |
| 233 | 276 | } |
| 234 | - | |
| 277 | + | |
| 235 | 278 | run_wp_data_access(); |
| 236 | -} | |
| 279 | +} | |