• I tried to get paid support from an expert on Digital Point, yet he was stumped! I am open to paid support if this is too complex to answer here…

    I want a simple Firefox Referral button after my text on this page: https://www.raisingsmallsouls.com/meet-ellen-c-braun/

    It’s WP 2.0 and Gila theme, with several tweaks I did.

    That page is a WP page, not post.

    You can view the source and see the firefox info from google in there.

    I know that the code needs to be this:

    <script type=”text/javascript”><!–
    google_ad_client = “pub-4625291688287995”;
    google_ad_width = 120;
    google_ad_height = 60;
    google_ad_format = “120x60_as_rimg”;
    google_cpa_choice = “CAAQ2eOZzgEaCD4zuVkdzt_CKI-293M”;
    //–></script>
    <script type=”text/javascript” src=”https://pagead2.googlesyndication.com/pagead/show_ads.js”&gt;
    </script>

    and I know that you see only this:

    <script type=”text/javascript”><!–
    google_ad_client = “pub-4625291688287995”;
    google_ad_width = 120;
    google_ad_height = 60;
    google_ad_format = “120x60_as_rimg”;
    google_cpa_choice = “CAAQ2eOZzgEaCD4zuVkdzt_CKI-293M”;
    //–></script>
    <script type=”text/javascript”> </script><script type=”text/javascript”> </script>

    I keep trying (for a month now!) to put it in correctly, yet somehow it’s not “taking” it!! Very weird!

    You can contact me directly through that page.

    Thanks in advance!

Viewing 15 replies - 16 through 30 (of 37 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    I found some php that helped using Google. I had to modify it and it’s not the most elegant solution in the world, but…

    Add this to the bottom of functions-formatting.php:
    function scriptFixer($text)
    {
    if (preg_match_all("{\<script\>(.*)\<\/script\>}siU", $text, $temp)) {
    while (list($k, $v) = each($temp[0])) {
    $text = str_replace($v, '<!-- h'.$k.'h -->', $text);
    $html[$k] = $temp[1][$k];
    }
    $text = preg_replace('|(?<!<br />)s*n|', "<br />n", $text);
    while (list($k, $v) = each($html)) {
    $text = str_replace('<!-- h'.$k.'h -->', '<script>'.$v.'</script>', $text);
    }
    }
    else {
    $text = preg_replace('|(?<!<br />)s*n|', "<br />n", $text);
    }
    return $text;
    }

    Then look in the wpautop() function. There’s a single line in there that looks like this:
    if ($br) $pee = preg_replace(...

    Replace that line with this:
    if ($br) $pee = scriptFixer($pee);

    Should work. I make no guarantees, as I haven’t tested it on an actual site yet. ??

    I wonder if this could be added in functions.php in a theme? It would be nice to do that, or even better, make it a plugin. Do we collectively know enough to do something like this? ( manstraw slyly looks at Otto ??

    Thread Starter ellencbraun

    (@ellencbraun)

    I truly wish I could implement this; however your very first line stumped me: What is functions-formatting.php ????

    If you care to contact me thru the page in question I’d be glad to give you my login info… you seem to be pretty smart people!

    Thanks again from one who disagrees that code is poetry;)

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    It would be nice to do that, or even better, make it a plugin.

    It could be made into a plugin. You’d have to replace the wpautop filter on the_content with your own, basically.

    I’ll give it a shot this evening and do some testing and such.

    If you need some help with testing or anything, I’m on standby. I’ve written a plugin or two, but I think you’ve got a lot more coding experience than I do. Still, if there is something you think I can help with, let me know.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Alright, first go at it. Seems to work on the very limited testing I did.

    https://ottodestruct.com/wpstuff/scriptenabler.zip

    hmm. I’ve tested it with wordpress 2.0.3. Still getting the br’s inside the script tags. I’m going to start turning off plugins and test further.

    update: i’ve turned off all other plugins, and I’m stilling the br’s added. I’m using the script above as my test script.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Ah.. Yes, I forgot to mention that.

    Remove the type="text/javascript" from any script tags you use. The plugin only recognizes <script>...</script> exactly. The type attribute isn’t really necessary anyway.

    And there we are, removing the type was the shiz.

    Something I can’t get rid of is the src, so I get the br’s on the second piece of the script. I’ll have a look to see if your script could be changed to look for <script instead of <script>. reg expressions cause my brain to sprain though. I really should get around to studying them up and get comfortable reading them.

    yep, not as simple as I was hoping it would be. I guess it needs to also hold what’s between <script and > to work with attributes inside the script tag. I’d have to study up to know the right way to do that. But if you don’t take it on Otto, I suppose I’ll start studying. I consider it an important thing to accommodate.

    I actually think this plugin would be extremely useful to many people. Good work Otto.

    This issue is being caused by newlines which are converted to BR tags right? Wouldn’t it be easier to just remove those newline characters from between those script tags?

    Those newlines are there for human readability only anyway.

    It’s a good point nazgul, but a plugin like this has to be useful for noobs. They’ll just cut and paste a script, without an understanding as to why it won’t work.

    You mean something like this? ??

    Edit: I’ve made a small change to it, because now it preserves the newlines, as well as supporting both the script and style tags.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    yep, not as simple as I was hoping it would be.

    Sure it is. Try the new version. Same link as before.

    Otto – oh yeah baby. I’m glad you thought it was easy.

    ah, I see you just moved it. clever donkey! I was trying to code in another (.*). silly me.

    oh well, could be worse, I cudda usta bin smart.

    nazgul – I haven’t checked your change. was it pretty much the same thing?

Viewing 15 replies - 16 through 30 (of 37 total)
  • The topic ‘WP is not accepting the code of Firefox Referral button’ is closed to new replies.