PHPCS zero-violation cleanup + GA4 event alignment + server-side Woo funnel events#60
Merged
Merged
Conversation
Clears the 138 manually-handled PHPCS violations so the project standard (phpcs.xml.dist) now reports zero across all files. No runtime behavior changed. - Add accurate function/file/class docblocks and complete @param tags. - Add terminating punctuation to inline comments; capitalize doc summaries. - Flip two conditions to Yoda style. - Rename class-site-health.php -> class-sitehealth.php and abstract-form-adapter.php -> class-abstract-form-adapter.php to match the autoloader's class-name-to-file mapping and WPCS file naming; update the two manual require/file_exists references. - Add justified // phpcs:ignore annotations (no code change) for: base64 token/ciphertext encoding (not obfuscation), silenced @inet_pton with checked false returns, local file_get_contents, sub-15-min cron interval, reserved-keyword and hook/interface-mandated parameters, and Gravity Forms external API object properties.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR has two parts: a full PHPCS cleanup (787 violations → 0) and two gap-closure features identified by an architecture review (GA4 vocabulary alignment and server-side WooCommerce funnel events). No existing runtime behavior changes; all new behavior is additive or behind a default-off flag.
Part 1 — PHPCS: 787 → 0 violations
Against the project standard (
phpcs.xml.dist— WordPress-Core/Extra/Docs + PSR formatting subset);vendor/bin/phpcsnow exits 0 across all files.@param/@returndescriptions, inline-comment punctuation, Yoda conditions.class-site-health.php→class-sitehealth.php,abstract-form-adapter.php→class-abstract-form-adapter.php(now also match the autoloader's class→file mapping); manualrequirereferences updated.// phpcs:ignoreannotations (no code change): base64 (AES-GCM ciphertext + Base64URL tokens, not obfuscation),@inet_pton(false returns checked), localfile_get_contents, sub-15-min cron interval, reserved-keyword/hook-mandated params, Gravity Forms camelCase API properties.Part 2 — GA4 event-name alignment (additive)
New
CLICUTCL\Tracking\Event_Name_Mapowns the internal→GA4 and internal→Meta vocabularies (lead→generate_lead,qualified_lead→qualify_lead,book_appointment→working_lead,order_refunded→refund, …).ga4_event_name(+platform_event_namefor Meta CAPI).event_namestays internal everywhere — stored data, dedup keys, queue rows, milestone markers untouched.order_paiddeliberately unmapped to avoid double-counting GA4purchase.clicutcl_event_name_map,clicutcl_meta_event_name_map, and opt-inclicutcl_ga4_rename_outbound(default off) which renames outright for sGTM/generic destinations while preservingsource_event_name.ga4_event_name; canonical v2 events carry it inmeta. Existing GTM triggers keep firing.Part 3 — Server-side WooCommerce funnel events (opt-in, default off)
view_item,add_to_cart,begin_checkoutemitted from PHP through the same Dispatcher path as purchase (consent gate, dedup, queue/retry, logging), behind a newwoocommerce_funnel_server_eventsfeature flag with an admin toggle.view_item_{product}_{session},add_to_cart_{cart_item_key}_{session}_{minute_bucket},begin_checkout_{session}_{cart_hash[0:8]}.clicutcl_woocommerce_storefront_event_payloadfilter.view_item/begin_checkoutreuse the PHP-computed event_id for GTM-side dedup.Verification
vendor/bin/phpcs --standard=phpcs.xml.dist→ exit 0, zero violationsvendor/bin/phpunit→ 30 tests, 40 assertions, all green (13 new for Event_Name_Map, 7 new for the funnel event-id builder)node --checkclean on both touched JS filesnpm run smoke→ 40 registry-backed smoke IDs passphp -lclean on every changed fileNote for reviewers
The PHPCS CI job (
.github/workflows/php-lint.yml) may currently fail with "Referenced sniff WordPress-Core does not exist" when Composer runs as root, because thedealerdirect/phpcodesniffer-composer-installerplugin gets disabled and WPCS paths are never registered. Worth hardening in a follow-up (e.g. explicitly setinstalled_pathsor allow the plugin in CI).https://claude.ai/code/session_0185zSs2xHGNh34UnBT5rXnF