June 12, 2008

Hana Code Insert WordPress Plugin

Filed under: WordPress — HanaDaddy @ 5:32 pm

Inserting some javascript or Html codes in the middle of an article is not an easy task. It’s hard to copy and paste bunch of codes into the article whenever you write an article. Sometimes, the code breaks and doesn’t work as intended because WordPress encodes HTML entities.

So I decided to come up with the plugin that will help me insert that AdSense or Paypal Donation code into the middle of article.

Download Hana Code Insert Plugin v1.0


Now with my plugin, Hana Code Insert, you can easily insert any complicated HTML and JAVASCRIPT code or even custom PHP output in your Wordpress article. Useful for adding AdSense and Paypal donation code in the middle of the WP article. You can manage multiple code entries.

After the plugin installation, you would setup the HTML or Javascript entries in the ‘Hana Code Insert’ Settings menu. Simply define a unique name and paste the complicated codes copied from AdSense or Paypal into the textarea. Then click on the ‘Create a new entry’ button.

After the creation, you can find that the newly added entry is shown in the bottom. Copy the usage code example and insert it in your article. That’s all.

Basically, you can place the specific tag element [hana-code-insert name='...' /] in your wordpress article to show the codes. The ‘name’ attribute is mandatory where you use the name of the code entry that you want to show.

For example, after you setup a code entry in the admin Settings with the name ‘AdSense’, you can invoke the code by using below element in your article.

[hana-code-insert name='AdSense' /]

Below is the Admin Settings (Options) Screen for ‘Hana Code Insert’. Four code entries are defined.

Here are the actual working samples.

[hana-code-insert name='donation' /]


[hana-code-insert name='donation with amount' /]

Did you enjoy my article or software? Thank you for the donation.
US $

[hana-code-insert name='adsense' /]

Note:
Also, you can use PHP codes. If you enable the ‘Evaluate as php code.’ option, the code entry will be evaluated as php codes. The output string will be embeded in the middle of your WP article. However, this option is disabled by default since it can be dangerous. If you want to enable the option, you need to edit the $WP_HOME/wp-content/plugins/hana-code-insert/hana-code-insert.php. Then, change var $eval_php=false; to var $eval_php=true;.

class hana_code_insert
{
	//---------------------------------------------
	// variable that can be modified
	//---------------------------------------------
	var $eval_php=false;	//Change this value to true to activate PHP eval.
	var $edit_col=80; 	//Textarea columns
	var $edit_row=5;  	//Textarea rows
	var $edit_wrap='on'; //off: wrap='off' , on : wrap='soft'
	//---------------------------------------------

	...

Now this is an actual example showing the current local time. If you refresh the page, you can see that the time changes and reflecting the latest time. This is not javascript, but created by PHP codes inserted in the middle of this blog! (Note that if you have Super Cache plugin installed and enabled, this PHP code may not work correctly.)

Result

12/01/2008 17:13:20

Here is the actual code used when setting up in the Settings/Options page with name “php example”.

print "<div style='border:1px dotted red; padding: 5px;'>";
print date("m/d/Y H:i:s"); 
print "</div>";

And here is the text inserted in the middle of the article.

[hana-code-insert name='php example' /]

If you have any question, leave in the comment section.

Thank you.

5 Comments »

  1. Hi:
    We bought Email Marketing 5.0, created the forms and pasted the HTML code generated by EM into one of our pages in WordPress ver 2.6 in the HTML section of the editor.

    The issue is that the captcha image in order to submit the fomr is not displayed. I think might have to do with WP editor.

    Any clues.

    Thanks,

    Charles

    Comment by charles — August 4, 2008 @ 12:02 am

  2. charles, are you actually using my plugin and having problem?
    If you see your test html output, ampersand and double quotes are transformed into corresponding HTML entities by WordPress. If you actually use my plugin, this problem can be fixed.


    <script>
    var url = "http://www.jurisad.com/em/admin/resources/form_designs/captcha/index.php?c=" + getRandom(1,1000)+ "&#038;ss=” + SetSID();
    document.write(”<img src=’” + url + “‘ alt=’img’/>&#8220;);
    </script>

    Comment by HanaDaddy — August 4, 2008 @ 8:08 am

  3. Hanna:

    Thank you so much for the reply.

    When I posted I have not installed yet your plugin. Now it is installed and everything working fine.

    Thanks again.

    Excellent plugin.

    Charles

    Comment by charles — August 5, 2008 @ 8:37 pm

  4. I am glad that my plugin helped you. Thank you.

    Comment by HanaDaddy — August 5, 2008 @ 9:31 pm

  5. Good thinking. This is something I have had the need for a lot lately. I am going to download this and give it a whirl.

    Have you tested this on Wordpress MU by chance?

    Comment by Ryan Gerardi — September 24, 2008 @ 2:04 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

 

42 queries. 0.411 seconds. Powered by WordPress