• Hi,
    I want to at some special code in my post, so I used the ‘edit html source’ option, where I pasted my code. It is code to show a gmapez google map, with some own modified lightbox-script (so I could not use a default plugin). Now this code contains some div’s and a ordened list for showing a route on the map. But unfortunally wordpress is setting everywhere paragraph <p> and break <br> tags. How can prevent this, because on this way, my cool map doesnt work… 🙁

Viewing 8 replies - 1 through 8 (of 8 total)
  • I’d suggest nixing the visual rich editor (Users > Your Profile, Personal Options) and see if you can insert the code using the basic editor.

    Thread Starter maximus43

    (@maximus43)

    Unfortunally it doesn’t work. I tried this, with adding the html directly in the database, but with showing the content, wordpress is again adding some <p> and <br>

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Are you trying to paste javascript into a post? If so, try using my little plugin to help this along.

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

    It should prevent WordPress from messing with your javascripts.

    Thread Starter maximus43

    (@maximus43)

    Well, it is not really javascript. I use some functions, but I included them (directly in the source. It is not a nice solution, but it works), but the data hava to be specified in html (I use the gmapez tool). For example:

    http://bluweb.com/us/chouser/gmapez/start.html

    To add a marker to my google map (with gmapez), I use:
    <div class=”GMapEZ” style=”width: 300px; height: 300px;”>


    </div>

    But WP is messing this by adding <P> and <BR> tags.
    Also drawing a line with gmapez is the

      and

    1. tag. WP is also messing this up…

    But Otto, your script looks interesting. Is it possible to extend or change the script that wordpress doesn’t mess up my html??

    for example everything between an artificial <nomess> tag:

    <nomess>
    <div>some data that should not be messed up</div>

    EXTENT

    </nomess>

    I don’t know so much about the inner structure of wordpress (there are so many functions). Do you know how I should do that?

    Thread Starter maximus43

    (@maximus43)

    hmzz. now is the link interpreted as a link: There should be the html of a link, like in gmapez…

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    oops – ignore this

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    But Otto, your script looks interesting. Is it possible to extend or change the script that wordpress doesn’t mess up my html??

    Sure. Open the plugin in a text editor. There’s two functions, a Pre and a Post. The Pre takes out the relevant code before WordPress messes with it, and the Post puts it back afterwards. If you wanted to have a “nomess” sort of tag, you could change the regular expressions accordingly.

    In the Pre, you’ll find this:
    if (preg_match_all("{\<script(.*)\<\/script\>}siU", $text, $temp)) {

    Change that to this:
    if (preg_match_all("{\<nomess\>(.*)\<\/nomess\>}siU", $text, $temp)) {

    Now it looks for nomess tags. You just have to fix the post portion to put the stuff back correctly. So in there, find this:
    $text = str_replace('<!-- h'.$k.'h -->', '<script'.$v.'</script>', $text);

    And change it to this:
    $text = str_replace('<!-- h'.$k.'h -->', $v, $text);

    That will put the text back into your post, but WITHOUT the nomess tags.

    Should work, I think. Haven’t tried it. 🙂

    And if you want a super simple way to insert google maps, try Windows Live Writer: blog page at http://windowslivewriter.spaces.live.com/ and download link at http://g.msn.com/8SEENUS030000TBR/WriterMSI

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Inserting own scriptingcode at a post’ is closed to new replies.