Last active
January 3, 2016 06:39
-
-
Save mgburns/8423646 to your computer and use it in GitHub Desktop.
Adds support for post excerpt and WordPress SEO meta fields to alternate versions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: BU Versions - WordPress SEO Support | |
Description: Adds support for post excerpt and WordPress SEO meta fields to alternate versions | |
*/ | |
/** | |
* Required as the WordPress SEO plugin doesn't use post type support, and BU Versions requires it. | |
*/ | |
function wpseo_feature_support() { | |
add_post_type_support( 'page', 'wpseo' ); | |
add_post_type_support( 'post', 'wpseo' ); | |
} | |
/** | |
* Register WordPress SEO meta keys for alternate versions. | |
*/ | |
function wpseo_alt_version_features( $features ) { | |
$features['wpseo'] = array( | |
'_yoast_wpseo_snippetpreview', | |
'_yoast_wpseo_focuskw', | |
'_yoast_wpseo_title', | |
'_yoast_wpseo_metadesc', | |
'_yoast_wpseo_metakeywords' | |
); | |
return $features; | |
} | |
/** | |
* Add "excerpts" to the alternate version post type registration arguments. | |
*/ | |
function wpseo_alt_version_args( $args, $post_type ) { | |
if ( post_type_supports( $post_type->name, 'excerpt' ) ) { | |
$args['supports'] = array_unique( array_merge( $args['supports'], array( 'excerpt' ) ) ); | |
} | |
return $args; | |
} | |
add_action( 'init', 'wpseo_feature_support' ); | |
add_filter( 'bu_alt_versions_feature_support', 'wpseo_alt_version_features' ); | |
add_filter( 'bu_alt_version_args', 'wpseo_alt_version_args', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment