indieweb / wordpress-micropub

A Micropub Endpoint plugin for WordPress
https://wordpress.org/plugins/micropub
51 stars 12 forks source link

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

Open snarfed opened 10 months ago

snarfed commented 10 months ago

Hi @dshanske et al! I'm seeing an odd behavior with HTML content: two <div class="e-content">s, one inside the other. I assume that's not expected? For example, this JSON request:

{
  "type": ["h-entry"],
  "properties": {
    "name": ["foo"],
    "category": ["reply"],
    "content": [{"html": "well <em>ok</em> is <a href=\"http://yahoo.com\">that so</a> <a href=\"http://bar.org\">http://bar.org</a>"}],
  }
}

results in this HTML:

<div class="entry-content clear">
<div class='e-content'><a class="u-in-reply-to" href="https://micropub.spec.indieweb.org/"></a></p>
<div class="e-content">
well <em>ok</em> is <a href="http://yahoo.com">that so</a> <a href="http://bar.org">http://bar.org</a>
</div>
</div>
<div class="syndication-links"></div>
</div><!-- .entry-content -->

I'm guessing because of this code?

https://github.com/indieweb/wordpress-micropub/blob/9bccb0bdc501a1dca9441b713811248e82f43191/includes/class-micropub-render.php#L96-L100

e-content is probably up to the theme, right? Should the plugin be injecting this extra e-content div?

janboddez commented 9 months ago

Just FYI: What I do in my theme (or rather, plugin, but a theme could do the same) is I check if there's a .e-content in the post content already and only add the class if there isn't. (For some post types, it makes sense to have a, e.g., reply context outside of .e-context, and since---in my case---both are part of my post content I can't just add an overall e-content class. Hence the check.)

But I also completely override the Micropub post content in a filter callback, so ... That could work too, at least temporarily. Just remove the div in a filter.

dshanske commented 9 months ago

There's a setting that disables it entirely which my Post Kinds plugin turns on... I have some ideas I might pursue though.

snarfed commented 6 months ago

FWIW, I debugged this a bit more just now, and it's not specific to HTML content or JSON input, evidently the plugin always does this when it creates posts. Eg a form-encoded micropub request with content=fooey results in this content HTML:

<div class="e-content">
fooey
</div>
snarfed commented 6 months ago

(I don't actually know what should happen here! Just adding info for now.)