Subscriptions 2.0 changed the way data was stored and instantiated. Because of this, it needed to deprecate a large number of existing hooks.
Some of these hooks had dynamic names, i.e. actions/filters where we don’t know what the hook actually is at run-time because it includes a payment gateway ID or another piece of dynamic data we don’t know in advance. Because of this, there was no choice but to either break backwards compatibility completely for those hooks (which would be severe in the case of scheduled subscription payment hooks) or add a small function to the
'all' hook to check if it’s a hook we have deprecated and maintain backwards compatibility.
The latter option was chosen as far better, but it may cause performance issues on some sites. We have, however, attempted to mitigate performance issues and also made sure there is a way to remove this code if your site is negatively affected and you know you have no deprecated code running on your site.
Mitigating performance issues ↑ Back to top
Functions attached to
'all', while running many times each request, are minor. They simply check the name of the hook to see if they start with 13 known hook prefixes.
This was done to mitigate any major performance impact on your site. However, depending on the number of plugins running on your site, you may find that running this tiny piece of logic on all hooks markedly reduces site performance. If this is the case, consider removing deprecated handling as outlined below.
Removing deprecated hook handling ↑ Back to top
If you know your site is not running outdated code, you can avoid having to load both this and other depreciation handling code to improve performance with Subscriptions 2.0.
The snippet below tells Subscriptions not to load deprecated handlers, including classes that attach to the
'all' hook to handle dynamic hooks:
This snippet can also be downloaded and installed as a plugin.
Warning ↑ Back to top
You must be certain that no third-party or custom code is running on your site that is dependent on deprecated hooks before disabling this deprecated hook handling. Disabling will break backwards compatibility with all old hooks and can, among other things:
- Prevent recurring payments being processed
- Break synchronization of subscription status between the payment gateway and store
- Break updating of a failing payment method
List of Deprecated Hooks ↑ Back to top
This gist provides a complete list of deprecated hooks, and their new counterpart, formatted as PHP arrays. The new hook is listed as the array key, and the deprecated hook as the value or values.