Skip to content

Commit

Permalink
Merge pull request #9 from WebDevStudios/ticket/8-filterable-meta
Browse files Browse the repository at this point in the history
#8 - Allows filtering yoast_meta
  • Loading branch information
ChazUK authored Mar 7, 2019
2 parents bd801c2 + af60320 commit ab5e45e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Description: Adds Yoast fields to page and post metadata to WP REST API responses
* Author: Niels Garve, Pablo Postigo, Tedy Warsitha, Charlie Francis
* Author URI: https://github.com/niels-garve
* Version: 1.4.1
* Version: 1.4.2
* Plugin URI: https://github.com/niels-garve/yoast-to-rest-api
*/
class Yoast_To_REST_API {
Expand Down Expand Up @@ -132,6 +132,17 @@ function wp_api_encode_yoast( $p, $field_name, $request ) {
'yoast_wpseo_canonical' => $wpseo_frontend->canonical( false ),
);

/**
* Filter the returned yoast meta.
*
* @since 1.4.2
* @param array $yoast_meta Array of metadata to return from Yoast.
* @param \WP_Post $p The current post object.
* @param \WP_REST_Request $request The REST request.
* @return array $yoast_meta Filtered meta array.
*/
$yoast_meta = apply_filters( 'wpseo_to_api_yoast_meta', $yoast_meta, $p, $request );

wp_reset_query();

return (array) $yoast_meta;
Expand All @@ -146,6 +157,15 @@ private function wp_api_encode_taxonomy() {
'yoast_wpseo_metadesc' => $wpseo_frontend->metadesc( false ),
);

/**
* Filter the returned yoast meta for a taxonomy.
*
* @since 1.4.2
* @param array $yoast_meta Array of metadata to return from Yoast.
* @return array $yoast_meta Filtered meta array.
*/
$yoast_meta = apply_filters( 'wpseo_to_api_yoast_taxonomy_meta', $yoast_meta );

return (array) $yoast_meta;
}

Expand Down

0 comments on commit ab5e45e

Please sign in to comment.