@@ -192,27 +192,27 @@ discard block |
||
192 | 192 | ); |
193 | 193 | |
194 | 194 | public function __construct() { |
195 | - add_filter( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10, 2 ); |
|
195 | + add_filter('wl_after_get_jsonld', array($this, 'wl_after_get_jsonld'), 10, 2); |
|
196 | 196 | } |
197 | 197 | |
198 | - public function wl_after_get_jsonld( $jsonld, $post_id ) { |
|
198 | + public function wl_after_get_jsonld($jsonld, $post_id) { |
|
199 | 199 | |
200 | - if ( count( $jsonld ) === 0 || ! is_array( $jsonld[0] ) || ! array_key_exists( '@type', $jsonld[0] ) || array_key_exists( 'mentions', $jsonld[0] ) ) { |
|
200 | + if (count($jsonld) === 0 || ! is_array($jsonld[0]) || ! array_key_exists('@type', $jsonld[0]) || array_key_exists('mentions', $jsonld[0])) { |
|
201 | 201 | return $jsonld; |
202 | 202 | } |
203 | 203 | |
204 | 204 | $type = $jsonld[0]['@type']; |
205 | 205 | |
206 | - if ( ! $this->entity_is_descendant_of_creative_work( $type ) && ! $this->entity_is_creative_work( $type ) ) { |
|
206 | + if ( ! $this->entity_is_descendant_of_creative_work($type) && ! $this->entity_is_creative_work($type)) { |
|
207 | 207 | return $jsonld; |
208 | 208 | } |
209 | 209 | |
210 | 210 | $entity_references = Object_Relation_Service::get_instance() |
211 | - ->get_references( $post_id, Object_Type_Enum::POST ); |
|
211 | + ->get_references($post_id, Object_Type_Enum::POST); |
|
212 | 212 | |
213 | 213 | $about_id = array(); |
214 | - if ( array_key_exists( 'about', $jsonld[0] ) && is_array( $jsonld[0]['about'] ) ) { |
|
215 | - foreach ( $jsonld[0]['about'] as $about ) { |
|
214 | + if (array_key_exists('about', $jsonld[0]) && is_array($jsonld[0]['about'])) { |
|
215 | + foreach ($jsonld[0]['about'] as $about) { |
|
216 | 216 | $about_id[] = $about['@id']; |
217 | 217 | } |
218 | 218 | } |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | $jsonld[0]['mentions'] = array_values( |
221 | 221 | array_filter( |
222 | 222 | array_map( |
223 | - function ( $item ) use ( $about_id ) { |
|
224 | - $id = \Wordlift_Entity_Service::get_instance()->get_uri( $item->get_id() ); |
|
225 | - if ( ! $id || in_array( $id, $about_id, true ) ) { |
|
223 | + function($item) use ($about_id) { |
|
224 | + $id = \Wordlift_Entity_Service::get_instance()->get_uri($item->get_id()); |
|
225 | + if ( ! $id || in_array($id, $about_id, true)) { |
|
226 | 226 | return false; |
227 | 227 | } |
228 | 228 | |
229 | - return array( '@id' => $id ); |
|
229 | + return array('@id' => $id); |
|
230 | 230 | |
231 | 231 | }, |
232 | 232 | $entity_references |
@@ -235,23 +235,23 @@ discard block |
||
235 | 235 | ); |
236 | 236 | |
237 | 237 | // Remove mentions if the count is zero. |
238 | - if ( count( $jsonld[0]['mentions'] ) === 0 ) { |
|
239 | - unset( $jsonld[0]['mentions'] ); |
|
238 | + if (count($jsonld[0]['mentions']) === 0) { |
|
239 | + unset($jsonld[0]['mentions']); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | return $jsonld; |
243 | 243 | } |
244 | 244 | |
245 | - private function entity_is_descendant_of_creative_work( $type ) { |
|
246 | - if ( is_string( $type ) ) { |
|
247 | - $type = array( $type ); |
|
245 | + private function entity_is_descendant_of_creative_work($type) { |
|
246 | + if (is_string($type)) { |
|
247 | + $type = array($type); |
|
248 | 248 | } |
249 | 249 | |
250 | - return count( array_intersect( $type, $this::$schema_descendants ) ) > 0; |
|
250 | + return count(array_intersect($type, $this::$schema_descendants)) > 0; |
|
251 | 251 | } |
252 | 252 | |
253 | - private function entity_is_creative_work( $type ) { |
|
254 | - return ( 'CreativeWork' === $type ) || ( is_array( $type ) && in_array( 'CreativeWork', $type, true ) ); |
|
253 | + private function entity_is_creative_work($type) { |
|
254 | + return ('CreativeWork' === $type) || (is_array($type) && in_array('CreativeWork', $type, true)); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | } |