Yoast / wordpress-seo

Yoast SEO for WordPress
https://yoast.com/wordpress/plugins/seo/
Other
1.75k stars 885 forks source link

Tap into the official Twitter plugin's Twitter Card and username filters #2248

Closed niallkennedy closed 7 years ago

niallkennedy commented 9 years ago

Sites with both Yoast SEO and the official Twitter plugin for WordPress installed may output multiple sets of Twitter Cards markup, competing for a slot in the final indexed content by Twitter's Card indexer. The Twitter plugin may be better at preparing and optimizing content for Twitter. Yoast may be better at collecting custom titles and descriptions. Creating awareness of other plugins touching the same outputs helps build the best final result for publishers.

Functionality is expected to be similar to the WPSEO_OpenGraph::facebook_filter method handler, but with per-field filters instead of a general filtered array.

Detect if the plugin is activated and the cards feature is present by testing for the array('\Twitter\WordPress\Head\CardsMetaElements', 'outputMetaElements') callback attached to wp_head after wp_head priority 1. Link to hook in code.

Override the card type selected by the Twitter plugin for WordPress by acting on the twitter_card_type filter if you believe Yoast SEO has done a better job selecting the card type for the WordPress view. The Twitter plugin for WordPress does not support player or app card types. Returning an unsupported card type will result in no Twitter Cards markup.

Change a Twitter Card title or description by acting on the twitter_card_title or twitter_card_description filter respectively. The value is only passed to the filter if not explicitly defined in a post meta box or other settings field. The query type and object id parameters passed with the filter provide information similar to what you'd expect in WP_Query.

An associative array of properties are passed through the twitter_card filter before they are output as meta elements. An image key will exist on the passed array with either an absolute URI string value or an associative array containing src, width, height keys. An existing image may have been chosen based on minimum dimensions requirements of the card and the maximum file size supported by Twitter.

A site username passes through the twitter_site_username filter. This value may be used to set the twitter:site meta element and the via attribution of a Tweet intent. The twitter_via_username filter should be used if you want to affect only via attribution.

The author username passes through the twitter_username filter after it is pulled from the twitter user meta or attribute value. This value may be used to set the twitter:creator meta element, initialize a follow intent when initialized without a username, and set related Twitter accounts on a Tweet intent.

Rarst commented 9 years ago

I don't think we are actively considering integrations with other extensions at the moment.

@omarreiss do we (potentially) want this?

moorscode commented 7 years ago

As @rarst said we are not going to build in specific plugin integrations. We are always open for specific filter requests if those are providing solutions to specific problems.