7
7
* Description: Adds Yoast fields to page and post metadata to WP REST API responses
8
8
* Author: Niels Garve, Pablo Postigo, Tedy Warsitha, Charlie Francis
9
9
* Author URI: https://github.com/niels-garve
10
- * Version: 1.4.1
10
+ * Version: 1.4.2
11
11
* Plugin URI: https://github.com/niels-garve/yoast-to-rest-api
12
12
*/
13
13
class Yoast_To_REST_API {
@@ -132,6 +132,17 @@ function wp_api_encode_yoast( $p, $field_name, $request ) {
132
132
'yoast_wpseo_canonical ' => $ wpseo_frontend ->canonical ( false ),
133
133
);
134
134
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
+
135
146
wp_reset_query ();
136
147
137
148
return (array ) $ yoast_meta ;
@@ -146,6 +157,15 @@ private function wp_api_encode_taxonomy() {
146
157
'yoast_wpseo_metadesc ' => $ wpseo_frontend ->metadesc ( false ),
147
158
);
148
159
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
+
149
169
return (array ) $ yoast_meta ;
150
170
}
151
171
0 commit comments