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/
93 stars 78 forks source link

Does't work for sites with custom home URL #72

Closed foliovision closed 8 years ago

foliovision commented 8 years ago

Hello Lester,

our site URL is: http://site.com/wordpress

But our site is operated on (home URL): http://site.com

The voted_{ID of poll} cookies are getting set incorrectly for http://site.com/wordpress because of using the SITECOOKIEPATH define.

Could you please figure out a right way of doing this - that means using the home URL for it? Looking at wp-includes/default-constants.php it appears you only need to change it to COOKIEPATH and it will be fine.

Thanks, Martin

lesterchan commented 8 years ago

You can overwrite the path

add_filter( 'wp_polls_cookiepath', 'wp_polls_cookiepath' );
function wp_polls_cookiepath() {
return COOKIEPATH;
}
foliovision commented 8 years ago

Hello Lester,

I see that, but won't it be better if your plugin worked properly from the start and no tweaks would be needed?

Thanks, Martin

lesterchan commented 8 years ago

I am not too sure of the impact of SITECOOKIEPATH vs COOKIEPATH, since all the while I have been using SITECOOKIEPATH and so far you are the only person reported this. So I rather be cautious and not change anything that drastic before knowing more. I just provide you the solution to get what you need.

lesterchan commented 8 years ago
= Version 2.65 =
* NEW: Use Dashicons
* NEW: Supports TinyMCE 4.0 For WordPress 3.9
* NEW: Added Poll ID after adding it
* FIXED: Use SITECOOKIEPATH instead of COOKIEPATH.
* FIXED: Use http://ipinfo.io instead of http://ws.arin.net to get check IP information.
* FIXED: Wrapped all JS function in jQuery.ready(). It is ugly, but it will do till I have time to rewrite it.
* FIXED: Add INDEX for wp_pollsip: pollip_ip_qid (pollip_ip, pollip_qid) to prevent full table scan. Thanks archon810 from AndroidPolice.

I can't remember why I change it because it is ages ago, but before that it was on COOKIEPATH

foliovision commented 8 years ago

Hello Lester,

my guess is that somebody had COOKIEPATH broken on their site but SITECOOKIEPATH set properly.

wp_set_comment_cookies() seems to work with COOKIEPATH: https://github.com/WordPress/WordPress/blob/master/wp-includes/comment.php#L515-L517

So I'm thinking perhaps the issue was with admin-ajax.php.

WordPress login seems to be setting the cookie for both, you could be doing something similar in your plugin: https://github.com/WordPress/WordPress/blob/master/wp-login.php#L415-L417

Thanks, Martin