
內容簡介
**總結:**
這是一個外掛程式,可添加簡單的短代碼以顯示當前年份或動態年份範圍,在網站底部特別適用於版權聲明。使用 [year] 來顯示當前年份,若提供起始年份,則會顯示日期範圍。亦可使用 [runthings_year] 作為自動後備代碼。
**問題與答案:**
1. 這個外掛的最基本用法是什麼?
- 答:使用 [year] 來顯示當前年份,若提供起始年份,則顯示該年份至當前年份的日期範圍。
2. 如何在外掛中創建動態年份範圍?
- 答:使用 [year from="2020"] 來創建動態年份範圍。
3. 如何在簡短格式中顯示年份範圍?
- 答:使用 [year from="2020" mode="short"] 來顯示簡短的年份範圍,例如 "2020-25"(如果當前年份為2025)。
4. 如果其他外掛已經使用了 [year] 這個短代碼,這個外掛會怎麼處理?
- 答:使用預設的後備短代碼 [runthings_year] 來替代,並可以透過 runthings_current_year_shortcode_tag 過濾器進行自訂設定。
5. 關於過濾器 runthings_current_year_shortcode_tag,它的主要功能是什麼?
- 答:此過濾器允許自定義外掛使用的短代碼標籤。
詳細文檔和例子可在 GitHub 上查看。
外掛標籤
開發者團隊
原文外掛簡介
This is a plugin which adds a simple shortcode to display the current year or a dynamic year range, particularly useful for copyright statements at the bottom of your website.
Its most basic usage is [year], which will display the current year. If you provide a starting year with the ‘from’ parameter, it will expand into a date range when the ‘from’ year is before the current year.
If [year] is used by another plugin, then it uses the fallback [runthings_year] which can be customised with the runthings_current_year_shortcode_tag filter. You can see the active shortcode tag in it entry in the installed plugins page.
Features
Display current year with [year]
Create a dynamic year range with [year from="2020"]
Abbreviated year format with [year from="2020" mode="short"], which shows “2020-26” (if the current year is 2026)
Automatic fallback shortcode [runthings_year] if another plugin already uses the ‘year’ shortcode
Filter (runthings_current_year_shortcode_tag) to set your own shortcode
Usage Examples
Assuming the current year is 2026:
[year] displays “2026”
[year from="2026"] displays “2026” (since it’s the current year)
[year from="1983"] displays “1983-2026”
[year from="2020" mode="short"] displays “2020-26” (shortened current year)
[year from="1995" mode="short"] displays “1995-2026” (not shortened because centuries differ)
Filters
runthings_current_year_shortcode_tag
This filter allows customization of the shortcode tag used by the plugin.
For detailed documentation and examples, see the full documentation on GitHub.
Parameters:
$tag (string): The shortcode tag to be registered. Defaults to ‘year’ or ‘runthings_year’ if conflicted.
Additional Notes
Built by Matthew Harris of runthings.dev, copyright 2021-2026.
Visit runthings.dev for more WordPress plugins and resources.
Contribute or report issues at GitHub repository.
License
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/gpl-3.0.html.
Icon – Calendar by Qadeer Hussain, from Noun Project, https://thenounproject.com/browse/icons/term/calendar/ (CC BY 3.0)
Icon – legal by hanis tusiyani, from Noun Project, https://thenounproject.com/browse/icons/term/legal/ (CC BY 3.0)
