Skip to content

Comments

Avoid duplicate e-content wrapper when theme supports microformats2#313

Open
pfefferle wants to merge 1 commit intotrunkfrom
fix/294-remove-extra-e-content-div
Open

Avoid duplicate e-content wrapper when theme supports microformats2#313
pfefferle wants to merge 1 commit intotrunkfrom
fix/294-remove-extra-e-content-div

Conversation

@pfefferle
Copy link
Member

Summary

  • Adds detection for microformats2 theme support
  • Checks explicit theme support via current_theme_supports('microformats2')
  • Falls back to detecting e-content class in rendered page output
  • Caches the result in an option for performance
  • Clears cache on theme switch
  • Ignores code/pre blocks to avoid false positives from user content
  • Only wraps content in e-content div when theme doesn't already provide it

Fixes #294

@pfefferle pfefferle force-pushed the fix/294-remove-extra-e-content-div branch from 1703ac7 to 22797df Compare January 11, 2026 21:39
@pfefferle pfefferle self-assigned this Jan 11, 2026
@pfefferle pfefferle requested review from Copilot and dshanske January 11, 2026 21:39
@pfefferle pfefferle force-pushed the fix/294-remove-extra-e-content-div branch from 22797df to 5e6cb6c Compare January 11, 2026 21:41
@dshanske
Copy link
Member

How does this integrate with #297 where I tried to switch to dynamic rendering?

@pfefferle pfefferle force-pushed the fix/294-remove-extra-e-content-div branch from 5e6cb6c to 588d98f Compare January 11, 2026 21:44
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 pull request adds detection for microformats2 theme support to avoid generating duplicate e-content wrapper divs when themes already provide microformats2 markup. The implementation checks for explicit theme support, falls back to cached detection results, and can detect support by analyzing rendered page output.

Changes:

  • Adds theme_supports_microformats2() method that checks explicit theme support, cached results, or triggers runtime detection
  • Implements detect_microformats2_support() to scan rendered HTML for e-content class usage
  • Conditionally wraps content in e-content div only when theme doesn't support microformats2
  • Clears detection cache on theme switch

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 10 comments.

File Description
includes/class-micropub.php Adds microformats2 detection logic with caching, theme switch handler, and option constant
includes/class-render.php Updates content wrapper logic to conditionally include e-content div based on theme support
tests/test_render.php Adds three test cases covering explicit support, no support, and cached support scenarios
tests/test_functions.php Adds comprehensive test suite for detection logic including edge cases for code blocks and plain text

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pfefferle
Copy link
Member Author

@dshanske so this is already fixed but simply not released?

@dshanske
Copy link
Member

@pfefferle Not exactly, the new rendering code only worked for new posts, not for old ones..as in pre 2.4.0

@pfefferle
Copy link
Member Author

But it seems to be still an issue!?

/cc @snarfed

Add detection for microformats2 theme support that:
- Checks explicit theme support via current_theme_supports('microformats2')
- Falls back to detecting e-content class in rendered page output
- Caches the result in an option for performance (not autoloaded)
- Clears cache on theme switch
- Ignores code/pre blocks to avoid false positives

Only wraps content in e-content div when theme doesn't provide it.

Fixes #294
@pfefferle pfefferle force-pushed the fix/294-remove-extra-e-content-div branch from 588d98f to c4386a8 Compare January 11, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Plugin always adds e-content div to post content. Should it?

2 participants