
內容簡介
Easy Weather Widget 提供一個易於使用的小工具,可以輸出天氣資訊。在建立小工具時,只需輸入您的美國郵編並保存,它將顯示當前的天氣資訊於您的網站。
我完全重寫了這個小工具並且讓它可過濾。您需要獲取並輸入 API 密鑰,該密鑰有一個免費級別,並且應該可以滿足許多使用場景,可在 WP 的後端設置>常規中獲取。有關更多信息,請參閱 http://openweathermap.org/api。
以下篩選器可用:
eww_template 可以覆蓋小工具的輸出模板,有關更多信息,請參閱以下內容。
注意,如果您覆蓋模板,請遵守 OpneWeatherMap 的許可證通知,其中規定“OpenWeatherMap”名稱必須在應用程序的可見部分中被提及為天氣資訊來源。(从 http://openweathermap.org/price 獲取的 2016 年 8 月)
eww_ioc_container 可以覆蓋 IoC 容器,如果您想在應用程序中使用不同的類(包括獲取天氣數據的 API)
使用 eww_template 篩選器
在您的模板目錄中添加一個名為“custom-eww.php”的“views”目錄和文件。該“custom-eww.php”文件將是您此示例的自定義模板。
使用自定義模板的範例 —— 該主題必須使用 PHP 5.3 以上的版本以允許閉包
<?php
add_filter('eww_template',function($template){
$template_dir = get_template_directory();
return $template_dir.'/views/custom-eww.php';
});
?>
Grunt
本外掛利用 Grunt 驗證 JavaScript,編譯 SASS 並進行最小化。要利用 Grunt,您必須安裝 npm 和 Grunt。訪問相應的網站以確保它們已安裝。一旦安裝,如果您想編輯/派生此外掛,熟悉這兩個工具將非常有幫助。
外掛標籤
開發者團隊
原文外掛簡介
Easy Weather Widget provides you with an easy to use widget which outputs weather information. When creating the widget just enter in your U.S. zip code and save, it will display the current weather on your site.
I completely rewrote the widget and made it filterable. You need to obtain and enter an API key, which has a free tier that should cover many use cases to obtain at Settings > General in your WP backend. See http://openweathermap.org/api for more information.
The following filters are available:
eww_template to override the output template for the widget, see below for more information.
note, if you are overriding the template, please heed the notice to comply with the OpneWeatherMap license which states the OpenWeatherMap name must be mentioned as a weather source in a visible part of the application. (obtained 8/2016 from http://openweathermap.org/price)
eww_ioc_container to override the IoC container if you want to use different classes in the application (including the API to grab weather data)
Usage of eww_template filter
Add a “views” directory and file named “custom-eww.php” to your template directory. The “custom-eww.php” file will be your custom template for this example.
Example of using a custom template from within your theme PHP 5.3+ which allows closures
Grunt
This plugin takes advantage of Grunt for validating JavaScript, SASS compilation and minification. To take advantage of Grunt you have to have both npm and Grunt installed. Visit the respective sites for the applications and make sure they are installed. Once installed, if you want to edit/fork this plugin, it will be helpful to be familiar with these two tools.
