Check if test is working properly with cron
Closed this issue · 12 comments
The carbon footprint test should take place in two ways:
- when the Site Health page is visited
- during Site Health's cron job
I am currently verifying whether the test is working correctly (it should I think) during cron. More information soon.
In version 1.1, I’ve fixed loading the class and helper file for the test to not only load in the admin (deleted the is_admin()
check), and that seems to fix the test not running during wp-cron.
If there are any problems, please share them here. :-)
I noticed that when the transient is set due to the test running during cron, the dashboard widget for homepages worse than 90% of pages tested is not shown. This is logical as designed right now (code to save data for widget does not run during cron...), but not correct.
Worked on this one. Some more testers would be great! Got a 503 error from the API last time, so still testing.
I'm tagging you @alokstha1 if you're interested, don't feel obligated though. :-)
@LittleBigThing May I ask what are the test cases?
Installed on a test site and got the below response.
Does this mean that No. 1 from #6 (comment) is passed?
Yes, thanks @alokstha1! :-)
I am glad to see the rating appearing correctly. 👍
What do you think @YellowlimeNL?
Did you think it was easy to find out what the plugin would do? Have you noticed the banner after activation that prompts you to test the site using Site Health?
What I did to test 2. (above) was installing the Transients Manager and the Crontrol plugins:
- the first one adds a screen under Tools listing the transients on your site. The Carbon Footprint plugin adds a transient (
carbonfootprint_test
) of 1 week after testing the site so we do not hit the API each time the Site Health cron job runs. - the second plugin adds a screen under Tools listing the cron events of your site. There you can force the Site Health cron job
wp_site_health_scheduled_check
to run.
So: I (first deactivated and then) activated the Carbon Footprint plugin and did not run Site Health. I checked and the transient carbonfootprint_test
was not there. I then ran the cron job. If you wait a while (max. 30 sec), the transient appears in the list under Tools and if you then go to Site Health, the results of the carbon test should be there, without the usual delay, since the transient is used to show the results.
Could you check if this is also the case for you?
I am not sure if everything goes well if the test is run for the first time for a large page. ‘First time’ meaning that the result is not cached by the plugin and neither by the API. I am not sure about the API, but I think it caches the result for 24h. The websitecarbon.com website does this for a longer period (but you can force it to re-test).
Thanks for any comments and testing! 🥇
If you ask me about the info shown, the info seems to be rather complete (at this stage of development). One thing I should add is the score, in this case 'C'. I would mention the scale .e.g "...C, on a scale of A to XX."
If you ask me about the info shown, the info seems to be rather complete (at this stage of development). One thing I should add is the score, in this case 'C'. I would mention the scale .e.g "...C, on a scale of A to XX."
Good point, thanks! I link to the description of the scale, but that’s a complex description. I'll think about what is the best way to show it/put it in context, since it is not just the letters, but that is a good start.
Yes, we should provide context to the grading, so adding the link and some text like "on a scale of A to F" (or similar) could be a good way to do it.
Okay, I might be one of the few who actually find the Site Health feature really useful, so I know where it is and what it does, but even given that “bias”, I must say, I find the current implementation and explanation, spot on.
Should I point at something - the carbon rating link should in my opinion, have an external link indicator, like the other external links. Good sources btw, and not too much.
Is it understood correctly, that there is a dashboard widget, but that it's only available if the grading is bad? Why is that? I'd find it useful with a persistent widget showing the grade, reminding me to continue my work bringing the footprint down. A cached result is fine.
Thanks for the positive feedback! 💚
@oldrup: the plugin is intended to integrate smoothly with WP features, without disrupting things too much. It is a valid point though I think about the dashboard widget. I think I kind of based it on how the website carbon calculator and the site health feature work. When something is considered a critical error, it warns the user through the site health function already, so the widget is kind of an informative support to that (only displayed when the error is considered critical).
We could consider showing it for lower thresholds. Maybe another ticket to discuss that?
I am not sure I have mentioned this somewhere but I was planning to add a filter to enable modifying the threshold for generating a critical error (and thus showing the widget), but did not experiment enough with it yet. Also, the filter must probably have a lower end limit to ensure that it is not turned off that way completely (I realise that all site health features can be turned off using a filter, which is probably a good thing and fits WP's philosophy).
Closing this issue since it is fixed.
I'll open issues for other suggestions/discussions separately, thanks! :-)