=== EcoMeter – Website Carbon Footprint ===
Contributors: okmultimedia
Tags: carbon, co2, sustainability, green, performance
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Estimate how much CO2 each page of your WordPress site emits per visit, with a rating from A+ to F and a badge for your visitors.

== Description ==

EcoMeter weighs every page of your site the way a browser downloads it (HTML, styles, scripts, images and backgrounds, fonts and videos that play on their own) and turns that weight into an estimate of grams of CO2 per visit with the Sustainable Web Design model (version 4) published by the Green Web Foundation. The figures are model-based estimates, not a direct measurement of energy use.

* Measures each page once a week, and again a minute after you publish or update it (up to 5,000 pages are kept).
* Failed measurements are retried automatically, shown on the EcoMeter screen and can be retried by hand.
* Rating from A+ (cleanest) to F.
* Card badge for your sidebar or any page: block, classic widget or shortcode.
* A details window opens when a visitor clicks the badge: weight by type of file and how it is measured.
* Optional green hosting check (off by default).
* Optional "by EcoMeter" credit under the badge (off by default).
* Your home page result, a "Measure now" button and five tips to make the site lighter, on the EcoMeter screen.
* Optional CO2 VERIFIED seal: keep your site at A or A+ for 30 days in a row and earn a seal checked every day by the EcoMeter verification service. Nothing is sent until you press "Start".

Measurements are made by your own server, which requests your own pages. Visitors only ever read a saved figure, so the badge adds no load to your pages.

== External services ==

This plugin can connect to two external services, and only if you switch them on:

* **Green Web Foundation – Green Web Check API.** When "Check whether my hosting runs on renewable energy" is ticked on the EcoMeter screen (it is off by default), the plugin sends your site's domain name (for example example.com) to https://api.thegreenwebfoundation.org once when you switch it on and then once a week, to know whether your hosting runs on renewable energy. No other data is sent. The answer is used to calculate the CO2 of your pages more accurately.
  Service: https://www.thegreenwebfoundation.org/green-web-check/
  API documentation: https://developers.thegreenwebfoundation.org/api/greencheck/v3/check-single-domain/
  Privacy statement: https://www.thegreenwebfoundation.org/privacy-statement/

* **EcoMeter verification service by OK Multimedia (CO2 VERIFIED seal).** Only after you press "Start" in the "CO2 VERIFIED seal" section of the EcoMeter screen (nothing is sent before). The plugin sends your home page address, a random code it creates for your site, the plugin version and the dashboard language to https://okmultimedia.com/ecometer/api/: when you press "Start", "Get the seal" or "Update", once a day, and at most once an hour when you open the EcoMeter screen. From then on, the service visits your home page and two random pages of your sitemap once a day, as a visitor would, to measure them; it also asks the Green Web Foundation whether your hosting runs on renewable energy (only your domain name). The plugin adds a fingerprint of the code (never the code itself) to your home page so the service knows the site is yours. No personal data is sent. Each enrolled site has a public verification page with its status and the results of the last 30 days, which opens when someone clicks the seal. Press "Leave the challenge", or deactivate the plugin, and nothing more is sent.
  Service terms and privacy: https://okmultimedia.com/en/ecometer/terms

The measurement of your pages does not use any external service: your own server downloads your own pages.

== Installation ==

1. Upload the plugin in Plugins > Add New Plugin > Upload Plugin, or install it from the plugin directory, and activate it.
2. Go to EcoMeter in the dashboard menu. Your home page is measured a few seconds after activation; you can also click "Measure the home page now".
3. Add the "EcoMeter badge" block, the "EcoMeter badge" widget or the [ecometer] shortcode where you want the badge.
4. Optional: press "Start" in the "CO2 VERIFIED seal" section. When your site has kept A or A+ for 30 days in a row, press "Get the seal" and add the "EcoMeter seal" block, the "EcoMeter seal" widget or the [ecometer_seal] shortcode.

== Frequently Asked Questions ==

= Where does the formula come from? =
From the Sustainable Web Design model, version 4, published by the Green Web Foundation. It turns the data transferred per visit into energy and then into CO2, using the global average grid intensity.

= The badge does not show on a page =
A page is measured the first time someone visits it with the badge, so the badge appears a minute or two later. Administrators see a short note meanwhile.

= My page cannot be measured =
Your server must be able to request its own pages. Some security plugins or hosting firewalls block this: allow requests from your own server, or ask your hosting provider.

= Does EcoMeter slow down my site? =
No. Measurements run in the background, one page a minute, never two at the same time, with limits on the number of files and the time per page. Visitors only read a saved result.

= How accurate are the figures? =
They are estimates. EcoMeter uses the Sustainable Web Design model, version 4, exactly as published by the Green Web Foundation in its CO2.js library: 0.055, 0.059 and 0.080 kWh per GB for the operational energy of data centres, networks and devices, 0.012, 0.013 and 0.081 kWh per GB for their embodied energy, a global grid intensity of 494 g CO2e per kWh, and the model's own rating bands (A+ up to 0.040 g, A up to 0.079 g, B up to 0.145 g, C up to 0.209 g, D up to 0.278 g, E up to 0.359 g, F above). With green hosting, the operational energy of the data centre counts as renewable, as in the model. Every visit is counted as a first visit, the model's default.

= What does the measurement not see? =
EcoMeter reads the page as it is served and the files it asks for: styles, scripts, fonts, images (for responsive images, the one a desktop browser would pick), background images of the elements on the page and videos that play on their own. It does not run JavaScript, so content that scripts load later (for example embedded videos, maps, ads or chat widgets) is not counted, or only in part. Lazy-loaded images are counted as if the visitor scrolled to the end. Browser caching for returning visitors is not taken into account. If a few files cannot be downloaded or a page asks for more than 120 files, the result is marked as possibly incomplete; if more than one in ten files fail, the result is not kept and the page is tried again later.

= How many pages can it measure? =
Up to 5,000 pages are kept. If a site has more, the pages checked longest ago make room for new ones.

= How does the CO2 VERIFIED seal work? =
Press "Start" and the EcoMeter verification service checks your site once a day: the home page and two random pages. Every day at A or A+ adds one day; a day at B or below starts the count again. After 30 days in a row, "Get the seal" becomes available. The seal stays while your site keeps A or A+, and shows the date you earned it. Visitors can click it to see the public verification page.

= Can I copy the seal or its shortcode to another site? =
No. The seal only shows on the site that earned it, and only while the verification service confirms it. On any other site the shortcode shows nothing.

= The service could not find the EcoMeter code on my home page =
If you use a cache plugin, clear its cache and press "Start" again, so the home page includes the code.

== Credits ==

* Menu icon: "Nature" from GitLab Interface Icons, Copyright (c) 2011-present GitLab Inc., MIT License (licenses/MIT-GitLab.txt).
* Seal font: Poppins Bold, Copyright 2020 The Poppins Project Authors, SIL Open Font License 1.1 (licenses/OFL-Poppins.txt).

== Changelog ==

= 1.0.1 =
* Results are kept in their own database table, with retries and an error list for failed measurements.
* Responsive images and <picture> are measured as a browser picks them; incomplete measurements are flagged or not kept.
* Limits on files and time per page, and only one measurement at a time.
* New published content of any public type is measured automatically.
* Clearer explanation of the estimates and their limits.
* Dates follow the site time zone; private and password-protected content is never queued; the answer of the seal service is validated.
* A static home page is listed and counted once.

= 1.0.0 =
* First public version: CO2 per visit of every page, A+ to F rating, Card badge (block, widget and shortcode), details window, optional green hosting check and the optional CO2 VERIFIED seal.
