*/ protected function input_properties(): array { return array( 'id' => array( 'type' => 'integer', 'description' => __( 'Snippet id.', 'acrossai-abilities-manager' ), ), ); } /** * @since 0.0.34 * @return array */ protected function required_input(): array { return array( 'id' ); } /** * @since 0.0.34 * @return array */ protected function output_properties(): array { return array( 'deleted_id' => array( 'type' => 'integer' ), 'title' => array( 'type' => 'string' ), ); } /** * @since 0.0.34 * @return array */ protected function annotations(): array { return array( 'readonly' => false, 'destructive' => true, 'idempotent' => false ); } /** * @since 0.0.34 * @return bool */ protected function requires_confirmation(): bool { return true; } /** * @since 0.0.34 * @return string */ protected function confirmation_message(): string { return __( 'Deleting a snippet cannot be undone. Pass confirm: true to proceed, or use deactivate-snippet to stop it running while keeping the code.', 'acrossai-abilities-manager' ); } /** * @since 0.0.34 * @param array $input Input. * @return array|WP_Error */ protected function run( array $input ) { $id = (int) ( $input['id'] ?? 0 ); $snippet = Snippet_Repository::find( $id ); if ( is_wp_error( $snippet ) ) { return $snippet; } $title = (string) $snippet->get_title(); $deleted = Snippet_Repository::delete( $id ); if ( is_wp_error( $deleted ) ) { return $deleted; } return array( 'deleted_id' => $id, 'title' => $title, ); } }