All Good Things Must Come To An End

As you all know, I have been doing WordPress plugins and supporting it for the past 6 years. These 6 years of my life, I have been through my polytechnic education, my national service as well as my university education.

I just graduated from university in December 2009 and have been looking for full-time jobs. I am offered a full-time job and will be starting work on 1st February 2010.

I regret to say that I am NOT ABLE to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

However, I WILL still update my plugins whenever I can and you still can report bugs to me via email and I will try to fix it.

Author Topic: WP site with Subdomains - Stuck on Loading , AJAX - HERE IS THE SOLUTION  (Read 19240 times)

0 Members and 1 Guest are viewing this topic.

Offline lokos

  • Newbie
  • *
  • Posts: 2
    • View Profile
WP 2.6.5 - # WP-PostRatings  1.3.1

So I came to this forum with the same problem a lot of people was having. When I tried to rate a post on Firefox the "loading" image stayed there forever.

After reading some answers here I realized that my problems was caused by subdomain plugin that allow me to create subdoimains for some categories, so I could access a category with http://category.mysitedomain.com and this was blocking the ajax request in Firefox and causing that the loading image got stuck. (This problem also occurs if you access your site thought http://domain.com instead of http://www.domain.com)

Here is how I fixed this issue:
Paste this function on the functions.php of your theme

function get_site_url(){
$domain = $_SERVER['SERVER_NAME'];
$domain = str_replace('www.', '', $domain);
$site_url = 'http://' . $domain;
return $site_url;
}

Then replace these lines on wp-postratings.php:

wp_register_script('wp-postratings', WP_PLUGIN_URL.'/wp-postratings/postratings-js-packed.js', false, '1.31');
with:
wp_register_script('wp-postratings', get_site_url().'/wp-content/plugins/wp-postratings/postratings-js-packed.js', false, '1.31');

echo "\t".'var ratings_plugin_url = \''.WP_PLUGIN_URL."/wp-postratings';\n";
with:
echo "\t".'ratings_plugin_url = \''.get_site_url().'/wp-content/plugins/wp-postratings/'."';\n";

echo "\t".'var ratings_ajax_url = \''.WP_PLUGIN_URL.'/wp-postratings/wp-postratings.php'."';\n";
with:
echo "\t".'var ratings_ajax_url = \''.get_site_url().'/wp-content/plugins/wp-postratings/wp-postratings.php'."';\n";


This will change the domain the plugin uses to defined the variables and register the script on the head for the ajax request with the domain you use to access the post page.

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Thanks for sharing! I have stickied the topic

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Herb

  • Newbie
  • *
  • Posts: 2
    • View Profile
Hi,

i have the same Problem with WP 2.7.1 and WP-Postratings 1.4. Only on Firefox (version 3.0.6) stays the loading image all time. (Page brettspiele-report.de. Installed only on single.php).

I have tested it with the default Theme, all other PlugIns disabled, but the loading image still stays. I am not using a "subdomain plugin".

Due to the Code change between 1.3.1 and 1.4 in WP-Postratings, the lines to replace in the solution from "Lokos" are not there any more.

Could some please tell me if they are still the same small changes to do in the code to solve the problem as in version 1.3.1? and how the changes looks like in version 1.4.

thanks

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
For WP-PostRatings 1.50.

You still need to place this function in your theme functions.php:
Code: [Select]
function get_site_url(){
$domain = $_SERVER['SERVER_NAME'];
$domain = str_replace('www.', '', $domain);
$site_url = 'http://' . $domain;
return $site_url;
}

Replace (in wp-postratings.php):
Code: [Select]
'plugin_url' => plugins_url('wp-postratings'),
'ajax_url' => plugins_url('wp-postratings/wp-postratings.php'),
With:
Code: [Select]
'plugin_url' => get_site_url().'/wp-content/plugins/wp-postratings',
'ajax_url' => get_site_url().'/wp-content/plugins/wp-postratings/wp-postratings.php',

Replace:
Code: [Select]
wp_enqueue_script('wp-postratings', plugins_url('wp-postratings/postratings-js.js'), array('jquery'), '1.50', true);With:
Code: [Select]
wp_enqueue_script('wp-postratings', get_site_url().'/wp-content/plugins/wp-postratings/postratings-js.js', array('jquery'), '1.50', true);
Replace:
Code: [Select]
if(@file_exists(TEMPLATEPATH.'/postratings-css.css')) {
wp_enqueue_style('wp-postratings', get_stylesheet_directory_uri().'/postratings-css.css', false, '1.50', 'all');
} else {
wp_enqueue_style('wp-postratings', plugins_url('wp-postratings/postratings-css.css'), false, '1.50', 'all');
}
if('rtl' == $text_direction) {
if(@file_exists(TEMPLATEPATH.'/postratings-css-rtl.css')) {
wp_enqueue_style('wp-postratings-rtl', get_stylesheet_directory_uri().'/postratings-css-rtl.css', false, '1.50', 'all');
} else {
wp_enqueue_style('wp-postratings-rtl', plugins_url('wp-postratings/postratings-css-rtl.css'), false, '1.50', 'all');
}
}
With:
Code: [Select]
if(@file_exists(TEMPLATEPATH.'/postratings-css.css')) {
wp_enqueue_style('wp-postratings', get_stylesheet_directory_uri().'/postratings-css.css', false, '1.50', 'all');
} else {
wp_enqueue_style('wp-postratings', get_site_url().'/wp-content/plugins/wp-postratings/postratings-css.css', false, '1.50', 'all');
}
if('rtl' == $text_direction) {
if(@file_exists(TEMPLATEPATH.'/postratings-css-rtl.css')) {
wp_enqueue_style('wp-postratings-rtl', get_stylesheet_directory_uri().'/postratings-css-rtl.css', false, '1.50', 'all');
} else {
wp_enqueue_style('wp-postratings-rtl', get_site_url().'/wp-content/plugins/wp-postratings/postratings-css-rtl.css', false, '1.50', 'all');
}
}
« Last Edit: 14 September 2009, 04:46 by GaMerZ »

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Herb

  • Newbie
  • *
  • Posts: 2
    • View Profile
Thanks for the quick response!

Meanwhile it functions without theses changes, do not know why?! It has to be some kind of Wordpress-Mystic ;-)

But will implement your changes...

Update: After doing the changes my wordpress-installation is not working anymore. Changed to the status before and it is working well again.

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Because I think the plugins_url() solves the problem of hard coded URL in 1.40

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline calfrog

  • Newbie
  • *
  • Posts: 1
    • View Profile
Hi.

I have Wordpress installed on one domain (hxxp://mydomain1.com/wp).

I added a subdomain of another domain to point to the same directory (hxxp://mysubdomain.mydomain2.com) and I changed Settings > Blog address point to that.

Then I started to having the "loading image stayed there forever." problem when I tried to rate.

I then saw this thread and applied the 1.40 version of the fix. Now my problem has changed.

Without trying to rate "loading..." stays forever and the circle spin around forever, but the image of the ratings have actually been loaded. (I see the yellow stars)

How can I fix this?

Thanks.

////////////////////

wp:Version 2.7.1
theme:Emporium 2.0
plug-in:WP-PostRatings v1.40
not sure about php and mysql version
blog url:editedout

« Last Edit: 21 March 2009, 16:10 by calfrog »

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Because hxxp://mysubdomain.mydomain2.com and hxxp://mydomain1.com/wp are different URL and hence your browser block the AJAX request for security reasons.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline ilgilibirbilgi

  • Newbie
  • *
  • Posts: 2
    • View Profile
Hi,

I have the same problem; it stucks and i have read and tried all ways (head php/this thread/reinstall/ etc) to solve the problem, but i still couldn't.

This is my test subdomain: http://eskisehir.ilgilibirbilgi.com/ I disabled the plugin on http://www.ilgilibirbilgi.com/

   1.  WordPress Version: 2.7.1
   2. Theme Name:Modern Notepad 1.92
   3. Blog URL: http://www.ilgilibirbilgi.com/
   4. Problem Plugin Name And Version: WP-PostRatings 1.40
   5. PHP And MYSQL Version: PHP version 5.2.8 / MySQL version   5.0.67-community

Thanks in advance and thanks for the plugin.

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Check your error log, http://eskisehir.ilgilibirbilgi.com/wp-content/plugins/wp-postratings/wp-postratings.php?pid=18&rate=5&rndval=1238130553827 is returning me a server error 500.

Also switch to the default theme and disable all other plugins to see if this problem persists.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline ilgilibirbilgi

  • Newbie
  • *
  • Posts: 2
    • View Profile
It persists...:-\

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Check your error_log

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline donorsi

  • Newbie
  • *
  • Posts: 1
    • View Profile
Hi guys and Lester

I alwys hate when my first post in a forum is a problem but after few hours of trial and error i have to do it.

The problem is same, Loading image shows forever and rating is not counted.

Here is more details about the install. Url is http://www.neatmovieslist.com/. It uses wp 2.7.1, wp-ratings plugin 1.40 and WP subdomains plugin. WP is installed in a folder, /wpblog/ and mapped to domain root. This should not be a problem since everything worked fine untill i installed the subdomains plugin. However, it still does not work even after i have made all changes mentioned here.

I even tried the "trick" Lester tried on another domain. I loaded in a browser http://action.neatmovieslist.com/wpblog/wp-content/plugins/wp-postratings/wp-postratings.php?pid=48&rate=5&rndval=1238130553827

That worked fine, rating was counted, but still, from post itself, it does not work. I am stucked with that Loading image.

Any help here will be greatly appreciated, really want to start this blog..

Thanks
Don

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Sorry, I am not using the sub domains plugin, perhaps you can drop lokos a PM or an email. He should be more knowledgeable then me in this area.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline bcee

  • Newbie
  • *
  • Posts: 8
    • View Profile
Great info. Thanks.

Offline meadorni

  • Newbie
  • *
  • Posts: 5
    • View Profile
 I got stuck on loading when I was testing my site in a subdomain. I couldn't find the code in wp-postratings.php that you suggested changing...so I put it off. Now the site is in a root domain and I'm still having the problem with the plugin. I tried deactivating all other plugins and switching to the default theme. This caused the ratings plugin to disappear from the post. Here's an example on my site:

http://www.supraterranean.com/2009/09/13/skinemax-i-women-of-the-future/

Thanks for your help. I appreciate your plugins.

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
meadorni: If you install WP on a subdomain, you do not need this code. This code is for users who have multiple subdomains, each subdomain for each category, this is done by a plugin. If you switch the theme to the default, you need to add it the php code to the default theme as well.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
I have updated the code in Reply #3 (http://forums.lesterchan.net/index.php/topic,3198.msg23862.html#msg23862) to WP-PostRatings 1.50, test it out and let me know

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline meadorni

  • Newbie
  • *
  • Posts: 5
    • View Profile
When I keep the desired theme and make the (updated) suggested changes to the code, I get this error:

Warning: Cannot modify header information - headers already sent by (output started at /home/headdres/public_html/supraterranean/wp-content/themes/linoluna/functions.php:16) in /home/headdres/public_html/supraterranean/wp-includes/pluggable.php on line 865

When I switch to default theme, disable all other plugins, and add the first bit of code to the default functions.php, I get this error:

Fatal error: Call to undefined function get_site_url() in /home/headdres/public_html/supraterranean/wp-content/plugins/wp-postratings/wp-postratings.php on line 131

Do you know what kind of conflicts can happen with other plugins? Thanks for your help!

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
You sure you need the modification at all, from what you have posted, it seems that you are just trying to install WP on subdomain that is all and not having each category of WP for each subdomain.

In that case you do not need this modification. Undo what you have did and ensure you have <?php wp_head(); ?> in your theme header.php and <?php wp_footer(); ?> in your theme footer.php.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.