Skip to main content

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:

PatchDescription
Plugin disablerCalls Suma_Config_Helper::disable_plugins() to deactivate env-specific plugins
Algolia index prefixForces the correct index prefix for the environment via WordPress option filter
Admin email overrideChanges the admin email to a developer address on non-production
SEO noindexAdds noindex meta to all pages (prevents staging indexing)
AvaTax debugSets AvaTax recording and commit to 'no' in non-production
Google AnalyticsClears GA tracking code on non-production to prevent data pollution
MailHog SMTPConfigures 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:

PatchDescription
Head scriptsInjects custom <head> scripts via wp_head action
Footer scriptsInjects custom footer scripts via wp_footer action
Google AnalyticsInjects GA4 tracking code via wp_head
Attentive SMSInjects the Attentive signup/popup script (patched version via 0001-Dev-updated-attentive-script-in-plugin.patch)
W Rocket cacheTriggers 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:

TypeLocationApplied WhenExample
Composer patchespatches/*.patchcomposer installRemoving Kount's verbose logging from PHP files
Suma Patches pluginweb/app/plugins/suma-patches/WordPress hook executionOverriding Algolia index prefix in DB options

Current patches/ Filesโ€‹

Patch FileTarget PluginEffect
0001-Dev-CryptoWoo-Disable-Requests.patchCryptoWooDisables external HTTP requests in dev
0001-Dev-fix-local-walmart-plugin-path.patchWalmart pluginFixes path for local dev
0001-Dev-remove-get_fonts.patchRedux FrameworkRemoves Google Fonts API call
0001-Dev-remove-HTTP-Calls-from-Redux.patchRedux FrameworkRemoves all external HTTP calls
0001-Dev-Removing-Angelleye-Logging-and-adding-checkout.patchPayPal PPCPReduces verbose logging, adds checkout hook
0001-Dev-updated-attentive-script-in-plugin.patchAttentiveUpdated tracking script
0001-Dev-Walmart-patch-missing-required-properties.patchWalmartAdds missing required product fields
0001-Feature-Added-Checkbox-for-ignoring-inventory-limits.patchWalmartPer-product inventory limit override
0001-Fix-Walmart-Patch-missing-required-properties-for-Pr.patchWalmartAdditional required field fixes
0001-Tweak-Disable-built-in-spot-price-update.patch(pricing plugin)Disables built-in price updater
2FA-fix-path-in-twilio.patchWP 2FA PremiumFixes Twilio SDK include path
Kount-Remove-Unecessary-Logging.patchKountRemoves verbose fraud log entries

Adding a New Patchโ€‹

Behavioral Patch (via suma-patches plugin):โ€‹

  1. Identify the appropriate class (Dev, Frontend, WooCommerce, etc.)
  2. Add a new hook registration in the constructor
  3. Implement the callback method
  4. 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