Suma Patches
Location: web/app/plugins/suma-patches/
Author: Rhino Group
Overviewโ
The suma-patches plugin applies site-specific patches, environment overrides, and integration tweaks that go beyond what can be handled in composer.json patch files. It acts as a catch-all for WordPress hooks and filters that customize third-party plugin behavior for Scottsdale Mint's specific needs.
The plugin is divided into focused classes, each responsible for a specific area of customization.
PHP Classesโ
class-dev.php โ Environment-Specific Patchesโ
This class applies overrides that should only run on non-production environments (dev, staging, local). On production, this class's critical changes are skipped or handled differently.
Key patches:
| Patch | Description |
|---|---|
| Plugin disabler | Calls Suma_Config_Helper::disable_plugins() to deactivate env-specific plugins |
| Algolia index prefix | Forces the correct index prefix for the environment via WordPress option filter |
| Admin email override | Changes the admin email to a developer address on non-production |
| SEO noindex | Adds noindex meta to all pages (prevents staging indexing) |
| AvaTax debug | Sets AvaTax recording and commit to 'no' in non-production |
| Google Analytics | Clears GA tracking code on non-production to prevent data pollution |
| MailHog SMTP | Configures WP Mail SMTP to use MailHog (local development only) |
class-frontend.php โ Script Injectionโ
Manages injection of custom scripts and styles that are not part of the theme.
Key patches:
| Patch | Description |
|---|---|
| Head scripts | Injects custom <head> scripts via wp_head action |
| Footer scripts | Injects custom footer scripts via wp_footer action |
| Google Analytics | Injects GA4 tracking code via wp_head |
| Attentive SMS | Injects the Attentive signup/popup script (patched version via 0001-Dev-updated-attentive-script-in-plugin.patch) |
| W Rocket cache | Triggers WP Rocket cache pre-clearing automation on price updates |
class-algolia.php โ Algolia HTTP Configurationโ
Patches the Algolia PHP client to set the correct Referer header on all API requests.
Why this is needed: Algolia can be configured to restrict API access by referrer domain. The WordPress backend needs to send the correct referrer to pass these restrictions.
add_filter( 'algolia_http_client_options', function( array $options ) : array {
$options[ CURLOPT_REFERER ] = get_site_url();
return $options;
} );
class-woocommerce.php โ WooCommerce Patchesโ
Applies minor WooCommerce behavioral patches:
- Auto-adds order notes when specific email notifications are sent
- Patches order total calculations for certain edge cases
- Hooks into WooCommerce email pipeline for custom tracking
class-system.php โ Environment Detectionโ
Provides utility methods for detecting the current environment type:
class System {
public static function is_herd() : bool { ... } // Running in Laravel Herd locally
public static function is_production() : bool { ... }
public static function is_staging() : bool { ... }
}
class-admin.php โ Admin Customizationsโ
Applies admin-panel-specific tweaks:
- Customizes admin bar items
- Adds quick-access links to Algolia, Kount, and NFusion dashboards
- Hides irrelevant admin menu items for specific user roles
class-images.php โ Image Handlingโ
Overrides image handling behavior:
- Custom image size registration (precise sizes for Elementor templates)
- Image optimization hooks
- Prevents certain image sizes from being generated (reduces storage)
Integration with Composer Patchesโ
suma-patches (the PHP plugin) handles WordPress-level behavioral patches. Filesystem-level patches to third-party plugin code are applied via Composer patches (cweagans/composer-patches). Both systems are in use:
| Type | Location | Applied When | Example |
|---|---|---|---|
| Composer patches | patches/*.patch | composer install | Removing Kount's verbose logging from PHP files |
| Suma Patches plugin | web/app/plugins/suma-patches/ | WordPress hook execution | Overriding Algolia index prefix in DB options |
Current patches/ Filesโ
| Patch File | Target Plugin | Effect |
|---|---|---|
0001-Dev-CryptoWoo-Disable-Requests.patch | CryptoWoo | Disables external HTTP requests in dev |
0001-Dev-fix-local-walmart-plugin-path.patch | Walmart plugin | Fixes path for local dev |
0001-Dev-remove-get_fonts.patch | Redux Framework | Removes Google Fonts API call |
0001-Dev-remove-HTTP-Calls-from-Redux.patch | Redux Framework | Removes all external HTTP calls |
0001-Dev-Removing-Angelleye-Logging-and-adding-checkout.patch | PayPal PPCP | Reduces verbose logging, adds checkout hook |
0001-Dev-updated-attentive-script-in-plugin.patch | Attentive | Updated tracking script |
0001-Dev-Walmart-patch-missing-required-properties.patch | Walmart | Adds missing required product fields |
0001-Feature-Added-Checkbox-for-ignoring-inventory-limits.patch | Walmart | Per-product inventory limit override |
0001-Fix-Walmart-Patch-missing-required-properties-for-Pr.patch | Walmart | Additional required field fixes |
0001-Tweak-Disable-built-in-spot-price-update.patch | (pricing plugin) | Disables built-in price updater |
2FA-fix-path-in-twilio.patch | WP 2FA Premium | Fixes Twilio SDK include path |
Kount-Remove-Unecessary-Logging.patch | Kount | Removes verbose fraud log entries |
Adding a New Patchโ
Behavioral Patch (via suma-patches plugin):โ
- Identify the appropriate class (
Dev,Frontend,WooCommerce, etc.) - Add a new hook registration in the constructor
- Implement the callback method
- Test on local, then staging
Filesystem Patch (via Composer):โ
# 1. Make your changes to the third-party plugin files
# 2. Generate a patch
git diff web/app/plugins/target-plugin/src/file.php > patches/My-Patch-Description.patch
# 3. Add to composer.json under extra.patches
# "target/package-name": {
# "Patch description": "patches/My-Patch-Description.patch"
# }
# 4. Test the patch applying
composer install