prefix . 'aimslms_course_sections', $wpdb->prefix . 'aimslms_course_lessons', $wpdb->prefix . 'aimslms_course_enrollments', $wpdb->prefix . 'aimslms_course_progress', $wpdb->prefix . 'aimslms_course_payment', $wpdb->prefix . 'aimslms_course_certificates', $wpdb->prefix . 'aimslms_course_orders', ); foreach ( $tables as $table ) { if ( 0 === strpos( $table, $wpdb->prefix . 'aimslms_' ) ) { $table = preg_replace( '/[^a-zA-Z0-9_]/', '', $table ); // phpcs:disable WordPress.DB.PreparedSQL // phpcs:disable WordPress.DB.DirectDatabaseQuery $wpdb->query( 'DROP TABLE IF EXISTS `' . $table . '`' ); // phpcs:enable WordPress.DB.PreparedSQL // phpcs:enable WordPress.DB.DirectDatabaseQuery } } /** * Delete Aims Infosoft LMS course posts. */ // phpcs:disable WordPress.DB.DirectDatabaseQuery $course_post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s", 'aimslms_course' ) ); // phpcs:enable WordPress.DB.DirectDatabaseQuery if ( ! empty( $course_post_ids ) ) { foreach ( $course_post_ids as $course_post_id ) { wp_delete_post( (int) $course_post_id, true ); } } /** * Note: the plugin's auto-created front-end pages (My Account, Courses, * Checkout, etc.) are intentionally NOT deleted here. AIMSLMS_Deactivator * already swaps their content for a "plugin is not available" notice when * the plugin is deactivated (which WordPress requires before it can be * deleted from the Plugins screen), so visitors see that message instead * of a broken shortcode. Deleting the pages here would only turn that * friendly notice into a 404. */ /** * Delete plugin options. */ $options = array( // General. 'aimslms_currency', 'aimslms_currency_position', 'aimslms_thousand_separator', 'aimslms_decimal_separator', 'aimslms_decimal_count', // Note: aimslms_account_page / aimslms_courses_page / aimslms_checkout_page (and // the other auto-created page options) are intentionally kept - the // pages themselves are kept too, so these must keep pointing at them. // Stripe. 'aimslms_enable_stripe', 'aimslms_stripe_payment_mode', 'aimslms_stripe_test_publishable', 'aimslms_stripe_test_secret', 'aimslms_stripe_live_publishable', 'aimslms_stripe_live_secret', 'aimslms_stripe_webhook_secret', 'aimslms_stripe_connection_status_sandbox', 'aimslms_stripe_connection_status_live', // PayPal. 'aimslms_enable_paypal', 'aimslms_paypal_payment_mode', 'aimslms_paypal_sandbox_client_id', 'aimslms_paypal_sandbox_secret', 'aimslms_paypal_live_client_id', 'aimslms_paypal_live_secret', 'aimslms_paypal_connection_status_sandbox', 'aimslms_paypal_connection_status_live', // Razorpay. 'aimslms_enable_razorpay', 'aimslms_razorpay_payment_mode', 'aimslms_razorpay_test_key_id', 'aimslms_razorpay_test_key_secret', 'aimslms_razorpay_live_key_id', 'aimslms_razorpay_live_key_secret', 'aimslms_razorpay_webhook_secret', 'aimslms_razorpay_connection_status_sandbox', 'aimslms_razorpay_connection_status_live', // Internal. 'aimslms_db_version', 'aimslms_menu_items_initialized', ); foreach ( $options as $option ) { delete_option( $option ); delete_site_option( $option ); }