WordPress.org

Forums

PHP Code Widget
[resolved] Parse error in php-code-widget/execphp.php(27) : eval()'d code on line 4 (5 posts)

  1. ReactorShop
    Member
    Posted 1 year ago #

    I'd really like to thank you for this plugin. It does the job really good.

    The only issue I have is that I'm currently showing a translation link inside a widget, but since the url for this link is http, I can't load it inside the widget without braking the browser padlock.

    I need to show it when doing http insecure connections, and hide it when the connection is done over SSL.

    This is what I put inside the PHP code widget:

    <?php if ( is_ssl() ) { esc_html_e( '<a href="http://free-website-translation.com/" id="ftwtranslation_button" hreflang="en" title="" style="border:0;"><img src="http://free-website-translation.com/img/fwt_button_en.gif" id="ftwtranslation_image" alt="FWT Homepage Translator" style="border:0;"/></a> <script type="text/javascript" src="http://free-website-translation.com/scripts/fwt.js" /></script>' ); } else { esc_html_e( 'Translations not available on secure connections.' ); ?>

    The issue is that every time the widget is loaded, I get the error I posted above, and I see that the error occurs when doing the eval.

    Is there a way to format the above code in order for it to appear when on SSL and show the text message when doing an http insecure connection?

    I'll appreciate any advice you may provide.

    http://wordpress.org/plugins/php-code-widget/

  2. Samuel Wood (Otto)
    WordPress.org Tech Guy
    Plugin Author

    Posted 1 year ago #

    This really doesn't have anything to do with the plugin, but I'll answer your question.

    The link isn't the problem. Your image and script URLs are. You need to change those to either be https all the time, or change them to be protocol-relative URLs.

    However, since "https://free-website-translation.com/img/fwt_button_en.gif" doesn't actually work, you'll have to copy the image locally and use the local URL instead.

    The padlock breaks when you load HTTP resources on an HTTPS page. If you want the padlock to not break, everything on the page must be available through HTTPS.

  3. Samuel Wood (Otto)
    WordPress.org Tech Guy
    Plugin Author

    Posted 1 year ago #

    Also, the is_ssl() code you're trying to use works, but it relies on the server accurately reporting if the current connection is SSL or not. It checks to see if $_SERVER['HTTPS'] is set, or if the $_SERVER['SERVER_PORT'] is 443 (which is the default https port). If you are using some other different kind of webserver than Apache, it may not be accurate for that case.

  4. Samuel Wood (Otto)
    WordPress.org Tech Guy
    Plugin Author

    Posted 1 year ago #

    ... and I just noticed, but you have your logic backwards. You're outputting the link *only* on SSL connections. is_ssl() returns true on SSL connections.

    Try reversing the order of your two pieces of code there. :)

  5. ReactorShop
    Member
    Posted 1 year ago #

    Got it. I was missing the last closing curly brace.

    Thank you for the heads up with the is_ssl() function. I'm switching my website from port 80 to port 443 and back depending if the page displayed requires user input or not (for now I'm doing this in my testing environment). The production server and my testing environment run Apache.

    I can't change that script because it's not hosted in my website and as you noticed, that translation website doesn't support ssl connections. That's why I'm excluding it from my HTTPS pages.

    Thank you for your help.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic