'6189', 'slug' => 'wp-data-access', 'type' => 'plugin', 'public_key' => 'pk_fc2d1714ca61c930152f6e326b575', 'is_premium' => false, 'premium_suffix' => 'Premium', 'has_addons' => false, 'has_paid_plans' => true, 'trial' => array( 'days' => 14, 'is_require_payment' => false, ), 'menu' => array( 'slug' => 'wpda_navi', 'contact' => false, 'network' => true, ), 'is_live' => true, 'is_org_compliant' => true, ) ); } return $wpda_freemius; } // Init Freemius. wpda_freemius(); // Signal that SDK was initiated. do_action( 'wpda_freemius_loaded' ); /** * Check if legacy tools are currently used on this server. * @return bool */ function wpda_has_legacy_tools_inuse() { $option_legacy_tools = WPDA::get_option( WPDA::OPTION_PLUGIN_LEGACY_TOOLS ); $has_legacy_tools = false; if ( !empty( $option_legacy_tools ) && is_array( $option_legacy_tools ) ) { foreach ( $option_legacy_tools as $tool ) { if ( isset( $tool[0] ) && $tool[0] === true && isset( $tool[1] ) && $tool[1] > 0 ) { $has_legacy_tools = true; break; } } } return $has_legacy_tools; } /** * Hook into the plugin_row_meta filter. * @param mixed $links Links. * @param mixed $file File. * @param mixed $data Data. * @return mixed */ function wpda_row_meta( $links, $file, $data ) { if ( plugin_basename( __FILE__ ) == $file ) { // Add settings link. $settings_url = admin_url( 'options-general.php' ) . '?page=wpdataaccess'; $settings_link = 'Settings'; array_push( $links, $settings_link ); // phpcs:ignore -- 8.1 proof // Add comment for legacy users only if ( wpda_has_legacy_tools_inuse() ) { if ( isset( $data['new_version'] ) ) { $new_version = $data['new_version']; if ( version_compare( $new_version, '6.0', '>=' ) ) { $notice = '

Warning for legacy users: Version ' . esc_html( $new_version ) . ' (available now) removes legacy tools. Stay on Version 5.x to keep using them. Read more →

'; } else { $notice = '

Info for legacy users: Version 6 is coming soon and removes legacy tools. Stay on Version 5.x to keep using them. Read more →

'; } $links[] = $notice; } } } return $links; } add_filter( 'plugin_row_meta', 'wpda_row_meta', 10, 3 ); /** * Remove last | character from plugin links. * @return void */ function wpda_clean_plugin_row_script() { if ( !wpda_has_legacy_tools_inuse() ) { return; } ?>

Version 6 is coming soon and removes legacy tools.

To keep using the legacy tools:
✓ Stay on the latest Version 5.x
✓ Disable auto-updates
✓ Do not update manually to Version 6

Read more →

options (unless settings indicate not to) * + Unscheduled all WP Data Access events * * Actions are processed on the current blog and are repeated for every blog on a multisite installation. Must be * called from the dashboard (WP_UNINSTALL_PLUGIN defined). User must have the proper privileges (activate_plugins). * * @author Peter Schulz * @since 1.0.0 */ function wpda_uninstall_blog() { global $wpdb; $drop_tables = get_option( 'wpda_uninstall_tables' ); // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange if ( 'on' === $drop_tables ) { // Get all plugin table names (without WP prefix). $plugin_tables = WPDataAccess\WPDA::get_wpda_tables(); foreach ( $plugin_tables as $plugin_table ) { // Loop through plugin tables. // Drop plugin table. $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS `%1s`', WPDataAccess\WPDA::remove_backticks( $plugin_table ) ) ); // db call ok; no-cache ok. // Get plugin backup tables (if applicable). $backup_tables = $wpdb->get_results( $wpdb->prepare( ' select table_name as table_name from information_schema.tables where table_schema = %s and table_name like %s ', array($wpdb->dbname, "{$plugin_table}_BACKUP_%") ), 'ARRAY_A' ); // db call ok; no-cache ok. foreach ( $backup_tables as $backup_table ) { // Drop plugin backup table. $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS `%1s`', WPDataAccess\WPDA::remove_backticks( $backup_table['table_name'] ) ) ); // db call ok; no-cache ok. } } } $delete_options = get_option( 'wpda_uninstall_options' ); if ( 'on' === $delete_options ) { // Delete all options from wp_options. $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" ); // db call ok; no-cache ok. $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" ); // db call ok; no-cache ok. } // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange } function wpda_unschedule_event( $hook ) { $crons = _get_cron_array(); foreach ( $crons as $timestamp => $cron ) { if ( isset( $cron[$hook] ) ) { foreach ( $cron[$hook] as $event ) { if ( isset( $event['args'] ) ) { wp_unschedule_event( $timestamp, $hook, $event['args'] ); } } } } } /** * Uninstall WP Data Access tables, options and meta keys * * @return void */ function wpda_uninstall() { if ( is_multisite() ) { global $wpdb; // Uninstall plugin for all blogs one by one (will fail silently for blogs having no plugin tables/options). // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange $blogids = $wpdb->get_col( "select blog_id from {$wpdb->blogs}" ); // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange foreach ( $blogids as $blog_id ) { // Uninstall blog. switch_to_blog( $blog_id ); wpda_uninstall_blog(); restore_current_blog(); } } else { // Uninstall on single site installation. wpda_uninstall_blog(); } WPDA::wpda_delete_content_folder(); // Unscheduled all WP Data Access events wpda_unschedule_event( 'wpda_data_backup' ); wpda_unschedule_event( \WPDataAccess\Query_Builder\WPDA_Query_Builder_Scheduler::SCHEDULER_HOOK_NAME ); wpda_unschedule_event( \WPDataAccess\Utilities\WPDA_Export_Scheduler::SCHEDULER_HOOK_NAME ); } wpda_freemius()->add_action( 'after_uninstall', 'wpda_uninstall' ); /** * Add WP Data Access icon to freemius * * @return string */ function wpda_freemius_icon() { return dirname( __FILE__ ) . '/vendor/freemius/assets/img/wpda.png'; } wpda_freemius()->add_filter( 'plugin_icon', 'wpda_freemius_icon' ); /** * Start plugin * * @author Peter Schulz * @since 1.0.0 */ function wpda_run() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-data-access.php'; $wpdataaccess = new WP_Data_Access(); $wpdataaccess->run(); } wpda_run(); }