<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>GuideCloud.com &#187; WP Plugins</title>
	<atom:link href="http://www.guidecloud.com/tag/wp-plugins/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.guidecloud.com</link>
	<description>WordPress, PHP and other development related stuff</description>
	<lastBuildDate>Tue, 05 Jul 2011 09:59:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Writing your own iframe shortcode plugin for WordPress</title>
		<link>http://www.guidecloud.com/2010/07/14/writing-your-own-iframe-shortcode-plugin-for-wordpress/</link>
		<comments>http://www.guidecloud.com/2010/07/14/writing-your-own-iframe-shortcode-plugin-for-wordpress/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 20:47:19 +0000</pubDate>
		<dc:creator>GuideCloud.com</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Iframe]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Shortcodes]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP Plugins]]></category>

		<guid isPermaLink="false">http://www.guidecloud.com/?p=43</guid>
		<description><![CDATA[When you want simplify publishing of specific elements or code chunks, WordPress Shortcodes might come in handy. Basically it replaces a piece of text that you insert via the editor with something else, defined in your template or in a plugin. <a href="http://www.guidecloud.com/2010/07/14/writing-your-own-iframe-shortcode-plugin-for-wordpress/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When you want simplify publishing of specific elements or code chunks, <a title="WordPress Shortcode API" href="http://codex.wordpress.org/Shortcode_API" target="_blank">WordPress Shortcodes</a> might come in handy. Basically it replaces a piece of text that you insert via the editor with something else, defined in your template or in a plugin.</p>
<p>Here&#8217;s an example on how to create a plugin that allows you to insert iframes using shortcodes. Regular iframe tags can be inserted via the HTML editor in WordPress, but the example below will give you a hint on what it can be used for.</p>
<pre class="brush: php;">
&lt;?php
/*
Plugin Name: Iframe Shortcode Plugin
Plugin URI: http://www.guidecloud.com/2010/07/14/writing-your-own-iframe-shortcode-plugin-for-wordpress/
Description: Add iframes to Posts and Pages within WordPress.
Author: GuideCloud.com
Version: 1.0
Author URI: http://www.guidecloud.com/
License: GPL2
*/

class guidecloud_iframe_shortcode {
    function shortcode($atts, $content=null) {
		extract(shortcode_atts(array(
			'url' 	=&gt; '',
			'scrolling' 	=&gt; 'no',
			'width' 	=&gt; '100%',
			'height' 	=&gt; '500',
			'frameborder' 	=&gt; '0',
			'marginheight' 	=&gt; '0',
		), $atts));

		if (empty($url)) return '&lt;!-- Iframe: You did not enter a valid URL --&gt;';

	return '&lt;iframe src=&quot;'.$url.'&quot; title=&quot;&quot; scrolling=&quot;'.$scrolling.'&quot; width=&quot;'.$width.'&quot; height=&quot;'.$height.'&quot; frameborder=&quot;'.$frameborder.'&quot; marginheight=&quot;'.$marginheight.'&quot;&gt;&lt;a href=&quot;'.$url.'&quot; target=&quot;_blank&quot;&gt;'.$url.'&lt;/a&gt;&lt;/iframe&gt;';
    }
}

add_shortcode('iframe', array('guidecloud_iframe_shortcode', 'shortcode'));
?&gt;
</pre>
<p>Create a new file called iframe-shortcode.php, paste the code above and upload it to your wp-content/plugins/ directory. Go to &#8220;Plugins&#8221; in your WordPress administration and activate the plugin.</p>
<p>Once the plugin has been activated you can place iframe shortcodes, like the example below, into your WordPress posts.</p>
<pre class="brush: php;">
[iframe url=&quot;http://www.linktoiframe.com/iframepage/&quot; height=&quot;500&quot; width=&quot;100%&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; marginheight=&quot;0&quot;]
</pre>
<p>You can also download the plugin here:<br />
<a title="Download the WordPress Iframe Shortcode Plugin" href="http://www.guidecloud.com/wp-content/uploads/2010/07/iframe-shortcode.zip" target="_blank">WordPress Iframe Shortcode Plugin</a></p>
<p>More reading:</p>
<ul>
<li><a title="How to write a WordPress plugin" href="http://codex.wordpress.org/Writing_a_Plugin" target="_blank">Writing a plugin &#8211; WordPress Codex</a></li>
<li><a title="More about the WordPress Shortcode API" href="http://codex.wordpress.org/Shortcode_API" target="_blank">WordPres Shortcode API</a></li>
</ul>



Share this post:


	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.guidecloud.com%2F2010%2F07%2F14%2Fwriting-your-own-iframe-shortcode-plugin-for-wordpress%2F&amp;title=Writing%20your%20own%20iframe%20shortcode%20plugin%20for%20WordPress&amp;bodytext=When%20you%20want%20simplify%20publishing%20of%20specific%20elements%20or%20code%20chunks%2C%20WordPress%20Shortcodes%20might%20come%20in%20handy.%20Basically%20it%20replaces%20a%20piece%20of%20text%20that%20you%20insert%20via%20the%20editor%20with%20something%20else%2C%20defined%20in%20your%20template%20or%20in%20a%20plugin." title="Digg"><img src="http://www.guidecloud.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.guidecloud.com%2F2010%2F07%2F14%2Fwriting-your-own-iframe-shortcode-plugin-for-wordpress%2F" title="Sphinn"><img src="http://www.guidecloud.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.guidecloud.com%2F2010%2F07%2F14%2Fwriting-your-own-iframe-shortcode-plugin-for-wordpress%2F&amp;title=Writing%20your%20own%20iframe%20shortcode%20plugin%20for%20WordPress&amp;notes=When%20you%20want%20simplify%20publishing%20of%20specific%20elements%20or%20code%20chunks%2C%20WordPress%20Shortcodes%20might%20come%20in%20handy.%20Basically%20it%20replaces%20a%20piece%20of%20text%20that%20you%20insert%20via%20the%20editor%20with%20something%20else%2C%20defined%20in%20your%20template%20or%20in%20a%20plugin." title="del.icio.us"><img src="http://www.guidecloud.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.guidecloud.com%2F2010%2F07%2F14%2Fwriting-your-own-iframe-shortcode-plugin-for-wordpress%2F&amp;t=Writing%20your%20own%20iframe%20shortcode%20plugin%20for%20WordPress" title="Facebook"><img src="http://www.guidecloud.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.guidecloud.com%2F2010%2F07%2F14%2Fwriting-your-own-iframe-shortcode-plugin-for-wordpress%2F&amp;title=Writing%20your%20own%20iframe%20shortcode%20plugin%20for%20WordPress" title="Mixx"><img src="http://www.guidecloud.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.guidecloud.com%2F2010%2F07%2F14%2Fwriting-your-own-iframe-shortcode-plugin-for-wordpress%2F&amp;title=Writing%20your%20own%20iframe%20shortcode%20plugin%20for%20WordPress&amp;annotation=When%20you%20want%20simplify%20publishing%20of%20specific%20elements%20or%20code%20chunks%2C%20WordPress%20Shortcodes%20might%20come%20in%20handy.%20Basically%20it%20replaces%20a%20piece%20of%20text%20that%20you%20insert%20via%20the%20editor%20with%20something%20else%2C%20defined%20in%20your%20template%20or%20in%20a%20plugin." title="Google Bookmarks"><img src="http://www.guidecloud.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.guidecloud.com/2010/07/14/writing-your-own-iframe-shortcode-plugin-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

