前言介紹
- 這款 WordPress 外掛「Greencharts」是 2023-02-13 上架。
- 目前尚無安裝啟用數,是個很新的外掛。如有要安裝使用,建議多測試確保功能沒問題!
- 上一次更新是 2023-02-14,距離現在已有 809 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 5.0 以上版本才可以安裝。
- 外掛要求網站主機運作至少需要 PHP 版本 7.0 以上。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
內容簡介
這個 WordPress 外掛可以讓你輕鬆地在你的網站上加入互動式圖表,使用 global-warming.org API 和 ChartJs 函式庫的資料。該外掛內建機制,如伺服器快取、延遲載入和客戶端快取,一起作用以減少每個圖表檢視所造成的網路或硬體使用所產生的二氧化碳排放量。
使用方式
當外掛安裝並設定完成後,你可以在你的網頁與文章中加入圖表短碼。以下為可用的短碼:
[greencharts-chart type="temperature"]:顯示全球溫度隨時間變化的折線圖。
[greencharts-chart type="co2"]:顯示各國二氧化碳排放量的折線圖。
[greencharts-chart type="methane"]:顯示全球甲烷氣體排放量的折線圖。
[greencharts-chart type="oceanwarming"]:顯示全球海洋暖化的折線圖。
你可以使用 ChartJs 函式庫的選項和回呼函式自訂圖表的外觀,並以 WordPress 的 js 鉤子製作。欲知詳細資訊,請參考 ChartJs 說明文件。
支援
如果你在使用外掛時有任何問題,請在 Github 上開啟問題或透過電子郵件聯絡我們。我們將盡力協助你。
貢獻
如果你想要為這個外掛的開發作出貢獻,請 fork 該存儲庫並提交拉取請求。
免責聲明
此外掛按「現狀」提供,並不附帶任何形式的保證,無論是明示或暗示的。Global warming.org 和 ChartJs 函式庫不贊同此外掛,也不對因使用該外掛而導致的任何損害或損失負責。
外掛鉤子
php [docs](https://developer.wordpress.org/plugins/hooks/)
使用 apply_filters 函式來將一個暫存值設定為 false。這將禁用 greencharts 資料的快取。
apply_filters('greencharts_transient_disableCache', false);
使用 apply_filters 函式來設定暫存的壽命。該過濾器可用於修改暫存在設置之前的壽命。該暫存用於快取遠端 API 請求,預設的暫存時間為 1 個月。壽命應該是秒數,請參閱 WordPress 的 $expiration 參數的 set_transient 函式
apply_filters('greencharts_transient_lifespan', $this->lifespan, $this);
使用 apply_filters 函式將日誌記錄器設為 true。這將啟用 greencharts 資料的記錄功能。
apply_filters('greencharts_logger_shouldLog', defined('WP_DEBUG') && true === WP_DEBUG);
使用 apply_filters 函式將冗長值設為 true。這會啟用 greencharts 資料的冗長記錄。
apply_filters('greencharts_logger_shouldBeVerbose', false);
使用 apply_filters 函式修改圖表使用的 ajax 回應資料。如果你需要新增更多圖表,這很有用。
apply_filters('greencharts_ajax_chartsApi',$charts->getChartsDataByType($type), $type);
js [docs](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-hooks/)
記得在 greencharts js 載入之前使用 wp.hooks.addFilter。
此程式碼對 chartConfig 物件應用篩選器,該物件用於在畫布上創建一個 greencharts_js_chartConfig 圖表。該篩選器用於修改 chartConfig 物件,以便創建自定義圖表。
原文外掛簡介
This WordPress plugin allows you to easily add interactive charts to your website, using data from the global-warming.org API and the ChartJs library. The plugin has built-in mechanisms such as server cache, lazy load and client cache, which work together to reduce the CO2 emissions caused by internet/hardware usage per chart view.
Usage
Once the plugin is installed and configured, you can add chart shortcodes to your pages and posts. The available shortcodes are:
[greencharts-chart type="temperature"]: Displays a line chart of global temperature change over time.
[greencharts-chart type="co2"]: Displays a line chart of CO2 emissions by country.
[greencharts-chart type="methane"]: Displays a line chart of global methane gas emissions.
[greencharts-chart type="oceanwarming"]: Displays a line chart of global ocean warming.
You can customize the appearance of the charts using the ChartJs library’s options and callbacks using wordpress js hooks. Visit ChartJs documentation for more information.
Support
If you have any issues with the plugin, please open a Github issue or contact us via email. We will do our best to assist you.
Contribution
If you would like to contribute to the development of this plugin, please fork the repository and submit a pull request.
Disclaimer
This plugin is provided “as is” without warranty of any kind, either express or implied. Global warming.org and ChartJs library do not endorse this plugin and are not responsible for any damages or losses that may result from its use.
Plugin hooks
php [docs](https://developer.wordpress.org/plugins/hooks/)
Use the apply_filters function to set a transient value to false. This will disable caching for the greencharts data.
apply_filters('greencharts_transient_disableCache', false);
Use the apply_filters function to set the lifespan of transient. The filter can be used to modify the lifespan of the transient before it is set. The transient is used to cache remote API requests, default transient is 1 month. The lifespan should be the number of seconds, see $expiration parameter of wordpress set_transient function
apply_filters('greencharts_transient_lifespan', $this->lifespan, $this);
Use the apply_filters function to set a logger value to true. This will enable logging for the greencharts data.
apply_filters('greencharts_logger_shouldLog', defined('WP_DEBUG') && true === WP_DEBUG);
Use the apply_filters function to set a verbose value to true. This will enable verbose logging for the greencharts data.
apply_filters('greencharts_logger_shouldBeVerbose', false);
Uses the apply_filters function to alter ajax resposes data used by charts. Useful if you need to add more charts.
apply_filters('greencharts_ajax_chartsApi',$charts->getChartsDataByType($type), $type);
js [docs](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-hooks/)
Remember to use wp.hooks.addFilter BEFORE greencharts js load.
This code applies a filter to the chartConfig object which is used to create a greencharts_js_chartConfig chart on the canvas. The filter is used to modify the chartConfig object so that it can be used to create a customized chart.
globalHooks.applyFilters("greencharts_js_chartConfig", chartConfig, canvas);
// usage example:
wp.hooks.addFilter(
"greencharts_js_chartConfig",
"defaultHooks",
(chartConfig, canvas) => {
console.log("THEME FILTER", chartConfig, canvas.dataset.type);
chartConfig.data.datasets[0].backgroundColor = "blue";
return chartConfig;
}
);
This code applies a filter to the debug var that control operations logging. The filter is set to false, meaning that any code related to greencharts_js_debug will not be logged in the browser js console.
globalHooks.applyFilters("greencharts_js_debug", false),
// usage example:
wp.hooks.addFilter("greencharts_js_debug", "defaultHooks", () => true);
This code applies a filter to the “greencharts_js_errorMessage” string. The filter takes in the string, along with the data and error objects, and returns a modified version of the string. This is useful for customizing error messages based on different scenarios.
globalHooks.applyFilters(
"greencharts_js_errorMessage",
"Something goes wrong during chart loading. Please retry later",
data,
error
);
This code applies a filter to the text of a “Reset zoom” button on a canvas element. This allows developers to customize the text of the button.
options.globalHooks.applyFilters(
"greencharts_js_resetZoomButtonText",
"Reset zoom",
canvas
);
This code applies a filter to the text of a “Load chart” button on a canvas element. This allows developers to customize the text of the button.
options.globalHooks.applyFilters(
"greencharts_js_loadButtonText",
"Load chart",
canvas
);
Assets attribution
– Image by (rawpixel.com)[https://www.freepik.com/free-vector/social-media-analysis-design-graphs_16323246.htm#query=minimal%20charts&position=3&from_view=search&track=ais] on Freepik
– Image by (Freepik)[https://www.freepik.com/free-vector/green-energy-buildings_713297.htm#query=eco%20green&position=31&from_view=search&track=ais]
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Greencharts」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
Deny All Firewall 》Deny All Firewall(拒絕所有防火牆), 此外掛會檢查您的 WordPress 安裝狀況,並將規則注入 .htaccess 檔案中,以完全阻擋除了正式網站內容以外的所有訪問。...。
WPSustainable 》檢查您的網站架設公司的可持續性和您的 IP 地址產生的二氧化碳排放。, 連結, , WordPress Web 主機團隊, Javier Casares, 。
Handprint 》什麼是Handprint外掛程式?, Handprint讓你可以透過你的電子商店每一次消費自動向非政府組織捐款。一旦設置完成,一個“小部件”會在你的購物車頁面顯示你的影...。
Green Living Tips 》隨機顯示綠色生活提示。, 您可以在此處查看工作演示和指示 - 綠色生活提示。, 可用語言;, , 阿拉伯語由 Ali 翻譯, 阿塞拜疆語由 Bohdan Zograf Web Rating 翻...。
Carbon Offset 》隨著網路能源消耗超越全球航空業,建立更可持續的網路變得至關重要。Carbon Offset 讓您可以抵銷您的網站二氧化碳排放,與 Cloverly API 整合。, 版本 1.0 可...。
Carbon Balance: Carbon calculation and offsetting for WooCommerce 》總結:Carbon Balance是一個平台,可協助網店減少碳足跡並提高轉換率,讓網店能夠鼓勵可持續消費並對環境產生正面影響。, , 問題與答案:, , 問題:Carbon Ba...。
WordPress Carbon Footprint 》WordPress碳足跡是一個WordPress簡單的外掛程式,它可以計算並顯示您的博客產生的碳足跡。它會計算您的博客中有多少字和圖像,然後估算出印刷一份拷貝需要多...。
Online Leaf 》由於全球瀏覽網頁耗能大量能源,Online Leaf 開發方法來減少瀏覽互聯網所需的能源量,使網站變得更綠色。, 這個外掛, 這個外掛可讓您的博客在博客上安裝綠色...。
Energy Saver 》若想瞭解 Energy Saver 的介紹及示範,請造訪插件頁面, Energy Saver 是一個為您的網站或部落格設計的輕量級外掛程式,當網頁失去焦點時,它會暗化網頁以省電...。
eGreen Web Meter 》透過這個外掛程式將您的網站轉換為碳中和的空間。, 主要好處有哪些呢?, , 讓您的網站成為綠色空間,對環境友善。(不僅涵蓋您的網站主機,也包含網路及訪客...。
ClimateClick: Climate Action for all 》讓您的客戶購物成為氣候中立的行為, Co2ok 從 2017 年開始就協助緩解商店的碳排放並增加轉換率。加入數百家線上商店的行列,一起推動可持續消費。, Co2ok 如...。
star-ganalytics 》簡單易用的 Google Analytics 外掛程式,能夠快速地在 WordPress 上加入 Google Analytics。, 半綠色軟體。我們只在 wp_options 資料表中新增了一個欄位 _sta...。
Green pay 》Green Pay 可以讓顧客支付他們的訂單,並將訂單金額的 1% 捐獻給 Splittypay 支援的其中一個項目。, 顧客將被重定向至 Splittypay 平台完成付款:從該平台,...。
South Pole: Climate action now 》讓你的客戶有機會實現零碳排放購物, South Pole 的電子商務解決方案能幫助組織抓住氣候變化帶來的機遇,並減緩與氣候變化相關的風險。下載我們的外掛程式,加...。
Skeleton Shortcodes Collection 》這個外掛可以加入簡短代碼,輕鬆地在文章或頁面中建立欄位。, 有不同的欄位寬度可供選擇,可以製作出各種組合:, , one_half (1/2), one_third (1/3), two_th...。