內容簡介
許多透過WordPress運行的網站想提供Web API,往往需要使用PHP或Ruby on Rails等編程語言並跳脫WordPress外,進而編寫功能以取得其WordPress站點資料庫內容。我認為這樣做有些不太對勁,因此撰寫了Web API的WordPress外掛。
藉由使用Web API外掛,您不再需要這樣做。這個外掛會建立一個名為API的自訂文章類型。當您發佈API文章時,所有內容都會被當作PHP程式碼執行,並在WordPress的佈景主題執行之前先執行。因此,您可以完全存取所有WordPress PHP函數,並創建任何您想要的內容:JSON輸出、HTML片段、不帶任何網站佈景主題或程式碼的完整HTML頁面,或任何您能想像到的東西。頁面程式碼執行完畢後,PHP會退出。
外掛標籤
開發者團隊
原文外掛簡介
Many times when a site powered by WordPress wants to supply a Web API for their site, they will work outside of WordPress using either PHP or Ruby on Rails. Then they have to write their own functions to get to the information inside the database for their WordPress site. I always thought that was a little backwards. That is why I wrote the Web API plugin for WordPress.
With the Web API plugin, you no longer have to do that. This plugin creates a custom post type called API. When you create an API post, all of the content will be executed as PHP code just before the theme stuff is executed in WordPress. Therefore, you have full access to all the WordPress PHP functions to create whatever you want: JSON output, HTML sniplets, full HTML pages without any of the sites theme or code, or anything else you can imagine. After the code on the page is executed, then the PHP session will be ended.
