Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Product slider SSL problems WordPress

  • SOLVED

Hi all,
the purchasable product slider plugin (for wp-ecommerce) is giving me some SSL headaches. I'm getting mixed content errors on the checkout page, the reason is below....

I get the following errors in the Google Chrome console:
<blockquote>The page at https://www.naturlea.com/products-page/checkout/ displayed insecure content from http://www.naturlea.com/wp-content/plugins/wpec_product_slider/themes/apple/images/rounded_prev_hover.png.
The page at https://www.naturlea.com/products-page/checkout/ displayed insecure content from http://www.naturlea.com/wp-content/plugins/wpec_product_slider/themes/apple/images/rounded_next_hover.png.</blockquote>

Tried turning off the plugin, errors disappear and SSL is happy as pie, so I'm assuming it's the product slider preloader (wpec_product_slider.php) doing the evil:
function product_slider_preload() {
$theme = product_slider_cur_theme();
echo "<script type='text/javascript'>rn";
echo "if (document.images)rn";
echo "{rn";
echo "image1= new Image(34,70);rn";
echo "image1.src="".WP_PLUGIN_URL."/wpec_product_slider/themes/".$theme."/images/rounded_prev_hover.png"rn";
echo "image2= new Image(34,70);rn";
echo "image2.src="".WP_PLUGIN_URL."/wpec_product_slider/themes/".$theme."/images/rounded_next_hover.png"rn";
echo "}rn";
echo "</script>rn";
}


I'm assuming that as a result of this code, the slider is preloaded for each and every page, even though it's only present on the home page (that's where the product slider is called). Is there some way around this?

I'm using the Wordpress-HTTPS plugin for force SSL, and seems to be doing the job apart from this. I'm not too confident about fixing it, does anyone have some ideas?

Many thanks,
Marcel

Answers (3)

2011-02-04

Denzel Chia answers:

Hi,

I do not know about https, but if you want to load the above code only in home page, just wrap it in a if(is_home()) function, like this.


function product_slider_preload() {
if(is_home()){
$theme = product_slider_cur_theme();

echo "<script type='text/javascript'>rn";

echo "if (document.images)rn";

echo "{rn";

echo "image1= new Image(34,70);rn";

echo "image1.src="".WP_PLUGIN_URL."/wpec_product_slider/themes/".$theme."/images/rounded_prev_hover.png"rn";

echo "image2= new Image(34,70);rn";

echo "image2.src="".WP_PLUGIN_URL."/wpec_product_slider/themes/".$theme."/images/rounded_next_hover.png"rn";

echo "}rn";

echo "</script>rn";

}

}


I assume the above code is either hook into init or wp_head
This will make it load only on home page.

Thanks.
Denzel

2011-02-04

Victor Teixeira answers:

There are some things you may try.

1- using this plugin: http://wordpress.org/extend/plugins/wordpress-https/

or if you want to change the plugin code:

2- try replacing WP_PLUGIN_URL with the plugins_url function - http://codex.wordpress.org/Function_Reference/plugins_url

or:

3- try to change your site url on the Wordpress configuration to an https address (all your site will be https)

2011-02-04

Oleg Butuzov answers:

replace in this code

WP_PLUGIN_URL
by
str_replace('http://', ($_SERVER["HTTPS"] == 'on'?'https://':'http://'), WP_PLUGIN_URL);


folette comments:

Hi Oleg,

I like the look of this solution, but where do I place the code you mentioned?
Also, what would you say the benefits are over Denzel's solution? Will your solution always load the product slider images using https? Does this also mean that I'll get mixed content errors on other pages?

Sorry, that's a lot of questions, but I'm very curious about your solution.

Cheers :)
Marcel


Oleg Butuzov comments:

1) you need to replace the code at the <strong>product_slider_preload</strong> function.
2) denzel solution? what it solve ? https issue?
3) my solution that you slider will produce a links to you depanding https turned on or not.

like for https - links for slider will be https based, same for http, if it http - it will work only http.

you can backup your code and make this small ammendment, just to try it out.

cheers.


Oleg Butuzov comments:

p/s/
code of that functions dosn't looks correct is it parse issues? it had few dbl quotes witch isn't posible for normal php script.