Skip to content

Fix: Email Content Editor for 'Delete Inactive Accounts' is not working#408

Open
reygcalantaol wants to merge 2 commits intodevelopfrom
wpum-security-#71-Email-Content-Editor-for-'Delete-Inactive-Accounts'-is-not-working
Open

Fix: Email Content Editor for 'Delete Inactive Accounts' is not working#408
reygcalantaol wants to merge 2 commits intodevelopfrom
wpum-security-#71-Email-Content-Editor-for-'Delete-Inactive-Accounts'-is-not-working

Conversation

@reygcalantaol
Copy link
Collaborator

@reygcalantaol reygcalantaol commented Jun 22, 2025

Resolves https://github.com/WPUserManager/wpum-security/issues/71

Summary

Fixes the email content editor (TinyMCE) not loading when a block theme (Full Site Editing) is active. Block-based themes don't load TinyMCE on admin pages outside the site editor, so the WPUM email customizer's rich text editor was blank.

Fix: Detect block themes via wp_is_block_theme() and manually fire admin_print_footer_scripts to initialize TinyMCE.

Note: This is a workaround for a WordPress core limitation. It may need revisiting if WP core changes how block themes handle TinyMCE.


Manual Test Plan

Prerequisites

  • WP User Manager active
  • A block theme activated (e.g. Twenty Twenty-Four, Twenty Twenty-Five)
  • WP_DEBUG enabled to catch any errors

1. Test with a block theme

  • Activate a block theme (e.g. Twenty Twenty-Five)
  • Go to Users > Emails
  • Click Customize on any email template (e.g. "New Account Notification")
  • Expected: The email customizer loads and the TinyMCE rich text editor appears
  • Expected: You can type in the editor, use formatting buttons (bold, italic, links)
  • Edit the email content and click Save & Publish
  • Expected: Changes are saved without error

2. Test all email templates

  • Go back to Users > Emails
  • Click Customize on each email template in turn:
    • New Account Notification
    • Password Recovery
    • Account Approved (if using approval workflow)
    • Delete Inactive Accounts (if WPUM Security active)
  • Expected: TinyMCE editor loads correctly for every template

3. Test with WPUM Security addon

  • Activate WPUM Security plugin
  • Go to Settings > Security > Cleanup and enable Delete Inactive Accounts
  • Go to Users > Emails > Customize "Delete Inactive Accounts"
  • Expected: The TinyMCE editor loads (this was the originally reported broken case)

4. Verify classic theme still works (regression)

  • Switch to a classic theme (e.g. Twenty Twenty-One)
  • Go to Users > Emails > Customize any email
  • Expected: TinyMCE editor loads as before — no regression

5. Check for console errors

  • Open browser DevTools (F12) on the email customizer page
  • Expected: No JavaScript errors in the console related to TinyMCE or WPUM

Test Coverage

No WPUnit tests — this is a browser rendering fix (TinyMCE initialization) that can only be verified via E2E or manual testing.

🤖 Generated with Claude Code

@polevaultweb polevaultweb requested a review from Copilot July 5, 2025 14:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures the TinyMCE editor loads in the email customizer when using block-based themes by explicitly firing footer scripts.

  • Adds a block-theme detection in customize_controls()
  • Calls admin_print_footer_scripts() to initialize TinyMCE under block themes
Comments suppressed due to low confidence (3)

includes/emails/class-wpum-emails-customizer-scripts.php:86

  • Instead of manually calling admin_print_footer_scripts, consider using wp_enqueue_editor() to load TinyMCE and its dependencies. This aligns with WordPress core APIs and reduces risk of duplicate script outputs.
		// This is a workaround to ensure that the tinymce editor is initialized in a block theme.

includes/emails/class-wpum-emails-customizer-scripts.php:87

  • [nitpick] Add a comment referencing the related WordPress core issue or the version when block themes stopped loading TinyMCE by default, so future maintainers understand the need for this workaround.
		if ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) {

includes/emails/class-wpum-emails-customizer-scripts.php:87

  • Introduce a test to verify that editor scripts are correctly initialized when wp_is_block_theme() returns true to prevent regression in block-theme contexts.
		if ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) {

Resolve conflict keeping block theme TinyMCE workaround from this branch.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants