<?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>wordpress插件 &#8211; 九创科技</title>
	<atom:link href="https://www.3code.cn/tag/wordpress%E6%8F%92%E4%BB%B6/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.3code.cn</link>
	<description>Wordpress外贸企业主题, Wp企业主题, wordpress企业主题, wordpress主题定制, WORDPRESS外贸网站建设SEO</description>
	<lastBuildDate>Wed, 16 May 2012 03:22:51 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>WordPress用户角色权限管理插件15款</title>
		<link>https://www.3code.cn/wordpress%e7%94%a8%e6%88%b7%e8%a7%92%e8%89%b2%e6%9d%83%e9%99%90%e7%ae%a1%e7%90%86%e6%8f%92%e4%bb%b615%e6%ac%be/</link>
		
		<dc:creator><![CDATA[寒林]]></dc:creator>
		<pubDate>Wed, 16 May 2012 03:22:51 +0000</pubDate>
				<category><![CDATA[wordpress插件]]></category>
		<category><![CDATA[WORDPRESS主题技术]]></category>
		<guid isPermaLink="false">https://www.3code.cn/?p=3046</guid>

					<description><![CDATA[wordpress 开放注册后的权限分配管理也是很重要的。下面，就请看看这15款WordPress角<a class="moretag" href="https://www.3code.cn/wordpress%e7%94%a8%e6%88%b7%e8%a7%92%e8%89%b2%e6%9d%83%e9%99%90%e7%ae%a1%e7%90%86%e6%8f%92%e4%bb%b615%e6%ac%be/"> 阅读更多&#8230;</a>]]></description>
										<content:encoded><![CDATA[<p>wordpress 开放注册后的权限分配管理也是很重要的。下面，就请看看这15款WordPress角色权限管理插件。</p>
<p>Role Manager WordPress Plugin<br />
这应该是目前最强大的一款WordPress角色管理插件，使用它，你可以:<br />
* 修改现有角色等级的名称。你可能并不需要”订阅者、编辑者、供稿者”这样的角色名称，而想用”探花，举人，状员”之类的。<br />
* 你还可以新建多个角色等级，并为每个等级的角色分配不同的权限，你甚至可以为同等级中的某一用户分配不同的权限。<br />
* 自定义角色等级的权限。<br />
总之，这是一款用户管理的首选插件。</p>
<p>Capability Manager<br />
这个WordPress插件可以让你拥有更强大的角色权限管理功能，它可以添加新的角色权限，并为每种角色设置可操作哪些东西。</p>
<p>RegLevel<br />
默认的WordPress只允许设置一种默认的注册角色权限，比如设置了新注册用户的权限为订阅者，那所有人注册都是订阅者。这个插件可以让你的注册机制更灵活些，让用户注册的时候可以直接选择注册哪个级别？但这也有问题: 用户可能会都愿意喜欢最高权限的级别，而不管实际上他是想当个订阅者还是编辑者。</p>
<p>Allow Categories<br />
Allow Categories是一个WordPress插件，可以让你分配哪些权限的用户只能访问哪些分类下的文章.</p>
<p>Show User Level Content<br />
这个插件也是根据用户级别来决定是否显示内容。</p>
<p>Change Uploaded File Permissions<br />
这个WordPress插件，可以在你上传图片或文件后，对这些文件进行访问权限设置。</p>
<p>AccessQontrol<br />
这个wordpress插件可以让你实现博客的私密化，通过它，你可以让你的博客:<br />
* 只允许注册用户访问<br />
* 除了你自己，任何人不能访问<br />
* 通过指定IP和IP段来禁止访问<br />
* 创建一个允许访问的白名单列表<br />
* 一个友好的禁止访问模板</p>
<p>Role Scoper<br />
这个WordPress插件可以为读者和编辑实现CMS风格的权限管理， 它凌驾于WordPress的角色之上，可实现指定的内容限制，可选的用户分组等等。</p>
<p>User Access Manager<br />
使用 “User Access Manager”插件，你可以管理用户查看你的文章，页面和文件的权限等。</p>
<p>WP-Invites<br />
可实现邀请系统的WordPress插件, 同时支持wordpress MU 和buddypress!</p>
<p>Member Access<br />
Member Access 是一个WordPress插件，可实现指定的文章或页面内容，必须登录才能查看.</p>
<p>Log User Access<br />
记录每一次WordPress 登录行为的用户名和具体时间。</p>
<p>Restrict Login By IP<br />
可以让你指定IP地址和主机来确定哪些用户允许登录。</p>
<p>Members Only<br />
这个WordPress插件也是可以让你的博客内容只对注册用户可读。</p>
<p>Social Access Control<br />
同上，控制访问内容的权限。</p>
<p>Private Files For Social Privacy<br />
加强私密日志的安全，防止一些狡猾的用户获取未经你授权的私密文章中的图片和附件。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>User Access Manager 用户文章阅读权限插件</title>
		<link>https://www.3code.cn/user-access-manager-%e7%94%a8%e6%88%b7%e6%96%87%e7%ab%a0%e9%98%85%e8%af%bb%e6%9d%83%e9%99%90%e6%8f%92%e4%bb%b6/</link>
		
		<dc:creator><![CDATA[寒林]]></dc:creator>
		<pubDate>Wed, 16 May 2012 03:15:02 +0000</pubDate>
				<category><![CDATA[wordpress插件]]></category>
		<category><![CDATA[User Access Manager]]></category>
		<guid isPermaLink="false">https://www.3code.cn/?p=3043</guid>

					<description><![CDATA[用“User Access Manager”-插件你可以管理访问你的文章,页面和文件。你只创建一个用<a class="moretag" href="https://www.3code.cn/user-access-manager-%e7%94%a8%e6%88%b7%e6%96%87%e7%ab%a0%e9%98%85%e8%af%bb%e6%9d%83%e9%99%90%e6%8f%92%e4%bb%b6/"> 阅读更多&#8230;</a>]]></description>
										<content:encoded><![CDATA[<p>用“User Access Manager”-插件你可以管理访问你的文章,页面和文件。你只创建一个用户组,将注册用户,设置为该小组的成员。从现在起post  /页面仅可为指定的组和可写。这个插件是有益的,如果你需要一个成员区域或私人部分在你的博客或者你希望别人可以写在你的博客,但是并不是到处都是。</p>
<p>下载地址：<a href="http://wordpress.org/extend/plugins/user-access-manager/">http://wordpress.org/extend/plugins/user-access-manager/</a></p>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>category image 插件</title>
		<link>https://www.3code.cn/category-image-%e6%8f%92%e4%bb%b6/</link>
		
		<dc:creator><![CDATA[寒林]]></dc:creator>
		<pubDate>Mon, 23 Apr 2012 06:01:13 +0000</pubDate>
				<category><![CDATA[wordpress插件]]></category>
		<guid isPermaLink="false">https://www.3code.cn/?p=3039</guid>

					<description><![CDATA[category image Download &#160; Using this plugin y<a class="moretag" href="https://www.3code.cn/category-image-%e6%8f%92%e4%bb%b6/"> 阅读更多&#8230;</a>]]></description>
										<content:encoded><![CDATA[<h2>category image</h2>
<p><a href="http://downloads.wordpress.org/plugin/tejus-add-cat-image.2.0.zip">Download</a></p>
<p>&nbsp;</p>
<p>Using this plugin you can associate one image with each of your category  created in wordpress. and you can call that image by using provided  function in any template file  tejus_dj_getcatimg($catid)  call this function in any template file it will return url of that  image. where $catid is category id of that category.</p>
<p>&nbsp;</p>
<p>使用这个插件，你可以在WordPress中创建您的类别相关联的一个图片。你可以调用该图像使用在任何模板文件用tejus_dj_getcatimg($catid），提供的功能，任何模板文件中调用此功能，它会返回该图像的URL。 $ catid没有这一类的类ID。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Admin Locale</title>
		<link>https://www.3code.cn/admin-locale/</link>
		
		<dc:creator><![CDATA[寒林]]></dc:creator>
		<pubDate>Mon, 12 Mar 2012 04:05:45 +0000</pubDate>
				<category><![CDATA[wordpress插件]]></category>
		<guid isPermaLink="false">https://www.3code.cn/?p=3024</guid>

					<description><![CDATA[This plugin gives you the ability to run the site <a class="moretag" href="https://www.3code.cn/admin-locale/"> 阅读更多&#8230;</a>]]></description>
										<content:encoded><![CDATA[<p>This plugin gives you the ability to run the site in a language  (Arabic for example) and use the admin panel in another (like English).</p>
<p>Just go to Settings » General and choose your language.</p>
<div>
<ol>
<li>Download the plugin, unzip it and upload it to <code>/wp-content/plugins/</code> directory.</li>
<li>Activate the plugin through the &#8216;Plugins&#8217; menu in WordPress.</li>
<li>Go to Settings » General and choose your language.</li>
</ol>
<p>http://wordpress.org/extend/plugins/admin-locale/installation</p>
<p>&nbsp;</p>
</div>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>WordPress分类插件：wp-category-meta</title>
		<link>https://www.3code.cn/wordpress%e5%88%86%e7%b1%bb%e6%8f%92%e4%bb%b6%ef%bc%9awp-category-meta/</link>
		
		<dc:creator><![CDATA[寒林]]></dc:creator>
		<pubDate>Sun, 11 Mar 2012 04:02:35 +0000</pubDate>
				<category><![CDATA[wordpress插件]]></category>
		<guid isPermaLink="false">https://www.3code.cn/?p=3018</guid>

					<description><![CDATA[Wordpress分类插件：wp-category-meta]]></description>
										<content:encoded><![CDATA[<div><strong>Authors:</strong> Eric Le Bail, Tom Ransom</div>
<p><a title="职称计算机考试软件2012" href="http://www.zhichengjsj.com" target="_blank">职称计算机考试软件2012</a></p>
<p>This plugins add meta data to the wordpress categories and terms. It Creates a wp-termsmeta table to store the entered meta. It adds input fields to the category and other term administration interface to enter the meta values. It provides functions to retrive / create / update / delete the category and terms meta. It can be used to add meta to custom taxonomies (terms).</p>
<p>This plugin has been tested with WP2.8.6 and WPmu2.8.6 and WP3.0</p>
<div>
<ol>
<li>Unzip into your <code>/wp-content/plugins/</code> directory. If you&#8217;re uploading it make sure to upload the top-level folder. Don&#8217;t just upload all the php files and put them in <code>/wp-content/plugins/</code>.</li>
<li>Activate the plugin through the &#8216;Plugins&#8217; menu in WordPress</li>
<li>Go to your Administration interface in the &#8220;Settings&#8221; menu a new &#8220;Category Meta&#8221; page is created. Configure the meta you want to use.</li>
<li>go to your Administration interface, in the &#8220;Category&#8221; menu -&gt;  new fields are displayed in the category creation/modification form with  the meta you configured.</li>
<li>That&#8217;s it!</li>
<li>you can use the folowing functions into your templates to retreive 1 meta:</li>
</ol>
<pre><code>if (function_exists('get_terms_meta'))
{
    $metaValue = get_terms_meta($category_id, $meta_key);
}</code></pre>
<ol>
<li>you can use the folowing functions into your templates to retreive all meta:</li>
</ol>
<pre><code>if (function_exists('get_all_terms_meta'))
{
    $metaList = get_all_terms_meta($category_id);
}</code></pre>
</div>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>WordPress实现前台英文，后台中文（插件）</title>
		<link>https://www.3code.cn/wordpress%e5%ae%9e%e7%8e%b0%e5%89%8d%e5%8f%b0%e8%8b%b1%e6%96%87%ef%bc%8c%e5%90%8e%e5%8f%b0%e4%b8%ad%e6%96%87%ef%bc%88%e6%8f%92%e4%bb%b6%ef%bc%89/</link>
		
		<dc:creator><![CDATA[寒林]]></dc:creator>
		<pubDate>Thu, 09 Feb 2012 01:52:35 +0000</pubDate>
				<category><![CDATA[wordpress插件]]></category>
		<guid isPermaLink="false">https://www.3code.cn/?p=3003</guid>

					<description><![CDATA[WordPress实现前台英文，后台中文（插件）]]></description>
										<content:encoded><![CDATA[<p>给一个外贸站升级，碰到一小问题：考虑到朋友以后的内容更新维护，我用WordPress 3.0.5的中文版来搭建的，因为中文的后台比较让人亲近，但是这样会在前台的页面有些地方，象注册登录，还有内容的源代码都会有些中文存在。有没有方法让WP的前台是纯英文而后台却是纯中文的呢？</p>
<p>Google 一下，找到解决办法，有个 “Admin Locale” 的插件正好可以实现我想要的功能。</p>
<p><strong>安装方法：</strong></p>
<p>到WP后台，添加新插件&#8211;&gt;搜索 Admin Locale，安装此插件并激活它。</p>
<p>再到 设置&#8211;&gt;常规，在下面 找到 Admin Language: 选择 Chinese (如下图)，更新即可。</p>
<p><strong>最后一步</strong>,不要忘了修改wp-config.php文件，把其中里面的一句代码：</p>
<p>define (&#8216;WPLANG&#8217;,&#8217;zh_CN&#8217;); 改成：</p>
<p>define (&#8216;WPLANG&#8217;, &#8216;en_US&#8217;);</p>
<p>上面的安装方法适合于WordPress中文版，如果你的WordPress本身就是英文版的话，wp-config.php就不用去修改了，同时必须把 WordPress 中文语言包拷贝到wp-content\languages （没有这个languages目录的话，自己新建这个目录）里。Admin Locale的设置方法同上。</p>
<p>WordPress 中文语言包下载地址：http://code.google.com/p/wpcn/downloads/list</p>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>No category parents插件</title>
		<link>https://www.3code.cn/no-category-parents%e6%8f%92%e4%bb%b6/</link>
		
		<dc:creator><![CDATA[寒林]]></dc:creator>
		<pubDate>Sun, 18 Sep 2011 10:13:21 +0000</pubDate>
				<category><![CDATA[wordpress插件]]></category>
		<category><![CDATA[wordpress 插件]]></category>
		<category><![CDATA[wordpress分类插件]]></category>
		<guid isPermaLink="false">https://www.3code.cn/?p=2849</guid>

					<description><![CDATA[No category parents插件是去除wordpress静态化以后所显示的分类路径，就是不管是父类还是子类，路径永远都是你的域名/分类名。
]]></description>
										<content:encoded><![CDATA[<p>No category parents插件是去除wordpress静态化以后所显示的分类路径，就是不管是父类还是子类，路径永远都是你的域名/分类名。</p>
<p>这样子的做法去除了搜索引擎探索的深度，个人认为对SEO效果有很大的帮助，推荐使用！</p>
<p><strong>安装方法：</strong><br />
直接在wordpress的后台搜索 “No category parents” 安装即可。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>wordpress搜索功能的Search Everything插件</title>
		<link>https://www.3code.cn/wordpress%e6%90%9c%e7%b4%a2%e5%8a%9f%e8%83%bd%e7%9a%84search-everything%e6%8f%92%e4%bb%b6/</link>
		
		<dc:creator><![CDATA[寒林]]></dc:creator>
		<pubDate>Sat, 06 Aug 2011 08:03:05 +0000</pubDate>
				<category><![CDATA[wordpress插件]]></category>
		<category><![CDATA[wordpress 插件]]></category>
		<guid isPermaLink="false">https://www.3code.cn/?p=2778</guid>

					<description><![CDATA[WordPress自带搜索功能并不是很好用，它只能搜索帖子的内容而不能搜索到帖子的评论留言什么的。但有时候读者会从评论留言中得到有效的信息，所以如果你想让你的WordPress搜索功能更强大，更好的为读者服务的话，你可以使用 Search Everything 这个插件。]]></description>
										<content:encoded><![CDATA[<p><strong>Search Everything插件介绍：</strong></p>
<p>WordPress自带搜索功能并不是很好用，它只能搜索帖子的内容而不能搜索到帖子的评论留言什么的。但有时候读者会从评论留言中得到有效的信息，所以如果你想让你的WordPress搜索功能更强大，更好的为读者服务的话，你可以使用 Search Everything 这个插件。</p>
<p><strong>Search Everything插件功能：</strong></p>
<p>Search Everything 是一个增加WordPress默认搜索能力的插件。它可以让你的WordPress 拥有更加高级的搜索功能:</p>
<p>搜索每个页面，标签和分类<br />
只搜索没有密码保护的日志<br />
搜索每条留言，通过审核的留言<br />
搜索草稿，摘要，附件<br />
搜索自定义字段<br />
从搜索结果中排除指定日志或指定分类</p>
<p><strong>Search Everything插件安装:</strong></p>
<p>下载Search Everything插件，将压缩包解压后，把文件夹上传到wp-content/plugins/目录下。<br />
登录WordPress管理后台，点击“Plugins”找到上传的插件，激活该插件,即可。<br />
激活插件后，在&#8221;Setting&#8221;版块下点击“Search Everything”对页面进行管理。</p>
<p>在这个后台页面有丰富的定义，你可以设置能搜索的内容：评论，页面，存档，连草稿和自定义域都能搜索到！不能不说它厉害。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>wordpress自动给关键字加链接的插件</title>
		<link>https://www.3code.cn/wordpress%e8%87%aa%e5%8a%a8%e7%bb%99%e5%85%b3%e9%94%ae%e5%ad%97%e5%8a%a0%e9%93%be%e6%8e%a5%e7%9a%84%e6%8f%92%e4%bb%b6/</link>
		
		<dc:creator><![CDATA[寒林]]></dc:creator>
		<pubDate>Mon, 25 Jul 2011 09:38:03 +0000</pubDate>
				<category><![CDATA[wordpress插件]]></category>
		<category><![CDATA[wordpress 插件]]></category>
		<guid isPermaLink="false">https://www.3code.cn/?p=2762</guid>

					<description><![CDATA[经常写blog的时候会有给关键字加链接的需求，比如，google，就想链接到www.google.com，说道baidu就链接到www.baidu.com这样。
前2天发现了一个。叫Blog Mechanics Keyword Link]]></description>
										<content:encoded><![CDATA[<p>经常写blog的时候会有给关键字加链接的需求，比如，google，就想链接到www.google.com，说道baidu就链接到www.baidu.com这样。<br />
前2天发现了一个。叫Blog Mechanics Keyword Link<br />
可以完成这个功能。<br />
你后台可以定义，维护关键字和对应的链接，还可以定义链接的类型。短小精悍，就一个文件，比较好用。</p>
<p>但是我试用的时候出了问题，没有效果，后来查代码发现，是正则表达式的问题，人家没考虑中文问题，所以在替换的时候，英文的关键字前后是有空格的，我们中文是没有空格的。修改了一点点代码，可以用了。</p>
<p>想省事的可以这里下载。<br />
<a title="blog-mechanics-keyword-link-plugin-v01.zip" href="https://www.3code.cn/download/blog-mechanics-keyword-link-plugin-v01.zip">wordpress给关键字加链接的插件</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>WordPress热文排行插件WordPress Popular Posts</title>
		<link>https://www.3code.cn/wordpress%e7%83%ad%e6%96%87%e6%8e%92%e8%a1%8c%e6%8f%92%e4%bb%b6wordpress-popular-posts/</link>
		
		<dc:creator><![CDATA[寒林]]></dc:creator>
		<pubDate>Mon, 25 Jul 2011 09:29:09 +0000</pubDate>
				<category><![CDATA[wordpress插件]]></category>
		<category><![CDATA[wordpress 插件]]></category>
		<guid isPermaLink="false">https://www.3code.cn/?p=2760</guid>

					<description><![CDATA[为了防止曾经的热文被淹没掉，博主最好添加一个热文排行榜，让博客中的那些流行度比较高的文章，持续它们的价值，所以，很有必要安装热文排行插件，通过这个插件，你可以自定义显示类别、标题、链接数以及显示的评论数。]]></description>
										<content:encoded><![CDATA[<p>为了防止曾经的热文被淹没掉，博主最好添加一个热文排行榜，让博客中的那些流行度比较高的文章，持续它们的价值，所以，很有必要安装热文排行插件，通过这个插件，你可以自定义显示类别、标题、链接数以及显示的评论数。</p>
<p>WordPress Popular Posts插件安装使用也十分的方便，下载Wordpress Popular Posts插件，将压缩包解压后，把文件夹上传到wp-content/plugins/目录下，登录WordPress管理后台，点击“Plugins”找到上传的插件，激活该插件，可以在“Appearance”&#8212;&gt;“Widgets”中把它添加到侧栏中去</p>
<p>WordPress热文排行插件Wordpress Popular Posts</p>
<p>插件的选项，在Time Range中你可以根据自己的情况选择，热文的时间范围，范围如下：<br />
Today：今天</p>
<p>Last 7 days：最近7天<br />
Last 30 days：最近30天<br />
All-times：所有时间的</p>
<p>这些设置可以把我们的热文排行展现的更加全面。</p>
<p>Sort posts by选择中，我们可以选择排序的方式：<br />
Comments：评论<br />
Total views：总浏览量<br />
Avg.daily views：平均日浏览量</p>
<p>出来这些，你还可以选择文章显示的分类、Tag显示的方式等等，也不需特别的设置，只要在前面勾选就OK了。</p>
<p>最后，就是HTML格式的设置了，你可以自定义HTML样式，也可以使用默认的样式，根据自己的选择，设置好后点击Save保存就OK了。</p>
<p>WordPress Popular Posts插件下载地址：点击下载<br />
Wordpress Popular Posts插件作者地址：点击进入</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>WordPress插件开发API(Plugin)</title>
		<link>https://www.3code.cn/wordpress%e6%8f%92%e4%bb%b6%e5%bc%80%e5%8f%91apiplugin/</link>
		
		<dc:creator><![CDATA[寒林]]></dc:creator>
		<pubDate>Thu, 07 Jul 2011 09:44:36 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[wordpress 插件]]></category>
		<category><![CDATA[wordpress插件]]></category>
		<category><![CDATA[wordpress教程]]></category>
		<guid isPermaLink="false">https://www.3code.cn/?p=2738</guid>

					<description><![CDATA[WordPress插件开发API(Plugin)]]></description>
										<content:encoded><![CDATA[<h2>Plugin API</h2>
<h3>介绍</h3>
<p>本文当主要介绍<a title="WP" href="http://wordpress.org/">WordPress</a>插件开发者可以使用的API Hook，以及如何使用它们。</p>
<p>本文假设您已经阅读了《<a title="Writing a Plugin" href="http://codex.wordpress.org/Writing_a_Plugin">Writing a Plugin</a>》（这篇文章概览了如何写一个插件）。本文主要介绍API Hook，也称作Filter和Action，<a title="WP" href="http://wordpress.org/">WordPress</a>使用这些函数来使您的插件起作用。</p>
<p>注意：本文的内容适用于WordPress1.2+。</p>
<p>&nbsp;</p>
<h3>Hook，Action和Filter</h3>
<p>Hook是<a title="Becoming Charles-WP" href="http://sexywp.com/cata/wp">WordPress</a>提供的一种机制，帮助您将您的插件加入到<a title="WP" href="http://wordpress.org/">WordPress</a>中；也即，在您的插件中，通过调用一些系统函数，使得您的插件可以运作起来。一共有两种Hook：</p>
<ol>
<li>Action：Action是<a title="WP" href="http://wordpress.org/">WordPress</a>内核在运行到某个特定的点的，或者某个特定的事件发生的时候执行的。您可以通过使用Action API让您的插件中的一个或者多个函数在这些特定的点执行。</li>
<li>Filter：Filter是<a title="Becoming Charles-WP" href="http://sexywp.com/cata/wp">WordPress</a>在将一段文本加入到数据库，或者发送给浏览器之前处理不同种类的文本用的。您的插件可以通过使用Filter API，让一个或者多个函数在这些时刻运行，以处理特定类型的文本。</li>
</ol>
<p>有的时候，您可以使用Action和Filter达到相同的目的。比如说，您希望你的插件可以更改一段日志的文本，您可能会往<code>publish_post</code>中添加一个Action函数（这段文字在被加入到数据库之前被修改了），或者往 <code>the_content</code>中添加一个Filter函数（这段文字在被发送给浏览器显示之前，被更改了）。</p>
<h3>Action</h3>
<p>Action由<a title="Becoming Charles-WP" href="http://sexywp.com/tags/wordpress">WordPress</a>中发生的一些特定的事件所触发，比如发布一篇日志，更改主题，或者在管理面板显示一个页面。您的插件可以通过执行一个PHP函数来响应事件，实现以下几个目的：</p>
<ul>
<li>修改数据库数据</li>
<li>发送Email信息</li>
<li>修改将要在浏览器上呈现的内容（管理员看到的或者访客看到的）</li>
</ul>
<p>要达到上述的目的，需要遵循的步骤为（下文有详细的描述）：</p>
<ol>
<li>在您的插件文件中，创建一个在某个事件发生时，需要运行的PHP函数。</li>
<li>通过调用<code>add_action</code>函数，将您的函数插入到<a title="WP" href="http://wordpress.org/">WordPress</a>中。</li>
<li>将您的插件文件放到插件目录下，然后激活它。</li>
</ol>
<h4>创建一个Action 函数</h4>
<p>在您的插件中创建一个Action的第一个步骤是创建一个能响应Action的函数，并且将它写入到您的插件文件里（您的插件文件最后会被放到<em>content/plugins</em>目录）。举个例子，如果您想要您的朋友在您发表了新文章的时候收到一封邮件，您可以创建下述函数：</p>
<p><code><br />
function email_friends($post_ID) {<br />
$friends = ‘bob@example.org,susie@example.org’;<br />
mail($friends, "sally’s blog updated",<br />
‘I just put something on my blog: http://blog.example.com’);<br />
return $post_ID;<br />
}<br />
</code></p>
<p>对于大多数的Action来说，您的函数要接受一个单一参数（通常是日志或这评论的ID，这要视情况而定）。有些Action接受多于一个的参数， 您可以查看WordPress的Action文档，或者直接查看WordPress源代码来取得第一手资料。除了一个参数外，您还可以访问 WordPress的全局变量，并且调用其他WordPress函数或者您插件中的其他函数（或者其他插件中的函数）。</p>
<p><strong>注意</strong>：您要始终留意，是否WordPress本身或者其他的插件已经使用了您想用的那个函数的名字。关于这点，您可以查看<a title="Avoiding Function Name Collisions" href="http://codex.wordpress.org/Writing_a_Plugin#Avoiding_Function_Name_Collisions">避免函数名冲突</a>这篇文章来获取更详细的信息。</p>
<h4>Hook到WordPress</h4>
<p>当您定义好您的函数后，下一步就是将您的函数Hook或者注册到WordPress中。在您的插件文件中的全局空间中调用函数 add_action()就可以了：</p>
<pre>add_action(’hook_name’, ‘your_filter’, [priority], [accepted_args]);</pre>
<p>该函数中：</p>
<ul>
<li><code>hook_name</code>是WordPress提供的供hook用的函数名，也即您的函数将关联到的事件的名称。</li>
<li><code>your_function_name</code> 是您希望在<code>hook_name</code>指定的事件发生时执行的函数的名称。这可以是一个在WordPress中定义好的标准的函数，也可以是一个您自己定义的函数（比如上面提到的<code>email_friends</code>）</li>
<li><code>priority</code>是一个可选的整型参数，可以指定可以指定关联到某个特定的函数的执行顺序。默认值是10。数字较小的执行较早，如果优先级相同，则按照他们hook进来的顺序先后来执行。</li>
<li><code>accepted_args</code>是一个可选的整型参数，它定义了您的函数可以接受多少个参数，默认是1。这个参数很有用，因为有些事件发生的时候，可能会向您的函数传递多于一个的参数。这个参数是从WordPress 1.5.1后的版本才开始有的。</li>
</ul>
<p>继续前文的例子，我们可以将下面一行代码加入到插件的文件中：</p>
<pre>add_filter(’comment_text’,'filter_profanity’);</pre>
<p>相似的，您也可以将一个函数从Action中移除。你可以参考移除Action来获得详细的信息。</p>
<h4>安装和激活</h4>
<p>让您的插件奏效的最后一个步骤就是安装和激活和插件了。您写好的函数和对add_action的调用，必须放到同一个文件中，插件文件必须被装到wp-content/plugins目录中。一旦插件安装好，您需要访问管理面板来激活您的插件。</p>
<h4>目前已有的Action Hook</h4>
<p>参见<a title="Plugin API Action Reference" href="http://codex.wordpress.org/Plugin_API/Action_Reference">Plugin API/Action Reference</a>来查看WordPress中的当前的Action列表。</p>
<h3>Filter</h3>
<p>Filter是在WordPress执行过程中，传递数据时，在对数据采取某种行动（将数据写入到数据库或者发送给访客的浏览器）之前执行的。（当 WordPress生成页面时）Filter就位于数据库和浏览器之间，（当WordPress向数据库添加日志和评论时）Filter就位于浏览器和数 据库之间。WordPress中的绝大多数的输入和输出过程都要通过至少一个Filter。WordPress自己有一些默认的Filter，您可以在插 件中使用自己的Filter。</p>
<p>将您自己的Filter添加到WordPress中，遵循以下几个步骤：</p>
<ul>
<li>创建一个PHP函数来过滤数据。</li>
<li>通过调用add_filter将这个Filter添加到WordPress中。</li>
<li>将您的PHP函数写入到一个插件文件中，激活它。</li>
</ul>
<h4>创建一个Filter函数</h4>
<p>一个Filter函数把未经修改的数据作为输入，返回修改过的数据（或者有的时候返回的空值，表明这些数据应该被删除）。如果您的Filter没有修改数据，那么原始的数据必须被返回回去，以便于后续的插件可以继续它们的修改工作。</p>
<p>所以，在您的插件中创建一个Filter的第一步，就是创建一个PHP函数来执行过滤动作，并且，将这个函数写入到您的插件文件中去。再举个例子， 如果您需要确定您的日志或者评论中没有出现违禁词汇，您可以定义一个全局变量，里面包含了全部的违禁词汇的列表，然后创建下面的PHP函数：</p>
<p><code><br />
function filter_profanity($content) {<br />
global $profanities;<br />
foreach($profanities as $profanity) {<br />
$content=str_ireplace($profanity,’{censored}’,$content);<br />
}<br />
return $content;<br />
}<br />
</code></p>
<p>注意：同样要小心您的函数的命名，不要和其他的WordPress函数和其他插件的函数冲突。</p>
<h4>将您的Filter Hook到WordPress</h4>
<p>在您的函数定义完毕后，下一步就是将您的函数&#8221;hook&#8221;或者说注册到WordPress中。在您的插件文件中，调用add_filter函数：</p>
<p><code><br />
add_filter(’hook_name’, ‘your_filter’, [priority], [accepted_args]);<br />
</code></p>
<p>其中：</p>
<ul>
<li><code>hook_name</code> 是WordPress提供的供hook的函数的名称，定义了您可以加入您自己的Filter的插入点。</li>
<li><code>your_filter</code>是您的filter函数的名称。这个函数可以是一个WordPress标准PHP函数，也即在WordPress内核中定义的函数，也可以使一个您自己定义的函数。</li>
<li><code>priority</code>是一个可选的整型参数，标明了注册到某个特定的filter中的函数的执行顺序。默认是10。较小的数字执行时较靠前。如果priority值相同，那么按照注册的先后顺序来执行。</li>
<li><code>accepted_args</code>是一个可选参数，用来标明您的函数能够接受的参数的个数，默认是1，某些hook可以像您的函数传递超过一个的参数。</li>
</ul>
<p>继续上面的例子，您可以使用下面的代码，让WordPress过滤您评论中的违禁词汇：</p>
<p><code><br />
add_filter(’comment_text’,'filter_profanity’);<br />
</code></p>
<p>您也可以使用<code>remove_filter()</code>函数来将一个Filter移除。</p>
<h4>安装和激活</h4>
<p>最后一个步骤就是使您的filter运作起来。你需要做的就是将您的插件文件放到<em><a title="标签 WordPress 下的日志" rel="tag" href="http://sexywp.com/tags/wordpress">wordpress</a>/plugins</em>目录，然后到后台管理界面激活。</p>
<h4>目前WordPress中可以注册的Filter</h4>
<p>参见Plugin API/Filter Reference。</p>
<h4>例子</h4>
<p>下面是一个例子，是Ozh曾经在邮件列表中描述过的，该插件修改（或者说覆盖）了默认的<code>bloginfo()</code>函数。这需要修改内核函数的行为。</p>
<p><code><br />
add_filter(’bloginfo’, ‘mybloginfo’, 1, 2);<br />
add_filter(’bloginfo_url’, ‘mybloginfo’, 1, 2);</code></p>
<p><code> </code></p>
<p><code>function mybloginfo($result=”, $show=”) {<br />
switch ($show) {<br />
case ‘wpurl’:<br />
$result = SITE_URL;<br />
break;<br />
case ‘template_directory’:<br />
$result = TEMPL_DIR;<br />
break;<br />
default:<br />
}<br />
return $result;<br />
}<br />
</code></p>
<h3>移除Action和Filter</h3>
<p>在某些情况下，您可能会发现，您的插件需要禁用WordPress中的内建Action或者Filter之一，或者某个其它插件添加的函数。您可以通过调用<code>remove_filter(’filter_hook’,'filter_function’)</code>或者 <code>remove_action(’action_hook’,'action_function’)</code>来达到目的。</p>
<p>比如，<code>remove_action(’publish_post’,'generic_ping’);</code>可以在您发表日志的时候，阻止您的博客向外发送ping。</p>
<p>注意，如果一个hook不是使用默认的优先级（priority）注册到系统中，那么您必须在<code>remove_action()</code>中指定那个hook使用的优先级。一般来说还要注意，除非您很清楚那个函数在干什么并且为什么要那么做，请不要移除任何函数。</p>
<h3>缺省加载的Filter和Action</h3>
<p>最可靠的获知WordPress缺省加载了哪些Filter和Action的方法就是在其源代码中搜索<code>add_filter</code>和<code>add_action</code>函数的调用。</p>
<h4>WordPress 2.1</h4>
<p>在WordPress2.1中，绝大多数的Filter和Action的加载是在<em>wp-include/default-filters.php</em>文件中进行的。其他的在下列的文件中加载：</p>
<ul>
<li><tt>wp-admin/admin-ajax.php</tt></li>
<li><tt>wp-admin/admin-functions.php</tt></li>
<li><tt>wp-admin/custom-header.php</tt></li>
<li><tt>wp-admin/edit.php</tt></li>
<li><tt>wp-admin/index.php</tt></li>
<li><tt>wp-admin/options-permalink.php</tt></li>
<li><tt>wp-admin/upload-functions.php</tt></li>
<li><tt>wp-admin/upload.php</tt></li>
<li><tt>wp-includes/bookmark.php</tt></li>
<li><tt>wp-includes/general-template.php</tt></li>
<li><tt>wp-includes/kses.php</tt></li>
<li><tt>wp-includes/plugin.php</tt></li>
<li><tt>wp-includes/rewrite.php</tt></li>
<li><tt>wp-includes/template-loader.php</tt></li>
<li><tt>wp-includes/theme.php</tt></li>
</ul>
<h4>WordPress 2.5</h4>
<p>(以后我会完善这个部分)</p>
<h3>您可以覆盖的函数</h3>
<p>除了使用hook（action和filter），另一个插件修改Wordpress行为方式是覆盖WordPress的函数。实际上，有一小组函 数，是WordPess希望被插件覆盖的。在所有的插件都已经启动后，如果他们还没有被覆盖的话，WordPress才启动这些函数。</p>
<p>这些函数在<em>wp-include/pluggable.php</em>文件中定义。这里有一个列表（WP2.1）。</p>
<ul>
<li><tt>set_current_user</tt></li>
<li><tt>wp_set_current_user</tt></li>
<li><tt>wp_get_current_user</tt></li>
<li><tt>get_currentuserinfo</tt></li>
<li><tt>get_userdata</tt></li>
<li><tt>update_user_cache</tt></li>
<li><tt>get_userdatabylogin</tt></li>
<li><tt>wp_mail</tt></li>
<li><tt>wp_login</tt></li>
<li><tt>is_user_logged_in</tt></li>
<li><tt>auth_redirect</tt></li>
<li><tt>check_admin_referer</tt></li>
<li><tt>wp_redirect</tt></li>
<li><tt>wp_get_cookie_login</tt></li>
<li><tt>wp_setcookie</tt></li>
<li><tt>wp_clearcookie</tt></li>
<li><tt>wp_notify_postauthor</tt></li>
<li><tt>wp_notify_moderator</tt></li>
<li><tt>wp_new_user_notification</tt></li>
<li><tt>wp_verify_nonce</tt></li>
<li><tt>wp_create_nonce</tt></li>
<li><tt>wp_salt</tt></li>
<li><tt>wp_hash</tt></li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
