<?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>木木木木木 &#187; 短代码</title>
	<atom:link href="http://immmmm.com/tag/%e7%9f%ad%e4%bb%a3%e7%a0%81/feed" rel="self" type="application/rss+xml" />
	<link>http://immmmm.com</link>
	<description>不问明天，悠然浪费</description>
	<lastBuildDate>Mon, 21 May 2012 12:03:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>WordPress 短代码之——Toggle 伸缩</title>
		<link>http://immmmm.com/wordpress-shortcodes-toggle.html</link>
		<comments>http://immmmm.com/wordpress-shortcodes-toggle.html#comments</comments>
		<pubDate>Fri, 21 Jan 2011 14:36:15 +0000</pubDate>
		<dc:creator>林木木</dc:creator>
				<category><![CDATA[折腾无休]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[短代码]]></category>

		<guid isPermaLink="false">http://immmmm.com/?p=1540</guid>
		<description><![CDATA[外话：其实这几天都没咋看书，折腾这折腾那的，都没啥成果。主要原因还是技术不到家，折腾各种API现在都需要Ou什么ath验证的，不会PHP折腾得很蛋疼…… 几天前有童鞋让我集成一个功能到主题里：文章内的短代码伸缩功能。 HTML模式下输入如下代码格式： &#160; [toggle]Google PR更新咯！[/toggle] 效果如下： [toggle]Google PR更新咯！[/toggle] 输入如下代码格式： &#160; [toggle title=&#34;蓝叉冰订婚了&#34;]他89的，咱88的，情何以堪？不堪！[/toggle] 效果如下： [toggle title="蓝叉冰订婚了"]他89的，咱88的，情何以堪？不堪！[/toggle] 这货没啥难度，一直拖到现在发文来凑数。function的php代码： &#160; function single_toggle&#40;$atts, $content=null&#41;&#123; &#160; extract&#40;shortcode_atts&#40;array&#40;&#34;title&#34;=&#62;' ↑ '&#41;,$atts&#41;&#41;; &#160; return '&#60;p class=&#34;tg_t&#34;&#62;'.$title.' ↓ &#60;/p&#62;&#60;p class=&#34;tg_c&#34; style=&#34;display:none;&#34;&#62;'.$content.'&#60;/p&#62;'; &#160; &#125; &#160; add_shortcode&#40;'toggle','single_toggle'&#41;; 两个参数，标题title和内容content，默认标题为“ ↑ ”，默认把内容隐藏了。具体含义见官方函数文档（这儿） 主要留了两个class方便jQuery获取和控制： &#160; //By ImMmMm.com &#160; $&#40;'.tg_t'&#41;.click&#40;function&#40;&#41;&#123;$&#40;this&#41;.next&#40;'.tg_c'&#41;.slideToggle&#40;400&#41;&#125;&#41;; 点击class=tg_t时，让其下一个元素class=&#8217;tg_c&#8217;伸缩，slideToggle神马意思？看jQuery文档的滑动效果属性部分～ 就这样，么了，句号。 哦，PR昨晚凌晨更新了，恭喜小闇家直接从1到3，哟西！～]]></description>
			<content:encoded><![CDATA[<p>外话：其实这几天都没咋看书，折腾这折腾那的，都没啥成果。主要原因还是技术不到家，折腾各种API现在都需要Ou什么ath验证的，不会PHP折腾得很蛋疼……</p>
<p>几天前有童鞋让我集成一个功能到主题里：文章内的短代码伸缩功能。</p>
<p>HTML模式下输入如下代码格式：</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:Microsoft Yahei;">&nbsp;
[toggle]Google PR更新咯！[/toggle]</pre></div></div>

<p>效果如下：<span id="more-1552"></span></p>
<p>[toggle]Google PR更新咯！[/toggle]</p>
<p>输入如下代码格式：</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:Microsoft Yahei;">&nbsp;
[toggle title=&quot;蓝叉冰订婚了&quot;]他89的，咱88的，情何以堪？不堪！[/toggle]</pre></div></div>

<p>效果如下：</p>
<p>[toggle title="蓝叉冰订婚了"]他89的，咱88的，情何以堪？不堪！[/toggle]</p>
<p>这货没啥难度，一直拖到现在发文来凑数。function的php代码：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:Microsoft Yahei;">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> single_toggle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;title&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">' ↑ '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;p class=&quot;tg_t&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$title</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' ↓ &lt;/p&gt;&lt;p class=&quot;tg_c&quot; style=&quot;display:none;&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$content</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/p&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'toggle'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'single_toggle'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>两个参数，标题title和内容content，默认标题为“ ↑ ”，默认把内容隐藏了。具体含义见官方函数文档（<a target='_blank' rel='nofollow' href='http://codex.wordpress.org/Shortcode_API'>这儿</a>）</p>
<p>主要留了两个class方便jQuery获取和控制：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:Microsoft Yahei;">&nbsp;
<span style="color: #006600; font-style: italic;">//By ImMmMm.com</span>
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.tg_t'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.tg_c'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideToggle</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">400</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>点击class=tg_t时，让其下一个元素class=&#8217;tg_c&#8217;伸缩，slideToggle神马意思？看jQuery文档的滑动效果属性部分～</p>
<p>就这样，么了，句号。</p>
<p>哦，PR昨晚凌晨更新了，恭喜<a target='_blank' href='http://www.rinkaiten.com/'>小闇</a>家直接从1到3，哟西！～</p>
]]></content:encoded>
			<wfw:commentRss>http://immmmm.com/wordpress-shortcodes-toggle.html/feed</wfw:commentRss>
		<slash:comments>67</slash:comments>
		</item>
		<item>
		<title>给WordPress主题添加短代码功能</title>
		<link>http://immmmm.com/add-shortcodes-wordpress-theme.html</link>
		<comments>http://immmmm.com/add-shortcodes-wordpress-theme.html#comments</comments>
		<pubDate>Sun, 31 Jan 2010 11:15:05 +0000</pubDate>
		<dc:creator>林木木</dc:creator>
				<category><![CDATA[折腾无休]]></category>
		<category><![CDATA[WordPress技巧]]></category>
		<category><![CDATA[短代码]]></category>

		<guid isPermaLink="false">http://immmmm.com/?p=1253</guid>
		<description><![CDATA[貌似这功能早在WP2.5已经支持，详细的描述请看：http://codex.wordpress.org/Shortcode_API 此文不解释原理（因为俺也说不清），就直接说具体的应用： 一、MP3播放器 1.添加：把以下代码复制至functions.php（注意在php循环内），然后下载mp3player.swf并放至主题根目录，MP3默认不自动播放 &#160; function mp3player&#40;$atts, $content=null&#41;&#123; &#160; extract&#40;shortcode_atts&#40;array&#40;&#34;auto&#34;=&#62;'0'&#41;,$atts&#41;&#41;; &#160; return '&#60;embed src=&#34;'.get_bloginfo&#40;&#34;template_url&#34;&#41;.'/mp3player.swf?url='.$content.'&#38;amp;autoplay='.$auto.'&#34; type=&#34;application/x-shockwave-flash&#34; wmode=&#34;transparent&#34; allowscriptaccess=&#34;always&#34; width=&#34;400&#34; height=&#34;30&#34;&#62;'; &#160; &#125; &#160; add_shortcode&#40;'mp3','mp3player'&#41;; 2.使用：撰写文章时在“HTML模式”下插入以下格式代码即可 &#160; [mp3]MP3文件URL[/mp3] 自动播放代码格式: &#160; [mp3 auto=&#34;1&#34;]MP3文件URL[/mp3] 3.演示： &#160; [mp3]http://storage.live.com/items/6E6B92BD0BA88634!163?filename=L.O.V.E.mp3[/mp3] [mp3]http://storage.live.com/items/6E6B92BD0BA88634!163?filename=L.O.V.E.mp3[/mp3] 二、Google文档预览 1.添加代码：默认宽600高300居中显示 &#160; function docsGoogle&#40;$atts, $content=null&#41;&#123; &#160; return '&#60;p style=&#34;text-align: center;&#34;&#62;&#60;iframe style=&#34;border-style: none;&#34; src=&#34;http://docs.google.com/viewer?url='.$content.'&#38;embedded=true&#34; width=&#34;600&#34; height=&#34;300&#34;&#62;&#60;/iframe&#62;&#60;/p&#62;'; &#160; &#125; &#160; add_shortcode&#40;'docs','docsGoogle'&#41;; 2.使用格式：目前Google文档查看器只“支持 [...]]]></description>
			<content:encoded><![CDATA[<p>貌似这功能早在WP2.5已经支持，详细的描述请看：<a rel="nofollow" href="http://codex.wordpress.org/Shortcode_API" target="_blank">http://codex.wordpress.org/Shortcode_API</a></p>
<p>此文不解释原理（因为俺也说不清），就直接说具体的应用：</p>
<p><strong><span style="color: #3366ff;">一、MP3播放器</span></strong></p>
<p><strong>1.添加：</strong>把以下代码复制至functions.php（注意在php循环内），然后下载<a target='_blank' rel='nofollow' href='https://dl-web.dropbox.com/u/837457/mp3player.swf'>mp3player.swf</a>并放至主题根目录，MP3默认不自动播放</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:Microsoft Yahei;">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> mp3player<span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;auto&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;embed src=&quot;'</span><span style="color: #339933;">.</span>get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;template_url&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/mp3player.swf?url='</span><span style="color: #339933;">.</span><span style="color: #000088;">$content</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;amp;autoplay='</span><span style="color: #339933;">.</span><span style="color: #000088;">$auto</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; type=&quot;application/x-shockwave-flash&quot; wmode=&quot;transparent&quot; allowscriptaccess=&quot;always&quot; width=&quot;400&quot; height=&quot;30&quot;&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mp3'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mp3player'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><span id="more-1253"></span><strong>2.使用：</strong>撰写文章时在“HTML模式”下插入以下格式代码即可</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:Microsoft Yahei;">&nbsp;
[mp3]MP3文件URL[/mp3]</pre></div></div>

<p>自动播放代码格式:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:Microsoft Yahei;">&nbsp;
[mp3 auto=&quot;1&quot;]MP3文件URL[/mp3]</pre></div></div>

<p><strong>3.演示：</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:Microsoft Yahei;">&nbsp;
[mp3]http://storage.live.com/items/6E6B92BD0BA88634!163?filename=L.O.V.E.mp3[/mp3]</pre></div></div>

<p>[mp3]http://storage.live.com/items/6E6B92BD0BA88634!163?filename=L.O.V.E.mp3[/mp3]</p>
<p><strong><span style="color: #3366ff;">二、Google文档预览</span></strong></p>
<p><strong>1.添加代码：</strong>默认宽600高300居中显示</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:Microsoft Yahei;">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> docsGoogle<span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;p style=&quot;text-align: center;&quot;&gt;&lt;iframe style=&quot;border-style: none;&quot; src=&quot;http://docs.google.com/viewer?url='</span><span style="color: #339933;">.</span><span style="color: #000088;">$content</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;embedded=true&quot; width=&quot;600&quot; height=&quot;300&quot;&gt;&lt;/iframe&gt;&lt;/p&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'docs'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'docsGoogle'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>2.使用格式：</strong>目前Google文档查看器只“支持 PDF 文档、PowerPoint 演示文稿和 TIFF 文件”</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:Microsoft Yahei;">&nbsp;
[docs]Docs(.pdf、.ppt、.tiff)文件URL[/docs]</pre></div></div>

<p><strong>3.效果演示：</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:Microsoft Yahei;">&nbsp;
[docs]http://storage.live.com/items/6E6B92BD0BA88634!158?filename=how-to-build-your-own-web-site.pdf[/docs]</pre></div></div>

<p>[docs]http://storage.live.com/items/6E6B92BD0BA88634!158?filename=how-to-build-your-own-web-site.pdf[/docs]</p>
<p><strong><span style="color: #3366ff;">三、Flash快捷插入</span></strong></p>
<p><strong>1.添加代码：</strong>默认宽480高360居中显示</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:Microsoft Yahei;">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> swf_player<span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;p style=&quot;text-align: center;&quot;&gt;&lt;embed type=&quot;application/x-shockwave-flash&quot; width=&quot;480&quot; height=&quot;360&quot; src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$content</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;&lt;/embed&gt;&lt;/p&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'swf'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'swf_player'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>2.使用格式及效果：</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:Microsoft Yahei;">&nbsp;
[swf]http://immmmm.com/download/chatnoir.swf[/swf]</pre></div></div>

<p>[swf]http://immmmm.com/download/chatnoir.swf[/swf]</p>
<p><strong><span style="color: #3366ff;">四、待添加……</span></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://immmmm.com/add-shortcodes-wordpress-theme.html/feed</wfw:commentRss>
		<slash:comments>127</slash:comments>
<enclosure url="http://storage.live.com/items/6E6B92BD0BA88634!163?filename=L.O.V.E.mp3" length="" type="564984" />
		</item>
	</channel>
</rss>

