Skip to content

Commit

Permalink
Release 2.0.0 (#270)
Browse files Browse the repository at this point in the history
* [CMSP-995] Notices for low max age values in Page Cache Options (#268)

* add initial admin interface class
hook to mu-plugin > 1.4.0

* some more scaffolding

* require at least 6.4

* don't show notices if wp_admin_notice doesn't exist

* add notice if mu-plugin was not found

* add notice if the mu-plugin is old

* fix link and change decimal to string

* use spaces instead of line breaks

* add helper function to get current max age
this is either set in the mu-plugin or empty. if empty, it should default to 1 week

* add notice if less than 1 week but not == 600 seconds

* add docblock

* add translator comments

* update tested up to and requires at least values in readmes

* version bump

* bump composer deps

* don't display the warnings if we aren't on the pantheon cache admin page

* convert static class to a namespace
there's no reason to make this a class since we're not using any class features

* add a bootstrapper for namespace-only files

* lint

* escape the wp_die message

* use a helper for humanized time calculations

* we still need to test the current max age

* pass the current max age to the message, too
and be specific that we're talking about seconds

* use the filterable value for default max age
because it could be something different

* add a helper function for retrieving the default max age
this is helpful so we can always return the filtered value

* also display the seconds in the successful test

* rank the max age value
don't say it's "very low" unless that's actually accurate.

* add caching to the ranked compare

* make the color more severe if it's a bigger issue

* change the color of the admin notice based on the severity of the diff

* clear the transient when the option is updated

* break notice type into a variable

* fix the translator note

* keep the rank but hide it from the dom

* add unit tests

* add initial behat test
let's just see if we can assume this will work

* fix failing test

* specify the element where the notices are

* add site health check test

* actually save the changes

* remove max age check
only exists in an html comment anyway

* simplify the site health check

* add the message when you expand the accordion

* add other site health things

* change press to click?

* add "open the accordion" as a custom step

* move behat stuff around

* move stuff around again

* update the behat.yml

* remove custom context and try "when I follow"

* move to checking the text inside the elements

* target the hidden element

* use hidden='hidden'

* call it a div

* simplify the tests

* remove press
since we can't actually press

* it did actually find the right heading
maybe it will find the right text?

* add @\since tags

* add changelog and upgrade notice

* let's try checking for some of the hidden text

* period at the end of the sentence

* add the ranks back
this shows us that our ranking function is working

* add the messages

* remove age rank tests
because goutte doesn't natively interpret html comments

* add github testing badge
since phpunit is no longer run on circle

* add script to maybe skip behat tests if we don't need to run them

* add step to workflow

* do not run if the circle config changes

* also ignore if scripts (that aren't behat-related) have changed

* fix the logic (again)

* one more flippity flip

* remove the "ignoring" message
it's actually implied by the fact that is_ignored is checked

* use function to determine if a file should be ignored

Co-authored-by: Phil Tyler <[email protected]>

* update changelog to note mu-plugin updates

* Update tests/phpunit/test-admin-interface.php

* use data providers to simplify the tests

---------

Co-authored-by: Phil Tyler <[email protected]>

* [CMSP-994] Automatically update the `default_ttl` value if it was set to 600 (#269)

* add initial admin interface class
hook to mu-plugin > 1.4.0

* some more scaffolding

* require at least 6.4

* don't show notices if wp_admin_notice doesn't exist

* add notice if mu-plugin was not found

* add notice if the mu-plugin is old

* fix link and change decimal to string

* use spaces instead of line breaks

* add helper function to get current max age
this is either set in the mu-plugin or empty. if empty, it should default to 1 week

* add notice if less than 1 week but not == 600 seconds

* add docblock

* add translator comments

* update tested up to and requires at least values in readmes

* version bump

* bump composer deps

* don't display the warnings if we aren't on the pantheon cache admin page

* convert static class to a namespace
there's no reason to make this a class since we're not using any class features

* add a bootstrapper for namespace-only files

* lint

* escape the wp_die message

* use a helper for humanized time calculations

* we still need to test the current max age

* pass the current max age to the message, too
and be specific that we're talking about seconds

* use the filterable value for default max age
because it could be something different

* add a helper function for retrieving the default max age
this is helpful so we can always return the filtered value

* also display the seconds in the successful test

* rank the max age value
don't say it's "very low" unless that's actually accurate.

* add caching to the ranked compare

* make the color more severe if it's a bigger issue

* change the color of the admin notice based on the severity of the diff

* clear the transient when the option is updated

* break notice type into a variable

* fix the translator note

* keep the rank but hide it from the dom

* add unit tests

* add initial behat test
let's just see if we can assume this will work

* fix failing test

* specify the element where the notices are

* add site health check test

* actually save the changes

* remove max age check
only exists in an html comment anyway

* simplify the site health check

* add the message when you expand the accordion

* add other site health things

* change press to click?

* add "open the accordion" as a custom step

* move behat stuff around

* move stuff around again

* update the behat.yml

* remove custom context and try "when I follow"

* move to checking the text inside the elements

* target the hidden element

* use hidden='hidden'

* call it a div

* simplify the tests

* remove press
since we can't actually press

* it did actually find the right heading
maybe it will find the right text?

* add @\since tags

* add changelog and upgrade notice

* let's try checking for some of the hidden text

* period at the end of the sentence

* add the ranks back
this shows us that our ranking function is working

* add the messages

* remove age rank tests
because goutte doesn't natively interpret html comments

* add github testing badge
since phpunit is no longer run on circle

* add script to maybe skip behat tests if we don't need to run them

* add step to workflow

* do not run if the circle config changes

* also ignore if scripts (that aren't behat-related) have changed

* fix the logic (again)

* one more flippity flip

* remove the "ignoring" message
it's actually implied by the fact that is_ignored is checked

* use function to determine if a file should be ignored

Co-authored-by: Phil Tyler <[email protected]>

* update changelog to note mu-plugin updates

* add functionality to automatically set the default_ttl if it was set to 600

* trigger the setting change and display an admin notice informing users it was done
only show the notice to users who haven't already seen it and who can manage_options

* add unit tests for set_max_age_to_default

* move the max age update notice to the bootstrap

* remove the set_max_age_updated helper
this wasn't working and meant that we were needing to make multiple update options in a short space of time. we might have actually been running into race conditions where one update was overwriting the other one.

* use a new option for the updated flag

* add _notice to the user meta key so it's distinct from the new option

* update tests for new changes

* add translator note

* user notice about 600 second update is not dismissable
because it only appears once

* don't show seconds in updated notice

* pass the function into the apply_filter hook
so you can selectively disable specific notices

* add docblock

* add test for the notice

* return the value of disable_notices
rather than hard-coded "false"

* Add scenario to set max-age to 600 and auto-update to the default value

* here's a behat test that might not work
not sure if it will know what pantheon-cache[default-ttl] is without giving it an element to look at.

* fixed it based on upstream tests

* refresh the page

* go to instead of refresh
since refresh isn't a thing ¯\_(ツ)_/¯

* add additional test failure messaging

* break up tests

---------

Co-authored-by: Phil Tyler <[email protected]>

* [CMSP-995] one more notice (#271)

* add a global admin notice that appears once

* remove seconds from the notice

* test the new notice

* set dismissable depending on which notice we're showing

* show the max age rank html comment

* fix the conditionals for cs

* update behat tests for new notice language

* bugfix: don't update user meta that max_age was updated if it hasn't been

* add one more thing to test in behat

* add a test for the error, specifically

* add a test for the warning

* simplify the conditionals

* lint

* specify the pages that we're on?

* remove specific element

* fix typo

* take out the dashboard main page goto

* validate the setting was saved

* let's just remove the 5 days notice

* just remove the test
we have similar things being tested in phpunit

* we can actually remove current_max_age >= WEEK_IN_SECONDS
this is covered by max_age_rank. if max_age_rank is 0 it, by definition, means that the current max age is >= WEEK_IN_SECONDS

* if we're only comparing two things, we don't need to break the if clauses up

* we do want to warn users if they have manually set their max age to 600
we just don't want to warn them if we're about to (or just did) change it to a week for them

* [CMSP-992] UI changes (#272)

* add initial admin interface class
hook to mu-plugin > 1.4.0

* some more scaffolding

* require at least 6.4

* don't show notices if wp_admin_notice doesn't exist

* add notice if mu-plugin was not found

* add notice if the mu-plugin is old

* fix link and change decimal to string

* use spaces instead of line breaks

* add helper function to get current max age
this is either set in the mu-plugin or empty. if empty, it should default to 1 week

* add notice if less than 1 week but not == 600 seconds

* add docblock

* add translator comments

* update tested up to and requires at least values in readmes

* version bump

* bump composer deps

* don't display the warnings if we aren't on the pantheon cache admin page

* convert static class to a namespace
there's no reason to make this a class since we're not using any class features

* add a bootstrapper for namespace-only files

* lint

* escape the wp_die message

* use a helper for humanized time calculations

* we still need to test the current max age

* pass the current max age to the message, too
and be specific that we're talking about seconds

* use the filterable value for default max age
because it could be something different

* add a helper function for retrieving the default max age
this is helpful so we can always return the filtered value

* also display the seconds in the successful test

* rank the max age value
don't say it's "very low" unless that's actually accurate.

* add caching to the ranked compare

* make the color more severe if it's a bigger issue

* change the color of the admin notice based on the severity of the diff

* clear the transient when the option is updated

* break notice type into a variable

* fix the translator note

* keep the rank but hide it from the dom

* add unit tests

* add initial behat test
let's just see if we can assume this will work

* fix failing test

* specify the element where the notices are

* add site health check test

* actually save the changes

* remove max age check
only exists in an html comment anyway

* simplify the site health check

* add the message when you expand the accordion

* add other site health things

* change press to click?

* add "open the accordion" as a custom step

* move behat stuff around

* move stuff around again

* update the behat.yml

* remove custom context and try "when I follow"

* move to checking the text inside the elements

* target the hidden element

* use hidden='hidden'

* call it a div

* simplify the tests

* remove press
since we can't actually press

* it did actually find the right heading
maybe it will find the right text?

* add @\since tags

* add changelog and upgrade notice

* let's try checking for some of the hidden text

* period at the end of the sentence

* add the ranks back
this shows us that our ranking function is working

* add the messages

* remove age rank tests
because goutte doesn't natively interpret html comments

* add github testing badge
since phpunit is no longer run on circle

* add script to maybe skip behat tests if we don't need to run them

* add step to workflow

* do not run if the circle config changes

* also ignore if scripts (that aren't behat-related) have changed

* fix the logic (again)

* one more flippity flip

* remove the "ignoring" message
it's actually implied by the fact that is_ignored is checked

* use function to determine if a file should be ignored

Co-authored-by: Phil Tyler <[email protected]>

* update changelog to note mu-plugin updates

* add functionality to automatically set the default_ttl if it was set to 600

* trigger the setting change and display an admin notice informing users it was done
only show the notice to users who haven't already seen it and who can manage_options

* add unit tests for set_max_age_to_default

* move the max age update notice to the bootstrap

* remove the set_max_age_updated helper
this wasn't working and meant that we were needing to make multiple update options in a short space of time. we might have actually been running into race conditions where one update was overwriting the other one.

* use a new option for the updated flag

* add _notice to the user meta key so it's distinct from the new option

* update tests for new changes

* add translator note

* user notice about 600 second update is not dismissable
because it only appears once

* don't show seconds in updated notice

* pass the function into the apply_filter hook
so you can selectively disable specific notices

* add docblock

* add test for the notice

* return the value of disable_notices
rather than hard-coded "false"

* Add scenario to set max-age to 600 and auto-update to the default value

* here's a behat test that might not work
not sure if it will know what pantheon-cache[default-ttl] is without giving it an element to look at.

* fixed it based on upstream tests

* refresh the page

* go to instead of refresh
since refresh isn't a thing ¯\_(ツ)_/¯

* remove all the old npm stuff and use all new npm stuff

* add node build to the build & tag workflow

* add del package

* repurpos gruntfile into gulpfile

* repackage gulpfile and package.json as a module

* add additional test failure messaging

* gitignore assets

* don't export the gulpfile

* invoke sass correctly

* proper sassing

* add a main.scss file

* compiler tweaks

* use concat

* initial styles

* enqueue css

* use the filter added in pantheon-systems/pantheon-mu-plugin#46 to add header

* some initial styles for the max age box

* add a global admin notice that appears once

* remove seconds from the notice

* test the new notice

* set dismissable depending on which notice we're showing

* show the max age rank html comment

* fix the conditionals for cs

* update behat tests for new notice language

* bugfix: don't update user meta that max_age was updated if it hasn't been

* add one more thing to test in behat

* add a test for the error, specifically

* add a test for the warning

* simplify the conditionals

* lint

* specify the pages that we're on?

* remove specific element

* fix typo

* take out the dashboard main page goto

* validate the setting was saved

* let's just remove the 5 days notice

* just remove the test
we have similar things being tested in phpunit

* we can actually remove current_max_age >= WEEK_IN_SECONDS
this is covered by max_age_rank. if max_age_rank is 0 it, by definition, means that the current max age is >= WEEK_IN_SECONDS

* if we're only comparing two things, we don't need to break the if clauses up

* we do want to warn users if they have manually set their max age to 600
we just don't want to warn them if we're about to (or just did) change it to a week for them

* there should only be one css file

* remove seconds

* check stored default_ttl value

* fix failing test

* fix translators note

* remove seconds

* remove redundant check

* tweak the logic again

* fix the test by updating the default ttl

* add the description after the input

* styles for box and info bar

* update the filter name

* filter the input box

* add a padding helper

* ...and use it

* lint

* add styling for links in the info bar.

* no padding on the right
padding the right makes the bar flush with the edge of the box

* adjust h3 margin
so it looks better when there's no banner

* style the select input

* don't render the info bar

* use wp_kses_post instead of esc_html_e
we might want to add links to this bar

* helper function for available dropdown options and make it filterable

* Refactor default_ttl_input function to handle custom options and filterable dropdown

* remove seconds from behat tests

* add a period for dumb lint rule

* remove hyphen from max-age
in everything user-facing

* update the tests

* conditionally append a timestamp to the css version
to refresh it on each page load if debug is true

* don't show the input box if the ttl is unset

* remove filters in teardown

* remove hyphen in tests

* specify method visibility

* test the setting description callback

* test the default ttl option input callback

* test max_age_options and filter

* add a behat test for the select input

* maybe change the then

* remove all hyphens

* be more specific about the select input

* try using the class and the select

* let's try checking to see if the response contains the selected option

* print for debugging

* one last try before I give up

* remove the new behat test

* use a simple true/false gate for max_age header

* display a warning if the default_ttl is saved to a value that's not one of the default optiosn

* show the dropdown with the custom value
so a new value can be selected from the droptdown when prompted

* remove placeholder comment

* gix the global warning shown logic

* make sure to take into consideration custom and filtered

* bail early if the max age is filtered

* better comment

* remove value range entirely

* remove recommendation if filtered

* break out custom and filtered outputs
filtered displays the grayed out input box
custom adds to the dropdown

* update tests

* translator note

* move the debug note

Co-authored-by: Phil Tyler <[email protected]>

* add since and return values

* push the description down a bit

* personalized message based on current cache max age

* remove current when not necessary

* update tests, add a data provider

* use boolean variable names
`$is_filtered` instead of `$filtered`
`$has_custom_ttl` instead of `$custom` and `$custom_ttl`

---------

Co-authored-by: Phil Tyler <[email protected]>

* [CMSP-992] plugin documentation update (#273)

* add initial admin interface class
hook to mu-plugin > 1.4.0

* some more scaffolding

* require at least 6.4

* don't show notices if wp_admin_notice doesn't exist

* add notice if mu-plugin was not found

* add notice if the mu-plugin is old

* fix link and change decimal to string

* use spaces instead of line breaks

* add helper function to get current max age
this is either set in the mu-plugin or empty. if empty, it should default to 1 week

* add notice if less than 1 week but not == 600 seconds

* add docblock

* add translator comments

* update tested up to and requires at least values in readmes

* version bump

* bump composer deps

* don't display the warnings if we aren't on the pantheon cache admin page

* convert static class to a namespace
there's no reason to make this a class since we're not using any class features

* add a bootstrapper for namespace-only files

* lint

* escape the wp_die message

* use a helper for humanized time calculations

* we still need to test the current max age

* pass the current max age to the message, too
and be specific that we're talking about seconds

* use the filterable value for default max age
because it could be something different

* add a helper function for retrieving the default max age
this is helpful so we can always return the filtered value

* also display the seconds in the successful test

* rank the max age value
don't say it's "very low" unless that's actually accurate.

* add caching to the ranked compare

* make the color more severe if it's a bigger issue

* change the color of the admin notice based on the severity of the diff

* clear the transient when the option is updated

* break notice type into a variable

* fix the translator note

* keep the rank but hide it from the dom

* add unit tests

* add initial behat test
let's just see if we can assume this will work

* fix failing test

* specify the element where the notices are

* add site health check test

* actually save the changes

* remove max age check
only exists in an html comment anyway

* simplify the site health check

* add the message when you expand the accordion

* add other site health things

* change press to click?

* add "open the accordion" as a custom step

* move behat stuff around

* move stuff around again

* update the behat.yml

* remove custom context and try "when I follow"

* move to checking the text inside the elements

* target the hidden element

* use hidden='hidden'

* call it a div

* simplify the tests

* remove press
since we can't actually press

* it did actually find the right heading
maybe it will find the right text?

* add @\since tags

* add changelog and upgrade notice

* let's try checking for some of the hidden text

* period at the end of the sentence

* add the ranks back
this shows us that our ranking function is working

* add the messages

* remove age rank tests
because goutte doesn't natively interpret html comments

* add github testing badge
since phpunit is no longer run on circle

* add script to maybe skip behat tests if we don't need to run them

* add step to workflow

* do not run if the circle config changes

* also ignore if scripts (that aren't behat-related) have changed

* fix the logic (again)

* one more flippity flip

* remove the "ignoring" message
it's actually implied by the fact that is_ignored is checked

* use function to determine if a file should be ignored

Co-authored-by: Phil Tyler <[email protected]>

* update changelog to note mu-plugin updates

* add functionality to automatically set the default_ttl if it was set to 600

* trigger the setting change and display an admin notice informing users it was done
only show the notice to users who haven't already seen it and who can manage_options

* add unit tests for set_max_age_to_default

* move the max age update notice to the bootstrap

* remove the set_max_age_updated helper
this wasn't working and meant that we were needing to make multiple update options in a short space of time. we might have actually been running into race conditions where one update was overwriting the other one.

* use a new option for the updated flag

* add _notice to the user meta key so it's distinct from the new option

* update tests for new changes

* add translator note

* user notice about 600 second update is not dismissable
because it only appears once

* don't show seconds in updated notice

* pass the function into the apply_filter hook
so you can selectively disable specific notices

* add docblock

* add test for the notice

* return the value of disable_notices
rather than hard-coded "false"

* Add scenario to set max-age to 600 and auto-update to the default value

* here's a behat test that might not work
not sure if it will know what pantheon-cache[default-ttl] is without giving it an element to look at.

* fixed it based on upstream tests

* refresh the page

* go to instead of refresh
since refresh isn't a thing ¯\_(ツ)_/¯

* remove all the old npm stuff and use all new npm stuff

* add node build to the build & tag workflow

* add del package

* repurpos gruntfile into gulpfile

* repackage gulpfile and package.json as a module

* add additional test failure messaging

* gitignore assets

* don't export the gulpfile

* invoke sass correctly

* proper sassing

* add a main.scss file

* compiler tweaks

* use concat

* initial styles

* enqueue css

* use the filter added in pantheon-systems/pantheon-mu-plugin#46 to add header

* some initial styles for the max age box

* add a global admin notice that appears once

* remove seconds from the notice

* test the new notice

* set dismissable depending on which notice we're showing

* show the max age rank html comment

* fix the conditionals for cs

* update behat tests for new notice language

* bugfix: don't update user meta that max_age was updated if it hasn't been

* add one more thing to test in behat

* add a test for the error, specifically

* add a test for the warning

* simplify the conditionals

* lint

* specify the pages that we're on?

* remove specific element

* fix typo

* take out the dashboard main page goto

* validate the setting was saved

* let's just remove the 5 days notice

* just remove the test
we have similar things being tested in phpunit

* we can actually remove current_max_age >= WEEK_IN_SECONDS
this is covered by max_age_rank. if max_age_rank is 0 it, by definition, means that the current max age is >= WEEK_IN_SECONDS

* if we're only comparing two things, we don't need to break the if clauses up

* we do want to warn users if they have manually set their max age to 600
we just don't want to warn them if we're about to (or just did) change it to a week for them

* there should only be one css file

* remove seconds

* check stored default_ttl value

* fix failing test

* fix translators note

* remove seconds

* remove redundant check

* tweak the logic again

* fix the test by updating the default ttl

* add the description after the input

* styles for box and info bar

* update the filter name

* filter the input box

* add a padding helper

* ...and use it

* lint

* add styling for links in the info bar.

* no padding on the right
padding the right makes the bar flush with the edge of the box

* adjust h3 margin
so it looks better when there's no banner

* style the select input

* don't render the info bar

* use wp_kses_post instead of esc_html_e
we might want to add links to this bar

* helper function for available dropdown options and make it filterable

* Refactor default_ttl_input function to handle custom options and filterable dropdown

* remove seconds from behat tests

* add a period for dumb lint rule

* remove hyphen from max-age
in everything user-facing

* update the tests

* conditionally append a timestamp to the css version
to refresh it on each page load if debug is true

* don't show the input box if the ttl is unset

* remove filters in teardown

* remove hyphen in tests

* specify method visibility

* test the setting description callback

* test the default ttl option input callback

* test max_age_options and filter

* add a behat test for the select input

* maybe change the then

* remove all hyphens

* be more specific about the select input

* try using the class and the select

* let's try checking to see if the response contains the selected option

* print for debugging

* one last try before I give up

* remove the new behat test

* use a simple true/false gate for max_age header

* display a warning if the default_ttl is saved to a value that's not one of the default optiosn

* show the dropdown with the custom value
so a new value can be selected from the droptdown when prompted

* remove placeholder comment

* gix the global warning shown logic

* make sure to take into consideration custom and filtered

* bail early if the max age is filtered

* better comment

* remove value range entirely

* remove recommendation if filtered

* break out custom and filtered outputs
filtered displays the grayed out input box
custom adds to the dropdown

* update tests

* translator note

* move the debug note

Co-authored-by: Phil Tyler <[email protected]>

* add since and return values

* push the description down a bit

* personalized message based on current cache max age

* remove current when not necessary

* update tests, add a data provider

* update changelog

* cache max age filter docs

* document filter to disable notices

* emdash

Co-authored-by: Phil Tyler <[email protected]>

* add missing links

* emdash

* update the 2.0.0 upgrade notice

* add upgrade notice to .md

* remove linebreak

* add -dev tag to versions

* fix readme spacing

---------

Co-authored-by: Phil Tyler <[email protected]>

* Add NPM Diff action (#275)

* use NPM Lockfile Changes

* make sure the workflow also runs when package-lock files are updated

* rename the workflow file
since it's not just composer anymore

* allow fuzzy matching
because excluded subdirectory files should not trigger behat tests

* Build unminified css (#276)

* add gulp-rename
for renaming the minified css file

* update the build workflow to create two css files

* explicitly enqueue the minified css file

* define the path

* full path to workspace?

* add an npm install step
to generate the lockfile
might be ignored by .gitattributes

* re-add path

* don't fail if the test fails

* temporarily don't ignore package-lock.json files

* remove path

* run workflow when the workflow itself is changed
so we can see the effects of our changes

* pass path

* remove unnecessary params
the defaults cover these

* comment out the npm package diff and add description why

* don't run on package-lock updates

* don't run the workflow if the release event is a pre-release (#277)

* update validator version to v1 (#278)

since autotag is now running

* remove gitignore rule to ignore compiled css files (#280)

* fix syntax error in conditional (#281)

* fix syntax error in conditional

* add a workflow that validates workflows

* [CMSP-1193] Filter `pantheon_cache_default_max_age`  when nonces are created (#282)

* require the wp_screen class if it's not loaded

* filter default cache max age to less than nonce_life when creating nonces

* add tests

* update changelog

* add props

* re-add package-lock.json to .gitattributes (#284)

* Release 2.0.0

---------

Co-authored-by: Chris Reynolds <[email protected]>
Co-authored-by: Phil Tyler <[email protected]>
Co-authored-by: Pantheon Automation <[email protected]>
  • Loading branch information
4 people authored May 28, 2024
1 parent faa6c47 commit c310f0a
Show file tree
Hide file tree
Showing 26 changed files with 5,872 additions and 1,586 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
- image: quay.io/pantheon-public/build-tools-ci:8.x-php8.2
steps:
- checkout
- run:
name: Check if we need to run Behat
command: ./bin/maybe-skip-tests.sh
- restore_cache:
keys:
- test-behat-dependencies-{{ checksum "composer.json" }}
Expand Down
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
/composer.json export-ignore
/composer.lock export-ignore
/CONTRIBUTING.md export-ignore
/Gruntfile.js export-ignore
/gulpfile.mjs export-ignore
/package-lock.json export-ignore
/package.json export-ignore
/phpcs.xml.dist export-ignore
/phpunit.xml.dist export-ignore
/README.md export-ignore
/README.md export-ignore
1 change: 1 addition & 0 deletions .github/workflows/build-tag-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ jobs:
with:
gh_token: ${{ github.token }}
readme_md: README.md
build_node_assets: true
28 changes: 0 additions & 28 deletions .github/workflows/composer-diff.yml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/composer-npm-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Composer and NPM Package Diff
on:
pull_request:
paths:
- 'composer.lock'
# - 'package-lock.json'
permissions:
contents: write
pull-requests: write
jobs:
composer-diff:
name: Composer Diff
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate composer diff
id: composer_diff
uses: IonBazan/composer-diff-action@v1
- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ steps.composer_diff.outputs.composer_diff_exit_code != 0 }}
with:
header: composer-diff
message: |
<strong>Composer Changes</strong>
${{ steps.composer_diff.outputs.composer_diff }}
# Removing because the workflow fails for some unknown reason, see https://github.com/pantheon-systems/pantheon-advanced-page-cache/actions/runs/9228002744/job/25391128483
# There's no support for this action, so we might need to build something new.
# npm-diff:
# name: NPM Lockfile Diff
# runs-on: ubuntu-latest
# continue-on-error: true
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - name: Compile NPM packages
# run: npm ci
# - name: NPM Lockfile Changes
# uses: codepunkt/npm-lockfile-changes@main
# with:
# token: ${{ github.token }}
2 changes: 1 addition & 1 deletion .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pantheon-systems/action-wporg-validator@1.0.0
- uses: pantheon-systems/action-wporg-validator@v1
with:
type: 'plugin'
test:
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/validate-actions-workflows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Validate GitHub Actions workflows
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review

jobs:
validate-workflows:
name: Validate GitHub Actions workflows
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install action-validator with NPM
run: |
npm install -g @action-validator/core @action-validator/cli --save-dev
action-validator --help
- name: Validate workflows
run: |
# Loop over all the workflows in the .github/workflows directory.
for file in .github/workflows/*.yml; do
action-validator $file
done
2 changes: 2 additions & 0 deletions .github/workflows/wordpress-plugin-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:

jobs:
release:
# Do not run this job for prerelease versions.
if: ${{ ! github.event.release.prerelease }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 0 additions & 23 deletions Gruntfile.js

This file was deleted.

61 changes: 55 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

**Contributors:** [getpantheon](https://profiles.wordpress.org/getpantheon), [danielbachhuber](https://profiles.wordpress.org/danielbachhuber), [kporras07](https://profiles.wordpress.org/kporras07), [jspellman](https://profiles.wordpress.org/jspellman/), [jazzs3quence](https://profiles.wordpress.org/jazzs3quence/), [ryanshoover](https://profiles.wordpress.org/ryanshoover/), [rwagner00](https://profiles.wordpress.org/rwagner00/), [pwtyler](https://profiles.wordpress.org/pwtyler)
**Tags:** pantheon, cdn, cache
**Requires at least:** 4.7
**Tested up to:** 6.4.3
**Stable tag:** 1.5.0-dev
**Requires at least:** 6.4
**Tested up to:** 6.5.3
**Stable tag:** 2.0.0
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Automatically clear related pages from Pantheon's Edge when you update content. High TTL. Fresh content. Visitors never wait.

## Description ##

[![Actively Maintained](https://img.shields.io/badge/Pantheon-Actively_Maintained-yellow?logo=pantheon&color=FFDC28)](https://pantheon.io/docs/oss-support-levels#actively-maintained-support) [![CircleCI](https://circleci.com/gh/pantheon-systems/pantheon-advanced-page-cache.svg?style=svg)](https://circleci.com/gh/pantheon-systems/pantheon-advanced-page-cache)
[![Actively Maintained](https://img.shields.io/badge/Pantheon-Actively_Maintained-yellow?logo=pantheon&color=FFDC28)](https://pantheon.io/docs/oss-support-levels#actively-maintained-support)
[![Lint and Test](https://github.com/pantheon-systems/pantheon-advanced-page-cache/actions/workflows/lint-test.yml/badge.svg)](https://github.com/pantheon-systems/pantheon-advanced-page-cache/actions/workflows/lint-test.yml)
[![CircleCI](https://circleci.com/gh/pantheon-systems/pantheon-advanced-page-cache.svg?style=svg)](https://circleci.com/gh/pantheon-systems/pantheon-advanced-page-cache)

For sites wanting fine-grained control over how their responses are represented in their edge cache, Pantheon Advanced Page Cache is the golden ticket. Here's a high-level overview of how the plugin works:

Expand Down Expand Up @@ -161,6 +163,20 @@ add_filter( 'pantheon_purge_post_type_ignored', 'filter_ignored_posts' );

This will prevent the cache from being purged if the given post type is updated.

### Setting the Cache Max Age with a filter

The cache max age setting is controlled by the [Pantheon Page Cache](https://docs.pantheon.io/guides/wordpress-configurations/wordpress-cache-pluginhttps://docs.pantheon.io/guides/wordpress-configurations/wordpress-cache-plugin) admin page. As of 2.0.0, there are three cache age options by default — 1 week, 1 month, 1 year. Pantheon Advanced Page Cache automatically purges the cache of updated and related posts and pages, but you might want to override the cache max age value and set it programmatically. In this case, you can use the `pantheon_cache_default_max_age` filter added in [Pantheon MU plugin 1.4.0+](https://docs.pantheon.io/guides/wordpress-configurations/wordpress-cache-plugin#override-the-default-max-age). For example:

```php
add_filter( 'pantheon_cache_default_max_age', function() {
return 10 * DAY_IN_SECONDS;
} );
```

When the cache max age is filtered in this way, the admin option is disabled and a notice is displayed.

![Page Cache Max Age with filtered value](.wordpress-org/screenshots/page-cache-max-age-filtered.png)

## WP-CLI Commands ##

This plugin implements a variety of [WP-CLI](https://wp-cli.org) commands. All commands are grouped into the `wp pantheon cache` namespace.
Expand Down Expand Up @@ -332,7 +348,7 @@ Different WordPress actions cause different surrogate keys to be purged, documen
## Surrogate Keys for taxonomy terms ##
Setting surrogate keys for posts with large numbers of taxonomies (such as WooCommerce products with a large number of global attributes) can suffer from slower queries. Surrogate keys can be skipped for 'product' post types' taxonomy terms (or any other criteria you see fit) with the following filter:

``` php
```php
function custom_should_add_terms($should_add_terms, $wp_query) {
if ( $wp_query->is_singular( 'product' ) ) {
return false;
Expand All @@ -342,6 +358,28 @@ function custom_should_add_terms($should_add_terms, $wp_query) {
add_filter('pantheon_should_add_terms', 'custom_should_add_terms', 10, 2);
```

## Other Filters ##

### `pantheon_apc_disable_admin_notices`
Since 2.0.0, Pantheon Advanced Page Cache displays a number of admin notices about your current cache max age value. You can disable these notices with the `pantheon_apc_disable_admin_notices` filter.

```php
add_filter( 'pantheon_apc_disable_admin_notices', '__return_true' );
```

Alternately, the function callback is passed into the `pantheon_apc_disable_admin_notices` filter, allowing you to specify precisely _which_ notice to disable, for example:

```php
add_filter( 'pantheon_apc_disable_admin_notices', function( $disable_notices, $callback ) {
if ( $callback === '\\Pantheon_Advanced_Page_Cache\\Admin_Interface\\admin_notice_maybe_recommend_higher_max_age' ) {
return true;
}
return $disable_notices;
}, 10, 2 );
```

The above example would disable _only_ the admin notice recommending a higher cache max age.

## Plugin Integrations ##

Pantheon Advanced Page Cache integrates with WordPress plugins, including:
Expand All @@ -353,7 +391,13 @@ Pantheon Advanced Page Cache integrates with WordPress plugins, including:
See [CONTRIBUTING.md](https://github.com/pantheon-systems/pantheon-advanced-page-cache/blob/master/CONTRIBUTING.md) for information on contributing.

## Changelog ##
### 1.5.0-dev (March 11, 2024) ###
### 2.0.0 ###
* Adds new admin alerts and Site Health tests about default cache max age settings and recommendations [[#268](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/268), [#271](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/271)]. The default Pantheon GCDN cache max age value has been updated to 1 week in the [Pantheon MU plugin](https://github.com/pantheon-systems/pantheon-mu-plugin). For more information, see the [release note](https://docs.pantheon.io/release-notes/2024/04/pantheon-mu-plugin-1-4-0-update).
* Updated UI in Pantheon Page Cache admin page when used in a Pantheon environment (with the Pantheon MU plugin). [[#272](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/272)]
* Automatically updates the cache max age to the recommended value (1 week) if it was saved at the old default value (600 seconds). [[#269](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/269)]
* Adds a hook into the `nonce_life` filter when nonces are created on the front-end to set the `pantheon_cache_default_max_age` to less than the nonce lifetime to avoid nonces expiring before the cache does. [[#282](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/282)] props [@ryanshoover](https://github.com/ryanshoover)

### 1.5.0 (March 11, 2024) ###
* Adds filter `pantheon_purge_post_type_ignored` to allow an array of post types to ignore before purging cache [[#258](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/258)]
* Adds [wpunit-helpers](https://github.com/pantheon-systems/wpunit-helpers) for running/setting up WP Unit tests

Expand Down Expand Up @@ -431,5 +475,10 @@ See [CONTRIBUTING.md](https://github.com/pantheon-systems/pantheon-advanced-page

## Upgrade Notice ##

### 2.0.0 ###
This release requires a minimum WordPress version of 6.4.0. It uses Site Health checks and the `wp_admin_notices` function to alert users to the new cache max-age default settings and recommendations. The plugin will still function with earlier versions, but you will not get the benefit of the alerts and Site Health checks.

This version also automatically updates the cache max age (set in the [Pantheon Page Cache settings](https://docs.pantheon.io/guides/wordpress-configurations/wordpress-cache-plugin)) to the recommended value (1 week) if it was saved at the old default value (600 seconds). If the cache max age was set to any other value (or not set at all), it will not be changed. A one-time notice will be displayed in the admin interface to inform administrators of this change.

### 1.3.0 ###
Note that the Pantheon Advanced Page Cache 1.3.0 release now prefixes keys on a WordPress Multisite (WPMS) with the blog ID. For users who already have this plugin installed on a WPMS, they will need to click the Clear Cache button on the settings page to generate the prefixed keys.
62 changes: 62 additions & 0 deletions assets/sass/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.pantheon-page-cache {
hr {
display: none;
}

tr.cache-default-max-age {
display: block;
padding: $padding;
background: $white;
color: $charcoal;
box-shadow: $shadow;

td {
padding: 0;
}

.pantheon-cache-default-max-age {
padding: 0 $padding $padding 0;

h3 {
margin-top: 0.5em;
}

i {
margin-right: $padding;
line-height: 1.0em;
}

&-info-bar {
background: $blue;
color: $white;
padding: $padding 0 $padding $padding;
text-align: left;
display: block;
width: 100%;
margin-bottom: 1em;

a {
color: $white;
text-decoration: underline;
}

a:hover, a:active {
color: $white;
text-decoration: none;
}
}

select {
background-color: $white;
color: $charcoal;
border: 1px solid $gray;
border-radius: 0;
}

&-description {
color: $gray;
margin: $padding 0 0 0;
}
}
}
}
9 changes: 9 additions & 0 deletions assets/sass/mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Colors
$blue: #1d7afc;
$white: #ffffff;
$gray: #757575;
$charcoal: #1e1e1e;

$shadow: 0 0 10px 5px rgba(0, 0, 0, 0.1);

$padding: 10px;
2 changes: 2 additions & 0 deletions assets/sass/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import 'mixins';
@import 'main';
Loading

0 comments on commit c310f0a

Please sign in to comment.