[WordPress] 外掛分享: GCal Days

首頁外掛目錄 › GCal Days
WordPress 外掛 GCal Days 的封面圖片
10+
安裝啟用
尚無評分
3583 天前
最後更新
問題解決
WordPress 3.6+ v1.2 上架:2014-03-24

內容簡介

這個外掛提供一個縮寫和一套函數,以返回在你的 Google 日曆中與指定的搜索詞匹配的最近過去事件之後的天數。該縮寫也可用於返回與指定搜索詞匹配的最接近未來事件的天數。

縮略語
[gcal-days search="" type="" id=""]

這個縮寫名稱是 gcal-days,它有三個屬性,但只有一個是絕對必要的:

search:(必需的)搜索詞。
type:(可選)搜索時間方向。預設為“自從”,即搜索過去的事件。 “直到”將搜索未來事件。
id:(條件可選)要搜索的日曆的ID。您可以通過外掛的設置頁面發現日曆的ID。如果在外掛的設置中定義了默認日曆,則可以從縮略語中選擇省略此縮略語屬性。

縮略語輸出表示與匹配事件的天數的數字。如果找不到事件,則顯示-1。

範例:[gcal-days search="dentist"],[gcal-days type="until" search="vacation" id="[email protected]"]

鏈接:外掛首頁 | 外掛目錄頁面 | 作者首頁

函數

該外掛提供了兩個函數供您在佈景主題模板、functions.php 或外掛中使用。

函數

<?php function gcal_days_since( $search, $calendar_id = '' ) ?>
<?php function gcal_days_until( $search, $calendar_id = '' ) ?>

參數

$search(字符串)
必填。要搜索的單詞或短語

$calendar_id(字符串)
可選的。Google 日曆的 ID。檢查外掛的設置頁面以獲取日曆 ID。只有在您通過外掛的設置定義了默認日曆時,此參數是可選的。

回傳值

與匹配事件相比的天數的整數值。如果沒有找到事件或遇到錯誤,則返回-1。

範例

<?php // 距離下一次牙醫預約的天數
$days_until = gcal_days_until( 'dentist' );
?>

<?php
// 取得從我最後一次休息的日子起的天數
$days_since = gcal_days_since( 'day off' );
// 使用該數字輸出一條消息
if ( -1 == $days_since ) {
echo "妳從來沒有放假過嗎?快去放假!";
} else {
printf( _n( '妳最後一次放假是 %d 天前。', '妳最後一次放假是 $d 天前。', $days_since ), $days_since );
}
?>

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.2) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「GCal Days」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

This plugin provides a shortcode and a set of functions to return the number of days since the most recent past event in your Google Calendar matching specified search terms. The shortcode can also be used to return the number of days until the closest upcoming event matching specified search terms.
The Shortcode
[gcal-days search="" type="" id=""]

The shortcode name is gcal-days. It has three attributes, but only one of which is absolutely necessary:

search: (Required.) The search term.
type: (Optional.) The direction in time to search. Defaults to “since”, which searches past events. “until” will search future events.
id: (Conditionally optional.) The ID of the calendar to search. You can discover the IDs of calendars via the plugin’s settings page. This shortcode attribute can only be optionally omitted from shortcodes if you define a default calendar in the plugin’s settings.

The shortcode outputs a number representing the number of days until a matching event. If no event is found, a -1 will be displayed.
Examples: [gcal-days search="dentist"], [gcal-days type="until" search="vacation" id="[email protected]"]
Links: Plugin Homepage | Plugin Directory Page | Author Homepage
Functions
The plugin provides two functions for use in your theme templates, functions.php, or in plugins.
Functions


Arguments

$search (string)
Required. The word or phrase to search for

$calendar_id (string)
Optional. The ID for the Google Calendar. Check the plugin’s settings page for calendar IDs. This argument is only optional if you have defined a default calendar via the plugin’s settings.

Return Value
An integer value of the number of days since/until the matching event. -1 is returned if no event was found or an error was encountered.
Examples

延伸相關外掛

文章
Filter
Apply Filters
Mastodon