WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#2346 closed defect (bug) (fixed)

wordpress editor adds <br /> after each line, breaking adsense code (and this is without the wysiwyg editor)

Reported by: howtoblog Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.0
Component: Administration Keywords: bg|has-patch
Focuses: Cc:

Description

I have the wysiwyg editor turned OFF.

I created a page with a slug of sidebar.

For it's contents I pasted the following code:

<strong>Make money from blogging!</strong>
<script type="text/javascript"><!--
google_ad_client = "pub-5867545511806378";
google_ad_width = 125;
google_ad_height = 125;
google_ad_format = "125x125_as_rimg";
google_cpa_choice = "CAAQ3bWazgEaCIDpU7OcSSWsKJ_D93M";
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

and that is how it appears in the html editor every time I go to edit the page.

Yet when the page is displayed in the browser, wordpress adds a <br /> after each line so that when you view the source you can see the code now looks like:

<script type="text/javascript"><!--<br />
google_ad_client = "pub-5867545511806378";<br />
google_ad_width = 125;<br />
google_ad_height = 125;<br />
google_ad_format = "125x125_as_rimg";<br />
google_cpa_choice = "CAAQ3bWazgEaCIDpU7OcSSWsKJ_D93M";<br />
//--></script><br />
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"><br />
</script>

This makes the Google Adsense ads not render in IE 6, and the status bar says, "Done, but with errors on page" after it loads the page.

While the Google Ads do display when viewed in Firefox, a view of the source shows the same problem with the code.

How can I get it to just take my html directly and not do anything to it???

See http://www.emilyrobbins.com/how-to-blog/sidebar/ for example.

Attachments (1)

no-newlines.diff (5.4 KB) - added by NathanWong 8 years ago.

Download all attachments as: .zip

Change History (2)

NathanWong8 years ago

comment:1 NathanWong8 years ago

  • Keywords bg|has-patch added
  • Priority changed from high to normal
  • Resolution set to fixed
  • Status changed from new to closed

I've attached a patch (from current SVN revision) for this, though it's not perfect (mainly it completely skips the call of wpautop, whether or not that's a problem I'm not sure). I'm not sure if this'll be used by WP, but hopefully it helps you. Enjoy.

Note: See TracTickets for help on using tickets.