RM Custom Code
Custom code snippets for site-specific functionality.
by RM · github.com/rosewoodmarketing/rm-custom-code · website
★ 0stars
0forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/rosewoodmarketing/rm-custom-code/archive/refs/heads/main.zipReadme
RM Custom Code
WordPress plugin for site-specific functionality, with focused tools for tracking-parameter preservation and optional WooCommerce URL customizations.
File Structure
rm-custom-code/
├── rm-custom-code.php Main bootstrap and lifecycle hooks
└── includes/
├── settings.php Shared settings helpers and sanitization
├── gclid.php Tracking parameter handling + frontend probe capture
├── admin.php Admin settings page, diagnostics, and probe viewer
└── woocommerce.php Optional WooCommerce category URL customizations
Core Behavior
GCLID and Query Handling
Implemented in includes/gclid.php:
- Preserves attribution values by disabling
redirect_canonicalwhengclidis present. - Optionally normalizes query parameter key names to lowercase aliases for case-insensitive key matching.
- Captures
gclidin a cookie (rmcc_gclid) with secure flags and value normalization. - Provides a protected frontend probe capture path for diagnostics.
Admin Settings and Diagnostics
Implemented in includes/admin.php and loaded only in wp-admin:
- Top-level RM Custom Code menu.
- Settings:
- Keep GCLID Value Case-Sensitive
- Treat Query Parameter Names As Case-Insensitive
- Enable WooCommerce Customizations
- Frontend Probe section for request/canonical callback visibility.
- Live Diagnostics for common lowercasing causes (Yoast, Redirection, rewrite rules, active plugin context).
WooCommerce URL Customizations (Optional)
Implemented in includes/woocommerce.php and loaded only when:
- WooCommerce is active, and
- The Enable WooCommerce Customizations setting is enabled.
Behavior:
- Removes
/product-category/base from product category URLs. - Rewrites category links and adds matching rewrite rules.
- Flushes rewrite rules on activation and when WooCommerce enablement is toggled.
Security and Hardening Notes
- Frontend probe writes are restricted to logged-in administrators with nonce validation.
- Probe data is stored per admin user transient key.
.htaccessprotection writes use explicit locking.- Cookie handling uses secure flags and value normalization.
Performance Notes
settings.phpis shared and lightweight.admin.phpis loaded only in wp-admin..htaccessprotection is run on activation/settings save, not every request.
Extending the Plugin
- Add a new include file in
includes/for your feature. - Load it conditionally in
rm-custom-code.phpwhen dependencies are present. - Keep request-path logic lightweight; move heavy tasks to activation/settings-save hooks when possible.