• Will, thanks for a awesome plugin. I am having an one issue. We are using Avada theme, with its page builder, I use a code block with the following code snippet:

    <script>
    $(document).ready(function () {
        var pdf = '[urlparam param="pdf" /]';
        var url = '[insert_php] echo esc_url(get_permalink(pdf)); [/insert_php]';
        window.location = url;
    });
    </script>

    the problem line is this one: var url = ‘[insert_php] echo esc_url(get_permalink(pdf)); [/insert_php]’;
    upon redirect it sends me back a url value of

    https://dev.example.net/thank-you/%5Binsert_php%5D%20echo%20esc_url(get_permalink(pdf));%20[/insert_php].

    So it is not parsing the Insert PHP tags correctly. Any help would be greatly appreciated.

    Thanks,

    Darren

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter dxladner

    (@dxladner)

    Will. I also tried to change it up using an example from your webpage. So I am following this example:
    [insert_php]
    $CookieName = “TestCookie”;
    $RedirectURL = “https://example.com/page.html&#8221;;
    if( empty($_COOKIE[$CookieName]) ) { echo “<script type=’text/javascript’>location.href=’$RedirectURL'</script>”; }
    [/insert_php]

    my new code block
    [ifurlparam param=”pdf”]
    [insert_php]
    $pdf = $_GET[‘pdf’];
    $RedirectURL = esc_url(get_permalink(pdf));
    echo “<script>window.location =’$RedirectURL’;</script>”;
    [/insert_php]
    [/ifurlparam]

    and now my new URL: https://hldwp-dev.azurewebsites.net/thank-you/$RedirectURL.

    again I cannot get the correct valued to be passed.

    Plugin Author WillBontrager

    (@willbontrager)

    Darren, I apologize my delayed reply.

    Try this to see what value esc_url(get_permalink(pdf)) provides.

    <pre>
    [insert_php] echo get_permalink(pdf); [/insert_php]
    <hr>
    [insert_php] echo esc_url(get_permalink(pdf)); [/insert_php]
    </pre>

    Note that the pdf value may need to be in quotes, as get_permalink(“pdf”) and esc_url(get_permalink(“pdf”))

    If you get values, you can see what is being inserted into your JavaScript.

    If you get no values, which is possible because both get_permalink() and esc_url() may be outside the scope of Insert PHP, then check your error logs. There may be a typo in the code or it may be a scope issue. Typos can be fixed. But a scope issue is rather permanent.

    Will

    • This reply was modified 6 years, 12 months ago by WillBontrager.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Insert PHP blocks not working correctly’ is closed to new replies.