Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f63e052ccd | ||
|
|
703e5a8692 |
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,3 +1,14 @@
|
|||||||
|
## 1.3.0
|
||||||
|
|
||||||
|
- Enable the plugin on the approved Jen Home production site as well as staging.
|
||||||
|
- Assign each new inquiry and its unique linked lead to WordPress user ID 7.
|
||||||
|
- Preserve the existing Houzez owner filter and avoid changing historical records.
|
||||||
|
|
||||||
|
## 1.2.2
|
||||||
|
|
||||||
|
- Remove the Source Link column and its values from both Leads and Inquiries CSVs.
|
||||||
|
- Keep Referral Source, CRM views, captured source URLs and historical records intact.
|
||||||
|
|
||||||
## 1.2.1
|
## 1.2.1
|
||||||
|
|
||||||
- Publish releases using the Requests API client, compatible with the Gitea host.
|
- Publish releases using the Requests API client, compatible with the Gitea host.
|
||||||
|
|||||||
25
README.md
25
README.md
@@ -1,6 +1,6 @@
|
|||||||
# Jen Home Contact Fields and Exports
|
# Jen Home Contact Fields and Exports
|
||||||
|
|
||||||
WordPress/Houzez customization for **staging.jenhome.net**.
|
WordPress/Houzez customization for **staging.jenhome.net** and **www.jenhome.net**.
|
||||||
|
|
||||||
Author: **Josh Stevens Sr** · Website: [hostLabs](https://hostlabs.pro/)
|
Author: **Josh Stevens Sr** · Website: [hostLabs](https://hostlabs.pro/)
|
||||||
|
|
||||||
@@ -14,6 +14,11 @@ answer to “How did you hear about us?”. The existing friend-name question is
|
|||||||
identified separately from a property address. Original forms, CRM persistence,
|
identified separately from a property address. Original forms, CRM persistence,
|
||||||
notifications and existing security checks remain in place.
|
notifications and existing security checks remain in place.
|
||||||
|
|
||||||
|
New inquiries are assigned to WordPress user ID 7, with the linked Houzez lead
|
||||||
|
owner updated in the same transaction. The update applies only when the new
|
||||||
|
inquiry is the lead's sole inquiry; ambiguous relationships keep their native
|
||||||
|
ownership and are logged. Existing records are never reassigned automatically.
|
||||||
|
|
||||||
Inquiries CSV columns, in order:
|
Inquiries CSV columns, in order:
|
||||||
|
|
||||||
1. Submission Date
|
1. Submission Date
|
||||||
@@ -22,12 +27,11 @@ Inquiries CSV columns, in order:
|
|||||||
4. Last Name
|
4. Last Name
|
||||||
5. Referral Source
|
5. Referral Source
|
||||||
6. Referrer Name
|
6. Referrer Name
|
||||||
7. Source Link
|
7. Email
|
||||||
8. Email
|
8. Mobile
|
||||||
9. Mobile
|
|
||||||
|
|
||||||
Submission dates use America/New_York with an explicit UTC offset. Leads exports
|
Submission dates use America/New_York with an explicit UTC offset. Leads exports
|
||||||
retain their existing fields. CRM views still show inquiry/property details even
|
omit Source Link and retain their other existing fields. CRM views still show inquiry/property details even
|
||||||
though the shorter Inquiries CSV omits them. Historical records are not backfilled
|
though the shorter Inquiries CSV omits them. Historical records are not backfilled
|
||||||
or split; relationships use IDs, never email matching.
|
or split; relationships use IDs, never email matching.
|
||||||
|
|
||||||
@@ -82,7 +86,7 @@ repository's Settings → Actions → Runners if retiring the computer.
|
|||||||
2. Commit and push to `main`. The workflow lints PHP, runs the standalone updater
|
2. Commit and push to `main`. The workflow lints PHP, runs the standalone updater
|
||||||
and CSV tests, and builds the ZIP.
|
and CSV tests, and builds the ZIP.
|
||||||
3. After checks and staging validation pass, create and push a matching tag:
|
3. After checks and staging validation pass, create and push a matching tag:
|
||||||
`git tag v1.2.2` then `git push origin v1.2.2`.
|
`git tag v1.2.3` then `git push origin v1.2.3`.
|
||||||
4. The tag workflow repeats checks, builds the package, uploads both assets to a
|
4. The tag workflow repeats checks, builds the package, uploads both assets to a
|
||||||
draft, and publishes the release only after uploads succeed.
|
draft, and publishes the release only after uploads succeed.
|
||||||
|
|
||||||
@@ -94,14 +98,15 @@ Local checks (PHP 8.1+ with ZIP support, Python 3):
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
php tests/unit.php
|
php tests/unit.php
|
||||||
python3 scripts/build-release.py v1.2.1
|
python3 scripts/build-release.py v1.3.0
|
||||||
```
|
```
|
||||||
|
|
||||||
## Scope and rollback
|
## Scope and rollback
|
||||||
|
|
||||||
The plugin runs only when both the home URL and WordPress directory identify
|
The plugin runs only when the home URL and WordPress directory match one of the
|
||||||
`staging.jenhome.net`. Installing it on production does not enable its behavior or
|
two approved installations: `staging.jenhome.net` in its staging directory or
|
||||||
updater. A production rollout requires a separately reviewed scope change.
|
`www.jenhome.net` in `httpdocs`. It also requires user ID 7 to exist as an
|
||||||
|
administrator. Other hosts and copied installations fail closed.
|
||||||
|
|
||||||
Back up the current plugin directory before the first updater installation.
|
Back up the current plugin directory before the first updater installation.
|
||||||
Deactivate this plugin to return to native behavior, or reinstall the previous
|
Deactivate this plugin to return to native behavior, or reinstall the previous
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ final class Jenhome_Gitea_Updater {
|
|||||||
'version' => $release['version'], 'author' => 'Josh Stevens Sr', 'author_profile' => 'https://hostlabs.pro/',
|
'version' => $release['version'], 'author' => 'Josh Stevens Sr', 'author_profile' => 'https://hostlabs.pro/',
|
||||||
'homepage' => 'https://hostlabs.pro/', 'requires' => '6.2', 'requires_php' => '8.1', 'tested' => '7.1.3',
|
'homepage' => 'https://hostlabs.pro/', 'requires' => '6.2', 'requires_php' => '8.1', 'tested' => '7.1.3',
|
||||||
'download_link' => $release['package'], 'last_updated' => $release['published_at'],
|
'download_link' => $release['package'], 'last_updated' => $release['published_at'],
|
||||||
'sections' => ['description' => 'Site-specific Houzez contact fields and CSV exports for staging.jenhome.net.',
|
'sections' => ['description' => 'Site-specific Houzez contact fields, account 7 inquiry ownership and CSV exports for Jen Home staging and production.',
|
||||||
'changelog' => wpautop(esc_html($release['body']))],
|
'changelog' => wpautop(esc_html($release['body']))],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
* Plugin Name: Jen Home Contact Fields and Exports
|
* Plugin Name: Jen Home Contact Fields and Exports
|
||||||
* Plugin URI: https://hostlabs.pro/
|
* Plugin URI: https://hostlabs.pro/
|
||||||
* Update URI: https://git.labs.casa/josh/jenhomeforms
|
* Update URI: https://git.labs.casa/josh/jenhomeforms
|
||||||
* Description: Staging-only Houzez name/referral capture and protected CSV exports.
|
* Description: Jen Home Houzez contact fields, inquiry ownership and protected CSV exports.
|
||||||
* Version: 1.2.1
|
* Version: 1.3.0
|
||||||
* Requires at least: 6.2
|
* Requires at least: 6.2
|
||||||
* Requires PHP: 8.1
|
* Requires PHP: 8.1
|
||||||
* Author: Josh Stevens Sr
|
* Author: Josh Stevens Sr
|
||||||
@@ -13,7 +13,8 @@
|
|||||||
defined('ABSPATH') || exit;
|
defined('ABSPATH') || exit;
|
||||||
|
|
||||||
final class Jenhome_Contact_Exports {
|
final class Jenhome_Contact_Exports {
|
||||||
const VERSION = '1.2.1';
|
const VERSION = '1.3.0';
|
||||||
|
const INQUIRY_OWNER_ID = 7;
|
||||||
const ACTIONS = ['houzez_ele_inquiry_form', 'houzez_ele_contact_form', 'houzez_property_agent_contact', 'houzez_schedule_send_message', 'houzez_contact_realtor'];
|
const ACTIONS = ['houzez_ele_inquiry_form', 'houzez_ele_contact_form', 'houzez_property_agent_contact', 'houzez_schedule_send_message', 'houzez_contact_realtor'];
|
||||||
// Verified Elementor widgets: contact page and the two Get Started popups.
|
// Verified Elementor widgets: contact page and the two Get Started popups.
|
||||||
const REFERRAL_FORMS = ['6o0tsaob0', '1cbfa42a', '2a2beb9b'];
|
const REFERRAL_FORMS = ['6o0tsaob0', '1cbfa42a', '2a2beb9b'];
|
||||||
@@ -24,9 +25,11 @@ final class Jenhome_Contact_Exports {
|
|||||||
private static $collector_wrapped = false;
|
private static $collector_wrapped = false;
|
||||||
|
|
||||||
public static function boot() {
|
public static function boot() {
|
||||||
// Fail closed on production, including if a staging clone is later copied there.
|
// Fail closed outside the two explicitly approved Jen Home installations.
|
||||||
if (wp_parse_url(home_url(), PHP_URL_HOST) !== 'staging.jenhome.net'
|
$host = strtolower((string)wp_parse_url(home_url(), PHP_URL_HOST));
|
||||||
|| basename(untrailingslashit(ABSPATH)) !== 'staging.jenhome.net') return;
|
$roots = ['staging.jenhome.net' => 'staging.jenhome.net', 'www.jenhome.net' => 'httpdocs'];
|
||||||
|
if (!isset($roots[$host]) || basename(untrailingslashit(ABSPATH)) !== $roots[$host]
|
||||||
|
|| !get_userdata(self::INQUIRY_OWNER_ID) || !user_can(self::INQUIRY_OWNER_ID, 'manage_options')) return;
|
||||||
require_once __DIR__ . '/gitea-updater.php';
|
require_once __DIR__ . '/gitea-updater.php';
|
||||||
Jenhome_Gitea_Updater::boot(__FILE__);
|
Jenhome_Gitea_Updater::boot(__FILE__);
|
||||||
self::install_storage();
|
self::install_storage();
|
||||||
@@ -227,11 +230,52 @@ final class Jenhome_Contact_Exports {
|
|||||||
$lead_id = $id;
|
$lead_id = $id;
|
||||||
} else return;
|
} else return;
|
||||||
if (!$lead_id) return;
|
if (!$lead_id) return;
|
||||||
|
if ($enquiry_id) self::assign_inquiry_owner($lead_id, $enquiry_id);
|
||||||
$form = $enquiry_id && self::input('is_estimation') === 'yes' && empty($_POST['listing_id']) ? self::$referrer_form : '';
|
$form = $enquiry_id && self::input('is_estimation') === 'yes' && empty($_POST['listing_id']) ? self::$referrer_form : '';
|
||||||
if (self::$middle_name === '' && $form === '') return;
|
if (self::$middle_name === '' && $form === '') return;
|
||||||
$wpdb->insert($wpdb->prefix . 'jenhome_contact_fields', ['lead_id' => $lead_id, 'enquiry_id' => $enquiry_id, 'middle_name' => self::$middle_name, 'referrer_form' => $form], ['%d', '%d', '%s', '%s']);
|
$wpdb->insert($wpdb->prefix . 'jenhome_contact_fields', ['lead_id' => $lead_id, 'enquiry_id' => $enquiry_id, 'middle_name' => self::$middle_name, 'referrer_form' => $form], ['%d', '%d', '%s', '%s']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Keep the native inquiry/lead relationship intact while assigning only this new inquiry. */
|
||||||
|
private static function assign_inquiry_owner($lead_id, $enquiry_id) {
|
||||||
|
global $wpdb;
|
||||||
|
$leads = $wpdb->prefix . 'houzez_crm_leads';
|
||||||
|
$inquiries = $wpdb->prefix . 'houzez_crm_enquiries';
|
||||||
|
$row = $wpdb->get_row($wpdb->prepare(
|
||||||
|
"SELECT e.user_id AS enquiry_user_id,l.user_id AS lead_user_id,(SELECT COUNT(*) FROM $inquiries x WHERE x.lead_id=e.lead_id) AS inquiry_count FROM $inquiries e JOIN $leads l ON l.lead_id=e.lead_id WHERE e.enquiry_id=%d AND e.lead_id=%d",
|
||||||
|
$enquiry_id, $lead_id
|
||||||
|
));
|
||||||
|
if (!$row || (int)$row->inquiry_count !== 1) {
|
||||||
|
error_log('Jen Home Contact Fields: skipped inquiry ownership update because its new inquiry/lead relationship was not unique.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$old_enquiry_owner = (int)$row->enquiry_user_id;
|
||||||
|
$old_lead_owner = (int)$row->lead_user_id;
|
||||||
|
if ($old_enquiry_owner === self::INQUIRY_OWNER_ID && $old_lead_owner === self::INQUIRY_OWNER_ID) return true;
|
||||||
|
if ($wpdb->query('START TRANSACTION') === false) {
|
||||||
|
error_log('Jen Home Contact Fields: could not start inquiry ownership transaction.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$lead_updated = $old_lead_owner === self::INQUIRY_OWNER_ID ? 0 : $wpdb->update(
|
||||||
|
$leads, ['user_id' => self::INQUIRY_OWNER_ID], ['lead_id' => $lead_id, 'user_id' => $old_lead_owner], ['%d'], ['%d', '%d']
|
||||||
|
);
|
||||||
|
$enquiry_updated = $old_enquiry_owner === self::INQUIRY_OWNER_ID ? 0 : $wpdb->update(
|
||||||
|
$inquiries, ['user_id' => self::INQUIRY_OWNER_ID], ['enquiry_id' => $enquiry_id, 'lead_id' => $lead_id, 'user_id' => $old_enquiry_owner], ['%d'], ['%d', '%d', '%d']
|
||||||
|
);
|
||||||
|
if (($old_lead_owner !== self::INQUIRY_OWNER_ID && $lead_updated !== 1)
|
||||||
|
|| ($old_enquiry_owner !== self::INQUIRY_OWNER_ID && $enquiry_updated !== 1)) {
|
||||||
|
$wpdb->query('ROLLBACK');
|
||||||
|
error_log('Jen Home Contact Fields: inquiry ownership update failed; changes were rolled back.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ($wpdb->query('COMMIT') === false) {
|
||||||
|
$wpdb->query('ROLLBACK');
|
||||||
|
error_log('Jen Home Contact Fields: inquiry ownership commit failed.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static function meta($value) {
|
public static function meta($value) {
|
||||||
$meta = is_serialized($value) ? @unserialize(trim($value), ['allowed_classes' => false]) : [];
|
$meta = is_serialized($value) ? @unserialize(trim($value), ['allowed_classes' => false]) : [];
|
||||||
return is_array($meta) ? $meta : [];
|
return is_array($meta) ? $meta : [];
|
||||||
@@ -314,7 +358,7 @@ final class Jenhome_Contact_Exports {
|
|||||||
|
|
||||||
public static function lead_rows($user_id) {
|
public static function lead_rows($user_id) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$fields = ['time', 'first_name', 'middle_name', 'last_name', 'source', 'referrer_name', 'source_link', 'prefix', 'display_name', 'email', 'mobile', 'home_phone', 'work_phone', 'address', 'city', 'state', 'country', 'zipcode', 'type', 'twitter_url', 'linkedin_url', 'facebook_url', 'private_note', 'message', 'inquiry_street_address'];
|
$fields = ['time', 'first_name', 'middle_name', 'last_name', 'source', 'referrer_name', 'prefix', 'display_name', 'email', 'mobile', 'home_phone', 'work_phone', 'address', 'city', 'state', 'country', 'zipcode', 'type', 'twitter_url', 'linkedin_url', 'facebook_url', 'private_note', 'message', 'inquiry_street_address'];
|
||||||
$rows = $wpdb->get_results($wpdb->prepare("SELECT l.*, f.middle_name FROM {$wpdb->prefix}houzez_crm_leads l LEFT JOIN {$wpdb->prefix}jenhome_contact_fields f ON f.lead_id=l.lead_id WHERE l.user_id = %d ORDER BY l.lead_id", $user_id), ARRAY_A);
|
$rows = $wpdb->get_results($wpdb->prepare("SELECT l.*, f.middle_name FROM {$wpdb->prefix}houzez_crm_leads l LEFT JOIN {$wpdb->prefix}jenhome_contact_fields f ON f.lead_id=l.lead_id WHERE l.user_id = %d ORDER BY l.lead_id", $user_id), ARRAY_A);
|
||||||
$related = [];
|
$related = [];
|
||||||
foreach (self::inquiry_records($user_id) as $inquiry) {
|
foreach (self::inquiry_records($user_id) as $inquiry) {
|
||||||
@@ -327,14 +371,13 @@ final class Jenhome_Contact_Exports {
|
|||||||
return array_map(function($row) use ($fields, $related) {
|
return array_map(function($row) use ($fields, $related) {
|
||||||
$row['time'] = self::submission_date($row['time'] ?? '');
|
$row['time'] = self::submission_date($row['time'] ?? '');
|
||||||
foreach (['referrer_name', 'inquiry_street_address'] as $key) $row[$key] = implode('; ', array_unique($related[$row['lead_id']][$key] ?? []));
|
foreach (['referrer_name', 'inquiry_street_address'] as $key) $row[$key] = implode('; ', array_unique($related[$row['lead_id']][$key] ?? []));
|
||||||
$row['source_link'] = html_entity_decode($row['source_link'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
||||||
return array_map(function($f) use ($row) { return $row[$f] ?? ''; }, $fields);
|
return array_map(function($f) use ($row) { return $row[$f] ?? ''; }, $fields);
|
||||||
}, $rows);
|
}, $rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function export_leads() {
|
public static function export_leads() {
|
||||||
self::authorize_export();
|
self::authorize_export();
|
||||||
self::write_csv('leads.csv', ['Submission Date', 'First Name', 'Middle Name', 'Last Name', 'Referral Source', 'Referrer Name', 'Source Link', 'Prefix', 'Full Name', 'Email', 'Mobile', 'Home Phone', 'Work Phone', 'Address', 'City', 'County / State', 'Country', 'Postal Code / Zip', 'Type', 'Twitter', 'Linkedin', 'Facebook', 'Private Note', 'Message', 'Inquiry Street Address'], self::lead_rows(get_current_user_id()));
|
self::write_csv('leads.csv', ['Submission Date', 'First Name', 'Middle Name', 'Last Name', 'Referral Source', 'Referrer Name', 'Prefix', 'Full Name', 'Email', 'Mobile', 'Home Phone', 'Work Phone', 'Address', 'City', 'County / State', 'Country', 'Postal Code / Zip', 'Type', 'Twitter', 'Linkedin', 'Facebook', 'Private Note', 'Message', 'Inquiry Street Address'], self::lead_rows(get_current_user_id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function inquiry_records($user_id, $ids = null) {
|
public static function inquiry_records($user_id, $ids = null) {
|
||||||
@@ -362,7 +405,6 @@ final class Jenhome_Contact_Exports {
|
|||||||
self::submission_date($row['time'] ?? ''),
|
self::submission_date($row['time'] ?? ''),
|
||||||
$row['first_name'] ?? '', $row['middle_name'] ?? '', $row['last_name'] ?? '',
|
$row['first_name'] ?? '', $row['middle_name'] ?? '', $row['last_name'] ?? '',
|
||||||
self::referral_source($row), self::referrer_name($row, $meta),
|
self::referral_source($row), self::referrer_name($row, $meta),
|
||||||
html_entity_decode($row['source_link'] ?? '', ENT_QUOTES, 'UTF-8'),
|
|
||||||
$row['email'] ?? '', $row['mobile'] ?? '',
|
$row['email'] ?? '', $row['mobile'] ?? '',
|
||||||
];
|
];
|
||||||
}, $rows);
|
}, $rows);
|
||||||
@@ -370,7 +412,7 @@ final class Jenhome_Contact_Exports {
|
|||||||
|
|
||||||
public static function export_inquiries() {
|
public static function export_inquiries() {
|
||||||
self::authorize_export();
|
self::authorize_export();
|
||||||
self::write_csv('inquiries.csv', ['Submission Date', 'First Name', 'Middle Name', 'Last Name', 'Referral Source', 'Referrer Name', 'Source Link', 'Email', 'Mobile'], self::inquiry_rows(get_current_user_id()));
|
self::write_csv('inquiries.csv', ['Submission Date', 'First Name', 'Middle Name', 'Last Name', 'Referral Source', 'Referrer Name', 'Email', 'Mobile'], self::inquiry_rows(get_current_user_id()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action('plugins_loaded', ['Jenhome_Contact_Exports', 'boot']);
|
add_action('plugins_loaded', ['Jenhome_Contact_Exports', 'boot']);
|
||||||
|
|||||||
@@ -93,13 +93,31 @@ try {
|
|||||||
$GLOBALS['responses'][$info['checksum_url']]=['status'=>200,'body'=>'not a checksum']; Jenhome_Gitea_Updater::clear();
|
$GLOBALS['responses'][$info['checksum_url']]=['status'=>200,'body'=>'not a checksum']; Jenhome_Gitea_Updater::clear();
|
||||||
check(Jenhome_Gitea_Updater::latest()===false,'invalid checksum metadata not advertised');
|
check(Jenhome_Gitea_Updater::latest()===false,'invalid checksum metadata not advertised');
|
||||||
|
|
||||||
|
$GLOBALS['wpdb']=new class {
|
||||||
|
public $prefix='test_'; public $state=['enquiry_user_id'=>1,'lead_user_id'=>1,'inquiry_count'=>1]; public $updates=[]; public $transactions=[];
|
||||||
|
public function prepare($query,...$args) { return $query; }
|
||||||
|
public function get_row($query) { return (object)$this->state; }
|
||||||
|
public function query($sql) { $this->transactions[]=$sql; return 1; }
|
||||||
|
public function update($table,$data,$where,$formats,$where_formats) {
|
||||||
|
$this->updates[]=$table;
|
||||||
|
if (str_ends_with($table,'houzez_crm_leads')) $this->state['lead_user_id']=$data['user_id'];
|
||||||
|
if (str_ends_with($table,'houzez_crm_enquiries')) $this->state['enquiry_user_id']=$data['user_id'];
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$assign = new ReflectionMethod(Jenhome_Contact_Exports::class,'assign_inquiry_owner'); $assign->setAccessible(true);
|
||||||
|
check($assign->invoke(null,11,10)===true && $GLOBALS['wpdb']->state['lead_user_id']===7 && $GLOBALS['wpdb']->state['enquiry_user_id']===7,'new inquiry and its unique lead are assigned together');
|
||||||
|
check($GLOBALS['wpdb']->transactions===['START TRANSACTION','COMMIT'],'inquiry owner update commits as one transaction');
|
||||||
|
$GLOBALS['wpdb']->state=['enquiry_user_id'=>1,'lead_user_id'=>1,'inquiry_count'=>2]; $GLOBALS['wpdb']->transactions=[];
|
||||||
|
check($assign->invoke(null,11,10)===false && $GLOBALS['wpdb']->transactions===[],'ambiguous reused lead is not reassigned');
|
||||||
|
|
||||||
$GLOBALS['wpdb']=new class {
|
$GLOBALS['wpdb']=new class {
|
||||||
public $prefix='test_';
|
public $prefix='test_';
|
||||||
public function prepare($query,...$args) { return $query; }
|
public function prepare($query,...$args) { return $query; }
|
||||||
public function get_results($query,$format) { return [[
|
public function get_results($query,$format) { return [[
|
||||||
'time'=>'2026-10-28 15:30:00','first_name'=>'Élodie','middle_name'=>'Anaïs','last_name'=>'de la Cruz',
|
'time'=>'2026-10-28 15:30:00','first_name'=>'Élodie','middle_name'=>'Anaïs','last_name'=>'de la Cruz',
|
||||||
'source'=>'Friend','source_link'=>'https://staging.jenhome.net/contact/','email'=>'synthetic@example.invalid','mobile'=>'2025550100',
|
'source'=>'Friend','source_link'=>'https://staging.jenhome.net/contact/','email'=>'synthetic@example.invalid','mobile'=>'2025550100',
|
||||||
'enquiry_id'=>10,'jenhome_enquiry_id'=>10,'jenhome_referrer_form'=>'6o0tsaob0','enquiry_meta'=>serialize(['streat_address'=>'María']),
|
'lead_id'=>11,'enquiry_id'=>10,'jenhome_enquiry_id'=>10,'jenhome_referrer_form'=>'6o0tsaob0','enquiry_meta'=>serialize(['streat_address'=>'María']),
|
||||||
'display_name'=>'DO NOT EXPORT','enquiry_type'=>'DO NOT EXPORT','message'=>'DO NOT EXPORT','private_note'=>'DO NOT EXPORT',
|
'display_name'=>'DO NOT EXPORT','enquiry_type'=>'DO NOT EXPORT','message'=>'DO NOT EXPORT','private_note'=>'DO NOT EXPORT',
|
||||||
]]; }
|
]]; }
|
||||||
};
|
};
|
||||||
@@ -107,9 +125,16 @@ try {
|
|||||||
ob_start(); try { Jenhome_Contact_Exports::export_inquiries(); } catch(Test_Die $e) {} $csv=ob_get_clean();
|
ob_start(); try { Jenhome_Contact_Exports::export_inquiries(); } catch(Test_Die $e) {} $csv=ob_get_clean();
|
||||||
$rows=explode("\r\n",substr($csv,3));
|
$rows=explode("\r\n",substr($csv,3));
|
||||||
$header=str_getcsv($rows[0],',','"',''); $row=str_getcsv($rows[1],',','"','');
|
$header=str_getcsv($rows[0],',','"',''); $row=str_getcsv($rows[1],',','"','');
|
||||||
check($header===['Submission Date','First Name','Middle Name','Last Name','Referral Source','Referrer Name','Source Link','Email','Mobile'],'requested nine-column inquiry export');
|
check($header===['Submission Date','First Name','Middle Name','Last Name','Referral Source','Referrer Name','Email','Mobile'],'requested eight-column inquiry export');
|
||||||
check(count($row)===9 && $row[2]==='Anaïs' && $row[5]==='María' && $row[8]==='2025550100','export values align with headings');
|
check(count($row)===8 && $row[2]==='Anaïs' && $row[5]==='María' && $row[6]==='synthetic@example.invalid' && $row[7]==='2025550100','export values align with headings');
|
||||||
check(!str_contains($csv,'DO NOT EXPORT'),'removed fields absent from CSV');
|
check(!str_contains($csv,'DO NOT EXPORT') && !str_contains($csv,'https://staging.jenhome.net/contact/'),'removed fields and source URL absent from inquiry CSV');
|
||||||
check($row[0]==='2026-10-28 11:30:00 -04:00','submission date remains first and localized');
|
check($row[0]==='2026-10-28 11:30:00 -04:00','submission date remains first and localized');
|
||||||
|
ob_start(); try { Jenhome_Contact_Exports::export_leads(); } catch(Test_Die $e) {} $csv=ob_get_clean();
|
||||||
|
$rows=explode("\r\n",substr($csv,3));
|
||||||
|
$header=str_getcsv($rows[0],',','"',''); $row=str_getcsv($rows[1],',','"','');
|
||||||
|
check(count($header)===24 && count($row)===24 && !in_array('Source Link',$header,true),'lead export omits Source Link heading and value');
|
||||||
|
check(!str_contains($csv,'https://staging.jenhome.net/contact/'),'source URL absent from lead CSV');
|
||||||
|
$lead=array_combine($header,$row);
|
||||||
|
check($lead['Referral Source']==='Friend' && $lead['Referrer Name']==='María' && $lead['Email']==='synthetic@example.invalid' && $lead['Mobile']==='2025550100','lead referral and contact values stay aligned');
|
||||||
echo "PASS: $checks updater and CSV checks\n";
|
echo "PASS: $checks updater and CSV checks\n";
|
||||||
} finally { foreach($paths as $p) if(file_exists($p)) unlink($p); }
|
} finally { foreach($paths as $p) if(file_exists($p)) unlink($p); }
|
||||||
|
|||||||
Reference in New Issue
Block a user