<?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-expert</title> <atom:link href="http://www.wordpress-expert.info/feed" rel="self" type="application/rss+xml" /><link>http://www.wordpress-expert.info</link> <description>all about wordpress: themes, plugins, money, projects, tips</description> <lastBuildDate>Sun, 11 Dec 2011 16:35:40 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator><meta
xmlns="http://www.w3.org/1999/xhtml" name="robots" content="noindex,follow" /> <item><title>博客圈最流行的30个 wordpress 插件</title><link>http://www.wordpress-expert.info/blog/%e5%8d%9a%e5%ae%a2%e5%9c%88%e6%9c%80%e6%b5%81%e8%a1%8c%e7%9a%8430%e4%b8%aa-wordpress-%e6%8f%92%e4%bb%b6.html</link> <comments>http://www.wordpress-expert.info/blog/%e5%8d%9a%e5%ae%a2%e5%9c%88%e6%9c%80%e6%b5%81%e8%a1%8c%e7%9a%8430%e4%b8%aa-wordpress-%e6%8f%92%e4%bb%b6.html#comments</comments> <pubDate>Sun, 11 Dec 2011 16:35:40 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[wordpress]]></category> <guid
isPermaLink="false">http://www.wordpress-expert.info/?p=236</guid> <description><![CDATA[原文：staska.net 翻译：sein 似乎每个写博的人都列举过自己喜欢的插件，这篇关于 wordpress 插件的文章，是在总结了 48个列表280个插件的基础上写出来的。 Akismet ：规则严厉的反 spam 插件。 Google Sitemap Generator ：SEO 利器，生成规范的站点地图以便 Google 收录。 Related posts ：自动搜索并列举相关文章的插件。 Wp-Contact form ：给你的 blog 加一个联系表单。加强版 / 防 spam 版 WordPress database backup ：数据库备份插件，免得进 phpmyadmin 那么麻烦，如果你的主机支持 smtp 的话，还可以直接把备份发送到邮箱。 Feedburner Feed Replacement ：将原始 feed 地址转向到 feedburner 的烧录地址。 Ultimate Tag Warrior ：经典的 tag 插件。 Subscribe to comments ：让回复者订阅该主题的回复，这样可以一厢情愿的让读者收到你的骚扰邮件。 AdSense Deluxe [...]]]></description> <content:encoded><![CDATA[<div
style="float:left;margin-right:10px;"><script type="text/javascript">google_ad_client = "ca-pub-2177081245618878";
/* we-content */
google_ad_slot = "1030718498";
google_ad_width = 250;
google_ad_height = 250;</script> <script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div><p>原文：<a
href="http://www.staska.net/2007/03/27/top-30-wordpress-plugins-in-blogosphere/" rel="external" target="_blank">staska.net</a><br
/> 翻译：<a
href="http://jandan.net/author/admin/" rel="external" target="_blank">sein</a></p><p>似乎每个写博的人都列举过自己喜欢的插件，这篇关于 wordpress 插件的文章，是在总结了 48个列表280个插件的基础上写出来的。</p><ol><ol><li><a
href="http://akismet.com/" rel="external" target="_blank">Akismet</a></li></ol></ol><p>：规则严厉的反 spam 插件。</p><ol><ol><li><a
href="http://www.arnebrachhold.de/2005/06/05/google-sitemaps-generator-v2-final?utm_source=wp-wm&amp;utm_medium=install&amp;utm_content=plugin-home" rel="external" target="_blank">Google Sitemap Generator</a></li></ol></ol><p>：SEO 利器，生成规范的站点地图以便 Google 收录。</p><ol><ol><li><a
href="http://wasabi.pbwiki.com/Related%20Entries" rel="external" target="_blank">Related posts</a></li></ol></ol><p>：自动搜索并列举相关文章的插件。</p><ol><ol><li><a
href="http://ryanduff.net/projects/wp-contactform/" rel="external" target="_blank">Wp-Contact form</a></li></ol></ol><p>：给你的 blog 加一个联系表单。<a
href="http://www.joostdevalk.nl/code/wordpress/enhanced-contact-form/" rel="external" target="_blank">加强版</a> / <a
href="http://www.douglaskarr.com/2006/09/22/wordpress-contact-form-with-spam-protection/" rel="external" target="_blank">防 spam 版</a></p><ol><ol><li><a
href="http://www.ilfilosofo.com/blog/wp-db-backup" rel="external" target="_blank">WordPress database backup</a></li></ol></ol><p>：数据库备份插件，免得进 phpmyadmin 那么麻烦，如果你的主机支持 smtp 的话，还可以直接把备份发送到邮箱。</p><ol><ol><li><a
href="http://orderedlist.com/wordpress-plugins/feedburner-plugin/" rel="external" target="_blank">Feedburner Feed Replacement</a></li></ol></ol><p>：将原始 feed 地址转向到 feedburner 的烧录地址。</p><ol><ol><li><a
href="http://www.neato.co.nz/ultimate-tag-warrior/" rel="external" target="_blank">Ultimate Tag Warrior</a></li></ol></ol><p>：经典的 tag 插件。</p><ol><ol><li><a
href="http://txfx.net/code/wordpress/subscribe-to-comments/" rel="external" target="_blank">Subscribe to comments</a></li></ol></ol><p>：让回复者订阅该主题的回复，这样可以一厢情愿的让读者收到你的骚扰邮件。</p><ol><ol><li><a
href="http://www.acmetech.com/blog/2005/07/26/adsense-deluxe-wordpress-plugin/" rel="external" target="_blank">AdSense Deluxe</a></li></ol></ol><p>：让你很方便的在 blog 里加入各种广告代码。</p><ol><ol><li><a
href="http://www.skippy.net/blog/2005/03/24/gravatars/" rel="external" target="_blank">Gravatars</a></li></ol></ol><p>：加入此插件后，会在回复者那里显示各自的 Gravatars 头像。</p><ol><ol><li><a
href="http://vapourtrails.ca/wp-keywords" rel="external" target="_blank">Jerome’s Keywords plugin</a></li></ol></ol><p>：另一个 关键字/tag 插件。相对 UTW 而言功能较少，但是更好用。<span
style="color: #ffffff;"># Copyright for</span><a
href="http://jandan.net/" rel="external" target="_blank"><span
style="color: #ffffff;">Jandan.net</span></a><span
style="color: #ffffff;">(http://jandan.net/)</span></p><ol><ol><li><a
href="http://elasticdog.com/2004/09/optimal-title/" rel="external" target="_blank">Optimal tit</a></li></ol></ol><p>：title 优化插件，有利于 SEO。</p><ol><ol><li><a
href="http://push.cx/sociable" rel="external" target="_blank">Sociable</a></li></ol></ol><p>：社会化书签插件，比如 Digg、del.icio.us、reddit 等。</p><ol><ol><li><a
href="http://mnm.uib.es/gallir/wp-cache-2/" rel="external" target="_blank">WP-Cache 2.0</a></li></ol></ol><p>：缓存插件，对于大流量的 blog 很有用，比如<a
href="http://sein.gaame.cn/" rel="external" target="_blank">我的个人 blog </a>一分钟几十万点这样的，不用不行啊。</p><ol><ol><li><a
href="http://alexking.org/projects/wordpress/readme?project=popularity-contest" rel="external" target="_blank">Popularity Contest</a></li></ol></ol><p>：自动高亮最热主题。</p><ol><ol><li><a
href="http://automattic.com/code/widgets/" rel="external" target="_blank">Sidebar Widgets</a></li></ol></ol><p>：加上它以后你的 wp 就可以在侧栏自由加载各种小东西了，居家旅行杀人放火必备之选。</p><ol><ol><li><a
href="http://www.calevans.com/view.php/page/notable" rel="external" target="_blank">Wp_Notable</a></li></ol></ol><p>：用另一种方式显示社会化书签小图标。</p><ol><ol><li><a
href="http://www.broobles.com/scripts/simpletags/" rel="external" target="_blank">Simple Tags</a></li></ol></ol><p>：最简单最好用的 Technorati tag 插件，只需在你的 post 里加上 [tags] [/tags] 标签即可。</p><ol><ol><li><a
href="http://wp-plugins.net/plugin/Adhesive/#plugin_63" rel="external" target="_blank">Adhesive</a></li></ol></ol><p>：固顶插件。</p><ol><ol><li><a
href="http://bluesome.net/post/2005/08/18/50/" rel="external" target="_blank">Exec-php</a></li></ol></ol><p>：在 post 里执行 php 代码。</p><ol><ol><li><a
href="http://www.sonsofskadi.net/extended-live-archive/" rel="external" target="_blank">Extended live archive</a></li></ol></ol><p>：动态显示存档。</p><ol><ol><li><a
href="http://www.exwebjunkie.com/2007/02/23/wordpress-plugin-no-ping-wait/" rel="external" target="_blank">No ping wait</a></li></ol></ol><p>：不用等待后台 trackback 的 ping 时间。</p><ol><ol><li><a
href="http://www.mightyseek.com/podpress/" rel="external" target="_blank">PodPress</a></li></ol></ol><p>：podcast / 播客插件。</p><ol><ol><li><a
href="http://www.sporadicnonsense.com/2005/04/28/clean-archives-plug-in/" rel="external" target="_blank">SRG Clean Archives</a></li></ol></ol><p>：另一个存档插件，可以按月/年显示。</p><ol><ol><li><a
href="http://www.lesterchan.net/wordpress/readme/wp-pagenavi.html" rel="external" target="_blank">WP-Page Navi</a></li></ol></ol><p>：翻页插件。</p><ol><ol><li><a
href="http://www.skippy.net/blog/category/wordpress/plugins/wp-cron/" rel="external" target="_blank">WP-Cron</a></li></ol></ol><p>：计划任务插件，比如配合备份插件使用，可以自动定时备份然后发送到你的邮箱。</p><ol><ol><li><a
href="http://blog.happyarts.de/wp-shortstat/" rel="external" target="_blank">Wp-Shortstat</a></li></ol></ol><p>：在后台显示你 blog 的相关信息。</p><ol><ol><li><a
href="http://www.4mj.it/lightbox-js-v20-wordpress/" rel="external" target="_blank">Lightbox 2</a></li></ol></ol><p>：灰盒子插件，用幻灯效果显示图片，很酷。</p><ol><ol><li><a
href="http://www.jcraveiro.com/v3/projectos/delicious-cached-pp/" rel="external" target="_blank">del.icio.us cached</a></li></ol></ol><p>：显示你最近的 del.icio.us。</p><ol><ol><li><a
href="http://blog.jodies.de/archiv/2004/11/13/recent-comments/" rel="external" target="_blank">Get Recent Comments</a></li></ol></ol><p>：显示最新回复的摘要，</p> ]]></content:encoded> <wfw:commentRss>http://www.wordpress-expert.info/blog/%e5%8d%9a%e5%ae%a2%e5%9c%88%e6%9c%80%e6%b5%81%e8%a1%8c%e7%9a%8430%e4%b8%aa-wordpress-%e6%8f%92%e4%bb%b6.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>如何提升 WordPress 性能</title><link>http://www.wordpress-expert.info/blog/%e5%a6%82%e4%bd%95%e6%8f%90%e5%8d%87-wordpress-%e6%80%a7%e8%83%bd.html</link> <comments>http://www.wordpress-expert.info/blog/%e5%a6%82%e4%bd%95%e6%8f%90%e5%8d%87-wordpress-%e6%80%a7%e8%83%bd.html#comments</comments> <pubDate>Sun, 11 Dec 2011 16:33:23 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[wordoress]]></category> <guid
isPermaLink="false">http://www.wordpress-expert.info/?p=235</guid> <description><![CDATA[使用 WP-Cache 插件，优化MySQL 查询缓存以及 PHP 定向(Opcode)缓存，更高级的还有修改 httpd.conf 和 php.ini 文件等等。因内容太过专业我看不懂，请大家自行前往观之。 以及相关资源： 优化你的 wordpress 载入时间 优化你的数据库 如何优化 CSS 优化 wordpress 性能 优化 wordpress 以适应高流量 高性能的 wordpress 优化 wordpress 以承受 digg 效应 加速你的 wordpress blog 让 digg 考验你的 wordpress wp2.1 比 2.0 快 2007 代码之夏：性能测试项目]]></description> <content:encoded><![CDATA[<div
style="float:left;margin-right:10px;"><script type="text/javascript">google_ad_client = "ca-pub-2177081245618878";
/* we-content */
google_ad_slot = "1030718498";
google_ad_width = 250;
google_ad_height = 250;</script> <script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div><p>使用 <a
href="http://mnm.uib.es/gallir/posts/2007/01/31/963/" rel="external" target="_blank">WP-Cache</a> 插件，优化<a
href="http://www.amazon.com/gp/product/0596003064?ie=UTF8&amp;tag=elliottback-20&amp;link_code=em1&amp;camp=212341&amp;creative=380429&amp;creativeASIN=0596003064&amp;adid=bbd5efeb-e650-4fdc-88ab-e710311b02f6" rel="external" target="_blank">MySQL 查询缓存</a>以及 <a
href="http://eaccelerator.net/" rel="external" target="_blank">PHP 定向(Opcode)缓存</a>，更高级的还有修改 httpd.conf 和 <a
href="http://phplens.com/lens/php-book/optimizing-debugging-php.php" rel="external" target="_blank">php.ini</a> 文件等等。因内容太过专业我看不懂，请大家自行前往<a
href="http://elliottback.com/wp/archives/2007/04/15/why-my-wordpress-site-is-so-much-faster-than-yours/" rel="external" target="_blank">观之</a>。</p><p>以及相关资源：</p><ul><li><a
href="http://www.ghacks.net/2007/03/19/optimize-wordpress-loading-times/" rel="external" target="_blank">优化你的 wordpress 载入时间</a></li><li><a
href="http://weblogtoolscollection.com/archives/2005/04/06/optimize-your-database/" rel="external" target="_blank">优化你的数据库</a></li><li><a
href="http://paulstamatiou.com/2007/03/18/how-to-optimize-your-css-even-more/" rel="external" target="_blank">如何优化 CSS</a></li><li><a
href="http://elliottback.com/wp/archives/2006/07/27/optimizing-wordpress-performance-speed/" rel="external" target="_blank">优化 wordpress 性能</a></li><li><a
href="http://blog.mozmonkey.com/2006/optimizing-wordpress-for-high-volume-traffic/" rel="external" target="_blank">优化 wordpress 以适应高流量</a></li><li><a
href="http://asymptomatic.net/2006/05/02/2327/high-performance-wordpress/" rel="external" target="_blank">高性能的 wordpress</a></li><li><a
href="http://vallery.net/2007/03/26/optimizing-wordpress-and-lamp-to-survive-the-digg-effect/" rel="external" target="_blank">优化 wordpress 以承受 digg 效应</a></li><li><a
href="http://www.earnersblog.com/blog-seo/digproof-your-wordpress/" rel="external" target="_blank">加速你的 wordpress blog</a></li><li><a
href="http://blog.circlesixdesign.com/2007/01/22/diggproof/" rel="external" target="_blank">让 digg 考验你的 wordpress</a></li><li><a
href="http://weblogtoolscollection.com/archives/2007/02/11/wp-21-performance/" rel="external" target="_blank">wp2.1 比 2.0 快</a></li><li><a
href="http://groups.google.com/group/wordpress-soc-2007/web/performance-testing" rel="external" target="_blank">2007 代码之夏：性能测试项目</a></li></ul> ]]></content:encoded> <wfw:commentRss>http://www.wordpress-expert.info/blog/%e5%a6%82%e4%bd%95%e6%8f%90%e5%8d%87-wordpress-%e6%80%a7%e8%83%bd.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>ubuntu下安装lampp+memcache</title><link>http://www.wordpress-expert.info/blog/ubuntu%e4%b8%8b%e5%ae%89%e8%a3%85lamppmemcache.html</link> <comments>http://www.wordpress-expert.info/blog/ubuntu%e4%b8%8b%e5%ae%89%e8%a3%85lamppmemcache.html#comments</comments> <pubDate>Sat, 10 Dec 2011 07:37:55 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[uncategories]]></category> <guid
isPermaLink="false">http://www.wordpress-expert.info/?p=232</guid> <description><![CDATA[ubuntu下安装lampp+memcache By KUCO &#124; Published: 2010/08/15 from:http://www.studyday.net/2010/08/15 部分内容来自这里 部分内容来自这里 部分内容来自这里 ########################## # LAMPP部分 ########################## 1, 下载 http://www.apachefriends.org/zh_cn/xampp-linux.html 2, 安装 1 sudo su #切换到root用户用户 2 tar xvfz xampp-linux-1.7.3a.tar.gz -C /opt #安装 就这样结束了。XAMPP 被安装在 /opt/lampp 目录下。 &#160; 3, 运行 1 /opt/lampp/lampp start 您应该能在屏幕上看到类似下面的提示信息： 1 Starting XAMPP 1.7.3a... 2 LAMPP: Starting Apache... 3 LAMPP: Starting MySQL... 4 LAMPP started. 好了。Apache 和 MySQL 正在运行中。 4, 其它 使用它, 在浏览器中输入 [...]]]></description> <content:encoded><![CDATA[<div
style="float:left;margin-right:10px;"><script type="text/javascript">google_ad_client = "ca-pub-2177081245618878";
/* we-content */
google_ad_slot = "1030718498";
google_ad_width = 250;
google_ad_height = 250;</script> <script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div><h1>ubuntu下安装lampp+memcache</h1><div>By <a
title="View all posts by kuco" href="http://www.studyday.net/author/kuco/">KUCO</a> | Published: <abbr
title="2010-08-15T22:04:13+0000">2010/08/15</abbr></div><div>from:<a
href="http://www.studyday.net/2010/08/15">http://www.studyday.net/2010/08/15</a></div><div><p>部分内容来自<a
href="http://www.apachefriends.org/zh_cn/xampp-linux.html" target="_blank">这里</a><br
/> 部分内容来自<a
href="http://www.javaeye.com/topic/193900" target="_blank">这里</a><br
/> 部分内容来自<a
href="http://sametouch.blog.163.com/blog/static/755906662009101611521508/" target="_blank">这里</a></p><p>##########################<br
/> # LAMPP部分<br
/> ##########################<br
/> 1, 下载 <a
href="http://www.apachefriends.org/zh_cn/xampp-linux.html" target="_blank">http://www.apachefriends.org/zh_cn/xampp-linux.html</a></p><p>2, 安装</p><div
id="highlighter_957731"><div><div><table><tbody><tr><td><code>1</code></td><td><code>sudo</code> <code>su</code> <code>#切换到root用户用户</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>2</code></td><td><code>tar</code> <code>xvfz xampp-linux-1.7.3a.</code><code>tar</code><code>.gz -C /opt </code><code>#安装</code></td></tr></tbody></table></div></div></div><p>就这样结束了。XAMPP 被安装在 /opt/lampp 目录下。</p><p>&nbsp;</p><p>3, 运行</p><div
id="highlighter_267579"><div><div><table><tbody><tr><td><code>1</code></td><td><code>/opt/lampp/lampp start</code></td></tr></tbody></table></div></div></div><p>您应该能在屏幕上看到类似下面的提示信息：</p><div
id="highlighter_496260"><div><div><table><tbody><tr><td><code>1</code></td><td><code>Starting XAMPP 1.7.3a...</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>2</code></td><td><code>LAMPP: Starting Apache...</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>3</code></td><td><code>LAMPP: Starting MySQL...</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>4</code></td><td><code>LAMPP started.</code></td></tr></tbody></table></div></div></div><p>好了。Apache 和 MySQL 正在运行中。</p><p>4, 其它<br
/> 使用它, 在浏览器中输入</p><div
id="highlighter_246017"><div><div><table><tbody><tr><td><code>1</code></td><td><code><a
href="http://localhost/">http://localhost</a></code></td></tr></tbody></table></div></div></div><p>高级的启动与停止参数</p><div
id="highlighter_918320"><div><div><table><tbody><tr><td><code>01</code></td><td><code>start </code><code>#启动 XAMPP。</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>02</code></td><td><code>stop </code><code>#停止 XAMPP。</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>03</code></td><td><code>restart </code><code>#重新启动 XAMPP。</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>04</code></td><td><code>startapache </code><code>#只启动 Apache。</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>05</code></td><td><code>startssl </code><code>#启动 Apache 的 SSL 支持。该命令将持续激活 SSL 支持，例如：执行该命令后，如果您关闭并重新启动 XAMPP，SSL 仍将处于激活状态。</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>06</code></td><td><code>startmysql </code><code>#只启动 MySQL 数据库。</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>07</code></td><td><code>startftp </code><code>#启动 ProFTPD 服务器。通过 FTP，您可以上传文件到您的网络服务器中（用户名“nobody”，密码“lampp”）。该命令将持续激活 ProFTPD，例如：执行该命令后，如果您关闭并重新启动 XAMPP，FTP 仍将处于激活状态。</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>08</code></td><td><code>stopapache </code><code>#停止 Apache。</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>09</code></td><td><code>stopssl </code><code>#停止 Apache 的 SSL 支持。该命令将持续停止 SSL 支持，例如：执行该命令后，如果您关闭并重新启动 XAMPP，SSL 仍将处于停止状态。</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>10</code></td><td><code>stopmysql </code><code>#停止 MySQL 数据库。</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>11</code></td><td><code>stopftp </code><code>#停止 ProFTPD 服务器。该命令将持续停止 ProFTPD，例如：执行该命令后，如果您关闭并重新启动 XAMPP，FTP 仍将处于停止状态。</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>12</code></td><td><code>security </code><code>#启动一个小型安全检查程序。</code></td></tr></tbody></table></div></div></div><p>重要的文件和目录</p><div
id="highlighter_868363"><div><div><table><tbody><tr><td><code>1</code></td><td><code>/opt/lampp/bin/ </code><code>#XAMPP 命令库。例如 /opt/lampp/bin/mysql 可执行 MySQL 监视器。</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>2</code></td><td><code>/opt/lampp/htdocs/ </code><code>#Apache 文档根目录。</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>3</code></td><td><code>/opt/lampp/etc/httpd.conf </code><code>#Apache 配制文件。</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>4</code></td><td><code>/opt/lampp/etc/my.cnf </code><code>#MySQL 配制文件。</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>5</code></td><td><code>/opt/lampp/etc/php.ini </code><code>#PHP 配制文件。</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>6</code></td><td><code>/opt/lampp/etc/proftpd.conf </code><code>#ProFTPD 配制文件。（从 0.9.5 版开始）</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>7</code></td><td><code>/opt/lampp/phpmyadmin/config.inc.php </code><code>#phpMyAdmin 配制文件。</code></td></tr></tbody></table></div></div></div><p>##########################<br
/> # MEMCACHE部分<br
/> ##########################<br
/> 1, 分别把memcached和libevent下载回来，放到 /tmp 目录下</p><div
id="highlighter_186496"><div><div><table><tbody><tr><td><code>1</code></td><td><code>cd</code> <code>/tmp</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>2</code></td><td><code>wget <a
href="http://www.danga.com/memcached/dist/memcached-1.2.0.">http://www.danga.com/memcached/dist/memcached-1.2.0.</a></code><code>tar</code><code>.gz</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>3</code></td><td><code>wget <a
href="http://www.monkey.org/">http://www.monkey.org/</a>~provos/libevent-1.2.</code><code>tar</code><code>.gz</code></td></tr></tbody></table></div></div></div><p>2, 先安装libevent</p><div
id="highlighter_609058"><div><div><table><tbody><tr><td><code>1</code></td><td><code>tar</code> <code>zxvf libevent-1.2.</code><code>tar</code><code>.gz</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>2</code></td><td><code>cd</code> <code>libevent-1.2</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>3</code></td><td><code>./configure –prefix=/usr</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>4</code></td><td><code>make</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>5</code></td><td><code>make</code> <code>install</code></td></tr></tbody></table></div></div></div><p>3, 测试libevent是否安装成功</p><div
id="highlighter_760484"><div><div><table><tbody><tr><td><code>1</code></td><td><code># ls -al /usr/lib | grep libevent</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>2</code></td><td><code>lrwxrwxrwx 1 root root 21 11?? 12 17:38 libevent-1.2.so.1 -&gt; libevent-1.2.so.1.0.3</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>3</code></td><td><code>-rwxr-xr-x 1 root root 263546 11?? 12 17:38 libevent-1.2.so.1.0.3</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>4</code></td><td><code>-rw-r–r– 1 root root 454156 11?? 12 17:38 libevent.a</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>5</code></td><td><code>-rwxr-xr-x 1 root root 811 11?? 12 17:38 libevent.la</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>6</code></td><td><code>lrwxrwxrwx 1 root root 21 11?? 12 17:38 libevent.so -&gt; libevent-1.2.so.1.0.3</code></td></tr></tbody></table></div></div></div><p>还不错，都安装上了。</p><p>4, 安装memcached，同时需要安装中指定libevent的安装位置</p><div
id="highlighter_512732"><div><div><table><tbody><tr><td><code>1</code></td><td><code>cd</code> <code>/tmp</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>2</code></td><td><code>tar</code> <code>zxvf memcached-1.2.0.</code><code>tar</code><code>.gz</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>3</code></td><td><code>cd</code> <code>memcached-1.2.0</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>4</code></td><td><code>./configure –with-libevent=/usr</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>5</code></td><td><code>make</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>6</code></td><td><code>make</code> <code>install</code></td></tr></tbody></table></div></div></div><p>如果中间出现报错，请仔细检查错误信息，按照错误信息来配置或者增加相应的库或者路径。<br
/> 安装完成后会把memcached放到 /usr/local/bin/memcached</p><p>5, 测试是否成功安装memcached</p><div
id="highlighter_566158"><div><div><table><tbody><tr><td><code>1</code></td><td><code># ls -al /usr/local/bin/mem*</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>2</code></td><td><code>-rwxr-xr-x 1 root root 137986 11?? 12 17:39 /usr/</code><code>local</code><code>/bin/memcached</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>3</code></td><td><code>-rwxr-xr-x 1 root root 140179 11?? 12 17:39 /usr/</code><code>local</code><code>/bin/memcached-debug</code></td></tr></tbody></table></div></div></div><p>6, 安装Memcache的PHP扩展<br
/> 在http://pecl.php.net/package/memcache 选择相应想要下载的memcache版本。<br
/> 安装PHP的memcache扩展</p><div
id="highlighter_426121"><div><div><table><tbody><tr><td><code>1</code></td><td><code>tar</code> <code>vxzf memcache-2.2.1.tgz</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>2</code></td><td><code>cd</code> <code>memcache-2.2.1</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>3</code></td><td><code>/opt/lampp/bin/phpize</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>4</code></td><td><code>./configure --with-php-config=/opt/lampp/bin/php-config --</code><code>enable</code><code>-memcache</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>5</code></td><td><code>make</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>6</code></td><td><code>make</code> <code>install</code></td></tr></tbody></table></div></div></div><p>如果安装成功会显示类似提示</p><div
id="highlighter_63942"><div><div><table><tbody><tr><td><code>1</code></td><td><code>Installing shared extensions: /opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/</code></td></tr></tbody></table></div></div></div><p>在 ./configure 时<br
/> 可能会遇到如下错误</p><div
id="highlighter_251352"><div><div><table><tbody><tr><td><code>1</code></td><td><code>Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable is set correctly and then rerun this script.</code></td></tr></tbody></table></div></div></div><p>解决:</p><div
id="highlighter_484675"><div><div><table><tbody><tr><td><code>01</code></td><td><code>cd</code> <code>/usr/src</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>02</code></td><td><code>wget <a
href="http://www.studyday.net/2010/08/15">http://</a></code><code>ftp</code><code>.gnu.org/gnu/m4/m4-1.4.9.</code><code>tar</code><code>.gz</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>03</code></td><td><code>tar</code> <code>-zvxf m4-1.4.9.</code><code>tar</code><code>.gz</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>04</code></td><td><code>cd</code> <code>m4-1.4.9/</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>05</code></td><td><code>./configure &amp;&amp; </code><code>make</code> <code>&amp;&amp; </code><code>make</code> <code>install</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>06</code></td><td><code>cd</code> <code>../</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>07</code></td><td><code>wget <a
href="http://www.studyday.net/2010/08/15">http://</a></code><code>ftp</code><code>.gnu.org/gnu/autoconf/autoconf-2.62.</code><code>tar</code><code>.gz</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>08</code></td><td><code>tar</code> <code>-zvxf autoconf-2.62.</code><code>tar</code><code>.gz</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>09</code></td><td><code>cd</code> <code>autoconf-2.62/</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>10</code></td><td><code>./configure &amp;&amp; </code><code>make</code> <code>&amp;&amp; </code><code>make</code> <code>instal</code></td></tr></tbody></table></div></div></div><p>可能会遇到如下错误</p><div
id="highlighter_195972"><div><div><table><tbody><tr><td><code>1</code></td><td><code>报错，缺少 php.h、zend_modules.h、zend_extensions.h</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>2</code></td><td><code>或 报错，configure: error: Cannot find php_session.h</code></td></tr></tbody></table></div></div></div><p>解决:<br
/> 错误原因是由于使用的Lampp是应用版，缺少必要的头文件！<br
/> 下载Lampp开发包（xampp-linux-devel-1.7.2.tar.gz）到临时目录<br
/> 下载地址还是：<a
href="http://www.apachefriends.org/zh_cn/xampp-linux.html" target="_blank">http://www.apachefriends.org/zh_cn/xampp-linux.html</a><br
/> 解压开发包，将其中的include目录复制到应用的lampp目录下</p><div
id="highlighter_233436"><div><div><table><tbody><tr><td><code>1</code></td><td><code>tar</code> <code>-zxvf xampp-linux-devel-1.7.2.</code><code>tar</code><code>.gz</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>2</code></td><td><code>cp</code> <code>./lampp/include /opt/lampp/ -R</code></td></tr></tbody></table></div></div></div><p>7， 修改Php配置文件，启用Memcache</p><div
id="highlighter_735172"><div><div><table><tbody><tr><td><code>1</code></td><td><code>vi</code> <code>/opt/lampp/etc/php.ini</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>2</code></td><td><code>//找到Dynamic Extensions的位置，添加一行：extension=</code><code>"memcache.so"</code></td></tr></tbody></table></div></div></div><p>8, 重启Lampp</p><div
id="highlighter_89215"><div><div><table><tbody><tr><td><code>1</code></td><td><code>/opt/lampp/lampp restart</code></td></tr></tbody></table></div></div></div><p>这时，使用phpinfo脚本查看时，会发现memcache的配置段，说明安装成功！</p><p>9, 启动Memcache的服务器端：</p><div
id="highlighter_442514"><div><div><table><tbody><tr><td><code>1</code></td><td><code>/usr/</code><code>local</code><code>/bin/memcached -d -m 10 -u root -l 192.168.0.101 -p 12000 -c 256 -P /tmp/memcached.pid</code></td></tr></tbody></table></div></div></div><p>-d选项是启动一个守护进程，<br
/> -m是分配给Memcache使用的内存数量，单位是MB，我这里是10MB，<br
/> -u是运行Memcache的用户，我这里是root，<br
/> -l是监听的服务器IP地址，如果有多个地址的话，我这里指定了服务器的IP地址192.168.0.101，<br
/> -p是设置Memcache监听的端口，我这里设置了12000，最好是1024以上的端口，<br
/> -c选项是最大运行的并发连接数，默认是1024，我这里设置了256，按照你服务器的负载量来设定，<br
/> -P是设置保存Memcache的pid文件，我这里是保存在 /tmp/memcached.pid，<br
/> 如果要结束Memcache进程，执行：</p><div
id="highlighter_760434"><div><div><table><tbody><tr><td><code>1</code></td><td><code>kill</code> <code>`</code><code>cat</code> <code>/tmp/memcached.pid`</code></td></tr></tbody></table></div></div></div><p>10, 在/opt/lampp/htdocs/下建立一个测试php：test.php</p><div
id="highlighter_211568"><div><div><table><tbody><tr><td><code>1</code></td><td><code>&lt;?php</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>2</code></td><td><code>$mem</code> <code>= </code><code>new</code> <code>Memcache;</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>3</code></td><td><code>$mem</code><code>-&gt;connect(</code><code>'192.168.1.101'</code><code>, 12000);</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>4</code></td><td><code>$mem</code><code>-&gt;set(</code><code>'key'</code><code>, </code><code>'This is a test!'</code><code>, 0, 60);</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>5</code></td><td><code>$val</code> <code>= </code><code>$mem</code><code>-&gt;get(</code><code>'key'</code><code>);</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>6</code></td><td><code>echo</code> <code>$val</code><code>;</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>7</code></td><td><code>?&gt;</code></td></tr></tbody></table></div></div></div></div><div>This entry was posted in <a
title="View all posts in Linux" href="http://www.studyday.net/category/linux" rel="category tag">Linux</a>, <a
title="View all posts in PHP" href="http://www.studyday.net/category/php" rel="category tag">PHP</a>, <a
title="View all posts in Tool" href="http://www.studyday.net/category/tool" rel="category tag">Tool</a> and tagged <a
href="http://www.studyday.net/tag/lampp" rel="tag">lampp</a>, <a
href="http://www.studyday.net/tag/memcache" rel="tag">memcache</a>, <a
href="http://www.studyday.net/tag/ubuntu" rel="tag">ubuntu</a>. Bookmark the <a
title="Permalink to ubuntu下安装lampp+memcache" href="http://www.studyday.net/2010/08/15">permalink</a>. Trackbacks are closed, but you can <a
title="Post a comment" href="http://www.studyday.net/2010/08/15#respond">post a comment</a>.</div> ]]></content:encoded> <wfw:commentRss>http://www.wordpress-expert.info/blog/ubuntu%e4%b8%8b%e5%ae%89%e8%a3%85lamppmemcache.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>How to Configure Apache to Gzip Your Components</title><link>http://www.wordpress-expert.info/blog/how-to-configure-apache-to-gzip-your-components.html</link> <comments>http://www.wordpress-expert.info/blog/how-to-configure-apache-to-gzip-your-components.html#comments</comments> <pubDate>Sat, 12 Nov 2011 18:17:53 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[linux]]></category> <category><![CDATA[gzip]]></category> <guid
isPermaLink="false">http://www.wordpress-expert.info/?p=222</guid> <description><![CDATA[Compressing your Web components will help speed up your Website.  The majority of your visitors will benefit as most all Web browsers support gzip compression.  You’ll want to compress all text, which includes html, css, javascript, xml, json, etc. Apache 2.x uses mod_deflate, and all you need to do is add the following to your [...]]]></description> <content:encoded><![CDATA[<div
style="float:left;margin-right:10px;"><script type="text/javascript">google_ad_client = "ca-pub-2177081245618878";
/* we-content */
google_ad_slot = "1030718498";
google_ad_width = 250;
google_ad_height = 250;</script> <script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div><p>Compressing your Web components will help speed up your Website.  The majority of your visitors will benefit as most all Web browsers support gzip compression.  You’ll want to compress all text, which includes html, css, javascript, xml, json, etc.</p><p>Apache 2.x uses mod_deflate, and all you need to do is add the following to your &lt;VirtualHost&gt; section of your Apache configuration:</p><p>AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript<br
/> BrowserMatch ^Mozilla/4 gzip-only-text/html<br
/> BrowserMatch ^Mozilla/4\.0[678] no-gzip<br
/> BrowserMatch \bMSIE !no-gzip !gzip-only-text/html</p><p>All you truly need is the first line.  The BrowserMatch lines are there to handle issues with old browsers.</p><p>You can read all about gzipping by reading Yahoo!’s <a
href="http://developer.yahoo.com/performance/rules.html#gzip" target="_blank">Best Practices for Speeding Up Your Website</a> guide.</p><p>Also, be sure to check out our post on <a
href="http://www.justinbritten.com/work/2008/12/how-to-set-an-expires-header-in-apache">How to Set an Expires Header in Apache</a>, which will also help speed up your Website.</p><p>&nbsp;</p><p>source: <a
href="http://www.justinbritten.com/work/2008/12/apache-gzip-configuration/">http://www.justinbritten.com/work/2008/12/apache-gzip-configuration/</a></p> ]]></content:encoded> <wfw:commentRss>http://www.wordpress-expert.info/blog/how-to-configure-apache-to-gzip-your-components.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>How to enable GZIP Compression in Apache Server to Speed up Website</title><link>http://www.wordpress-expert.info/blog/how-to-enable-gzip-compression-in-apache-server-to-speed-up-website.html</link> <comments>http://www.wordpress-expert.info/blog/how-to-enable-gzip-compression-in-apache-server-to-speed-up-website.html#comments</comments> <pubDate>Sat, 12 Nov 2011 18:17:24 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[linux]]></category> <category><![CDATA[gzip]]></category> <guid
isPermaLink="false">http://www.wordpress-expert.info/?p=221</guid> <description><![CDATA[Compression is a simple and effective way to speed up your site. Modern browsers supports gzip compressed content and are capable of uncompressing gzip data into plain text. The gzip module configuration depends on your Apache Server version: Apache 1.3 uses mod_gzip while Apache 2.x uses mod_deflate. mod_gzip configuration for Apache 1.3.x: &#60;IfModule mod_gzip.c&#62; mod_gzip_on Yes mod_gzip_dechunk Yes [...]]]></description> <content:encoded><![CDATA[<div
style="float:left;margin-right:10px;"><script type="text/javascript">google_ad_client = "ca-pub-2177081245618878";
/* we-content */
google_ad_slot = "1030718498";
google_ad_width = 250;
google_ad_height = 250;</script> <script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div><p>Compression is a simple and effective way to speed up your site. Modern browsers supports gzip compressed content and are capable of uncompressing gzip data into plain text.</p><p>The gzip module configuration depends on your Apache Server version:<br
/> Apache 1.3 uses <a
href="http://sourceforge.net/projects/mod-gzip/" target="_blank">mod_gzip</a> while Apache 2.x uses <a
href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html" target="_blank">mod_deflate</a>.</p><p><strong>mod_gzip configuration for Apache 1.3.x:</strong></p><div>&lt;IfModule mod_gzip.c&gt;<br
/> mod_gzip_on Yes<br
/> mod_gzip_dechunk Yes<br
/> mod_gzip_item_include file \.(html?|txt|css|js|php)$<br
/> mod_gzip_item_include handler ^cgi-script$<br
/> mod_gzip_item_include mime ^text/.*<br
/> mod_gzip_item_include mime ^application/x-javascript.*<br
/> mod_gzip_item_exclude mime ^image/.*<br
/> mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*<br
/> &lt;/IfModule&gt;</div><p><strong>mod_deflate configuration for Apache 2.x:</strong></p><div>&lt;IfModule mod_deflate.c&gt;<br
/> SetOutputFilter DEFLATE# Don’t compress<br
/> SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary<br
/> SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary</p><p>#Dealing with proxy servers<br
/> &lt;IfModule mod_headers.c&gt;<br
/> Header append Vary User-Agent<br
/> &lt;/IfModule&gt;</p><p>&lt;/IfModule&gt;</p></div><p><strong>Online web page compression / deflate / gzip test tool</strong><br
/> 1. <a
href="http://www.port80software.com/tools/compresscheck.asp" target="_blank">Port80 Compression Check</a><br
/> 2. <a
href="http://www.gidnetwork.com/tools/gzip-test.php" target="_blank">GIDZipTest</a></p><p><strong>Resources</strong><br
/> <a
href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html" target="_blank">Apache Module mod_deflate</a><br
/> <a
href="http://www.linuxjournal.com/article/6802" target="_blank">Compressing Web Content with mod_gzip and mod_deflate</a><br
/> <a
href="http://www.cyberciti.biz/tips/speed-up-apache-20-web-access-or-downloads-with-mod_deflate.html" target="_blank">Speed up Apache 2.0 web access or downloads with mod_deflate</a></p><p>source:<a
href="http://www.techiepark.com/tutorials/how-to-enable-gzip-compression-in-apache-server-to-speed-up-website/">http://www.techiepark.com/tutorials/how-to-enable-gzip-compression-in-apache-server-to-speed-up-website/</a></p> ]]></content:encoded> <wfw:commentRss>http://www.wordpress-expert.info/blog/how-to-enable-gzip-compression-in-apache-server-to-speed-up-website.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>How To Optimize Your Site With GZIP Compression</title><link>http://www.wordpress-expert.info/blog/how-to-optimize-your-site-with-gzip-compression.html</link> <comments>http://www.wordpress-expert.info/blog/how-to-optimize-your-site-with-gzip-compression.html#comments</comments> <pubDate>Sat, 12 Nov 2011 18:15:22 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[linux]]></category> <category><![CDATA[wordoress]]></category> <category><![CDATA[gzip]]></category> <guid
isPermaLink="false">http://www.wordpress-expert.info/?p=219</guid> <description><![CDATA[Compression is a simple, effective way to save bandwidth and speed up your site. I hesitated when recommending gzip compression when speeding up your javascriptbecause of problems in older browsers. But it&#8217;s the 21st century. Most of my traffic comes from modern browsers, and quite frankly, most of my users are fairly tech-savvy. I don&#8217;t want to slow everyone else down [...]]]></description> <content:encoded><![CDATA[<div
style="float:left;margin-right:10px;"><script type="text/javascript">google_ad_client = "ca-pub-2177081245618878";
/* we-content */
google_ad_slot = "1030718498";
google_ad_width = 250;
google_ad_height = 250;</script> <script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div><p>Compression is a simple, effective way to save bandwidth and speed up your site. I hesitated when recommending gzip compression when <a
href="http://betterexplained.com/articles/speed-up-your-javascript-load-time/">speeding up your javascript</a>because of <a
href="http://support.microsoft.com/kb/837251">problems</a> <a
href="http://support.microsoft.com/kb/823386">in</a> <a
href="http://schroepl.net/projekte/mod_gzip/browser.htm">older browsers</a>.</p><p>But it&#8217;s the 21st century. Most of my traffic comes from modern browsers, and quite frankly, most of <a
href="http://instacalc.com/">my users</a> are fairly tech-savvy. I don&#8217;t want to slow everyone else down because somebody is chugging along on IE 4.0 on Windows 95. Google and Yahoo use gzip compression. A modern browser is needed to enjoy modern web content and modern web speed &#8212; so gzip encoding it is. Here&#8217;s how to set it up.</p><h2>Wait, wait, wait: Why are we doing this?</h2><p>Before we start I should explain what content encoding is. When you request a file like<code>http://www.yahoo.com/index.html</code>, your browser talks to a web server. The conversation goes a little like this:</p><p><img
title="HTTP_request.png" src="http://betterexplained.com/wp-content/uploads/compression/HTTP_request.png" alt="HTTP_request.png" width="437" height="221" border="0" /></p><p>1. Browser: Hey, <strong>GET</strong> me /index.html<br
/> 2. Server: Ok, let me see if index.html is lying around&#8230;<br
/> 3. Server: Found it! Here&#8217;s your response code (200 OK) and I&#8217;m sending the file.<br
/> 4. Browser: 100KB? Ouch&#8230; waiting, waiting&#8230; ok, it&#8217;s loaded.</p><p>Of course, the actual headers and protocols are much more formal (monitor them with<a
href="http://betterexplained.com/articles/how-to-debug-web-applications-with-firefox/">Live HTTP Headers</a> if you&#8217;re so inclined).</p><p>But it worked, and you got your file.</p><h2>So what&#8217;s the problem?</h2><p>Well, the system works, but it&#8217;s not that efficient. 100KB is a <strong>lot of text</strong>, and frankly,HTML is redundant. Every <code>&lt;html&gt;, &lt;table&gt; and &lt;div&gt;</code> tag has a closing tag that&#8217;s almost the same. Words are repeated throughout the document. Any way you slice it, HTML(and its beefy cousin, XML) is not lean.</p><p>And what&#8217;s the plan when a file&#8217;s too big? Zip it!</p><p>If we could send a .zip file to the browser (index.html.zip) instead of plain old index.html, we&#8217;d save on bandwidth and download time. The browser could download the zipped file, extract it, and then show it to user, who&#8217;s in a good mood because the page loaded quickly. The browser-server conversation might look like this:</p><p><img
title="HTTP_request_compressed.png" src="http://betterexplained.com/wp-content/uploads/compression/HTTP_request_compressed.png" alt="HTTP_request_compressed.png" width="436" height="213" border="0" /></p><p>1. Browser: Hey, can I <strong>GET</strong> index.html? I&#8217;ll take a compressed version if you&#8217;ve got it.<br
/> 2. Server: Let me find the file&#8230; yep, it&#8217;s here. And you&#8217;ll take a compressed version? Awesome.<br
/> 3. Server: Ok, I&#8217;ve found index.html (200 OK), am zipping it and sending it over.<br
/> 4. Browser: Great! It&#8217;s only 10KB. I&#8217;ll unzip it and show the user.</p><p>The formula is simple: Smaller file = faster download = <strong>happy user</strong>.</p><p>Don&#8217;t believe me? The HTML portion of the yahoo home page goes from 101kb to 15kb after compression:</p><p><img
title="yahoo_compression.PNG" src="http://betterexplained.com/wp-content/uploads/compression/yahoo.png" alt="yahoo_compression.PNG" width="391" height="50" border="0" /></p><h2>The (not so) hairy details</h2><p>The tricky part of this exchange is the browser and server knowing it&#8217;s ok to send a zipped file over. The agreement has two parts</p><ul><li>The <strong>browser sends a header</strong> telling the server it accepts compressed content (gzip and deflate are two compression schemes): <code>Accept-Encoding: gzip, deflate</code></li></ul><ul><li>The <strong>server sends a response</strong> if the content is actually compressed: <code>Content-Encoding: gzip</code></li></ul><p>If the server doesn&#8217;t send the content-encoding response header, it means the file is not compressed (the default on many servers). The “Accept-encoding” header is just a request by the browser, not a demand. If the server doesn&#8217;t want to send back compressed content, the browser has to make do with the heavy regular version.</p><h2>Setting up the server</h2><p>The “good news” is that we can&#8217;t control the browser. It either sends the <code>Accept-encoding: gzip, deflate</code> header or it doesn&#8217;t.</p><p>Our job is to configure the server so it returns zipped content if the browser can handle it, saving bandwidth for everyone (and giving us a happy user).</p><p>For IIS, <a
href="http://technet.microsoft.com/en-us/library/cc771003(WS.10).aspx">enable compression</a> in the settings.</p><p>In Apache, <a
href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html">enabling output compression</a> is fairly straightforward. Add the following to your .htaccess file:</p><pre><code> # compress text, html, javascript, css, xml: AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript # Or, compress certain file types by extension: &lt;files *.html&gt; SetOutputFilter DEFLATE &lt;/files&gt; </code></pre><p>Apache actually has two compression options:</p><ul><li><strong>mod_deflate</strong> is easier to set up and is standard.</li><li><strong>mod_gzip</strong> seems more powerful: you can pre-compress content.</li></ul><p>Deflate is quick and works, so I use it; use mod_gzip if that floats your boat. In either case, Apache checks if the browser sent the “Accept-encoding” header and returns the compressed or regular version of the file. However, some older browsers may have trouble (more below) and there are special directives you can add to correct this.</p><p>If you can&#8217;t change your .htaccess file, you can <a
href="http://perishablepress.com/press/2007/03/26/fast-effective-php-compression/">use PHP</a> to return compressed content. Give your HTML file a .php extension and add this code to the top:</p><p>In PHP:</p><p>&lt;?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], &#8216;gzip&#8217;)) ob_start(“ob_gzhandler”); else ob_start(); ?&gt;</p><p>We check the “Accept-encoding” header and return a gzipped version of the file (otherwise the regular version). This is almost like building your own webserver (what fun!). But really, try to use Apache to compress your output if you can help it. You don&#8217;t want to monkey with your files.</p><h2>Verify Your Compression</h2><p>Once you&#8217;ve configured your server, check to make sure you&#8217;re actually serving up compressed content.</p><ul><li><strong>Online:</strong> Use the <a
href="http://www.gidnetwork.com/tools/gzip-test.php">online gzip test</a> to check whether your page is compressed.</li><li><strong>In your browser:</strong> Use <a
href="https://addons.mozilla.org/en-US/firefox/addon/60">Web Developer Toolbar</a> &gt; Information &gt; View Document Size (like I did for Yahoo, above) to see whether the page is compressed.</li><li><strong>View the headers:</strong> Use <a
href="https://addons.mozilla.org/en-US/firefox/addon/3829">Live HTTP Headers</a> to examine the response. Look for a line that says “Content-encoding: gzip”.</li></ul><p>Be prepared to marvel at the results. The <a
href="http://instacalc.com/">instacalc homepage</a> shrunk from 36k to 10k, a 75% reduction in size.</p><h2>Try Some Examples</h2><p>I&#8217;ve set up some pages and a <a
href="http://betterexplained.com/examples/compressed/compression-example.zip">downloadable example</a>:</p><ul><li><a
href="http://betterexplained.com/examples/compressed/index.html">index.html</a> - No explicit compression (on this server, I am using compression by default <img
src="http://betterexplained.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" /> ).</li><li><a
href="http://betterexplained.com/examples/compressed/index.htm">index.htm</a> - Explicitly compressed with Apache .htaccess using *.htm as a rule</li><li><a
href="http://betterexplained.com/examples/compressed/index.php">index.php</a> - Explicitly compressed using the PHP header</li></ul><p>Feel free to download the files, put them on your server and tweak the settings.</p><h2>Caveats</h2><p>As exciting as it may appear, HTTP Compression isn&#8217;t all fun and games. Here&#8217;s what to watch out for:</p><ul><li><strong>Older browsers</strong>: Yes, some browsers still may have trouble with compressed content (they say they can accept it, but really they can&#8217;t). If your site absolutely must work with Netscape 1.0 on Windows 95, you may not want to use HTTPCompression. Apache mod_deflate <a
href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html#recommended">has some rules</a> to avoid compression for older browsers.</li><li><strong>Already-compressed content</strong>: Most images, music and videos are already compressed. Don&#8217;t waste time compressing them again. In fact, you probably only need to compress the “big 3&#8243; (HTML, CSS and Javascript).</li><li><strong>CPU-load</strong>: Compressing content on-the-fly uses CPU time and saves bandwidth. Usually this is a great tradeoff given the speed of compression. There are ways to pre-compress static content and send over the compressed versions. This requires more configuration; even if it&#8217;s not possible, compressing output may still be a net win. Using CPU cycles for a faster user experience is well worth it, given the short attention spans on the web.</li></ul><p>Enabling compression is one of the fastest ways to improve your site&#8217;s performance. Go forth, set it up, and let your users enjoy the benefits.</p><p>&nbsp;</p><p>Sourse: <a
href="http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/">http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/</a></p> ]]></content:encoded> <wfw:commentRss>http://www.wordpress-expert.info/blog/how-to-optimize-your-site-with-gzip-compression.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Post types and formats and taxonomies, oh my!</title><link>http://www.wordpress-expert.info/blog/post-types-and-formats-and-taxonomies-oh-my.html</link> <comments>http://www.wordpress-expert.info/blog/post-types-and-formats-and-taxonomies-oh-my.html#comments</comments> <pubDate>Mon, 07 Nov 2011 15:08:07 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[wordpress]]></category> <category><![CDATA[Post Formats]]></category> <guid
isPermaLink="false">http://www.wordpress-expert.info/?p=218</guid> <description><![CDATA[A lot of people have been debating back and forth lately about post formats and custom post formats. This discussion also gets all confused with post types, and custom taxonomies, and categories, and tags… It’s time for some clarity. Mark had a really good poston the topic, but I think this needs to be explored in [...]]]></description> <content:encoded><![CDATA[<div
style="float:left;margin-right:10px;"><script type="text/javascript">google_ad_client = "ca-pub-2177081245618878";
/* we-content */
google_ad_slot = "1030718498";
google_ad_width = 250;
google_ad_height = 250;</script> <script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div><p>A lot of people have been debating back and forth lately about post formats and custom post formats. This discussion also gets all confused with post types, and custom taxonomies, and categories, and tags… It’s time for some clarity. Mark had a <a
href="http://markjaquith.wordpress.com/2010/11/12/post-formats-vs-custom-post-types/">really good post</a>on the topic, but I think this needs to be explored in more detail.</p><p>Also, can’t have a good explanation without a bad analogy. I mean, this is the <em>internet</em>, right? So I should probably try to relate it to cars somehow.</p><h3>A Post Type as a Car</h3><p>Okay, so let’s say we have a post type. It’s called “car”. Anything that even vaguely resembles a car (including trucks, SUVs, jeeps, fire engines) gets lumped together in this post type.</p><p>We can categorize cars by type: Truck. Van. Hummer. Ford. Whatever.</p><p>We can add tags to cars: Four-door. Premium-sound. 6-disc-changer. Etc.</p><p>We can come up with custom taxonomies for them: A Color taxonomy could contain red, blue, black, silver, white, brown, etc.</p><p>The point here is that the post type is the thing itself, the various taxonomies are merely descriptions of it. You wouldn’t have both a “car” and a “truck” post type, because those are the same type of thing. If you prefer to be generic, you could make your post_type into “automobile”, which sorta fits both. That’s just a matter of naming choice.</p><p>Post types are <strong>NOUNS</strong>. Taxonomy terms are <strong>ADJECTIVES</strong>. Taxonomies themselves are <strong>related groups of adjectives</strong>.</p><p>This is why people using post types for things like Podcasts or Comic Strips or Video or something else are just fundamentally wrong. They’re using different nouns to describe the same thing, when they should be using the adjectives to sort out what those things are.</p><h3>Displaying Different Things Differently</h3><p>Historically with WordPress, categories have been used for more than just ways to classify posts. They’ve often been used to define different ways of displaying something.</p><p>The classic example is an “aside”. An aside has been traditionally defined as, basically, a short form post. <a
href="http://ma.tt/">Matt</a> loves asides and he uses them far more often than long format posts:</p><div
id="attachment_307"><p><a
href="http://ottopress.com/files/2010/11/mattaside.png"><img
title="mattaside" src="http://ottopress.com/files/2010/11/mattaside.png" alt="A couple of aside posts on ma.tt" width="770" height="408" /></a>A couple of aside posts on ma.tt</p></div><p>Matt also uses a special format for his gallery posts:</p><div
id="attachment_309"><p><a
href="http://ottopress.com/files/2010/11/mattgallery.png"><img
title="mattgallery" src="http://ottopress.com/files/2010/11/mattgallery.png" alt="One of ma.tt's gallery posts" width="774" height="374" /></a>One of ma.tt&#8217;s gallery posts</p></div><p>Compare these to his normal long format posts:</p><div
id="attachment_308"><p><a
href="http://ottopress.com/files/2010/11/mattessay.png"><img
title="mattessay" src="http://ottopress.com/files/2010/11/mattessay.png" alt="A normal long format post on ma.tt" width="772" height="244" /></a>A normal long format post on ma.tt</p></div><p>You can easily see some of the differences. Asides don’t display a title. Galleries display a photo on the left hand side and the title is shortened and to the right. Long format posts have that double line underneath them, and also show the categories (essays in the above case).</p><p>The way he does these, and the way they have traditionally been done in WordPress in the past, is to co-opt categories. So he has an “Asides” category, and a “Gallery” category. In the code for his theme, he then has code that looks kinda like this:</p><div
id="highlighter_777765"><div><div><table><tbody><tr><td><code>1</code></td><td><code>if</code> <code>(in_category(</code><code>'asides'</code><code>)) {</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>2</code></td><td><code>   </code><code>// stuff to display the aside format post here</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>3</code></td><td><code>} </code><code>else</code> <code>if</code> <code>(in_category(</code><code>'gallery'</code><code>)) {</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>4</code></td><td><code>   </code><code>// stuff to display the gallery format post here</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>5</code></td><td><code>} </code><code>else</code> <code>{</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>6</code></td><td><code>   </code><code>// code to display the normal format post here</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>7</code></td><td><code>}</code></td></tr></tbody></table></div></div></div><p>Then, when he makes a post, he just picks the right category for it and that changes how it shows up on the site.</p><p>The problem is that this is a bit lame. Categories should be adjectives describing the post, not sorting them into functionally different buckets for use by the theme. Sure, you can use them that way, but that’s confusing to some users. You could use tags in the exact same way with the has_tag() function, but that doesn’t make it a good idea.</p><h3>Post Formats (coming soon to a WordPress 3.1 near you)</h3><p>Enter <a
href="http://codex.wordpress.org/Post_Formats">Post Formats</a>. Tumblr has had these for a long time:</p><div
id="attachment_310"><p><a
href="http://ottopress.com/files/2010/11/tumblrpostformats.jpg"><img
title="tumblrpostformats" src="http://ottopress.com/files/2010/11/tumblrpostformats.jpg" alt="Tumblr's post formats" width="500" height="120" /></a>Tumblr&#8217;s post formats</p></div><p>Basically they just define a format for a post to fit into at display time. So the theme could say “asides won’t have a title displayed for them”, and voila. A theme can do something like this to define what formats it supports:</p><div
id="highlighter_335691"><div><div><table><tbody><tr><td><code>1</code></td><td><code>add_theme_support( </code><code>'post-formats'</code><code>, </code><code>array</code><code>( </code><code>'aside'</code><code>, </code><code>'gallery'</code> <code>) );</code></td></tr></tbody></table></div></div></div><p>And it can do something like this when displaying things differently:</p><div
id="highlighter_836919"><div><div><table><tbody><tr><td><code>1</code></td><td><code>if</code> <code>( has_post_format( </code><code>'aside'</code> <code>) ) {</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>2</code></td><td><code>   </code><code>// display the aside format</code></td></tr></tbody></table></div><div><table><tbody><tr><td><code>3</code></td><td><code>}</code></td></tr></tbody></table></div></div></div><p>So there we go. Theme authors can define what formats they support, and they can style those formats appropriately. And we didn’t use categories at all.</p><p>Additional: For those people trying to implement this in themes, post formats also add new styles to the post_class() call. You can use .format-XXX to style based on post formats on a post.</p><h3>Custom Post Formats and why you don’t need them</h3><p>As soon as this was announced, naturally theme authors got up in arms, because theme authors are a rowdy bunch of folks. They like to do things their own way. So there was instantly the question of “how do I add my own format”? The answer is: you don’t, nor should you even think about it.</p><p>Why? Why prevent customization? Think of it from the perspective of the user:</p><ul><li>They’ve got an existing set of posts.</li><li>Those posts have formats.</li><li>They switch to your theme, which uses some custom formats.</li><li>Now their own posts don’t display properly with the new theme, because it’s using a whole different set of formats.</li><li>Bad user experience, that is.</li></ul><p>Now, from the perspective of a theme author, I understand the reasoning here. You want to be able to display things differently.</p><p>The problem is that <em>you were already able to do that before</em>.</p><p>Custom taxonomies have been around a long time. All you had to do was to a) create a custom taxonomy (call it “mytheme_formats”), b) allow users to sort posts into your taxonomy, and c) display things differently in the theme based on the terms in that taxonomy.</p><p>Post Formats is just a taxonomy. It’s a set of adjectives, describing the nouns that are the posts. So now we have “aside posts” and “gallery posts” and “chat posts” and “video posts” and so on. If you want to make your own formats, then you’ve had that ability forever. Why have you not already used it?</p><p>The answer to why you didn’t do it before is because <em>there was no standard set of formats</em>.</p><p>Without a standard set to work with, users won’t have any idea what your formats mean. You have to write documentation. You have to educate the user. You have to explain what this weirdness in your theme is.</p><p>Post formats changes that. Now you have a standard set of formats, and the user, having used other themes that support those formats too, will have some idea of what they mean already. But in order for this to work, themes must all use the same basic formats. There has to be a standard set of adjectives to describe the posts.</p><p>If you want to create your own set, then create your own taxonomy and box to have your set in it. But don’t complain when users don’t understand why your theme’s formats don’t mesh with the formats of every other theme that does support them.</p><p>The point of standards is to be standard. You don’t have to support the standard, but you also will have to deal with the consequences of being non-standard.</p><h3>Summing up</h3><p>In the end, you want to present things to your users in a method that causes the least confusion. If your user wants to display things in a single stream, then those things need to be Posts. If the user wants different things in that stream to display in different ways, then you should use a taxonomy to do that, and the post format taxonomy provides a nice and easy way to standardize that and be compatible with other themes.</p><p>If you want to go it alone with custom things, feel free, but be aware of the risk.</p><p>&nbsp;</p><p>from：<a
href="http://ottopress.com/2010/post-types-and-formats-and-taxonomies-oh-my/">http://ottopress.com/2010/post-types-and-formats-and-taxonomies-oh-my/</a></p> ]]></content:encoded> <wfw:commentRss>http://www.wordpress-expert.info/blog/post-types-and-formats-and-taxonomies-oh-my.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Post Formats vs. Custom Post Types</title><link>http://www.wordpress-expert.info/blog/post-formats-vs-custom-post-types.html</link> <comments>http://www.wordpress-expert.info/blog/post-formats-vs-custom-post-types.html#comments</comments> <pubDate>Mon, 07 Nov 2011 14:23:00 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[wordpress]]></category> <category><![CDATA[Post Formats]]></category> <guid
isPermaLink="false">http://www.wordpress-expert.info/?p=217</guid> <description><![CDATA[Some people are confused about the Post Formats feature that will be made available to themes in WordPress 3.1, especially how it differs from Custom Post Types. CUSTOM POST TYPES These were poorly named. Think: Custom Content Types. That is, non-post content. Examples: employees, products, attachments, menu items, pages, pets. If you want it to show up [...]]]></description> <content:encoded><![CDATA[<div
style="float:left;margin-right:10px;"><script type="text/javascript">google_ad_client = "ca-pub-2177081245618878";
/* we-content */
google_ad_slot = "1030718498";
google_ad_width = 250;
google_ad_height = 250;</script> <script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div><p>Some people are confused about the Post Formats feature that will be made available to themes in WordPress 3.1, especially how it differs from Custom Post Types.</p><h3>CUSTOM POST TYPES</h3><p>These were poorly named. Think: Custom <em>Content</em> Types. That is, non-post content. Examples: employees, products, attachments, menu items, pages, pets. If you want it to show up in your site’s main RSS feed, then it’s probably not a custom post type.</p><h3>POST FORMATS</h3><p>A Post Format is a formatting designation made to a post. For example, a post could be a short “aside,” or a Kottke.org-style link post, or a video post, or a photo gallery post. The data you input might be slightly different — video post should contain a video, an aside should probably not be very long, a link post should have a link. And the way that the post is displayed on the site might be very different — an aside will typically be displayed without a title, a link post may have the title point to the link. A video post may be wider, or have social sharing buttons auto-appended. <strong>But they’re all still posts.</strong> They still show up in your feed, and you still find them in the Posts section of the WordPress backend.</p><p>The important thing to note about Post Formats is that they are going to be a standardized convention. So any theme that supports Post Formats and follows the standard will display your posts in a way that makes sense. Before, themes had to set up category-based conventions, and these conventions weren’t shared by other themes. This is a better way of handling that, and it should make it even easier to switch between themes than before!</p><p>Themers should turn to the <a
href="http://codex.wordpress.org/Post_Formats">Post Formats</a> page in the Codex for info on implementation. Note that we’re not yet in beta, so expect this page to change a bit.</p><p>&nbsp;</p><p>from:<a
href="http://markjaquith.wordpress.com/2010/11/12/post-formats-vs-custom-post-types/">http://markjaquith.wordpress.com/2010/11/12/post-formats-vs-custom-post-types/</a></p> ]]></content:encoded> <wfw:commentRss>http://www.wordpress-expert.info/blog/post-formats-vs-custom-post-types.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Post Formats</title><link>http://www.wordpress-expert.info/blog/post-formats.html</link> <comments>http://www.wordpress-expert.info/blog/post-formats.html#comments</comments> <pubDate>Mon, 07 Nov 2011 14:21:41 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[wordpress]]></category> <category><![CDATA[Post Formats]]></category> <guid
isPermaLink="false">http://www.wordpress-expert.info/?p=216</guid> <description><![CDATA[Post Formats is a theme feature introduced with Version 3.1. A Post Format is a piece of meta information that can be used by a theme to customize its presentation of a post. The Post Formats feature provides a standardized list of formats that are available to all themes that support the feature. Themes are [...]]]></description> <content:encoded><![CDATA[<div
style="float:left;margin-right:10px;"><script type="text/javascript">google_ad_client = "ca-pub-2177081245618878";
/* we-content */
google_ad_slot = "1030718498";
google_ad_width = 250;
google_ad_height = 250;</script> <script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div><p>Post Formats is a theme feature introduced with Version 3.1. A Post Format is a piece of meta information that can be used by a theme to customize its presentation of a post. The Post Formats feature provides a standardized list of formats that are available to all themes that support the feature. Themes are not required to support every format on the list. New formats cannot be introduced by themes nor even plugins. The standardization of this list provides both compatibility between numerous themes and an avenue for external blogging tools to access this feature in a consistent fashion.</p><p>In short, with a theme that supports Post Formats, a blogger can change how each post looks by choosing a Post Format from a radio-button list.</p><p>Using Asides as an example, in the past, a category called Asides was created, and posts were assigned that category, and then displayed differently based on styling rules from post_class() or from in_category(&#8216;asides&#8217;). With Post Formats, the new approach allows a theme to define a Post Format (e.g. add_theme_support(&#8216;post-formats&#8217;, array(&#8216;aside&#8217;))), and then the post format can be selected in the Publish meta box when saving the post. A function call of get_post_format( $post->ID ) can be used to determine the format, and post_class() will also create the “format-asides” class, for pure-css styling.</p><p>Contents</p><p>[hide]<br
/> 1 Supported Formats<br
/> 2 Function Reference<br
/> 3 Adding Theme Support<br
/> 4 Adding Post Type Support<br
/> 5 Using Formats<br
/> 5.1 Suggested Styling<br
/> 5.2 Formats in a Child Theme<br
/> 6 Backwards Compatibility<br
/> 7 Source File<br
/> 8 External Resources<br
/> 9 Related<br
/> Supported Formats<br
/> The following Post Formats are available for users to choose from, if the theme enables support for them.</p><p>Note that while the actual post content entry won&#8217;t change, the theme can use this user choice to display the post differently based on the format chosen. For example, a theme could leave off the display of the title for a “Status” post. How things are displayed is entirely up to the theme, but here are some general guidelines.</p><p>aside &#8211; Typically styled without a title. Similar to a Facebook note update.<br
/> gallery &#8211; A gallery of images. Post will likely contain a gallery shortcode and will have image attachments.<br
/> link &#8211; A link to another site. Themes may wish to use the first <a
href=””> tag in the post content as the external link for that post. An alternative approach could be if the post consists only of a URL, then that will be the URL and the title (post_title) will be the name attached to the anchor for it.<br
/> image &#8211; A single image. The first <img
/> tag in the post could be considered the image. Alternatively, if the post consists only of a URL, that will be the image URL and the title of the post (post_title) will be the title attribute for the image.<br
/> quote &#8211; A quotation. Probably will contain a blockquote holding the quote content. Alternatively, the quote may be just the content, with the source/author being the title.<br
/> status &#8211; A short status update, similar to a Twitter status update.<br
/> video &#8211; A single video. The first <video
/> tag or object/embed in the post content could be considered the video. Alternatively, if the post consists only of a URL, that will be the video URL. May also contain the video as an attachment to the post, if video support is enabled on the blog (like via a plugin).<br
/> audio &#8211; An audio file. Could be used for Podcasting.<br
/> chat &#8211; A chat transcript, like so:<br
/> John: foo<br
/> Mary: bar<br
/> John: foo 2<br
/> Note: When writing or editing a Post, Standard is used to designate that no Post Format is specified. Also if a format is specified that is invalid then standard (no format) will be used.</p><p>Function Reference<br
/> Main Functions<br
/> set_post_format()<br
/> get_post_format()<br
/> has_post_format()<br
/> Other Functions<br
/> get_post_format_link()<br
/> get_post_format_string()<br
/> Adding Theme Support<br
/> Themes need to use add_theme_support() in the functions.php file to tell WordPress which post formats to support by passing an array of formats like so:</p><p>add_theme_support( &#8216;post-formats&#8217;, array( &#8216;aside&#8217;, &#8216;gallery&#8217; ) );<br
/> Note that you must call this before the init hook gets called! A good hook to use is the after_setup_theme hook.</p><p>Adding Post Type Support<br
/> Post Types need to use add_post_type_support() in the functions.php file to tell WordPress which post formats to support:</p><p>// add post-formats to post_type &#8216;page&#8217;<br
/> add_post_type_support( &#8216;page&#8217;, &#8216;post-formats&#8217; );</p><p>// add post-formats to post_type &#8216;my_custom_post_type&#8217;<br
/> add_post_type_support( &#8216;my_custom_post_type&#8217;, &#8216;post-formats&#8217; );<br
/> Or in the function register_post_type(), add &#8216;post-formats&#8217;, in &#8216;supports&#8217; parameter array:</p><p>$args = array(<br
/> &#8230;<br
/> &#8216;supports&#8217; => array(&#8216;title&#8217;, &#8216;editor&#8217;, &#8216;author&#8217;, &#8216;post-formats&#8217;)<br
/> );<br
/> register_post_type(&#8216;book&#8217;, $args);<br
/> Using Formats<br
/> In the theme, make use of get_post_format() to check the format for a post, and change its presentation accordingly. Note that posts with the default format will return a value of FALSE. Or make use of the has_post_format() conditional tag:</p><p>if ( has_post_format( &#8216;video&#8217; )) {<br
/> echo &#8216;this is the video format&#8217;;<br
/> }<br
/> An alternate way to use formats is through styling rules. Themes should use the post_class() function in the wrapper code that surrounds the post to add dynamic styling classes. Post formats will cause extra classes to be added in this manner, using the “format-foo” name.</p><p>For example, one could hide post titles from status format posts in this manner:</p><p>.format-status .post-title {<br
/> display:none;<br
/> }<br
/> Suggested Styling<br
/> Although you can style and design your formats to be displayed any way you see fit, each of the formats lends itself to a certain type of “style”, as dictated by modern usage. It is well to keep in mind the intended usage for each format, as this will lend them towards being easily recognized as a specific type of thing visually by readers.</p><p>For example, the aside, link, and status formats will typically be displayed without title or author information. They are simple, short, and minor. The aside could contain perhaps a paragraph or two, while the link would probably be only a sentence with a link to some URL in it. Both the link and aside might have a link to the single post page (using the_permalink() ) and would thus allow comments, but the status format very likely would not have such a link.</p><p>An image post, on the other hand, would typically just contain a single image, with or without a caption/text to go along with it. An audio/video post would be the same but with audio/video added in. Any of these three could use either plugins or standard Embeds to display their content. Titles and authorship might not be displayed for them either, as the content could be self-explanatory.</p><p>The quote format is especially well suited to posting a simple quote from a person with no extra information. If you were to put the quote into the post content alone, and put the quoted person&#8217;s name into the title of the post, then you could style the post so as to display the_content() by itself but restyled into a blockquote format, and use the_title() to display the quoted person&#8217;s name as the byline.</p><p>A chat in particular will probably tend towards a monospaced type display, in many cases. With some styling on the .format-chat, you can make it display the content of the post using a monospaced font, perhaps inside a gray background div or similar, thus distinguishing it visually as a chat session.</p><p>Formats in a Child Theme<br
/> Child Themes inherit the post formats defined by the parent theme. Calling add_theme_support() for post formats in a child theme will override the existing list, not add to it. Calling remove_theme_support(&#8216;post-formats&#8217;) will remove it all together.</p><p>Backwards Compatibility<br
/> If your plugin or theme needs to be compatible with earlier versions of WordPress, you need to add terms named post-format-$format to the “post_format” taxonomy. For example,</p><p>wp_insert_term( &#8216;post-format-aside&#8217;, &#8216;post_format&#8217; );<br
/> You must also register the post_format taxonomy with register_taxonomy().</p> ]]></content:encoded> <wfw:commentRss>http://www.wordpress-expert.info/blog/post-formats.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Creating Custom Fields for Attachments in WordPress</title><link>http://www.wordpress-expert.info/blog/creating-custom-fields-for-attachments-in-wordpress.html</link> <comments>http://www.wordpress-expert.info/blog/creating-custom-fields-for-attachments-in-wordpress.html#comments</comments> <pubDate>Wed, 07 Sep 2011 17:38:51 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[wordoress]]></category> <category><![CDATA[wordpress]]></category> <guid
isPermaLink="false">http://www.wordpress-expert.info/?p=206</guid> <description><![CDATA[Custom fields in WordPress make it easy to customize your theme in a variety of ways; plus, they are simple to implement for posts and pages. Attachments, on the other hand, take a bit more work to implement, requiring you to read through and decipher core source code in order to make them work. We’ll [...]]]></description> <content:encoded><![CDATA[<div
style="float:left;margin-right:10px;"><script type="text/javascript">google_ad_client = "ca-pub-2177081245618878";
/* we-content */
google_ad_slot = "1030718498";
google_ad_width = 250;
google_ad_height = 250;</script> <script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div><p>Custom fields in WordPress make it easy to customize your theme in a variety of ways; plus, they are simple to implement for posts and pages. Attachments, on the other hand, take a bit more work to implement, requiring you to read through and decipher core source code in order to make them work. We’ll be walking through the use of a couple undocumented WordPress hooks in this tutorial to make this process much easier.<br
/> Preface: About The Hooks<br
/> Both these hooks have been around since WordPress 2.5, and are applied in wp-admin/includes/media.php, but remain underused in the community most likely because they’re undocumented in the Codex. Below is where the hooks are applied in the core code, letting us know what will be passed to the functions we add to each hook.<br
/> attachment_fields_to_edit<br
/> view plaincopy to clipboardprint?<br
/> function get_attachment_fields_to_edit($post, $errors = null) {<br
/> // &#8230;<br
/> $form_fields = apply_filters(“attachment_fields_to_edit”, $form_fields, $post);<br
/> // &#8230;<br
/> }<br
/> $form_fields is a special array which will be described in detail in a moment.<br
/> $post is the attachment as an object (attachments are treated as post objects in WordPress).<br
/> attachment_fields_to_save<br
/> view plaincopy to clipboardprint?<br
/> function media_upload_form_handler() {<br
/> // &#8230;<br
/> $post = apply_filters(“attachment_fields_to_save”, $post, $attachment);<br
/> // &#8230;<br
/> }<br
/> $post is the attachment as an array (attachments are treated as post objects in WordPress).<br
/> $attachment is the attachment part of the form $_POST which will include the fields setup through the attachment_fields_to_edit hook.<br
/> Note: Be careful in your code, as $post is sent to one function as an object and to the other as an array.<br
/> Custom Field Naming Tips<br
/> The new fields being added will be saved as post meta, just like the custom fields section of the post/page edit screen. Fields prefixed with an underscore (_my_custom_field) will not be listed in the drop down of available custom fields on the post/page screen; all other existing post meta fields will be listed. We can use this knowledge to hide the fields we’re adding to the media form, since they aren’t relevant for posts/pages.</p><p>There is a similar rule to keep in mind when choosing the $form_fields array key to use for your new field. Here, if you use an underscore ($form_fields['_my_custom_field']) your field will be skipped and will not be added to the form.<br
/> So in order to show our fields in the media form, but also not list them in the page/post custom fields drop down, we must combine both methods. This will invlove both the edit and save functions we’ll be creating. For the ‘attachment_fields_to_edit‘ hook we’ll set the $form_fields keys up to not have underscore prefixes, and for the ‘attachment_fields_to_save‘ hook we’ll prefix our fields with an underscore before saving them as post meta. This is a workaround worth doing in order to not muddy our users’ interface with unneeded info.<br
/> Hook 1: attachment_fields_to_edit<br
/> Below is an example of how to add your own custom fields to the attachment form.<br
/> view plaincopy to clipboardprint?<br
/> /**<br
/> * Adding our custom fields to the $form_fields array<br
/> *<br
/> * @param array $form_fields<br
/> * @param object $post<br
/> * @return array<br
/> */<br
/> function my_image_attachment_fields_to_edit($form_fields, $post) {<br
/> // $form_fields is a special array of fields to include in the attachment form<br
/> // $post is the attachment record in the database<br
/> //     $post->post_type == &#8216;attachment&#8217;<br
/> // (attachments are treated as posts in WordPress)</p><p> // add our custom field to the $form_fields array<br
/> // input type=”text” name/id=”attachments[$attachment->ID][custom1]”<br
/> $form_fields["custom1"] = array(<br
/> “label” => __(“Custom Text Field”),<br
/> “input” => “text”, // this is default if “input” is omitted<br
/> “value” => get_post_meta($post->ID, “_custom1&#8243;, true)<br
/> );<br
/> // if you will be adding error messages for your field,<br
/> // then in order to not overwrite them, as they are pre-attached<br
/> // to this array, you would need to set the field up like this:<br
/> $form_fields["custom1"]["label"] = __(“Custom Text Field”);<br
/> $form_fields["custom1"]["input"] = “text”;<br
/> $form_fields["custom1"]["value"] = get_post_meta($post->ID, “_custom1&#8243;, true);</p><p> return $form_fields;<br
/> }<br
/> // attach our function to the correct hook<br
/> add_filter(“attachment_fields_to_edit”, “my_image_attachment_fields_to_edit”, null, 2);<br
/> The $form_fields array has several options for including different types of inputs and custom content. I’ve compiled the various methods below with notes and screenshots of how they render in the form.<br
/> Text Input<br
/> view plaincopy to clipboardprint?<br
/> // input type=”text”<br
/> $form_fields["custom1"]["label"] = __(“Custom Text Field”);<br
/> $form_fields["custom1"]["input"] = “text”; // this is default if “input” is omitted<br
/> $form_fields["custom1"]["value"] = get_post_meta($post->ID, “_custom1&#8243;, true);<br
/> Renders in the form as:</p><p>Textarea<br
/> view plaincopy to clipboardprint?<br
/> // textarea<br
/> $form_fields["custom2"]["label"] = __(“Custom Textarea”);<br
/> $form_fields["custom2"]["input"] = “textarea”;<br
/> $form_fields["custom2"]["value"] = get_post_meta($post->ID, “_custom2&#8243;, true);<br
/> Renders in the form as:</p><p>Hidden Field<br
/> Hidden fields are compiled together and output at the end of the form.<br
/> view plaincopy to clipboardprint?<br
/> // input type=”hidden”<br
/> // no need for a label<br
/> $form_fields["custom3"]["input"] = “hidden”;<br
/> $form_fields["custom3"]["value"] = get_post_meta($post->ID, “_custom3&#8243;, true);<br
/> Other Field Types<br
/> If you need an input type other than ‘text’, ‘textarea’, or ‘hidden,’ then use ‘html’ which allows you to pass your own custom content to use for the input element of your choice. When you create your own input html, it’s important to set the ‘name’ attribute on the element correctly, in order for the field to be passed to our save function later. You want something like this: name = “attachments[$post->ID][my_custom_key]” .<br
/> view plaincopy to clipboardprint?<br
/> $form_fields["custom4"]["label"] = __(“Custom Select”);<br
/> $form_fields["custom4"]["input"] = “html”;<br
/> $form_fields["custom4"]["html"] = ”</p> <select
name='attachments[{$post->ID}][custom4]&#8216; id=&#8217;attachments[{$post->ID}][custom4]&#8216;></p><option
value='1'>Option 1</option><option
value='2'>Option 2</option><option
value='3'>Option 3</option> </select><p>“;</p><p>// another example<br
/> $form_fields["custom5"]["label"] = __(“Custom Checkbox”);<br
/> $form_fields["custom5"]["input"] = “html”;<br
/> $form_fields["custom5"]["html"] = “the html output goes here, like a checkbox:</p> <input
type='checkbox' value='1'<br /> name='attachments[{$post->ID}][custom5]&#8216;<br
/> id=&#8217;attachments[{$post->ID}][custom5]&#8216; />”;<br
/> Renders in the form as:</p><p>Special Attributes<br
/> There are several special attributes you can add to your custom fields to enhance them.<br
/> helps – This attribute adds a help string to your custom field.<br
/> view plaincopy to clipboardprint?<br
/> $form_fields["custom6"]["label"] = __(“Custom Field with Helpful Text”);<br
/> $form_fields["custom6"]["value"] = get_post_meta($post->ID, “_custom6&#8243;, true);<br
/> $form_fields["custom6"]["helps"] = “Put helpful text here.”;<br
/> This renders in the form as:</p><p>required – This attribute will mark the field as required; but it is only a visual reference. We’ll have to write code later in the save function to enforce it.<br
/> view plaincopy to clipboardprint?<br
/> $form_fields["custom7"]["label"] = __(“Required Field”);<br
/> $form_fields["custom7"]["value"] = get_post_meta($post->ID, “_custom7&#8243;, true);<br
/> $form_fields["custom7"]["required"] = TRUE; // default is FALSE<br
/> Renders in the form as:</p><p>extra_rows – This attribute lets you add an array of rows right after your custom field. The markup for each array item is shown below: the array key will become the class of the td, and the value is the content:<br
/> view plaincopy to clipboardprint?<br
/> // extra_rows markup:<br
/> //<br
/><tr> //<td></td><p>//<td
class="{arrayItemKey}">{arrayItemValue}</td><p>//</tr><p>$form_fields["custom8"]["label"] = __(“Custom Field with Extra Rows”);<br
/> $form_fields["custom8"]["value"] = get_post_meta($post->ID, “_custom8&#8243;, true);<br
/> // extra_rows must be an associative array $cssClass => $content<br
/> $form_fields["custom8"]["extra_rows"] = array(<br
/> “cssClass1&#8243; => “If you need a few rows after your field&#8230;”,<br
/> “cssClass2&#8243; => “&#8230;to maybe explain something or add some imagery?<br
/> <img
src='".get_bloginfo("wpurl")."/wp-admin/images/align-left.png' /><br
/> <img
src='".get_bloginfo("wpurl")."/wp-admin/images/align-center.png' /><br
/> <img
src='".get_bloginfo("wpurl")."/wp-admin/images/align-right.png' />“,<br
/> );<br
/> Renders in the form as:</p><p>tr – While extra_rows only lets you add table cells directly under your custom field’s input element, this attribute lets you create entire rows.<br
/> The table we’re adding a row to has two columns, so keep that in mind when using this method. And this doesn’t have to be a form field, you could just add a row that explains the next few fields, add all of your fields manually, or something else entirely.<br
/> view plaincopy to clipboardprint?<br
/> $form_fields["custom8"]["tr"] = ”</p><tr
id='MySpecialRow'><td
colspan='2' style='background:#000;color:#fff;'> Can do whatever you want, style it, add some fields, display a table of data&#8230;sky&#8217;s the limit</td></tr><p>“;<br
/> Renders in the form as:</p><p>Hook 2: attachment_fields_to_save<br
/> Saving your custom fields is a much simpler process than adding them to the form; just check if your field is set and update its value as post meta. Remeber to prefix your field with an underscore when saving to hide it on the post/page edit screen.<br
/> view plaincopy to clipboardprint?<br
/> /**<br
/> * @param array $post<br
/> * @param array $attachment<br
/> * @return array<br
/> */<br
/> function my_image_attachment_fields_to_save($post, $attachment) {<br
/> // $attachment part of the form $_POST ($_POST[attachments][postID])<br
/> // $post attachments wp post array &#8211; will be saved after returned<br
/> //     $post['post_type'] == &#8216;attachment&#8217;<br
/> if( isset($attachment['my_field']) ){<br
/> // update_post_meta(postID, meta_key, meta_value);<br
/> update_post_meta($post['ID'], &#8216;_my_field&#8217;, $attachment['my_field']);<br
/> }<br
/> return $post;<br
/> }<br
/> You can also add errors here that will automatically be displayed below your field in the form. The $post['errors'] array gets merged with the $form_fields array before being sent through the attachment_fields_to_edit hook.<br
/> view plaincopy to clipboardprint?<br
/> /**<br
/> * @param array $post<br
/> * @param array $attachment<br
/> * @return array<br
/> */<br
/> function my_image_attachment_fields_to_save($post, $attachment) {<br
/> if( isset($attachment['my_field']) ){<br
/> if( trim($attachment['my_field']) == ” ){<br
/> // adding our custom error<br
/> $post['errors']['my_field']['errors'][] = __(&#8216;Error text here.&#8217;);<br
/> }else{<br
/> update_post_meta($post['ID'], &#8216;my_field&#8217;, $attachment['my_field']);<br
/> }<br
/> }<br
/> return $post;<br
/> }<br
/> Note Regarding Custom Errors: There are a couple long standing bugs in WordPress (as of version 3.0-RC3) that have to do with the display of custom errors.<br
/> One will prevent your custom error messages from showing up on the single media edit page.<br
/> The other bug is in the modal popup for media items used on the post/page edit screen. The errors do display<br
/> here, it’s just the problem of initially seeing them. After saving you’re automatically switched to the<br
/> ‘Gallery’ tab where there’s a minimized list of media items. If you click on ‘show’ to open your new item,<br
/> you’ll see your error messages in the form. The problem is that if there are errors, that items form is supposed to<br
/> be open by default. There’s a bug in the css where the class ‘startopen’ (which is present on the item if<br
/> there are errors to show) has the value of ‘display:none’ in a few places in the core stylesheets.<br
/> I have submitted patches for both of these issues (#13810 &#038; #13838), and have been told they should be reviewed and included by version 3.1. So for now, don’t rely on your error messages too much, just be glad you know how to work with them for when they become more useful in the near future.<br
/> Other Ideas<br
/> You may want to include some of your fields on only audio attachments, or just images attached to the front page. To further customize your attachment forms, just wrap your special fields in distinguishing statements for both the edit and save functions.<br
/> view plaincopy to clipboardprint?<br
/> // for audio files<br
/> if( substr($post->post_mime_type, 0, 5) == &#8216;audio&#8217; ){<br
/> // add your custom fields for audio files<br
/> }</p><p>// OR for images on a specific page</p><p>$page_id = 5; // set the id to whatever page you want these applied to<br
/> if( $post->post_parent == $page_id &#038;&#038; substr($post->post_mime_type, 0, 5) == &#8216;image&#8217; ){<br
/> // add your image specific custom fields for this particular page<br
/> }<br
/> If you think of any clever ways to use custom fields with attachments, share it with us in the comments!</p> ]]></content:encoded> <wfw:commentRss>http://www.wordpress-expert.info/blog/creating-custom-fields-for-attachments-in-wordpress.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
