Hello,
My website works fine in port 80 (using http://mysite.com), but my admin site works in 443 using ssl (https://mysite.com/wp-admin).
When the full calendar [eo_fullcalendar] calls ajax admin-ajax.php the connection between http://mysite.com and the https://mysite.com/wp-admin call cannot be establish…this is what I see in the console.
https://mysite.com/wp-admin/admin-ajax.php?action=eventorganiser-fullcal&start=2015-11-01&end=2015-12-06&timeformat=g%3Ai+a&users_events=false
Unfortunately I don’t have a way to change the segments of the wordpress site to make them work under http or https for all pages (admin and not admin pages).
My question is, how I can do the ajax call the events without the need to call admin-ajax.php wordpress program in the admin site…maybe I can implement an ajax call in the front page side? is it possible?
Karen Acklin
Hi Karen,
It would be possible to create a plug-in which creates a front-end endpoint and calls the appropriate ajax function. The callback for the front-end calendar can be found here: https://github.com/stephenharris/Event-Organiser/blob/9d265a91bada8355811e4132f22cd4f5f47a7248/includes/event-organiser-ajax.php#L19-L26
The function simply prints the appropriate JSON data.
The difficulty is in telling the plug-in to use a different endpoint from the admin-ajax.php
. This is the ajax endpoint for WordPress, and its standard practise for it to be used for front-end AJAX requests. This endpoint is hardcoded into the plug-in here: https://github.com/stephenharris/Event-Organiser/blob/9d265a91bada8355811e4132f22cd4f5f47a7248/classes/class-eventorganiser-shortcodes.php#L436-L442 (see ajaxurl
property).
There are two solutions here:
1) Edit that line to use your front-end endpoint. The disadvantage here is that you will then need to maintain that patch when the plug-in updates.
2) or, Use the admin_url
to filter the admin url (see http://queryposts.com/function/get_admin_url/ ). You would want to check when the path is equal admin-ajax.php
, and most likely when is_admin()
returns false. The advantage here is that you don’t have to maintain a patch on third-party code. The disadvantage is that you would need to do a lot of testing to ensure you haven’t broken any existing functionality.
My personal advice would be to go down (2) unless you can create an exception for the admin-ajax.php
file.
Stephen Harris