lesterchan / wp-polls

Adds an AJAX poll system to your WordPress blog. You can also easily add a poll into your WordPress's blog post/page.
https://wordpress.org/plugins/wp-polls/
91 stars 78 forks source link

Ajax on password secured wp-admin folder #137

Closed ei23com closed 4 years ago

ei23com commented 4 years ago

Hi, is it possible to do the ajax stuff without the "admin_url('admin-ajax.php')" stuff? I would like to have my wp-admin folder password secured with htaccess, but then public polls wont work.

lesterchan commented 4 years ago

Sadly, despite the name and location, that is the correct way to do it. You need to whitelist admin-ajax.php https://wordpress.stackexchange.com/questions/77407/how-does-admin-ajax-php-work

ei23com commented 4 years ago

I learned something, thank you!

Here is what I whitelisted it in .htaccess

SetEnvIf Request_URI "(admin-ajax\.php)$"  allow
SetEnvIf Request_URI "(admin-post\.php)$"  allow
Order allow,deny
Allow from env=allow
Satisfy any
AuthUserFile /path/to/.htpasswd
AuthGroupFile /dev/null
AuthName 'admin'
AuthType Basic
require valid-user