| @@ -439,9 +439,18 @@ | ||
| 439 | 439 | * only ever set by the capture paths. |
| 440 | 440 | * |
| 441 | 441 | * @return array[] Rows of [session_id, visitor_email, visitor_name]. |
| 442 | 442 | */ |
| 443 | - public static function identity_rows() { | |
| 443 | + /** | |
| 444 | + * Sessions carrying visitor identity. | |
| 445 | + * | |
| 446 | + * @param bool $include_nameless_email Also return sessions that have a | |
| 447 | + * NAME but no email address. Off by default, so every existing | |
| 448 | + * caller sees exactly the rows it always has; the Leads tab opts in | |
| 449 | + * when the owner has made the email field optional (c0cfaf), where | |
| 450 | + * a name-only capture is a real lead rather than a half-filled one. | |
| 451 | + */ | |
| 452 | + public static function identity_rows($include_nameless_email = false) { | |
| 444 | 453 | global $wpdb; |
| 445 | 454 | |
| 446 | 455 | if (!self::ensure_table()) { |
| 447 | 456 | return array(); |
| @@ -448,11 +457,16 @@ | ||
| 448 | 457 | } |
| 449 | 458 | |
| 450 | 459 | $table = self::table(); |
| 451 | 460 | |
| 461 | + $where = "visitor_email IS NOT NULL AND visitor_email != ''"; | |
| 462 | + if ($include_nameless_email) { | |
| 463 | + $where = "($where) OR (visitor_name IS NOT NULL AND visitor_name != '')"; | |
| 464 | + } | |
| 465 | + | |
| 452 | 466 | $rows = $wpdb->get_results( |
| 453 | 467 | "SELECT session_id, visitor_email, visitor_name FROM `$table` |
| 454 | - WHERE visitor_email IS NOT NULL AND visitor_email != ''", | |
| 468 | + WHERE $where", | |
| 455 | 469 | ARRAY_A |
| 456 | 470 | ); |
| 457 | 471 | |
| 458 | 472 | return is_array($rows) ? $rows : array(); |