'testimonial', 'post_status' => array( 'any', 'trash' ), 'numberposts' => -1, 'fields' => 'ids', 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, ) ); foreach ( $ids as $id ) { wp_delete_post( $id, true ); } // 2. Delete all groups (terms). $terms = get_terms( array( 'taxonomy' => 'testimonial_group', 'hide_empty' => false, 'fields' => 'ids', ) ); if ( is_array( $terms ) ) { foreach ( $terms as $term_id ) { wp_delete_term( $term_id, 'testimonial_group' ); } } // 3. Delete options. delete_option( 'advanced_testimonial_version' ); delete_option( 'advanced_testimonial_settings' ); delete_option( 'advanced_testimonial_debug' ); delete_option( 'advanced_testimonial_cache_ver' ); delete_option( 'advanced_testimonial_review' ); // 4. Delete transients (query cache + form rate limits + one-time tools notices). global $wpdb; $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- one-off cleanup on uninstall; transients are not cacheable here. "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_at\_q\_%' OR option_name LIKE '\_transient\_timeout\_at\_q\_%' OR option_name LIKE '\_transient\_at\_rate\_%' OR option_name LIKE '\_transient\_timeout\_at\_rate\_%' OR option_name LIKE '\_transient\_advanced\_testimonial\_%' OR option_name LIKE '\_transient\_timeout\_advanced\_testimonial\_%'" ); } // Deleting a plugin on Multisite removes it from the whole network, so every // site has to be swept — not just the one the deletion was triggered from. if ( is_multisite() ) { $advanced_testimonial_site_ids = get_sites( array( 'fields' => 'ids', 'number' => 0, ) ); foreach ( $advanced_testimonial_site_ids as $advanced_testimonial_site_id ) { switch_to_blog( $advanced_testimonial_site_id ); advanced_testimonial_uninstall_site(); restore_current_blog(); } } else { advanced_testimonial_uninstall_site(); }