$headers ) { if ( $file === $current ) { continue; } $identity = get_file_data( WP_PLUGIN_DIR . '/' . $file, array( 'edition' => 'Abientot Edition' ), 'plugin' ); if ( in_array( $identity['edition'], array( 'free', 'pro' ), true ) ) { return; } } $settings = get_option( 'abientot_settings', array() ); Capabilities::remove_from_administrators(); if ( ! is_array( $settings ) || empty( $settings['delete_data_on_uninstall'] ) ) { return; } self::drop_tables(); self::delete_options(); global $wpdb; delete_metadata( 'user', 0, $wpdb->prefix . 'abientot_staff_id', '', true ); } private static function drop_tables(): void { global $wpdb; $tables = array( 'activity_log', 'public_tokens', 'payment_webhook_receipts', 'payment_refunds', 'payment_plans', 'service_payment_rules', 'reminder_queue', 'attendance', 'notification_attempts', // Retained optional stores must also be removable after returning to Free. 'sms_jobs', 'sms_state', 'calendar_feeds', 'calendar_oauth_states', 'calendar_busy', 'calendar_connections', 'booking_selections', 'dependants', 'party_commands', 'booking_attendees', 'guardian_authorities', 'parties_configuration', 'service_instructions', 'booking_instructions', 'instruction_jobs', 'credit_authorities', 'credit_movements', 'credit_applications', 'credit_grants', 'credit_packages', 'import_rows', 'import_batches', 'service_selection_definitions', 'waitlist_offers', 'waitlist_jobs', 'waitlist_automation', 'waitlist_preferences', 'waitlist_entries', 'group_commands', 'group_memberships', 'group_sessions', 'resource_allocations', 'resource_bookings', 'resource_profiles', 'resource_categories', 'service_resources', 'resources', 'recurrence_occurrences', 'series_tokens', 'recurrence_commands', 'recurrence_exceptions', 'recurrence_revisions', 'recurrence_series', 'payment_records', 'availability_exceptions', 'availability_rules', 'appointments', 'booking_statuses', 'customers', 'staff_locations', 'staff_services', 'locations', 'staff', 'services', 'service_categories', ); foreach ( $tables as $suffix ) { $table = $wpdb->prefix . 'abientot_' . $suffix; $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $table ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange -- Removing the plugin tables on uninstall. } } private static function delete_options(): void { global $wpdb; delete_option( 'abientot_pro_sms' ); delete_option( 'abientot_sms_schema_version' ); delete_option( 'abientot_sms_cursor' ); delete_option( 'abientot_sms_last_run' ); delete_option( 'abientot_sms_last_error' ); wp_clear_scheduled_hook( 'abientot_sms_tick' ); delete_option( 'abientot_pro_activation_prompt' ); delete_option( 'abientot_version' ); delete_option( 'abientot_db_version' ); delete_option( 'abientot_settings' ); delete_option( 'abientot_privacy_retention' ); delete_option( 'abientot_notification_preferences' ); delete_metadata( 'user', 0, $wpdb->prefix . 'abientot_activity_dismissed', '', true ); delete_metadata( 'user', 0, $wpdb->prefix . 'abientot_review_request', '', true ); delete_option( 'abientot_review_request_ready' ); delete_transient( 'abientot_review_request_ready' ); delete_option( 'abientot_location_weekly_schedule' ); delete_option( 'abientot_portal_schema_version' ); delete_option( 'abientot_payments_schema_version' ); delete_option( 'abientot_pro_payments' ); delete_option( 'abientot_reminders_schema_version' ); delete_option( 'abientot_agenda_schema_version' ); delete_option( 'abientot_notifications_schema_version' ); delete_option( 'abientot_notifications_enabled' ); delete_option( 'abientot_recurrence_schema_version' ); delete_option( 'abientot_customer_series_schema_version' ); delete_option( 'abientot_resources_schema_version' ); delete_option( 'abientot_resource_booking_schema_version' ); delete_option( 'abientot_resource_booking_form' ); delete_option( 'abientot_booking_forms' ); delete_option( 'abientot_calendars_schema_version' ); delete_option( 'abientot_calendar_inbound_schema_version' ); delete_option( 'abientot_selections_schema_version' ); delete_option( 'abientot_credits_schema_version' ); delete_option( 'abientot_parties_schema_version' ); delete_option( 'abientot_instructions_schema_version' ); delete_option( 'abientot_instructions_last_run' ); delete_option( 'abientot_import_schema_version' ); delete_option( 'abientot_import_preview_epoch' ); delete_option( 'abientot_groups_schema_version' ); delete_option( 'abientot_waitlist_schema_version' ); delete_option( 'abientot_public_waitlist_schema_version' ); delete_option( 'abientot_public_waitlist_settings' ); delete_option( 'abientot_reminders_settings' ); delete_option( 'abientot_reminders_scan_cursor' ); delete_option( 'abientot_reminders_last_run' ); delete_transient( 'abientot_reminders_schema_retry' ); delete_transient( 'abientot_booking_page_ids' ); delete_option( 'abientot_wpml_strings_fingerprint' ); delete_option( 'abientot_status_labels_locale' ); delete_transient( 'abientot_status_labels_locale_retry' ); wp_clear_scheduled_hook( 'abientot_reminders_tick' ); wp_clear_scheduled_hook( 'abientot_instructions_tick' ); wp_clear_scheduled_hook( 'abientot_notifications_cleanup' ); wp_clear_scheduled_hook( 'abientot_public_waitlist_tick' ); wp_clear_scheduled_hook( 'abientot_public_waitlist_tick_wake' ); global $wpdb; $keys = $wpdb->get_col( $wpdb->prepare( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s", $wpdb->esc_like( 'abientot_pro_location_schedule_' ) . '%' ) ); foreach ( $keys as $key ) { delete_option( $key ); } $epochKeys = $wpdb->get_col( $wpdb->prepare( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s", $wpdb->esc_like( 'abientot_calendar_authority_epoch_' ) . '%' ) ); foreach ( $epochKeys as $key ) { delete_option( $key ); } } }