I am attempting to call a class in a required file, but I am getting the error
PHP Fatal error: Class 'SampleClass' not found in /home2/domain/public_html/website/v2/wp-content/plugins/myplugin.php on line 23
I can tell that the file is required correctly as I have echoed some text in it and it displays. I am using WordPress – is there anything weird about WordPress which would prevent this from working?
As soon as I copied the class into the original file (as opposed to including it from somewhere else) it works fine.
Any ideas? Can provide more info if needed, but I’m opposed to copying the code it here because it would be mostly irrelevant.
To use that class you have to prefix the class name with the namespace for example:-
Instead of:
new Codebird;
You would write:
new CodebirdCodebird;