I have no idea why this should solve the issue but I can solve it. Use a different file name. For example: include('my_widgets.php');
I get the error you describe with include('widgets.php');
but not with a different file name. I don’t know why. I do know that WordPress has a Core file named widgets.php
but I can’t work out why there should be a conflict. It must have to do with the way that include
crawls for files but I’d have to do some research– get under the hood, so to speak. Moral of the story: Don’t use generic file names 🙂