get_results( $wpdb->prepare( "SELECT t.term_id, tt.term_taxonomy_id FROM {$wpdb->terms} t INNER JOIN {$wpdb->term_taxonomy} tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ( %s )", $taxonomy ) ); if ( ! empty( $terms ) ) { foreach ( $terms as $term ) { $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ), array( '%d' ) ); $wpdb->delete( $wpdb->term_relationships, array( 'term_taxonomy_id' => $term->term_taxonomy_id ), array( '%d' ) ); $wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ), array( '%d' ) ); } } $wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ) ); } } } private static function remove_attachments() { global $wpdb; $attachments = $wpdb->get_results( "SELECT posts.ID FROM {$wpdb->posts} posts INNER JOIN {$wpdb->posts} parent ON posts.post_parent = parent.ID WHERE posts.post_type = 'attachment' AND parent.post_type = 'awsm_job_application'" ); if ( ! empty( $attachments ) ) { foreach ( $attachments as $attachment ) { wp_delete_attachment( $attachment->ID, true ); } } } private static function remove_posts() { global $wpdb; self::remove_attachments(); $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN( 'awsm_job_openings', 'awsm_job_application' );" ); $wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" ); } private static function remove_role_caps() { global $wp_roles; $caps = self::get_custom_caps(); $role_slugs = array_keys( $wp_roles->roles ); foreach ( $role_slugs as $slug ) { $role = get_role( $slug ); foreach ( $caps as $cap ) { $role->remove_cap( $cap ); } } // Now, remove the custom role if ( get_role( 'hr' ) ) { remove_role( 'hr' ); } } private static function delete_options() { $options = self::get_all_options(); foreach ( $options as $option ) { delete_option( $option ); } } }