--
-- wp_presentation__delete_audience/1
--
create or replace function wp_presentation__delete_audience(
  integer
) returns int4 as $$

declare
    audience_item_id    alias for $1;
begin
    delete from cr_wp_presentations_aud
    where exists (select 1 from cr_revisions 
                    where revision_id = cr_wp_presentations_aud.id 
                    and item_id = audience_item_id);

    delete from cr_item_publish_audit where item_id = audience_item_id;
     
    perform content_item__delete(audience_item_id);

    return 0;
end;$$ language plpgsql;