array( 'type' => 'integer', 'minimum' => 1, 'description' => __( 'The organizer ID.', 'acrossai-abilities-manager' ), ), ); } protected function required_input(): array { return array( 'id' ); } protected function output_properties(): array { return array( 'id' => array( 'type' => 'integer' ), 'trashed' => array( 'type' => 'boolean' ), 'linked_events' => array( 'type' => 'integer' ), ); } protected function annotations(): array { return array( 'readonly' => false, 'destructive' => true, 'idempotent' => false, ); } protected function requires_confirmation(): bool { return true; } protected function confirmation_message(): string { return __( 'Events already linked to this are not updated — they keep pointing at it. Pass confirm: true to proceed.', 'acrossai-abilities-manager' ); } protected function run( array $input ) { $id = (int) $input['id']; $post = Event_Repository::require_post( $id, 'organizer' ); if ( is_wp_error( $post ) ) { return $post; } $linked = Event_Repository::linked_event_count( $id, 'organizer' ); $title = (string) get_the_title( $id ); $trashed = Event_Repository::trash( $id ); if ( is_wp_error( $trashed ) ) { return $trashed; } return array( 'id' => $id, 'trashed' => true, 'linked_events' => $linked, 'message' => sprintf( /* translators: 1: name, 2: number of events */ __( 'Trashed "%1$s". %2$d event(s) still reference it and were not changed.', 'acrossai-abilities-manager' ), $title, $linked ), ); } }