I’ve got this error when I activated one plugin. I’m not a professional programmer, but I have some php experience. Help me please. The error is in the if ( in_array('template-widget', $widgets)) {
line.
function ActionWpPrintScripts() {
global $post;
// Check to see if widget is present on page
$sidebars_widgets = wp_get_sidebars_widgets(false);
$widget_loaded = false;
if ( is_array($sidebars_widgets) ) {
foreach ( $sidebars_widgets as $sidebar => $widgets ) {
if ( in_array('template-widget', $widgets)) {
$widget_loaded = true;
}
}
}
}
The function
wp_get_sidebars_widgets
is not supposed to be called by plugins, only used internally. The documentation also states thatSo that might be the reason why it does not work in the context you are calling it.
My suggestion is to try another approach for whatever you are trying to accomplish.