Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Sensei Email template being set as default template in editor when Gutenberg is installed #7517

Merged
merged 3 commits into from Feb 29, 2024

Conversation

Imran92
Copy link
Contributor

@Imran92 Imran92 commented Feb 28, 2024

Resolves #7516

Proposed Changes

The latest GB sends an Ajax request to the server and fetches available templates. When we include the Sensei Email template using the get_block_templates filter, we check the Post Type, URL, template type, etc to make sure to only load this template for either sensei_email CPT or Site Editor (in which case, the current post type is null). But this ajax request was passing the Site Editor check because of its URL structure. To prevent it, we are returning early without adding Sensei Email to the list when it's a lookup request from the editor.

Testing Instructions

  1. Have latest Gutenberg installed
  2. Have DEBUG logging on
  3. Open an existing and a new Post in GB editor
  4. Make sure Sensei Email is not set as the Template
  5. Check the same for Pages, Courses and Lessons
  6. Check Sensei LMS -> Settings -> Emails
  7. Open and Email and make sure it's appearing as before
  8. Send an Email and make sure it's working as before
  9. Open site editor and make sure Sensei Email is there
  10. Disable Gutenberg and perform the same tests, make sure nothing is breaking
  11. Check your debug log and make sure you don't see any error - especially something like PHP Warning: Undefined array key "single-sensei_email" in ........

Bonus: Try thinking about any scenario where it can have side effects and check if it does. LMK if you find any.

Pre-Merge Checklist

  • PR title and description contain sufficient detail and accurately describe the changes
  • Acceptance criteria is met
  • Decisions are publicly documented
  • Adheres to coding standards (PHP, JavaScript, CSS, HTML)
  • All strings are translatable (without concatenation, handles plurals)
  • Follows our naming conventions (P6rkRX-4oA-p2)
  • Hooks (p6rkRX-1uS-p2) and functions are documented
  • New UIs are responsive and use a mobile-first approach
  • New UIs match the designs
  • Different user privileges (admin, teacher, subscriber) are tested as appropriate
  • Legacy courses (course without blocks) are tested
  • Code is tested on the minimum supported PHP and WordPress versions
  • User interface changes have been tested on the latest versions of Chrome, Firefox and Safari
  • "Needs Documentation" label is added if this change requires updates to documentation
  • Known issues are created as new GitHub issues

Otherwise it Sensei Email becomes the default selected template for all post types in the GB editor. Happens when GB is installed.
@Imran92 Imran92 added the Emails label Feb 28, 2024
@Imran92 Imran92 added this to the 4.21.1 milestone Feb 28, 2024
@Imran92 Imran92 requested a review from a team February 28, 2024 18:18
@Imran92 Imran92 self-assigned this Feb 28, 2024
@Imran92 Imran92 marked this pull request as ready for review February 28, 2024 18:18
Copy link

codecov bot commented Feb 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.51%. Comparing base (c39ebf7) to head (0c601eb).
Report is 1 commits behind head on trunk.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              trunk    #7517   +/-   ##
=========================================
  Coverage     51.51%   51.51%           
- Complexity    11231    11234    +3     
=========================================
  Files           622      622           
  Lines         47505    47508    +3     
  Branches        414      414           
=========================================
+ Hits          24471    24474    +3     
  Misses        22701    22701           
  Partials        333      333           
Files Coverage Δ
...udes/internal/emails/class-email-page-template.php 72.72% <100.00%> (+2.72%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 28aef97...0c601eb. Read the comment docs.

Copy link
Contributor

@renatho renatho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the quick fix, @Imran92! It works well for me! =)

@Imran92 Imran92 merged commit 66c1ab6 into trunk Feb 29, 2024
25 checks passed
@Imran92 Imran92 deleted the fix/email-post-type-being-set-for-all-posts branch February 29, 2024 06:40
@merkushin merkushin mentioned this pull request Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sensei Email template automatically selected on the editor
2 participants