lesterchan / wp-postratings

Adds an AJAX rating system for your WordPress blog's post/page.
https://wordpress.org/plugins/wp-postratings/
122 stars 82 forks source link

Fix warning when accessing a 404 page #159

Open 8ctopus opened 1 year ago

8ctopus commented 1 year ago

155

lesterchan commented 1 year ago

Why will this cause an issue on the 404 page? This seems to be a site specific issue. Not closing it because I think there is room for discussions for this

8ctopus commented 1 year ago

@lesterchan When you reach a 404 page, do the WP-PostRatings js and css load or not? In my case, they do load and that causes the problem. With this PR, the problem disappears.

lesterchan commented 1 year ago

Yeap they do load, I think it is your theme issue though, it works on my end with 404, https://lesterchan.net/wordpress/asdasdasdadsd

8ctopus commented 1 year ago

Do you not get any warnings in your php logs?

lesterchan commented 1 year ago

Nope, my variables in the JS got loaded correctly, so that is why I say it is a theme issue, you can view source and see. In the #155, the line you pointing to is the config and it is global, there is no way it doesn't load on 404 page.

My guess is some theme or plugin is trying to do optimization on 404 pages and that breaks the plugin.

<script id='wp-postratings-js-extra'>
var ratingsL10n = {"plugin_url":"https:\/\/lesterchan.net\/wordpress\/content\/plugins\/wp-postratings","ajax_url":"https:\/\/lesterchan.net\/wordpress\/core\/wp-admin\/admin-ajax.php","text_wait":"Please rate only 1 item at a time.","image":"stars_crystal","image_ext":"gif","max":"5","show_loading":"0","show_fading":"0","custom":"0"};
var ratings_mouseover_image=new Image();ratings_mouseover_image.src="https://lesterchan.net/wordpress/content/plugins/wp-postratings/images/stars_crystal/rating_over.gif";;
</script>