Microformats 2 Rendering
@snarfed, @pfefferle and I were discussing the problem of various plugin interoperability in https://github.com/pfefferle/SemPress/issues/51
It occurred to me, if we are going to set this up, this repo is probably the better place to keep the discussion and possibly any functionality or such we want to support it.
Right now, Micropub takes over rendering if add_theme_support( 'microformats2' ) is not set. This plugin loads microformats2 compatibility functions(add h-entry, etc) if the same flag is set.
So, the add theme support flag should, in future, be used solely to discuss a theme's support for marking up standard WordPress elements, as opposed to properties stored solely in meta. We can be more granular in future if needed.
Rendering microformats2 properties from Post Meta probably requires a global variable(the same way that add_theme_support, register_post_type, etc are in reality global variables).
The issue that was being discussed was priority on any given feature. WordPress registration does this with the last one to register, as registration is done by hook. Same can apply here.
While I still think we can combine our rendering efforts, for now, I want to try to build this as a class here in Microformats 2, which could then be included in the other plugins. Thoughts?
thanks for summing this up!
hey, great! happy to talk wherever. and expanding to also include wordpress element markup sounds fine too.
i do still think we need to support priority, though. the micropub plugin, for example, needs to be able to render all mf2 properties that it handles, but it also should defer to any other feature-specific plugin that handles an individual mf2 property, since those plugins will generally be better.
i think we also need this coordination to work regardless of which specific plugins are installed. SemPress users, for example, often won't have this uf2 plugin, but should still be able to use micropub and other feature-specific plugins together happily.
given all that, the global variable approach seems to have two flaws:
- no priority support.
- no obvious single place to actually create the global variable(s). we could make all plugins create it (them) if necessary, but that seems error prone at best.
i'm not excited about the feature approach described in https://github.com/pfefferle/SemPress/issues/51#issuecomment-303311143 either. it requires all plugins that use it to check and use the filter return value correctly. still, it may be the least bad option we have so far...?
@snarfed That's why I suggested this repo as the 'canonical' place for any microformats2 in wordpress discussion. The lack of single place to discuss things.
This is really where plugin dependencies would help a great deal, but saying that doesn't help with this. But why can't SemPress users, Micropub users, and Post Kinds users be encouraged to install this plugin, especially if it doesn't activate the extra features if the theme says it already supports them?
I'm worried about not only creating confusion for us, but for new people(who already find it confusing). I don't think there is an easy answer, but what we have now isn't working exactly.
My idea:
I agree with @snarfed, every plugin should handle it's properties, the best it can.
The main other authority for the rendering is the theme, so I would start defining the add_theme_support( 'microformats2-rendering', array( 'mf2_photo', 'mf2_name' ) ); discussed here: https://github.com/pfefferle/SemPress/issues/51#issuecomment-303132817
If a plugin like indie-post-kinds want to overwrite micropub functionality, it should be done individually be remove actions or filters or with changes done by filters and actions.
I might not want to. @snarfed's rendering could be nicer than mine.
Why 'mf2_photo' as opposed to 'photo' ?
If the theme is the only authority it is even better.
The syntax of the theme support was only a first shot, I would highly recommend to discuss and change the feature flags!
The theme being the top authority makes sense...as long as the theme knows how to do something. If it doesn't, it needs to fall back on something.
sure, and that can be handled with more granular theme support flags.
So, 'microformats2' as a theme_supports flag will have arguments for WordPress properties..For example, author, content, etc.
'microformats2_rendering' would have arguments for properties that don't directly map to WordPress properties? Or do we want to combine them into one single microformats2 flag with the differences set in properties?
We still, either way, end up with collision.
exactly. i would use microformats2 (because of its adoption) for both
Then prefixing the mf2 properties with mf2_ makes sense, I suppose.
ah, now I know why I proposed a new rendering flag... Let me think about that... perhaps we should create a section on the wiki, where we collect the different ideas and where we can define the flags. I hope @snarfed is ok with this too.
Why not have all possible plugins register support, and have the user specify their priority for applying them if both have support for that property? For example, both Post Kinds and Micropub register they support rendering checkins. The user specifies in configuration that they'd prefer rendering in the event of both?
-1 to putting the onus on the user to specify priority. They aren't going to want that responsibility, they just want an integrated experience. Just sounds like opening up a bad UX with a ton of options and configurations.
I'm suggesting 1 option...who has priority. Not on a per property basis.
We can call it, "Specify Default Rendering Plugin." or such. Rather than saying that each plugin sets a priority on a per property basis. It seems like that is too many low level settings.
https://indieweb.org/WordPress/Data - Is where we've put this stuff on the wiki before. I'll go garden a bit.
Playing devil's advocate, a user is going to ask why would I need to specify default rendering? We already hear routinely "why not just one plugin". Requiring a user to specify even once what plugin gets priority is just going to exacerbate that.
Then we're right back at, why not spin rendering out of all plugins into its own?
I don't begin to have an answer to the how, and as I stated in chat, it's a hard problem you are trying to solve with multiple plugins. But one worth tackling. I'm just trying to provide some perspective from user stand point based on feed back I've seen and read.
But that is what I meant... the main renderer is the plugin itself but it can be disabled by the theme... if a second plugin thinks it's a better renderer it should handle it individually using hooks and actions...
do we have cases where a plugin uses data from an other plugin?
Yes, Post Kinds uses any data stored in mf2_ whether it stored it or not. Micropub also stores there. But as I documented, there are some issues.
I mentioned that in a comment above and you corrected me:
If a plugin like indie-post-kinds want to overwrite micropub functionality, it should be done individually by remove actions or filters or with changes done by filters and actions.
Perhaps a misunderstanding...but as I said, this can be done individually, like we do with webmentions and semantic linkbacks https://github.com/pfefferle/wordpress-semantic-linkbacks/blob/master/semantic-linkbacks.php#L52 or am I wrong?
It can. I just want to brainstorm all options before we adopt. It is harder to change later.
ok, got you, but we shouldn't over engineer the feature on the other hand! plugins working really good together at the moment and we only have a problem to identify if a theme supports render features or not!
... and we should fix that in time... at least before we start investing time in new wp-uf2 features, because we currently only know if a plugin supports microformats2 or not and this might cause issues like with sempress and micropub.
hey @kraftbj, you've been interested in indieweb recently, any chance you could give us some expert guidance here? no good deed goes unpunished, and all that. :P
we're still discussing the exact goals, but broadly, we're trying to figure out how multiple plugins/themes should coordinate and decide, at post render time, which one renders a specific piece of mf2. here are some constraints:
- for each piece of mf2 in the post, we want at most one thing to render it, either the theme or a single plugin. (if nothing is available to render it, that's fine.)
- we don't want to assume that any single specific plugin or theme is installed. (ie, we don't have a single obvious master coordinator.)
- we want plugins/themes to declare their own priority, and have the highest priority win and render.
options we've considered:
- filters. straw man design: if the value passed to the filter is null, render and return the rendered HTML. otherwise return it unchanged. nice, built in, no need for a master coordinator, supports priority...but requires all plugin/theme authors to implement that logic (correctly).
- registration into global config var, a la post types. similarly requires every contributing plugin to implement the registration code and global var.
- ...?
i'm sure other people have figured this out before, but i haven't had much luck googling for it (e.g. wordpress multiple plugins coordination :/). any ideas?
thanks in advance!
That's a dilly of a pickle. I would venture that this is something that's ripe for a filter--it already has the built-in priority system.
With both issues, it requires buy-in from other plugin/theme authors to use a common format/scheme. I think the filter is more akin to WordPress thinking. Let me read through this issue, the core ticket that was attempted for mf2 support, etc with more thought some.
another thought: is there any way to get the full list of callbacks registered for a given filter, along with their priority? if so, we could use that and just call the first one. kind of goes against the philosophy, i know, but still.
i didn't find anything like that in the docs, so i'm guessing not, but figured it was worth checking.