query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $wpdb->esc_like( 'mapsemble_feed_generation_' ) . '%' ) ); // Transients keyed per query and per user: cached geocoder answers // (mirrors Mapsemble\Rest\GeocodeController::CACHE_PREFIX) and the // location box's one-shot errors (MetaBox::ERROR_TRANSIENT). Each has a // value row and a timeout row. foreach ( array( 'mapsemble_geocode_', 'mapsemble_location_error_' ) as $prefix ) { foreach ( array( '_transient_', '_transient_timeout_' ) as $row ) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- one-off teardown of transients named after queries and users nothing else lists. $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $wpdb->esc_like( $row . $prefix ) . '%' ) ); } } wp_cache_delete( 'alloptions', 'options' ); // The map configurations themselves. The post type is not registered // during uninstall, so the posts are found by name — get_posts() would // filter them out against the registered post type list. // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- one-off teardown of an unregistered post type. $map_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s", 'mapsemble_map' ) ); foreach ( $map_ids as $map_id ) { wp_delete_post( (int) $map_id, true ); } foreach ( wp_roles()->role_objects as $role ) { foreach ( mapsemble_uninstall_capabilities() as $cap ) { $role->remove_cap( $cap ); } } if ( $delete_meta ) { delete_post_meta_by_key( '_mapsemble_lat' ); delete_post_meta_by_key( '_mapsemble_lng' ); delete_post_meta_by_key( '_mapsemble_hidden' ); } } if ( is_multisite() ) { // number => 0 lifts get_sites()' default cap of 100 sites. $mapsemble_site_ids = get_sites( array( 'fields' => 'ids', 'number' => 0, ) ); foreach ( $mapsemble_site_ids as $mapsemble_site_id ) { switch_to_blog( (int) $mapsemble_site_id ); mapsemble_uninstall_site(); restore_current_blog(); } } else { mapsemble_uninstall_site(); }