Hi @hlhs
It seems that the error is related to a custom function called “custom_plugin_styless” which is not found or invalid. This function is being called by the ‘admin_head’ action in your WordPress installation. The error itself is not directly related to WooCommerce, but it might be triggered due to a compatibility issue with the latest WooCommerce update (V7.6.1) and another plugin or custom code on your site.
Before you start the process of eliminating plugins, I’d recommend the following steps to help narrow down the issue:
1. Check your theme’s functions.php file or any custom plugin files for the “custom_plugin_styless” function. If you find it, ensure that it’s correctly defined and has no syntax errors.
2. Temporarily switch to a default WordPress theme (e.g., Twenty Twenty-One) to see if the issue persists. If the issue is resolved, it could indicate a problem with the Storefront theme or customizations made to it.
3. If the issue still occurs with a default theme, try disabling plugins one by one to identify the plugin causing the conflict. Start with any custom plugins or those that have recently been updated.
4. If the issue persists after disabling all plugins, it’s possible that there’s a conflict with the core WooCommerce plugin. In this case, you can try rolling back to a previous version of WooCommerce to see if the issue is resolved. You can use the WP Rollback plugin to do this safely. Remember to always create a backup of your site before making any changes.
If you have followed these steps and are still experiencing issues, please share your System Status Report, which you can find via WooCommerce > Status. Select Get system report and then Copy for support. Once you’ve done that, paste it into your reply here. This will help the WooCommerce team investigate further and provide a more accurate solution.
I hope these steps help you identify and resolve the issue. Thanks!
Thread Starter
hlhs
(@hlhs)
Thank you very much. Apologies for the delay, but I will givethe above a try and report back.
Hi @hlhs ,
That sounds like a plan!
Should the issue persist, please can you clarify if you are using any User Role plugins on your site at all?
Additionally, kindly share the following, in order for us to have a better understanding of your sites current environment:
- System Status Report: navigate to WooCommerce → Status. Select
Get system report and then Copy for support.
- Fatal Error log: Share a copy of any additional fatal error logs found under WooCommerce → Status → Logs.
Once you have these, please share them in your response here.
Cheers!
Thread Starter
hlhs
(@hlhs)
Following your advice, the problem was in the Storefront child theme the site was using. It contained the following customisation CSS in its functions.php file:
function isSiteAdmin() {
return in_array( 'administrator', wp_get_current_user()->roles );
}
add_action( 'admin_head', 'custom_plugin_styless' );
if ( isSiteAdmin() ) {
function custom_plugin_styless() {
echo '<style>
#hiddenoptions_tr, #hiddenoptions_line_tr {
display: none;
}
</style>';
}
}
I’ve inherited this so don’t really know where it has come from (or what is doing). I can only guess that if the user role is “Shop Manager” (not “administrator”), then something is going wrong. I wonder if the “add_action(…)” be within the “If ( isSiteAdmin() )…” statement, so is only executed if the condition is satisfied?
I don’t know if you can tell from this whether something in the latest WooCommerce version is conflicting with this?
Hello @hlhs,
Glad to hear you figured it out! 😃
I’m not sure which part of the snippet is falling, but you can try using these hooks to achieve the same result with fewer lines:
/* --- Print a script with wp_print_scripts hook --- */
add_action( 'wp_print_scripts', 'Print_snippet_CSS' );
function Print_snippet_CSS() {
if( ! is_admin() ) {
return;
}
?> <style>
#hiddenoptions_tr, #hiddenoptions_line_tr {
display: none;
}
</style> <?php
}
Reference:
– https://developer.wordpress.org/reference/functions/wp_print_scripts/
– https://developer.wordpress.org/reference/functions/is_admin/
Alternatively, you can print CSS to admins only using the Simple Custom CSS and JS plugin.
Cheers!
Thread Starter
hlhs
(@hlhs)
Thank you. Replacing the troublesome snippet with the code you provided seems to work and fixes the problem.
Cheers!
Hi @hlhs ,
Glad to hear that the provided code resolves the issue!
I will go ahead and mark this as resolved then. Feel free to create a new topic if you need further help 🙂
Also, if you have a few minutes, we’d love it if you could leave us a review:
https://wordpress.org/support/plugin/woocommerce/reviews/
Cheers!