Avoid duplicate e-content wrapper when theme supports microformats2#313
Avoid duplicate e-content wrapper when theme supports microformats2#313
Conversation
1703ac7 to
22797df
Compare
22797df to
5e6cb6c
Compare
|
How does this integrate with #297 where I tried to switch to dynamic rendering? |
5e6cb6c to
588d98f
Compare
There was a problem hiding this comment.
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 fore-contentclass usage - Conditionally wraps content in
e-contentdiv 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.
|
@dshanske so this is already fixed but simply not released? |
|
@pfefferle Not exactly, the new rendering code only worked for new posts, not for old ones..as in pre 2.4.0 |
|
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
588d98f to
c4386a8
Compare
Summary
current_theme_supports('microformats2')e-contentclass in rendered page outputFixes #294