這個外掛並未在最新的 3 個 WordPress 主要版本上進行測試。開發者可能不再對這個外掛進行維護或提供技術支援,並可能會與更新版本的 WordPress 產生使用上的相容性問題。

Churro

描述

Churro is a plugin that allows developers to easily create pages and functionality, in a style similar to CodeIgniter. By itself, Churro will not add any functionality to your WordPress site.

Tested with WordPress and WordPress MU 2.8.0 ~ 3.0.5
Requires PHP 5. PHP 4 is like 10 years old, you know?

Churro Basics

= URLs =
Churro requires friendly urls rather than query strings. Your url will usually be mapped as following: yoursite.com/class/method/variables

Controllers

The controller will be directly mapped to a file and class with the same name. For example,
yoursite.com/contact
will look for a file named contact.php in the /churro/ directory. This file should have a class contact that extends Churro. Without a defined method, it will default to index. All methods accessible through URLs will have ‘Action’ appended to it. The following code will provide scaffolding for yoursite.com/contact and yoursite.com/contact/submit

<?php
class contact extends Churro {
    public function indexAction(){

    }

    public function submitAction(){

    }
}

Models

Churro gives you access to several important WordPress Models through the $this keyword. The $wp, $wpdb, and $wp_query classes, as well as $blog_id in MU are all availble without using the global keyword, eg $this->wpdb.

Views

Your views belong in your normal theme directory. If you are using multiple themes, you can override the direcotry using $this->Theme( 'directory-name' ) any place in the controller. To specify a view to use, $this->View( 'file-name' ). Seperating logic from views is the most important thing to remember in Churro. To set varaibles in your view, use $this->vars->var_name in the controller, and $var_name in your view.

Ajax / Javascript

If you use the excellent jQuery javascript library, Churro will detect ajax requests and automatically return JSON. Churro defines a constant ISAJAX on each request. With a little planning, it is very easy to create a dynamic application in a way that is totally accessible without javascript.

Learning Churro

There is much more functionality in Churro than outlined here. As of September 2, 2009, there is no complete, formal, documentation for writing code with Churro. Stay tuned to Substance Labs for tutorials.

螢幕截圖

  • Churros are delicious /trunk/screenshot-1.png

安裝

  1. Place entire /churro/ directory to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Write some code

常見問題

This doesn’t do anything!

Churro does not add any functionality to WordPress by itself. Instead, it allows developers a structure to integrate well organized, easily maintainable, object oriented MVC code into their applications.

Why did you create Churro?

Churro was originally developed as a stand-alone framework, sort of a hobby project after I had learned Zend framework and wanted to use the same concepts in my own projects, with simpler syntax and lighter footprint. After Churro reached a fairly stable state, I realized it’s similarities to CodeIgniter. After wrestling with WordPress, I decided to refactor the Churro code as a plugin, to allow easy, rapid development.

評價

There are no reviews for this plugin.

貢獻者及開發者

“Churro” 是一個開源的軟體。以下的人對這個外掛作出了貢獻。

貢獻者

將 Churro 外掛本地化為台灣繁體中文版。

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

修改日誌

0.3

  • Fairly major refactoring of code, moved virtually all functions into class methods.

0.2

  • Cleaning things up, more testing. No new functionality.

0.14

  • Experimental support for HTML Tidy.

0.13

  • Minor bug fix in jquery queue in admin.

0.12

  • Bug fixes, slightly more documentation.

0.1

  • Initial public release. No documentation.