Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
703e5a8692 | ||
|
|
770a08d5e9 |
@@ -17,7 +17,7 @@ jobs:
|
||||
- name: Install build tools
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install -y --no-install-recommends git python3 libzip-dev
|
||||
apt-get install -y --no-install-recommends git python3 python3-requests libzip-dev
|
||||
docker-php-ext-install zip
|
||||
- name: Check out the triggering commit
|
||||
run: |
|
||||
|
||||
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,4 +1,13 @@
|
||||
## 1.2.0
|
||||
## 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
|
||||
|
||||
- Publish releases using the Requests API client, compatible with the Gitea host.
|
||||
|
||||
## 1.2.0 (unpublished)
|
||||
|
||||
- Add WordPress-managed updates from published stable Gitea releases.
|
||||
- Verify the release checksum, package contents and version before installation.
|
||||
|
||||
11
README.md
11
README.md
@@ -22,12 +22,11 @@ Inquiries CSV columns, in order:
|
||||
4. Last Name
|
||||
5. Referral Source
|
||||
6. Referrer Name
|
||||
7. Source Link
|
||||
8. Email
|
||||
9. Mobile
|
||||
7. Email
|
||||
8. Mobile
|
||||
|
||||
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
|
||||
or split; relationships use IDs, never email matching.
|
||||
|
||||
@@ -82,7 +81,7 @@ repository's Settings → Actions → Runners if retiring the computer.
|
||||
2. Commit and push to `main`. The workflow lints PHP, runs the standalone updater
|
||||
and CSV tests, and builds the ZIP.
|
||||
3. After checks and staging validation pass, create and push a matching tag:
|
||||
`git tag v1.2.1` then `git push origin v1.2.1`.
|
||||
`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
|
||||
draft, and publishes the release only after uploads succeed.
|
||||
|
||||
@@ -94,7 +93,7 @@ Local checks (PHP 8.1+ with ZIP support, Python 3):
|
||||
|
||||
```sh
|
||||
php tests/unit.php
|
||||
python3 scripts/build-release.py v1.2.0
|
||||
python3 scripts/build-release.py v1.2.2
|
||||
```
|
||||
|
||||
## Scope and rollback
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Plugin URI: https://hostlabs.pro/
|
||||
* Update URI: https://git.labs.casa/josh/jenhomeforms
|
||||
* Description: Staging-only Houzez name/referral capture and protected CSV exports.
|
||||
* Version: 1.2.0
|
||||
* Version: 1.2.2
|
||||
* Requires at least: 6.2
|
||||
* Requires PHP: 8.1
|
||||
* Author: Josh Stevens Sr
|
||||
@@ -13,7 +13,7 @@
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
final class Jenhome_Contact_Exports {
|
||||
const VERSION = '1.2.0';
|
||||
const VERSION = '1.2.2';
|
||||
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.
|
||||
const REFERRAL_FORMS = ['6o0tsaob0', '1cbfa42a', '2a2beb9b'];
|
||||
@@ -314,7 +314,7 @@ final class Jenhome_Contact_Exports {
|
||||
|
||||
public static function lead_rows($user_id) {
|
||||
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);
|
||||
$related = [];
|
||||
foreach (self::inquiry_records($user_id) as $inquiry) {
|
||||
@@ -327,14 +327,13 @@ final class Jenhome_Contact_Exports {
|
||||
return array_map(function($row) use ($fields, $related) {
|
||||
$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] ?? []));
|
||||
$row['source_link'] = html_entity_decode($row['source_link'] ?? '', ENT_QUOTES, 'UTF-8');
|
||||
return array_map(function($f) use ($row) { return $row[$f] ?? ''; }, $fields);
|
||||
}, $rows);
|
||||
}
|
||||
|
||||
public static function export_leads() {
|
||||
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) {
|
||||
@@ -362,7 +361,6 @@ final class Jenhome_Contact_Exports {
|
||||
self::submission_date($row['time'] ?? ''),
|
||||
$row['first_name'] ?? '', $row['middle_name'] ?? '', $row['last_name'] ?? '',
|
||||
self::referral_source($row), self::referrer_name($row, $meta),
|
||||
html_entity_decode($row['source_link'] ?? '', ENT_QUOTES, 'UTF-8'),
|
||||
$row['email'] ?? '', $row['mobile'] ?? '',
|
||||
];
|
||||
}, $rows);
|
||||
@@ -370,7 +368,7 @@ final class Jenhome_Contact_Exports {
|
||||
|
||||
public static function export_inquiries() {
|
||||
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']);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Publish a tested tag using Gitea Actions' ephemeral repository token."""
|
||||
from pathlib import Path
|
||||
import json, os, re, sys, urllib.error, urllib.request, uuid
|
||||
import json, os, re, sys, uuid
|
||||
import requests
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
base = 'https://git.labs.casa/api/v1/repos/josh/jenhomeforms'
|
||||
tag = os.environ.get('RELEASE_TAG', '')
|
||||
@@ -10,22 +11,19 @@ if not re.fullmatch(r'v\d+\.\d+\.\d+', tag):
|
||||
token = os.environ.get('GITEA_TOKEN', '')
|
||||
if not token:
|
||||
sys.exit('Gitea Actions repository token is unavailable.')
|
||||
class NoRedirect(urllib.request.HTTPRedirectHandler):
|
||||
def redirect_request(self, *args):
|
||||
return None
|
||||
opener = urllib.request.build_opener(NoRedirect())
|
||||
def request(method, path, data=None, content_type='application/json'):
|
||||
body = json.dumps(data).encode() if isinstance(data, dict) else data
|
||||
req = urllib.request.Request(base + path, data=body, method=method, headers={
|
||||
'Authorization': 'token ' + token, 'Content-Type': content_type, 'Accept': 'application/json'})
|
||||
try:
|
||||
with opener.open(req, timeout=60) as response:
|
||||
raw = response.read()
|
||||
return response.status, json.loads(raw) if raw else {}
|
||||
except urllib.error.HTTPError as error:
|
||||
if error.code == 404:
|
||||
response = requests.request(method, base + path, data=body, timeout=60,
|
||||
allow_redirects=False, headers={'Authorization': 'token ' + token,
|
||||
'Content-Type': content_type, 'Accept': 'application/json'})
|
||||
except requests.RequestException:
|
||||
sys.exit('Gitea release API connection failed; no credentials are logged.')
|
||||
if response.status_code == 404:
|
||||
return 404, {}
|
||||
sys.exit(f'Gitea release API failed: HTTP {error.code} ({method} {path}).')
|
||||
if not 200 <= response.status_code < 300:
|
||||
sys.exit(f'Gitea release API failed: HTTP {response.status_code} ({method} {path}).')
|
||||
return response.status_code, response.json() if response.content else {}
|
||||
status, release = request('GET', '/releases/tags/' + tag)
|
||||
if status == 200 and not release.get('draft'):
|
||||
sys.exit('This version is already published; published releases are not overwritten.')
|
||||
|
||||
@@ -99,7 +99,7 @@ try {
|
||||
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',
|
||||
'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',
|
||||
]]; }
|
||||
};
|
||||
@@ -107,9 +107,16 @@ try {
|
||||
ob_start(); try { Jenhome_Contact_Exports::export_inquiries(); } 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($header===['Submission Date','First Name','Middle Name','Last Name','Referral Source','Referrer Name','Source Link','Email','Mobile'],'requested nine-column inquiry export');
|
||||
check(count($row)===9 && $row[2]==='Anaïs' && $row[5]==='María' && $row[8]==='2025550100','export values align with headings');
|
||||
check(!str_contains($csv,'DO NOT EXPORT'),'removed fields absent from CSV');
|
||||
check($header===['Submission Date','First Name','Middle Name','Last Name','Referral Source','Referrer Name','Email','Mobile'],'requested eight-column inquiry export');
|
||||
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') && !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');
|
||||
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";
|
||||
} finally { foreach($paths as $p) if(file_exists($p)) unlink($p); }
|
||||
|
||||
Reference in New Issue
Block a user