WP Manifestindependent plugin directory
manifest / analytics / rm-custom-code

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.zip

Readme

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:

  1. Preserves attribution values by disabling redirect_canonical when gclid is present.
  2. Optionally normalizes query parameter key names to lowercase aliases for case-insensitive key matching.
  3. Captures gclid in a cookie (rmcc_gclid) with secure flags and value normalization.
  4. Provides a protected frontend probe capture path for diagnostics.

Admin Settings and Diagnostics

Implemented in includes/admin.php and loaded only in wp-admin:

  1. Top-level RM Custom Code menu.
  2. Settings:
    • Keep GCLID Value Case-Sensitive
    • Treat Query Parameter Names As Case-Insensitive
    • Enable WooCommerce Customizations
  3. Frontend Probe section for request/canonical callback visibility.
  4. 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:

  1. WooCommerce is active, and
  2. The Enable WooCommerce Customizations setting is enabled.

Behavior:

  1. Removes /product-category/ base from product category URLs.
  2. Rewrites category links and adds matching rewrite rules.
  3. Flushes rewrite rules on activation and when WooCommerce enablement is toggled.

Security and Hardening Notes

  1. Frontend probe writes are restricted to logged-in administrators with nonce validation.
  2. Probe data is stored per admin user transient key.
  3. .htaccess protection writes use explicit locking.
  4. Cookie handling uses secure flags and value normalization.

Performance Notes

  1. settings.php is shared and lightweight.
  2. admin.php is loaded only in wp-admin.
  3. .htaccess protection is run on activation/settings save, not every request.

Extending the Plugin

  1. Add a new include file in includes/ for your feature.
  2. Load it conditionally in rm-custom-code.php when dependencies are present.
  3. Keep request-path logic lightweight; move heavy tasks to activation/settings-save hooks when possible.

Read the full README on GitHub →