Well, I think “Payments” works like “Marketing Hub”.
I found:
plugins/woocommerce/packages/woocommerce-admin/includes/includes/feature-config.php
……
function wc_admin_get_feature_config() {
return array(
‘activity-panels’ => true,
‘analytics’ => true,
‘analytics-dashboard’ => true,
‘analytics-dashboard/customizable’ => true,
‘coupons’ => true,
‘devdocs’ => false,
‘marketing’ => true,
‘onboarding’ => true,
‘remote-inbox-notifications’ => false,
‘shipping-label-banner’ => true,
‘store-alerts’ => true,
‘unminified-js’ => false,
‘wcpay’ => true,
‘homescreen’ => true,
);
}
……
I hacked your lovely plugin to hard-code add (jeez – I’m just testing LOL)
code to the marketing disable code: function disable_features( $features ) {
……
$analytics = array_search(‘analytics’, $features);
unset( $features[$analytics] );
$analytics = array_search(‘analytics-dashboard’, $features);
unset( $features[$analytics] );
$analytics = array_search(‘analytics-dashboard/customizable’, $features);
unset( $features[$analytics] );
$marketing = array_search(‘marketing’, $features);
unset( $features[$marketing] );
return $features;
……
When “WooCommerce Admin” is re-enabled, Payments comes back and seems A-OK on front-end, payments section, and dashboaard.
Unfortunately, the blasted wc-analytics background tasks still trigger. 🙁 🙁
OK, one more step through the swamp.
Kill the REST endpoints. Ya, they’ll probably still get called – but should yield a 404 and not eat the server. I am see the the call that (I think) triggers the REST happening, but I m not seeing any delay in response – and it was a solid 60+ seconds every time before).
HUGE shout out to:
https://wpreset.com/remove-default-wordpress-rest-api-routes-endpoints/
for the code below.
Throw this in somewhere (I have it in my theme/functions.php
// —————————————————————————
// Kill the wc-analytics REST endpoints
add_filter( ‘rest_endpoints’, ‘kill_wc_analytics_endpoints’ );
function kill_wc_analytics_endpoints( $endpoints ) {
$prefix = ‘wc-analytics’;
foreach ( $endpoints as $endpoint => $details ) {
if ( !fnmatch( ‘/’ . $prefix . ‘/*’, $endpoint, FNM_CASEFOLD ) ) {
unset( $endpoints[$endpoint] );
}
}
return $endpoints;
}
SO – if all my above checks out from an independent test, I would suggest adding support for Woo Payments like for the Marketing Hub, and add the REST endpoint killer shown above as a new quick option – that may be useful across the board.
ARRGGHH.
The snippet to kill the wc-analytics endpoint as posted above has a stray bang (!) in front of the fnmatch – remove it.
The original snippet is set to keep ONLY the prefixed items while we want to keep all BUT the prefix.
Sorry about that chief!
Plugin Contributor
ospiotr
(@ospiotr)
Hi @simonkane
I was struggling to remove specific WC Admin features without removing other, but I didn’t work it out yet 🙁
I’ve been trying to use this technique. If you manage to achieve this somehow, please let me know!
I’m marking this thread as resolved for now.
Hi!
I think I already addressed this above.
https://ww.wp.xz.cn/support/topic/plugin-breaks-woocommerce-payments/#post-13518390
1. I found “wc_admin_get_feature_config”
2. I found how to kill the Analytics items (the ‘unset’s that I dropped into the “wrong” place (function disable_features) for testing – as I mentioned. The last 3 lines (first is $marketing ….) are yours.
If you clone your “kill marketing” feature (renames as needed), add the feature control, and use my unset code.
Same concept with other features in that first list – I would think.
THEN – the big fix (kills the background server-killing tasks) is my ‘kill_wc_analytics_endpoints’ filter —
just don’t forget to remove that stray bang (!) in front of the fnmatch.
I think I would implement that as a separate sub-feature of the “kill analytics” new feature that is a clone of “kill marketing”.
To state it another way, the Woo Admin Dashboard infrastructure is needed to allow various other features like “Woocommerce Payments”.
So – using the master “Disable” checkbox can not be used by everybody.
Having granular controls (Marketing, Analytics, Payments, etc.) keeps some of the bloat away – but the big monster seems to be the REST API calls – which I solved above.
I found something else. My mod breaks the Woo Customers table.
At least I think it’s my fault. Probably due to killing the wc-analytics REST API.
If you “Disable WooCommerce Admin” via the checkbox, the “Customers” option disappears entirely. So, if I/we want to keep using “WooCommerce Payments” cleanly, I/we should find a way to kill the “Customers” menu option of Woo without using the “Disable WooCommerce Admin” feature. This will avoid users seeing the error you get.
Any idea where that lives? And/or any other analysis of how to kill the resource hog background tasks besides my method?