WordPress常用Template Tag
- the_ permalink(): Returns the URL of your post.
- the_title(): Returns the title of the post.
- the_ID(): Returns the unique ID of your post.
- the_content(): Returns the full content of your post.
- the_excerpt(): Returns just an excerpt of your post. If the Excerpt field is filled out on the Post edit screen, that will be used. If not WordPress will auto-generate a short excerpt from your post content.
- the_time(): Returns the date/time your post was published.
- the_author(): Returns the author of the post.
- the_tags(): Returns the tags attached to the post.
- the_category(): Returns the categories assigned to the post.
- edit_ post_link(): Displays an ‘edit; link that is shown only if you are logged in and allowed to edit the post.
- comments_ popup_link(): Displays a link to the comments form of your post.
WordPress3 全新菜单系统
WordPress的菜单一直是很多Theme开发者头疼的一件事。WordPress3为解决此问题引入了全新的菜单系统。
默认Theme并不会打开此功能,所以很多人奇怪为何twentyten的模板的Appearance模块中有Menus,而自己的Theme为何却没有此菜单选项。
其实为自己的Theme加入Menus是非常容易的一件事情,在你的theme的functions.php中加入以下代码:
add_action( 'init', 'mytheme_register_menu' );
function mytheme_register_menu() {
register_nav_menu( 'primary-menu', __( 'Primary Menu' ) );
}
如果想添加多个菜单可以把register_nav_menu替换成register_nav_menus,代码如下:
add_action( 'init', 'mytheme_register_menus' );
function mytheme_register_menus() {
register_nav_menus(
array(
'primary-menu' => __( 'Primary Menu' ),
'secondary-menu' => __( 'Secondary Menu' ),
'tertiary-menu' => __( 'Tertiary Menu' )
)
);
}
最后在theme里调用函数wp_nav_menu()显示你自定义的菜单。
更多内容可以参加:http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus
WordPress Theme Blog info (获取WordPress博客信息)
bloginfo(“name”): The blog’s title
bloginfo(“description“): The blog’s tag line
bloginfo(“url“): The URL to the blog’s home page
bloginfo(“wpurl“): The URL to the WordPress installation
bloginfo(“rdf_url“): The URL for the blog’s RDF/RSS 1.0 feed
bloginfo(“rss_url“): The URL for the blog’s RSS 0.92 feed
bloginfo(“atom_url“): The URL for the blog’s ATOM feed
bloginfo(“comments_rss2_url“): The URL for the blog’s comments RSS 2.0 feed
bloginfo(“pingback_url“): The URL for the pingback XML-RPC file
bloginfo(“stylesheet_url“): The URL for the primary CSS file of the active theme
bloginfo(“stylesheet_directory“): The URL of the style sheet directory of the active theme
bloginfo(“template_directory“):The directory of the active theme
bloginfo(“template_url“): The URL of the active theme’s directory
bloginfo(“admin_email“): The e-mail address of the blog administrator
bloginfo(“charset“): The blog’s encoding for pages and feeds
bloginfo(“version“): The blog’s version of WordPress
bloginfo(“html_type“): The content type of WordPress HTML pages
bloginfo函数 会把相关信息直接显示在网站上,如需获取数据值而不立刻显示可以使用get_bloginfo函数。
WordPress User Roles (WordPress用户角色)
- Subscribers: can edit their own profiles and not much else.
- Contributors: can submit posts for editors’ approval, but can’t publish anything.
- Authors: can write and publish posts.
- Editors: can write and publish posts and pages. They can also publish posts and pages submitted by other users.
- Administrators: can do everything.
The Size of Linux Partition
- /boot Primary partition Ext2 100 MB
- /var LVM XFS 4 GB
- /home LVM XFS 200 GB
- /root LVM Ext3 50 GB
- swap LVM Swap 1 GB
用.htaccess让文件自动下载而不是打开
<FilesMatch "\.(?i:doc|odf|pdf|rtf|txt)$"> Header set Content-Disposition attachment </FilesMatch>
使用PHP读取Excel文件
可能这应该算得上一个很古老的问题,解决的也有多种多样,不过Internet上比较多的是Excel的保存的范例,所以写一篇如何读取Excel,可能对大家有所帮助。
- 使用COM接口调用,把Excel应用程序作为一个Server,PHP间接使用Excel来读取文件。
- 使用PHPExcel的程序包。它的优点不单单读取资料而且可以保存资料为Excel文件,同时还支持Excel 2007的格式。方法就是把Excel看作一个普通的Excel文件读取。
- 还有一种是PHP Excel Reader,它把Excel文件看作一个二进制文件读取,不过不支持新版本Excel文件。
方法2可能看起来不错,不过当你在读取资料大比较大的文件时,会有一个致命的缺点:内存溢出。因为它必须把整个Excel读入内存。有点像XML的DOM接口,不清楚是否有类型XML的SAX的方法。
方法3有类似方法2内存溢出的问题,同时对新版的支持较差。
方法1应该是属于非常传统的方式,只有支持COM程序接口就可。同时只有你能用当前安装的Excel打开此文件,你就可以通过COM接口读取文件。缺点就是你必须在你的电脑上安装Excel。不过对于大文件现在只能使用这个方法。
$doc = "test.xls" ;
$excel_app = new COM("Excel.Application", NULL, CP_UTF8) or die ("Please install the Excel. \n");
#$excel_app->Visible = 1;
$workbook = $excel_app->Workbooks->Open($doc) or die("Can't open ".$doc);
$worksheet = $workbook->WorkSheets(1);
$worksheet->activate;
$min_row = $worksheet->UsedRange->Row;
$min_col = $worksheet->UsedRange->Column;
$max_row = $worksheet->UsedRange->Rows->Count;
$max_col = $worksheet->UsedRange->Columns->Count;
for ($row = $min_row ; $row < $max_row; $row ++){
for ($column = $min_col ; $column <= $max_col; $column ++){
$value = $worksheet->Cells($row, $column)->value;
echo $value."\n";
}
}
$excel_app->Workbooks->Close();
$excel_app->Quit();
Programming Cocoa with Ruby: Create Compelling Mac Apps Using RubyCocoa

Introduction:
This is a book for the Ruby programmer who’s never written a Mac app before. Through this hands-on tutorial, you’ll learn all about the Cocoa framework for programming on Mac OS X. Join the author’s journey as this experienced Ruby programmer delves into the Cocoa framework right from the beginning, answering the same questions and solving the same problems that you’ll face.
Together you’ll build a single application that threads throughout the book, and it’s not a toy. You’ll cover topics that may not be the flashiest parts of Cocoa, but they’re ones you’ll need to know to create robust, feature-rich applications for yourself. And you’ll learn more than just Cocoa and RubyCocoa, you’ll get first-hand effective agile development practices. You’ll see test-first development of user-interface code, little domain-specific languages that take advantage of Ruby features, and other Rubyish tricks.
At the end of the book, you’ll be ready to write a real Mac OS X application that can be distributed to real users.
Publisher: Pragmatic Bookshelf
Date: 2009-08-10
ISBN: 1934356190
Page: 300 pages
Size: 6,2 MB
Developing Facebook Platform Applications with Rails

Introduction:
Developing Facebook Platform Applications with Rails leads you through the steps necessary to build your first application. You’ll get hands-on experience with Facebook technologies such as FBML and FQL, and master messaging and news feeds.
You’ll do more than just study the Facebook API-you’ll get practical tips from an experienced Facebook developer. We’ll cover advanced techniques such as AJAX and asynchronous messaging, and you’ll see how to slash development time with facebooker, the leading Ruby library for Facebook Platform development.
Together, we’ll build Karate Poke, a real Facebook Platform application, from configuration to deployment. You’ll get deep into Facebook requests right off the bat. From there, you’ll build the core of Karate Poke and then get a detailed look at the Facebook canvas and social features. We’ll finish by looking at advanced features and tips for handling millions of users.
Developing for the Facebook Platform can seem like a different world at first. Developing Facebook Platform Applications with Rails is your tour guide.
Publisher: Pragmatic Bookshelf
Date: 2008-10-28
ISBN: 1934356123
Page: 196 pages
Size: 2,8 MB
Pragmatic Version Control Using Git

Introduction:
# Whether you’re making the switch from a traditional centralized version control system or are a new programmer just getting started, this book prepares you to start using Git in your everyday programming.Pragmatic Version Control Using Git starts with an overview of version control systems, and shows how being distributed enables you to work more efficiently in our increasingly mobile society. It then progresses through the basics necessary to get started using Git.You’ll get a thorough overview of how to take advantage of Git. By the time you finish this book you’ll have a firm grounding in how to use Git, both by yourself and as part of a team. Learn how to use how to use Git to protect all the pieces of your project
# Work collaboratively in a distributed environment
# Learn how to use Git’s cheap branches to streamline your development
# Install and administer a Git server to share your repository
About the Author:
Travis Swicegood is part of the AppDev team at Ning helping to build the platform that lets you create a social network. He’s been programming professionally for nearly a decade, but would still be doing it for fun even if he was selling cars for a living.
He is actively involved in the development of several open-source automation tools in the PHP community, including several testing frameworks. He is also an active member of his local programming community, founding Lawrence Programmers. When not learning new programming languages or tools, he’s normally found on one of his many bikes, tasting his latest culinary creation, or experimenting with a new home brew.
Publisher: Pragmatic Bookshelf
Publish Date: December 28, 2008
ISBN: 1934356158
pages: 190
Size: 6 MB