gravity-pdf icon indicating copy to clipboard operation
gravity-pdf copied to clipboard

Filter Notification messages exclusively to Gravity PDF pages.

Open jestonihpi opened this issue 3 years ago • 3 comments

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

jestonihpi avatar Jun 22 '22 02:06 jestonihpi

Codecov Report

Merging #1353 (40603b9) into development (e7313ae) will increase coverage by 0.01%. The diff coverage is 82.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.

codecov[bot] avatar Jun 22 '22 02:06 codecov[bot]

Also, missing unit tests.

jakejackson1 avatar Jun 30 '22 04:06 jakejackson1

Hi @jakejackson1 , can you check on this PR as well? Thanks!

jestonihpi avatar Aug 31 '22 05:08 jestonihpi

Copy @jakejackson1. Thanks!

jestonihpi avatar Sep 06 '22 00:09 jestonihpi

Hey @jakejackson1 , this PR is now ready for your review.

jestonihpi avatar Sep 06 '22 01:09 jestonihpi

@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:

  1. Core Registers Notices class
  2. Previewer Registers Notices class
  3. Bulk Generator Registers Notices class
  4. Core Registers Override Hooks
  5. Previewer Registers Override Hooks
  6. Bulk Generator Registers Override Hooks
  7. Core Override Triggers and returns the "Success" message
  8. Previewer Override Triggers and returns empty array
  9. Bulk Generator Override Triggers and returns empty array
  10. 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?

jakejackson1 avatar Sep 06 '22 02:09 jakejackson1

None for now @jakejackson1 , but I will keep you posted for further questions.

jestonihpi avatar Sep 06 '22 02:09 jestonihpi

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.

jestonihpi avatar Sep 15 '22 04:09 jestonihpi

@jakejackson1 , converting this PR to draft for now. Its not working as expected. image

jestonihpi avatar Sep 16 '22 01:09 jestonihpi

@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).

jakejackson1 avatar Sep 21 '22 00:09 jakejackson1

Copy @jakejackson1.

jestonihpi avatar Sep 21 '22 03:09 jestonihpi