Skip to content

Commit 69b0f41

Browse files
phatskgregrickaby
authored andcommitted
ChazUK#8 - Allows filtering yoast_meta (#1)
1 parent bd801c2 commit 69b0f41

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

plugin.php

+21-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Description: Adds Yoast fields to page and post metadata to WP REST API responses
88
* Author: Niels Garve, Pablo Postigo, Tedy Warsitha, Charlie Francis
99
* Author URI: https://github.com/niels-garve
10-
* Version: 1.4.1
10+
* Version: 1.4.2
1111
* Plugin URI: https://github.com/niels-garve/yoast-to-rest-api
1212
*/
1313
class Yoast_To_REST_API {
@@ -132,6 +132,17 @@ function wp_api_encode_yoast( $p, $field_name, $request ) {
132132
'yoast_wpseo_canonical' => $wpseo_frontend->canonical( false ),
133133
);
134134

135+
/**
136+
* Filter the returned yoast meta.
137+
*
138+
* @since 1.4.2
139+
* @param array $yoast_meta Array of metadata to return from Yoast.
140+
* @param \WP_Post $p The current post object.
141+
* @param \WP_REST_Request $request The REST request.
142+
* @return array $yoast_meta Filtered meta array.
143+
*/
144+
$yoast_meta = apply_filters( 'wpseo_to_api_yoast_meta', $yoast_meta, $p, $request );
145+
135146
wp_reset_query();
136147

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

160+
/**
161+
* Filter the returned yoast meta for a taxonomy.
162+
*
163+
* @since 1.4.2
164+
* @param array $yoast_meta Array of metadata to return from Yoast.
165+
* @return array $yoast_meta Filtered meta array.
166+
*/
167+
$yoast_meta = apply_filters( 'wpseo_to_api_yoast_taxonomy_meta', $yoast_meta );
168+
149169
return (array) $yoast_meta;
150170
}
151171

0 commit comments

Comments
 (0)