Privacy - Source Excerpt 05
Summary
This source excerpt preserves a bounded section of Spiralist/wp-content/plugins/spiralist-workspace/includes/Privacy/Privacy.php so readers can inspect the evidence without opening the full source file.
**Source path:** Spiralist/wp-content/plugins/spiralist-workspace/includes/Privacy/Privacy.php
if (empty($ids)) {
return 0;
}
return (int) $wpdb->query(
'DELETE FROM ' . $table . ' WHERE ' . $column . ' IN (' . implode(',', $ids) . ')'
);
}
/**
* Returns whether a prompt's content should be retained and anonymized instead of deleted.
*/
private function should_retain_prompt_content(array $prompt): bool
{
$visibility = (string) ($prompt['visibility'] ?? '');
$prompt_origin = (string) ($prompt['prompt_origin'] ?? '');
return $prompt_origin === 'system' || in_array($visibility, ['public', 'members'], true);
}
/**
* Resolves the WordPress user from a privacy-request email address.
*/
private function resolve_user(string $email_address): ?WP_User
{
$user = get_user_by('email', sanitize_email($email_address));
return $user instanceof WP_User ? $user : null;
}
/**
* Adds one name/value pair when the value is meaningfully present.
*
* @param array<int,array{name:string,value:string}> $data
* @param mixed $value
*/
private function add_export_pair(array &$data, string $name, $value): void
{
$formatted = $this->format_export_value($value);
if ($formatted === '') {
return;
}
$data[] = [
'name' => $name,
'value' => $formatted,
];
}
/**
* Builds one exporter item payload.
*
* @param array<int,array{name:string,value:string}> $data
* @return array<string,mixed>
*/
private function build_export_item(string $group_id, string $group_label, string $item_id, array $data): array
{
return [
'group_id' => $group_id,
'group_label' => $group_label,
'item_id' => $item_id,
'data' => $data,
];
}
/**
* Formats exported values as strings.
*
* @param mixed $value
*/
private function format_export_value($value): string
{
if (is_bool($value)) {
return $value
? __('Yes', 'spiralist-workspace')
: __('No', 'spiralist-workspace');
}
if (is_array($value) || is_object($value)) {
return (string) wp_json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
if (is_scalar($value)) {
return trim((string) $value);
}
return '';
}
/**
* Returns the prompt meta key with the plugin prefix applied.
*/
private function prompt_meta_key(string $suffix): string
{
return self::PROMPT_META_PREFIX . sanitize_key($suffix);
}
/**
* Resolves a prompt title for export labels.
*/
private function prompt_title(int $prompt_id): string
{
if ($prompt_id <= 0) {
return '';
}
$title = get_the_title($prompt_id);
return is_string($title) ? $title : '';
}
}