gravity-pdf
gravity-pdf copied to clipboard
Filter Notification messages exclusively to Gravity PDF pages.
Create a separate method that returns our errors and notices messages exclusively to Gravity PDF pages.
NOTE: This may need some improvements on how to properly initialize the Helper_Notice class exclusively to Gravity PDF pages as well.
Description
Testing instructions
Install Gravity Forms Akismet Add-On. Its default error message should not display on PDF settings.
Screenshots
Checklist:
- [x] I've tested the code.
- [ ] My code is easy to read, follow, and understand
- [ ] My code follows the accessibility standards.
- [ ] My code has proper inline documentation / docblocks.
Additional Comments
Codecov Report
Merging #1353 (40603b9) into development (e7313ae) will increase coverage by
0.01%. The diff coverage is82.05%.
@@ Coverage Diff @@
## development #1353 +/- ##
=================================================
+ Coverage 78.13% 78.14% +0.01%
- Complexity 2923 2925 +2
=================================================
Files 243 243
Lines 10188 10202 +14
Branches 370 370
=================================================
+ Hits 7960 7972 +12
- Misses 2220 2222 +2
Partials 8 8
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/View/html/Settings/licence.php | 0.00% <0.00%> (ø) |
|
| src/View/html/Settings/tools.php | 0.00% <0.00%> (ø) |
|
| src/bootstrap.php | 74.07% <0.00%> (-0.51%) |
:arrow_down: |
| src/Helper/Helper_Notices.php | 91.52% <93.93%> (+5.52%) |
:arrow_up: |
| src/View/html/Settings/help.php | 90.00% <100.00%> (+1.11%) |
:arrow_up: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
Also, missing unit tests.
Hi @jakejackson1 , can you check on this PR as well? Thanks!
Copy @jakejackson1. Thanks!
Hey @jakejackson1 , this PR is now ready for your review.
@jestonihpi I found problems with the notices being displayed when any Gravity PDF extensions are also activated on the site. This is because each extension creates a new Notices object on initialisation and they all add their own independent maybe_remove_non_pdf_messages hook (and subsequent override hooks).
The exact flow when two Gravity PDF extensions are activated and the Core plugin saves the PDF settings to display the "Successful" message is:
- Core Registers Notices class
- Previewer Registers Notices class
- Bulk Generator Registers Notices class
- Core Registers Override Hooks
- Previewer Registers Override Hooks
- Bulk Generator Registers Override Hooks
- Core Override Triggers and returns the "Success" message
- Previewer Override Triggers and returns empty array
- Bulk Generator Override Triggers and returns empty array
- Gravity Forms displays no notices
I think the best way to handle this is to split up the gform_admin_messages and gform_admin_error_messages actions we register so that we empty any existing messages at priority 999 (return [] and add any Gravity PDF messages at priority 1000 return array_merge( $messages, $this->notices ).
This will ensure Gravity PDF Core and Extensions can still have unique Notices classes, non-Gravity PDF notices are removed on Gravity PDF pages, and each plugin won't override each other's messages.
Does that make sense?
None for now @jakejackson1 , but I will keep you posted for further questions.
Hi @jakejackson1 , I have updated the unit tests. I have separated the non-filtered test and filtered. So with this, non-filtered should only reuse the notice object in the init, while the filtered test needs to re initialize starting from init.
@jakejackson1 , converting this PR to draft for now. Its not working as expected.

@jestonihpi I reverted your last change. I believe the Core Font installer / registered actions inside of Controller_Actions / certain folder permissions make use of the notice class to output messages to the end user. These notices can be shown outside Gravity PDF pages and this handles that use-case.
I also committed a tweak that should handle the GF-messages registered outside the gform_admin_messages processing (needs further testing).
Copy @jakejackson1.