Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Why is this shortcode plugin not working? WordPress

I've solved this problem now. WordPress was escaping the attributes on the script tags.



I mustn't have explained this correctly initially as the responses so far haven't made any sense. So here's the simplest way of wording that I can come up with.

(1) The following plugin is not working as expected ... http://pixopoint.com/uploads/pixopoint-adsense_v0_1.zip
(2) If you copy and paste the first block of code below into a WordPress post or page, on publishing (or updating if it already exists), the code should be automagically converted into the second block of text further down this page.
(3) Please fix

* I assume I did something wrong with the 'content_save_pre' filter, but I'm not sure what.


<small>Text before publishing or updating a post/page</small>
BEGINNING
<script type="text/javascript"><!--
google_ad_client = "ca-pub-4209458083008072";
/* test2 */
google_ad_slot = "7550838362";
google_ad_width = 125;
google_ad_height = 135;
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
MIDDLE
<script type="text/javascript"><!--
google_ad_client = "ca-pub-jweiov23v";
/* test3 */
google_ad_slot = "124124v";
google_ad_width = 250;
google_ad_height = 140;
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
END




<small>Text SHOULD look like this after publishing or updating a post/page</small>

jisd wj ewek j wekwh ewkejr wkej wer sd sd
[adsense client="ca-pub-4209458083008072" slot="7550838362" width="125" height="135"]
32 ewiu hehr wejk sd 23w ejk2 jisd wj ewek

jisd wj ewek j wekwh ewkejr wkej wer sd sd
[adsense client="ca-pub-jweiov23v" slot="124124v" width="250" height="140"]
32 ewiu hehr wejk sd 23w ejk2 jisd wj ewek

Answers (2)

2011-01-14

Tobias Nyholm answers:

Use my plugin: http://wordpress.org/extend/plugins/simple-adsense/

It does exactly what you are trying to accomplish.


Ryan Hellyer comments:

Not it doesn't. That is just an Adsense widget.


Tobias Nyholm comments:

Nope, you can use an inline code as well.


Ryan Hellyer comments:

That still doesn't do what my plugin is intended to do. I inserted the Adsense javascript into my post, and it didn't do anything. The same javascript was still present after submission.

2011-01-14

Dan | gteh answers:

Double check that your wordpress theme has this function call inside the footer (likely in footer.php)
wp_footer();


A lot of theme developers forget to put a call to that function in their themes and a lot of plugins require it because they insert code at run-time via that function.


Ryan Hellyer comments:

Huh? This problem is totally unrelated to the theme. I'm trying to filter post content on submission to the database. The theme hasn't even loaded at that point.


Dan | gteh comments:

Oh sorry.. I misunderstood. I thought the problem was that the shortcode was not being translated into what it was supposed to be doing. My bad.


Ryan Hellyer comments:

Even if that was the problem, that still wouldn't help, as wp_footer() doesn't fire until long after the post is served.