Open mauteri opened 12 months ago
There is no need for a polling api, the standard way of doing this in wordpress is the heartbeat api just piigy back on that
There is no need for a polling api, the standard way of doing this in wordpress is the heartbeat api just piigy back on that
Isn't heartbeat API only in the admin? I might be wrong, but thought it was just an admin thing and couldn't be used on the frontend, where it would be needed here.
Core uses it in only back end and with the admin bar. But it is used by 100s of plugins in the front end and the Wordpress documentation specifically mentions the front end
https://developer.wordpress.org/plugins/javascript/heartbeat-api/
I use it extensively in my plugins and of course it’s used by buddypress/buddyboss.
It is the standard way of doing polling and the beauty of it is that you add your requests to the heartbeat which may already be running so there are no additional http requests and meaning lower server load than rolling your own solution
Ok, I haven't really used it that much and thought it was very much an admin thing. I was under the impression it leveraged admin-ajax which isn't something you would want to use on the frontend. I'll take a look. Thanks for the info!
It does use admin-ajax.php. But Im' not sure what the issue is using that on the front end?
One day wordpress will add similar functionality to the json api but for now heartbeat is the standard way of doing two way polling in wordpress both on the front and back end.
The major advantages are it has a good api (no need to reinvent the wheel) and because you piggy back on the existing polling heartbeat you are not creating extraneous http requests
Yeah, okay, I think it will be fine with Heartbeat API since this feature is only for logged in users and should also be a setting that can be toggle on/off in the admin as it could be problematic for some hosting. Should be easy to move to JSON API once that functionality is available.
To create a more real-time feel, we should have a polling API that GatherPress can use on event pages. To start this will do 2 things:
Polling will run every minute and will need to be a setting to enable/disable. I'm thinking it should be disabled by default as it could be problematic on some shared hosting servers.