pfefferle / wordpress-opengraph

Open Graph plugin for WordPress
http://wordpress.org/plugins/opengraph/
Apache License 2.0
22 stars 13 forks source link

Added framework to support twitter cards #19

Closed elroyjetson closed 10 years ago

elroyjetson commented 10 years ago

Established the framework to support Twitter cards. I only added the twitter:card property which will be set to summary if the opengraph_default_type == article. This is the major tag that needs to be added to support Twitter cards, as the other properties fail over to the open graph equivalents or are optional.

Relevant Twitter documentation: https://dev.twitter.com/docs/cards https://dev.twitter.com/docs/cards/markup-reference https://dev.twitter.com/docs/cards/validation/validator

willnorris commented 10 years ago

So I've gone back and forth on including Twitter's tags, mainly because it is technically outside the scope of the Open Graph Protocol. For about six months now, I've used this code to add Twitter metadata on my own site using the hooks provided in the opengraph plugin. This is also why 2426c14bdbb9a138c71b018c7a6d6abe62b899a4 added support for populating the meta name in addition to property.

Also, the Twitter tags are useless unless you get your site whitelisted by Twitter, so for many people it wouldn't actually do any good. Maybe hide it behind a constant then that you have to enable?

@pfefferle, what do you think?

elroyjetson commented 10 years ago

I get that. I am sure it is probably not something many people would want and to be truly effective you would need to come up with a way for them to add their twitter username.

Whitelisting is instant, but it isn't the easiest thing for people to figure out. So you really have to want it. Perhaps just update the documentation with a note about adding it yourself for those that really want it and leaving it at that would suffice?

pfefferle commented 10 years ago

I think it is a bit "hacky" because Twitter Cards are not really part of the OGP... But what do you think about a separate plugin based on the hooks of the OGP one? I discovered that @willnorris is using something like that for his blog, perhaps we can combine his code with my little snippet https://github.com/pfefferle/wordpress-twitter-creator to release a Twitter Card "extension"...

pfefferle commented 10 years ago

Oh sorry, haven't seen the gist that @willnorris already shared :grin:

pfefferle commented 10 years ago

I like @elroyjetson idea to mention the possibility of adding twitter cards in the FAQ of the OGP plugin and to perhaps link to @willnorris gist.

pfefferle commented 10 years ago

So, after sleeping on it, I am not sure if it is a good idea to add the twitter-card stuff the same way as the OGP ones, because it might cause problems with RDFa parsers (because of the missing prefix for example). I like the Idea of using the meta-content besides the property attribute for OGP though (because a lot of people are accidentaly using the content instead of the property) and I like the Idea to re-use the OGP properties (title, description, images, ...) to generate the twitter-cards, but is there a nicer way to render the output only using meta-content?