The API reports that it is connected in the admin - so I’m assuming that part of the setup is correct. In my theme (sage) I’m getting an error on the designated ‘eventbrite’ page: Fatal error: Class 'Eventbrite_Query' not found in /srv/www/myurl.dev/current/web/app/themes/sage/eventbrite/eventbrite-index.php on line 16
which is: $events = new Eventbrite_Query( apply_filters( 'eventbrite_query_args', array(
I think this is an issue with namespacing - so my question is:
a) Is this actually a namespacing issue - if so how do I go about resolving it given the structure of this plugin
b) do I need to edit the actual plugin files to add namespace Roots/Eventbrite; etc. ? This would then require commiting the plugin to my repo rather than using composer… or is there another method to namespace a plugin. bonus question
c) Why does this particular plugin (perhaps) require namespacing - when others don’t?
I assume you are in a PHP file with a namespace. You need to either set at the top of the file, below the namespace: use Eventbrite_Query; to tell PHP that the EventBrite_Query class is in the global namespace. Alternatively, you can also do that by writing $events = new \Eventbrite_Query( apply_filters( 'eventbrite_query_args', []);
No, the issue is not with the plugin’s namespace, it’s with how you are having PHP look for the class. Copying files from a plugin or PHP package should never be an option.
Oh boy
It doesn’t, as explained. Generally, since WP requires only PHP 5.2 and namespaces were not introduced until PHP 5.3, there are almost no mainstream plugins that have true namespacing. The namespacing that takes place is in the class name, which is why you get Eventbrite_Query instead of Eventbrite\Query
The file I’m working on to output the events is a template which is set up as per the plugins readme ie.
“…compare your markup to that of the plugin’s included templates. Make your own copies, adjusting the markup as needed, and then assign your templates in an add_theme_support call.”
register theme support add_theme_support( 'eventbrite' ); (in lib/setup ‘after_setup_theme’ action)
from reading around in the forum I tried $events = new \Eventbrite_Query( apply_filters( 'eventbrite_query_args',[]);
as the first solution, but the error remains the same
Thanks for the help - I just wasn’t sure if namespaces were playing a part (need to read up -again!) anyway I’ll work on the assumption that this is a plugin issue.