@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @since 3.10.0 |
75 | 75 | */ |
76 | - public function __construct( $entity_type_service, $user_service, $attachment_service, $property_getter ) { |
|
76 | + public function __construct($entity_type_service, $user_service, $attachment_service, $property_getter) { |
|
77 | 77 | $this->entity_type_service = $entity_type_service; |
78 | 78 | $this->user_service = $user_service; |
79 | 79 | $this->attachment_service = $attachment_service; |
@@ -92,19 +92,19 @@ discard block |
||
92 | 92 | * @since 3.10.0 |
93 | 93 | */ |
94 | 94 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
95 | - public function convert( $post_id, &$references = array(), &$references_infos = array(), $relations = null ) { |
|
95 | + public function convert($post_id, &$references = array(), &$references_infos = array(), $relations = null) { |
|
96 | 96 | |
97 | 97 | // Get the post instance. |
98 | - $post = get_post( $post_id ); |
|
99 | - if ( null === $post ) { |
|
98 | + $post = get_post($post_id); |
|
99 | + if (null === $post) { |
|
100 | 100 | // Post not found. |
101 | 101 | return null; |
102 | 102 | } |
103 | 103 | |
104 | 104 | // Get the post URI @id. |
105 | - $id = Wordlift_Entity_Service::get_instance()->get_uri( $post->ID ); |
|
106 | - if ( $id === null ) { |
|
107 | - $id = 'get_uri returned null, dataset is ' . wl_configuration_get_redlink_dataset_uri(); |
|
105 | + $id = Wordlift_Entity_Service::get_instance()->get_uri($post->ID); |
|
106 | + if ($id === null) { |
|
107 | + $id = 'get_uri returned null, dataset is '.wl_configuration_get_redlink_dataset_uri(); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /* |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | */ |
117 | 117 | // Get the entity @type. We consider `post` BlogPostings. |
118 | 118 | // $type = $this->entity_type_service->get( $post_id ); |
119 | - $types = $this->entity_type_service->get_names( $post_id ); |
|
120 | - $type = self::make_one( $types ); |
|
119 | + $types = $this->entity_type_service->get_names($post_id); |
|
120 | + $type = self::make_one($types); |
|
121 | 121 | |
122 | 122 | // Prepare the response. |
123 | 123 | $jsonld = array( |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | '@type' => $type, |
127 | 127 | ); |
128 | 128 | |
129 | - if ( post_type_supports( $post->post_type, 'excerpt' ) ) { |
|
130 | - $jsonld['description'] = Wordlift_Post_Excerpt_Helper::get_text_excerpt( $post ); |
|
129 | + if (post_type_supports($post->post_type, 'excerpt')) { |
|
130 | + $jsonld['description'] = Wordlift_Post_Excerpt_Helper::get_text_excerpt($post); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // Set the `mainEntityOfPage` property if the post has some contents. |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @since 3.20.0 |
141 | 141 | */ |
142 | - $post_content = apply_filters( 'wl_post_content', $post->post_content, $post ); |
|
143 | - if ( ! empty( $post_content ) || in_array( 'Product', (array) $type, true ) ) { |
|
142 | + $post_content = apply_filters('wl_post_content', $post->post_content, $post); |
|
143 | + if ( ! empty($post_content) || in_array('Product', (array) $type, true)) { |
|
144 | 144 | // We're setting the `mainEntityOfPage` to signal which one is the |
145 | 145 | // main entity for the specified URL. It might be however that the |
146 | 146 | // post/page is actually about another specific entity. How WL deals |
@@ -151,29 +151,29 @@ discard block |
||
151 | 151 | // No need to specify `'@type' => 'WebPage'. |
152 | 152 | // |
153 | 153 | // See https://github.com/insideout10/wordlift-plugin/issues/451. |
154 | - $jsonld['mainEntityOfPage'] = get_the_permalink( $post->ID ); |
|
154 | + $jsonld['mainEntityOfPage'] = get_the_permalink($post->ID); |
|
155 | 155 | |
156 | 156 | /** |
157 | 157 | * @see https://github.com/insideout10/wordlift-plugin/issues/1207 |
158 | 158 | * |
159 | 159 | * @since 3.27.7 |
160 | 160 | */ |
161 | - if ( in_array( |
|
161 | + if (in_array( |
|
162 | 162 | $type, |
163 | 163 | array( |
164 | 164 | 'Occupation', |
165 | 165 | 'OccupationAggregationByEmployer', |
166 | 166 | ), |
167 | 167 | true |
168 | - ) ) { |
|
168 | + )) { |
|
169 | 169 | $jsonld['mainEntityOfPage'] = array( |
170 | 170 | '@type' => 'WebPage', |
171 | - 'lastReviewed' => get_post_time( 'Y-m-d\TH:i:sP', true, $post, false ), |
|
171 | + 'lastReviewed' => get_post_time('Y-m-d\TH:i:sP', true, $post, false), |
|
172 | 172 | ); |
173 | 173 | } |
174 | 174 | }; |
175 | 175 | |
176 | - $this->set_images( $this->attachment_service, $post, $jsonld ); |
|
176 | + $this->set_images($this->attachment_service, $post, $jsonld); |
|
177 | 177 | |
178 | 178 | // Naveen: Get the entities referenced by this post and set it to the `references` |
179 | 179 | // array so that the caller can do further processing, such as printing out |
@@ -187,33 +187,33 @@ discard block |
||
187 | 187 | // $references_without_locations = $object_relation_service->get_references( $post_id, Object_Type_Enum::POST ); |
188 | 188 | |
189 | 189 | $relation_service = Relation_Service::get_instance(); |
190 | - $content_id = Wordpress_Content_Id::create_post( $post_id ); |
|
191 | - $relation_service->add_relations( $content_id, $relations ); |
|
192 | - $this->add_relations_to_references( $relations, $references ); |
|
190 | + $content_id = Wordpress_Content_Id::create_post($post_id); |
|
191 | + $relation_service->add_relations($content_id, $relations); |
|
192 | + $this->add_relations_to_references($relations, $references); |
|
193 | 193 | |
194 | - $this->expand_references_with_location( $references ); |
|
194 | + $this->expand_references_with_location($references); |
|
195 | 195 | |
196 | 196 | return $jsonld; |
197 | 197 | } |
198 | 198 | |
199 | - public function expand_references_with_location( &$references ) { |
|
199 | + public function expand_references_with_location(&$references) { |
|
200 | 200 | $entity_type_service = Wordlift_Entity_Type_Service::get_instance(); |
201 | 201 | |
202 | 202 | // check if any of the references has the entity type set to Action, Event or organisation. |
203 | 203 | $references_with_location = array_filter( |
204 | 204 | $references, |
205 | - function ( $post_id ) use ( $entity_type_service ) { |
|
206 | - return ( $entity_type_service->has_entity_type( $post_id, 'http://schema.org/Action' ) |
|
207 | - || $entity_type_service->has_entity_type( $post_id, 'http://schema.org/Event' ) |
|
208 | - || $entity_type_service->has_entity_type( $post_id, 'http://schema.org/Organization' ) ); |
|
205 | + function($post_id) use ($entity_type_service) { |
|
206 | + return ($entity_type_service->has_entity_type($post_id, 'http://schema.org/Action') |
|
207 | + || $entity_type_service->has_entity_type($post_id, 'http://schema.org/Event') |
|
208 | + || $entity_type_service->has_entity_type($post_id, 'http://schema.org/Organization')); |
|
209 | 209 | } |
210 | 210 | ); |
211 | 211 | |
212 | 212 | // If set, then get all the location ids and push them to references. |
213 | - foreach ( $references_with_location as $post_id ) { |
|
214 | - $post_location_ids = get_post_meta( $post_id, Wordlift_Schema_Service::FIELD_LOCATION ); |
|
215 | - $post_location_ids = is_array( $post_location_ids ) ? $post_location_ids : array(); |
|
216 | - $references = array_merge( $post_location_ids, $references ); |
|
213 | + foreach ($references_with_location as $post_id) { |
|
214 | + $post_location_ids = get_post_meta($post_id, Wordlift_Schema_Service::FIELD_LOCATION); |
|
215 | + $post_location_ids = is_array($post_location_ids) ? $post_location_ids : array(); |
|
216 | + $references = array_merge($post_location_ids, $references); |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @param Relations $relations |
224 | 224 | */ |
225 | - private function add_relations_to_references( $relations, &$references ) { |
|
225 | + private function add_relations_to_references($relations, &$references) { |
|
226 | 226 | /** @var Relation $relation */ |
227 | - foreach ( $relations->toArray() as $relation ) { |
|
227 | + foreach ($relations->toArray() as $relation) { |
|
228 | 228 | $object = $relation->get_object(); |
229 | 229 | $object_id = $object->get_id(); |
230 | - if ( $object->get_type() === Object_Type_Enum::POST && ! in_array( $object_id, $references, true ) ) { |
|
230 | + if ($object->get_type() === Object_Type_Enum::POST && ! in_array($object_id, $references, true)) { |
|
231 | 231 | $references[] = $object_id; |
232 | 232 | } |
233 | 233 | } |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | * @return string The property value without the context. |
271 | 271 | * @since 3.10.0 |
272 | 272 | */ |
273 | - public function relative_to_context( $value ) { |
|
274 | - return ! is_array( $value ) && 0 === strpos( $value, self::CONTEXT . '/' ) ? substr( $value, strlen( self::CONTEXT ) + 1 ) : $value; |
|
273 | + public function relative_to_context($value) { |
|
274 | + return ! is_array($value) && 0 === strpos($value, self::CONTEXT.'/') ? substr($value, strlen(self::CONTEXT) + 1) : $value; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -286,14 +286,14 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @since 3.10.0 |
288 | 288 | */ |
289 | - public static function set_images( $attachment_service, $post, &$jsonld ) { |
|
289 | + public static function set_images($attachment_service, $post, &$jsonld) { |
|
290 | 290 | |
291 | 291 | // Prepare the attachment ids array. |
292 | 292 | $ids = array(); |
293 | 293 | |
294 | 294 | // Set the thumbnail id as first attachment id, if any. |
295 | - $thumbnail_id = get_post_thumbnail_id( $post->ID ); |
|
296 | - if ( '' !== $thumbnail_id && 0 !== $thumbnail_id ) { |
|
295 | + $thumbnail_id = get_post_thumbnail_id($post->ID); |
|
296 | + if ('' !== $thumbnail_id && 0 !== $thumbnail_id) { |
|
297 | 297 | $ids[] = $thumbnail_id; |
298 | 298 | } |
299 | 299 | |
@@ -304,34 +304,34 @@ discard block |
||
304 | 304 | // |
305 | 305 | // Get the embeds, removing existing ids. |
306 | 306 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
307 | - if ( apply_filters( 'wl_feature__enable__image-embeds', false ) ) { |
|
308 | - $embeds = array_diff( $attachment_service->get_image_embeds( $post->post_content ), $ids ); |
|
307 | + if (apply_filters('wl_feature__enable__image-embeds', false)) { |
|
308 | + $embeds = array_diff($attachment_service->get_image_embeds($post->post_content), $ids); |
|
309 | 309 | } else { |
310 | 310 | $embeds = array(); |
311 | 311 | } |
312 | 312 | |
313 | 313 | // Get the gallery, removing existing ids. |
314 | - $gallery = array_diff( $attachment_service->get_gallery( $post ), $ids, $embeds ); |
|
314 | + $gallery = array_diff($attachment_service->get_gallery($post), $ids, $embeds); |
|
315 | 315 | |
316 | 316 | // Map the attachment ids to images' data structured for schema.org use. |
317 | 317 | $images_with_sizes = array_filter( |
318 | 318 | array_reduce( |
319 | - array_merge( $ids, $embeds, $gallery ), |
|
320 | - function ( $carry, $item ) { |
|
319 | + array_merge($ids, $embeds, $gallery), |
|
320 | + function($carry, $item) { |
|
321 | 321 | /* |
322 | 322 | * @todo: we're not sure that we're getting attachment data here, we |
323 | 323 | * should filter `false`s. |
324 | 324 | */ |
325 | 325 | |
326 | 326 | $sources = array_merge( |
327 | - Wordlift_Image_Service::get_sources( $item ), |
|
328 | - array( wp_get_attachment_image_src( $item, 'full' ) ) |
|
327 | + Wordlift_Image_Service::get_sources($item), |
|
328 | + array(wp_get_attachment_image_src($item, 'full')) |
|
329 | 329 | ); |
330 | 330 | |
331 | 331 | $sources_with_image = array_filter( |
332 | 332 | $sources, |
333 | - function ( $source ) { |
|
334 | - return ! empty( $source[0] ); |
|
333 | + function($source) { |
|
334 | + return ! empty($source[0]); |
|
335 | 335 | } |
336 | 336 | ); |
337 | 337 | |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | // or from uploads dir, but the image id still exists as featured image |
346 | 346 | // or in [gallery] shortcode. |
347 | 347 | // if ( empty( $attachment[0] ) ) { |
348 | - if ( empty( $sources_with_image ) ) { |
|
348 | + if (empty($sources_with_image)) { |
|
349 | 349 | return $carry; |
350 | 350 | } |
351 | 351 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | |
364 | 364 | // Refactor data as per schema.org specifications. |
365 | 365 | $images = array_map( |
366 | - function ( $attachment ) { |
|
366 | + function($attachment) { |
|
367 | 367 | return Wordlift_Abstract_Post_To_Jsonld_Converter::set_image_size( |
368 | 368 | array( |
369 | 369 | '@type' => 'ImageObject', |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | ); |
377 | 377 | |
378 | 378 | // Add images if present. |
379 | - if ( 0 < count( $images ) ) { |
|
379 | + if (0 < count($images)) { |
|
380 | 380 | $jsonld['image'] = $images; |
381 | 381 | } |
382 | 382 | |
@@ -394,9 +394,9 @@ discard block |
||
394 | 394 | * @since 3.8.0 |
395 | 395 | * @access private |
396 | 396 | */ |
397 | - protected static function make_one( $value ) { |
|
397 | + protected static function make_one($value) { |
|
398 | 398 | |
399 | - return 1 === count( $value ) ? $value[0] : $value; |
|
399 | + return 1 === count($value) ? $value[0] : $value; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | /** |
@@ -409,17 +409,17 @@ discard block |
||
409 | 409 | * @return array The enriched `ImageObject` array. |
410 | 410 | * @since 3.14.0 |
411 | 411 | */ |
412 | - public static function set_image_size( $image, $attachment ) { |
|
412 | + public static function set_image_size($image, $attachment) { |
|
413 | 413 | |
414 | 414 | // If you specify a "width" or "height" value you should leave out |
415 | 415 | // 'px'. For example: "width":"4608px" should be "width":"4608". |
416 | 416 | // |
417 | 417 | // See https://github.com/insideout10/wordlift-plugin/issues/451. |
418 | - if ( isset( $attachment[1] ) && is_numeric( $attachment[1] ) && 0 < $attachment[1] ) { |
|
418 | + if (isset($attachment[1]) && is_numeric($attachment[1]) && 0 < $attachment[1]) { |
|
419 | 419 | $image['width'] = $attachment[1]; |
420 | 420 | } |
421 | 421 | |
422 | - if ( isset( $attachment[2] ) && is_numeric( $attachment[2] ) && 0 < $attachment[2] ) { |
|
422 | + if (isset($attachment[2]) && is_numeric($attachment[2]) && 0 < $attachment[2]) { |
|
423 | 423 | $image['height'] = $attachment[2]; |
424 | 424 | } |
425 | 425 | |
@@ -438,33 +438,33 @@ discard block |
||
438 | 438 | * @since 3.20.0 This code moved from the above function `convert`, used for entity types defined in |
439 | 439 | * the {@link Wordlift_Schema_Service} class. |
440 | 440 | */ |
441 | - protected function process_type_custom_fields( &$jsonld, $fields, $post, &$references, &$references_infos ) { |
|
441 | + protected function process_type_custom_fields(&$jsonld, $fields, $post, &$references, &$references_infos) { |
|
442 | 442 | |
443 | 443 | // Set a reference to use in closures. |
444 | 444 | $converter = $this; |
445 | 445 | |
446 | 446 | // Try each field on the entity. |
447 | - foreach ( $fields as $key => $value ) { |
|
447 | + foreach ($fields as $key => $value) { |
|
448 | 448 | |
449 | 449 | // Get the predicate. |
450 | - $name = $this->relative_to_context( $value['predicate'] ); |
|
450 | + $name = $this->relative_to_context($value['predicate']); |
|
451 | 451 | |
452 | 452 | // Get the value, the property service will get the right extractor |
453 | 453 | // for that property. |
454 | - $value = $this->property_getter->get( $post->ID, $key, Object_Type_Enum::POST ); |
|
454 | + $value = $this->property_getter->get($post->ID, $key, Object_Type_Enum::POST); |
|
455 | 455 | |
456 | - if ( empty( $value ) ) { |
|
456 | + if (empty($value)) { |
|
457 | 457 | continue; |
458 | 458 | } |
459 | 459 | |
460 | 460 | // Map the value to the property name. |
461 | 461 | // If we got an array with just one value, we return that one value. |
462 | 462 | // If we got a Wordlift_Property_Entity_Reference we get the URL. |
463 | - $jsonld[ $name ] = self::make_one( |
|
463 | + $jsonld[$name] = self::make_one( |
|
464 | 464 | array_map( |
465 | - function ( $item ) use ( $converter, &$references, &$references_infos ) { |
|
465 | + function($item) use ($converter, &$references, &$references_infos) { |
|
466 | 466 | |
467 | - if ( $item instanceof Wordlift_Property_Entity_Reference ) { |
|
467 | + if ($item instanceof Wordlift_Property_Entity_Reference) { |
|
468 | 468 | |
469 | 469 | $url = $item->get_url(); |
470 | 470 | |
@@ -473,12 +473,12 @@ discard block |
||
473 | 473 | $references[] = $item->get_id(); |
474 | 474 | |
475 | 475 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable |
476 | - $references_infos[] = array( 'reference' => $item ); |
|
476 | + $references_infos[] = array('reference' => $item); |
|
477 | 477 | |
478 | - return array( '@id' => $url ); |
|
478 | + return array('@id' => $url); |
|
479 | 479 | } |
480 | 480 | |
481 | - return $converter->relative_to_context( $item ); |
|
481 | + return $converter->relative_to_context($item); |
|
482 | 482 | }, |
483 | 483 | $value |
484 | 484 | ) |
@@ -32,6 +32,6 @@ |
||
32 | 32 | * @since 3.16.0 $references argument added. |
33 | 33 | * @since 3.10.0 |
34 | 34 | */ |
35 | - public function convert( $post_id, &$references = array(), &$references_infos = array(), $relations = null ); |
|
35 | + public function convert($post_id, &$references = array(), &$references_infos = array(), $relations = null); |
|
36 | 36 | |
37 | 37 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @since 3.8.0 |
57 | 57 | */ |
58 | - public function __construct( $entity_uri, $id, $required = false, $type = Object_Type_Enum::POST ) { |
|
58 | + public function __construct($entity_uri, $id, $required = false, $type = Object_Type_Enum::POST) { |
|
59 | 59 | |
60 | 60 | $this->url = $entity_uri; |
61 | 61 | $this->id = $id; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @since 3.27.1 |
122 | 122 | */ |
123 | - public function set_required( $value ) { |
|
123 | + public function set_required($value) { |
|
124 | 124 | |
125 | 125 | $this->required = $value; |
126 | 126 | |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | |
129 | 129 | public function to_reference() { |
130 | 130 | |
131 | - if ( Object_Type_Enum::POST === $this->type ) { |
|
132 | - return new Post_Reference( $this->id ); |
|
131 | + if (Object_Type_Enum::POST === $this->type) { |
|
132 | + return new Post_Reference($this->id); |
|
133 | 133 | } |
134 | - if ( Object_Type_Enum::TERM === $this->type ) { |
|
135 | - return new Term_Reference( $this->id ); |
|
134 | + if (Object_Type_Enum::TERM === $this->type) { |
|
135 | + return new Term_Reference($this->id); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | protected function __construct() { |
45 | 45 | global $wpdb; |
46 | 46 | |
47 | - self::$log = Wordlift_Log_Service::get_logger( get_class() ); |
|
47 | + self::$log = Wordlift_Log_Service::get_logger(get_class()); |
|
48 | 48 | |
49 | 49 | // The relations table. |
50 | 50 | $this->relation_table = "{$wpdb->prefix}wl_relation_instances"; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public static function get_instance() { |
71 | 71 | |
72 | - if ( ! isset( self::$instance ) ) { |
|
72 | + if ( ! isset(self::$instance)) { |
|
73 | 73 | self::$instance = new self(); |
74 | 74 | } |
75 | 75 | |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | * @return array|object|null Database query results |
97 | 97 | * @since 3.15.0 |
98 | 98 | */ |
99 | - public function get_article_subjects( $object_id, $fields = '*', $predicate = null, $status = null, $excludes = array(), $limit = null, $include = null, $order_by = null, $post_types = array(), $offset = null ) { |
|
99 | + public function get_article_subjects($object_id, $fields = '*', $predicate = null, $status = null, $excludes = array(), $limit = null, $include = null, $order_by = null, $post_types = array(), $offset = null) { |
|
100 | 100 | global $wpdb; |
101 | 101 | |
102 | 102 | // The output fields. |
103 | - $actual_fields = self::fields( $fields ); |
|
103 | + $actual_fields = self::fields($fields); |
|
104 | 104 | |
105 | - self::$log->trace( 'Getting article subjects for object ' . implode( ', ', (array) $object_id ) . '...' ); |
|
105 | + self::$log->trace('Getting article subjects for object '.implode(', ', (array) $object_id).'...'); |
|
106 | 106 | |
107 | - $objects = $this->article_id_to_entity_id( $object_id ); |
|
107 | + $objects = $this->article_id_to_entity_id($object_id); |
|
108 | 108 | |
109 | 109 | // If there are no related objects, return an empty array. |
110 | - if ( empty( $objects ) ) { |
|
111 | - self::$log->debug( 'No entities found for object ' . implode( ', ', (array) $object_id ) . '.' ); |
|
110 | + if (empty($objects)) { |
|
111 | + self::$log->debug('No entities found for object '.implode(', ', (array) $object_id).'.'); |
|
112 | 112 | |
113 | 113 | return array(); |
114 | 114 | } |
115 | 115 | |
116 | - self::$log->debug( count( $objects ) . ' entity id(s) found for object ' . implode( ', ', (array) $object_id ) . '.' ); |
|
116 | + self::$log->debug(count($objects).' entity id(s) found for object '.implode(', ', (array) $object_id).'.'); |
|
117 | 117 | |
118 | 118 | $sql = |
119 | 119 | " |
@@ -123,20 +123,20 @@ discard block |
||
123 | 123 | ON p.id = r.subject_id |
124 | 124 | " |
125 | 125 | // Add the status clause. |
126 | - . self::and_status( $status ) |
|
126 | + . self::and_status($status) |
|
127 | 127 | . self::inner_join_is_article() |
128 | - . self::where_object_id( $objects ) |
|
128 | + . self::where_object_id($objects) |
|
129 | 129 | // Since `object_id` can be an article ID we need to exclude it from |
130 | 130 | // the results. |
131 | - . self::and_article_not_in( array_merge( $excludes, (array) $object_id ) ) |
|
132 | - . self::and_article_in( $include ) |
|
133 | - . self::and_post_type_in( $post_types ) |
|
134 | - . self::and_predicate( $predicate ) |
|
135 | - . self::order_by( $order_by ) |
|
136 | - . self::limit( $limit ) |
|
137 | - . self::offset( $offset ); |
|
138 | - |
|
139 | - return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
131 | + . self::and_article_not_in(array_merge($excludes, (array) $object_id)) |
|
132 | + . self::and_article_in($include) |
|
133 | + . self::and_post_type_in($post_types) |
|
134 | + . self::and_predicate($predicate) |
|
135 | + . self::order_by($order_by) |
|
136 | + . self::limit($limit) |
|
137 | + . self::offset($offset); |
|
138 | + |
|
139 | + return '*' === $actual_fields ? $wpdb->get_results($sql) : $wpdb->get_col($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -148,16 +148,16 @@ discard block |
||
148 | 148 | * @return string The `post_type IN` clause. |
149 | 149 | * @since 3.15.3 |
150 | 150 | */ |
151 | - private static function and_post_type_in( $post_types = array() ) { |
|
151 | + private static function and_post_type_in($post_types = array()) { |
|
152 | 152 | |
153 | - if ( array() === $post_types ) { |
|
153 | + if (array() === $post_types) { |
|
154 | 154 | $post_types = Wordlift_Entity_Service::valid_entity_post_types(); |
155 | 155 | } |
156 | 156 | |
157 | 157 | return " AND p.post_type IN ( '" |
158 | 158 | . implode( |
159 | 159 | "','", |
160 | - array_map( 'esc_sql', $post_types ) |
|
160 | + array_map('esc_sql', $post_types) |
|
161 | 161 | ) |
162 | 162 | . "' )"; |
163 | 163 | } |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | * @return string The limit clause (empty if no limit has been specified). |
171 | 171 | * @since 3.15.0 |
172 | 172 | */ |
173 | - private static function limit( $limit = null ) { |
|
173 | + private static function limit($limit = null) { |
|
174 | 174 | |
175 | - if ( null === $limit ) { |
|
175 | + if (null === $limit) { |
|
176 | 176 | return ''; |
177 | 177 | } |
178 | 178 | |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | * @return string The offset clause (empty if no offset has been specified). |
188 | 188 | * @since 3.35.11 |
189 | 189 | */ |
190 | - private static function offset( $offset = null ) { |
|
190 | + private static function offset($offset = null) { |
|
191 | 191 | |
192 | - if ( null === $offset || ! is_numeric( $offset ) ) { |
|
192 | + if (null === $offset || ! is_numeric($offset)) { |
|
193 | 193 | return ''; |
194 | 194 | } |
195 | 195 | |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - private static function order_by( $order_by ) { |
|
205 | - if ( ! $order_by ) { |
|
204 | + private static function order_by($order_by) { |
|
205 | + if ( ! $order_by) { |
|
206 | 206 | return ''; |
207 | 207 | } |
208 | 208 | $order_by = (string) $order_by; |
209 | - $order_by_clauses = array( 'DESC', 'ASC' ); |
|
209 | + $order_by_clauses = array('DESC', 'ASC'); |
|
210 | 210 | |
211 | - if ( in_array( $order_by, $order_by_clauses, true ) ) { |
|
211 | + if (in_array($order_by, $order_by_clauses, true)) { |
|
212 | 212 | return " ORDER BY p.post_modified ${order_by} "; |
213 | 213 | } else { |
214 | 214 | return ' ORDER BY p.post_modified DESC '; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @return array An array of entities' ids. |
225 | 225 | * @since 3.15.0 |
226 | 226 | */ |
227 | - private function article_id_to_entity_id( $object_id ) { |
|
227 | + private function article_id_to_entity_id($object_id) { |
|
228 | 228 | |
229 | 229 | $entity_service = Wordlift_Entity_Service::get_instance(); |
230 | 230 | |
@@ -232,12 +232,12 @@ discard block |
||
232 | 232 | |
233 | 233 | return array_reduce( |
234 | 234 | (array) $object_id, |
235 | - function ( $carry, $item ) use ( $entity_service, $relation_service ) { |
|
236 | - if ( $entity_service->is_entity( $item ) ) { |
|
237 | - return array_merge( $carry, (array) $item ); |
|
235 | + function($carry, $item) use ($entity_service, $relation_service) { |
|
236 | + if ($entity_service->is_entity($item)) { |
|
237 | + return array_merge($carry, (array) $item); |
|
238 | 238 | } |
239 | 239 | |
240 | - return array_merge( $carry, $relation_service->get_objects( $item, 'ids' ) ); |
|
240 | + return array_merge($carry, $relation_service->get_objects($item, 'ids')); |
|
241 | 241 | }, |
242 | 242 | array() |
243 | 243 | ); |
@@ -252,15 +252,15 @@ discard block |
||
252 | 252 | * @return string The WHERE clause. |
253 | 253 | * @since 3.15.0 |
254 | 254 | */ |
255 | - private static function where_object_id( $object_id ) { |
|
255 | + private static function where_object_id($object_id) { |
|
256 | 256 | |
257 | - if ( empty( $object_id ) ) { |
|
257 | + if (empty($object_id)) { |
|
258 | 258 | // self::$log->warn( sprintf( "%s `where_object_id` called with empty `object_id`.", var_export( debug_backtrace( false, 3 ), true ) ) ); |
259 | 259 | |
260 | 260 | return ' WHERE 1 = 1'; |
261 | 261 | } |
262 | 262 | |
263 | - return ' WHERE r.object_id IN ( ' . implode( ',', wp_parse_id_list( (array) $object_id ) ) . ' )'; |
|
263 | + return ' WHERE r.object_id IN ( '.implode(',', wp_parse_id_list((array) $object_id)).' )'; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | * @return string The exclude clause. |
272 | 272 | * @since 3.15.0 |
273 | 273 | */ |
274 | - private static function and_article_not_in( $exclude ) { |
|
274 | + private static function and_article_not_in($exclude) { |
|
275 | 275 | |
276 | - return ' AND NOT p.ID IN ( ' . implode( ',', wp_parse_id_list( (array) $exclude ) ) . ' )'; |
|
276 | + return ' AND NOT p.ID IN ( '.implode(',', wp_parse_id_list((array) $exclude)).' )'; |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -285,13 +285,13 @@ discard block |
||
285 | 285 | * clause. |
286 | 286 | * @since 3.15.0 |
287 | 287 | */ |
288 | - private static function and_article_in( $include = null ) { |
|
288 | + private static function and_article_in($include = null) { |
|
289 | 289 | |
290 | - if ( null === $include ) { |
|
290 | + if (null === $include) { |
|
291 | 291 | return ''; |
292 | 292 | } |
293 | 293 | |
294 | - return ' AND p.ID IN ( ' . implode( ',', wp_parse_id_list( (array) $include ) ) . ' )'; |
|
294 | + return ' AND p.ID IN ( '.implode(',', wp_parse_id_list((array) $include)).' )'; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -305,23 +305,23 @@ discard block |
||
305 | 305 | * @return array|object|null Database query results |
306 | 306 | * @since 3.15.0 |
307 | 307 | */ |
308 | - public function get_non_article_subjects( $object_id, $fields = '*', $status = null ) { |
|
308 | + public function get_non_article_subjects($object_id, $fields = '*', $status = null) { |
|
309 | 309 | global $wpdb; |
310 | 310 | |
311 | 311 | // The output fields. |
312 | - $actual_fields = self::fields( $fields ); |
|
312 | + $actual_fields = self::fields($fields); |
|
313 | 313 | |
314 | 314 | $sql = $wpdb->prepare( |
315 | 315 | "SELECT p.$actual_fields FROM {$wpdb->prefix}wl_relation_instances r INNER JOIN $wpdb->posts p ON p.id = r.subject_id" // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
316 | 316 | // Add the status clause. |
317 | - . self::and_status( $status ) // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
317 | + . self::and_status($status) // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
318 | 318 | . self::inner_join_is_not_article() // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
319 | 319 | . ' WHERE r.object_id = %d ' |
320 | 320 | . self::and_post_type_in(), // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
321 | 321 | $object_id |
322 | 322 | ); |
323 | 323 | |
324 | - return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
324 | + return '*' === $actual_fields ? $wpdb->get_results($sql) : $wpdb->get_col($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | /** |
@@ -338,24 +338,24 @@ discard block |
||
338 | 338 | * @deprecated since it doesn't handle the subject_type nor the object_type |
339 | 339 | * @since 3.15.0 |
340 | 340 | */ |
341 | - public function get_objects( $subject_id, $fields = '*', $predicate = null, $status = null ) { |
|
341 | + public function get_objects($subject_id, $fields = '*', $predicate = null, $status = null) { |
|
342 | 342 | global $wpdb; |
343 | 343 | |
344 | 344 | // The output fields. |
345 | - $actual_fields = self::fields( $fields ); |
|
345 | + $actual_fields = self::fields($fields); |
|
346 | 346 | |
347 | 347 | $sql = $wpdb->prepare( |
348 | 348 | "SELECT p.$actual_fields FROM {$this->relation_table} r INNER JOIN $wpdb->posts p ON p.id = r.object_id" // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
349 | 349 | // Add the status clause. |
350 | - . self::and_status( $status ) // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
350 | + . self::and_status($status) // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
351 | 351 | . self::inner_join_is_not_article() // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
352 | 352 | . ' WHERE r.subject_id = %d ' |
353 | 353 | . self::and_post_type_in() // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
354 | - . self::and_predicate( $predicate ), // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
354 | + . self::and_predicate($predicate), // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
355 | 355 | $subject_id |
356 | 356 | ); |
357 | 357 | |
358 | - return '*' === $actual_fields ? $wpdb->get_results( $sql ) : $wpdb->get_col( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
358 | + return '*' === $actual_fields ? $wpdb->get_results($sql) : $wpdb->get_col($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
@@ -366,13 +366,13 @@ discard block |
||
366 | 366 | * @return string An empty string if $status is null, otherwise the status clause. |
367 | 367 | * @since 3.15.0 |
368 | 368 | */ |
369 | - private static function and_status( $status = null ) { |
|
369 | + private static function and_status($status = null) { |
|
370 | 370 | |
371 | - if ( null === $status ) { |
|
371 | + if (null === $status) { |
|
372 | 372 | return ''; |
373 | 373 | } |
374 | 374 | |
375 | - return " AND p.post_status IN ('" . implode( "', '", array_map( 'esc_sql', (array) $status ) ) . "')"; |
|
375 | + return " AND p.post_status IN ('".implode("', '", array_map('esc_sql', (array) $status))."')"; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
@@ -384,13 +384,13 @@ discard block |
||
384 | 384 | * clause. |
385 | 385 | * @since 3.15.0 |
386 | 386 | */ |
387 | - private static function and_predicate( $predicate = null ) { |
|
387 | + private static function and_predicate($predicate = null) { |
|
388 | 388 | |
389 | - if ( null === $predicate ) { |
|
389 | + if (null === $predicate) { |
|
390 | 390 | return ''; |
391 | 391 | } |
392 | 392 | |
393 | - return " AND r.predicate IN ('" . implode( "', '", array_map( 'esc_sql', (array) $predicate ) ) . "')"; |
|
393 | + return " AND r.predicate IN ('".implode("', '", array_map('esc_sql', (array) $predicate))."')"; |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * @return string The `id` field if `ids` otherwise `*`. |
402 | 402 | * @since 3.15.0 |
403 | 403 | */ |
404 | - private static function fields( $fields = '*' ) { |
|
404 | + private static function fields($fields = '*') { |
|
405 | 405 | |
406 | 406 | // The output fields. |
407 | 407 | return 'ids' === $fields ? 'id' : '*'; |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @since 3.10.0 |
48 | 48 | */ |
49 | - public function __construct( $entity_type_service, $user_service, $attachment_service, $disable_convert_filters = false ) { |
|
50 | - parent::__construct( $entity_type_service, $user_service, $attachment_service, Wordlift_Property_Getter_Factory::create() ); |
|
49 | + public function __construct($entity_type_service, $user_service, $attachment_service, $disable_convert_filters = false) { |
|
50 | + parent::__construct($entity_type_service, $user_service, $attachment_service, Wordlift_Property_Getter_Factory::create()); |
|
51 | 51 | $this->disable_convert_filters = $disable_convert_filters; |
52 | 52 | // Set a reference to the logger. |
53 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Post_To_Jsonld_Converter' ); |
|
53 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Post_To_Jsonld_Converter'); |
|
54 | 54 | |
55 | 55 | self::$instance = $this; |
56 | 56 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | public function new_instance_with_filters_disabled() { |
65 | - return new static( $this->entity_type_service, $this->user_service, $this->attachment_service, true ); |
|
65 | + return new static($this->entity_type_service, $this->user_service, $this->attachment_service, true); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -76,30 +76,30 @@ discard block |
||
76 | 76 | * @return array A JSON-LD array. |
77 | 77 | * @since 3.10.0 |
78 | 78 | */ |
79 | - public function convert( $post_id, &$references = array(), &$references_infos = array(), $relations = null ) { |
|
79 | + public function convert($post_id, &$references = array(), &$references_infos = array(), $relations = null) { |
|
80 | 80 | |
81 | 81 | // Get the post instance. |
82 | - $post = get_post( $post_id ); |
|
83 | - if ( null === $post ) { |
|
82 | + $post = get_post($post_id); |
|
83 | + if (null === $post) { |
|
84 | 84 | // Post not found. |
85 | 85 | return null; |
86 | 86 | } |
87 | 87 | |
88 | 88 | // Get the base JSON-LD and the list of entities referenced by this entity. |
89 | - $jsonld = parent::convert( $post_id, $references, $references_infos, $relations ); |
|
89 | + $jsonld = parent::convert($post_id, $references, $references_infos, $relations); |
|
90 | 90 | |
91 | 91 | // Set WebPage by default. |
92 | - if ( empty( $jsonld['@type'] ) ) { |
|
92 | + if (empty($jsonld['@type'])) { |
|
93 | 93 | $jsonld['@type'] = 'WebPage'; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Get the entity name. |
97 | 97 | $jsonld['headline'] = $post->post_title; |
98 | 98 | |
99 | - $custom_fields = $this->entity_type_service->get_custom_fields_for_post( $post_id ); |
|
99 | + $custom_fields = $this->entity_type_service->get_custom_fields_for_post($post_id); |
|
100 | 100 | |
101 | - if ( isset( $custom_fields ) ) { |
|
102 | - $this->process_type_custom_fields( $jsonld, $custom_fields, $post, $references, $references_infos ); |
|
101 | + if (isset($custom_fields)) { |
|
102 | + $this->process_type_custom_fields($jsonld, $custom_fields, $post, $references, $references_infos); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | // Set the published and modified dates. |
@@ -112,19 +112,19 @@ discard block |
||
112 | 112 | */ |
113 | 113 | try { |
114 | 114 | $default_timezone = date_default_timezone_get(); |
115 | - $timezone = get_option( 'timezone_string' ); |
|
116 | - if ( ! empty( $timezone ) ) { |
|
117 | - date_default_timezone_set( $timezone ); //phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set |
|
118 | - $jsonld['datePublished'] = get_post_time( 'Y-m-d\TH:i:sP', false, $post ); |
|
119 | - $jsonld['dateModified'] = get_post_modified_time( 'Y-m-d\TH:i:sP', false, $post ); |
|
120 | - date_default_timezone_set( $default_timezone ); //phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set |
|
115 | + $timezone = get_option('timezone_string'); |
|
116 | + if ( ! empty($timezone)) { |
|
117 | + date_default_timezone_set($timezone); //phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set |
|
118 | + $jsonld['datePublished'] = get_post_time('Y-m-d\TH:i:sP', false, $post); |
|
119 | + $jsonld['dateModified'] = get_post_modified_time('Y-m-d\TH:i:sP', false, $post); |
|
120 | + date_default_timezone_set($default_timezone); //phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set |
|
121 | 121 | } else { |
122 | - $jsonld['datePublished'] = get_post_time( 'Y-m-d\TH:i', true, $post, false ); |
|
123 | - $jsonld['dateModified'] = get_post_modified_time( 'Y-m-d\TH:i', true, $post, false ); |
|
122 | + $jsonld['datePublished'] = get_post_time('Y-m-d\TH:i', true, $post, false); |
|
123 | + $jsonld['dateModified'] = get_post_modified_time('Y-m-d\TH:i', true, $post, false); |
|
124 | 124 | } |
125 | - } catch ( Exception $e ) { |
|
126 | - $jsonld['datePublished'] = get_post_time( 'Y-m-d\TH:i', true, $post, false ); |
|
127 | - $jsonld['dateModified'] = get_post_modified_time( 'Y-m-d\TH:i', true, $post, false ); |
|
125 | + } catch (Exception $e) { |
|
126 | + $jsonld['datePublished'] = get_post_time('Y-m-d\TH:i', true, $post, false); |
|
127 | + $jsonld['dateModified'] = get_post_modified_time('Y-m-d\TH:i', true, $post, false); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | // Get the word count for the post. |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @since 3.20.0 |
137 | 137 | */ |
138 | - if ( ! empty( $jsonld['@type'] ) && 'WebPage' !== $jsonld['@type'] ) { |
|
139 | - $post_adapter = new Wordlift_Post_Adapter( $post_id ); |
|
138 | + if ( ! empty($jsonld['@type']) && 'WebPage' !== $jsonld['@type']) { |
|
139 | + $post_adapter = new Wordlift_Post_Adapter($post_id); |
|
140 | 140 | $jsonld['wordCount'] = $post_adapter->word_count(); |
141 | 141 | } |
142 | 142 | |
@@ -147,17 +147,17 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @since 3.27.2 |
149 | 149 | */ |
150 | - if ( ! empty( $jsonld['@type'] ) && 'WebPage' !== $jsonld['@type'] ) { |
|
151 | - $post_adapter = new Wordlift_Post_Adapter( $post_id ); |
|
150 | + if ( ! empty($jsonld['@type']) && 'WebPage' !== $jsonld['@type']) { |
|
151 | + $post_adapter = new Wordlift_Post_Adapter($post_id); |
|
152 | 152 | $keywords = $post_adapter->keywords(); |
153 | 153 | $article_section = $post_adapter->article_section(); |
154 | 154 | $comment_count = $post_adapter->comment_count(); |
155 | 155 | $locale = $post_adapter->locale(); |
156 | 156 | |
157 | - if ( isset( $keywords ) ) { |
|
157 | + if (isset($keywords)) { |
|
158 | 158 | $jsonld['keywords'] = $keywords; |
159 | 159 | } |
160 | - if ( ! empty( $article_section ) ) { |
|
160 | + if ( ! empty($article_section)) { |
|
161 | 161 | $jsonld['articleSection'] = $article_section; |
162 | 162 | } |
163 | 163 | $jsonld['commentCount'] = $comment_count; |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | // Set the publisher. |
168 | - $this->set_publisher( $jsonld ); |
|
168 | + $this->set_publisher($jsonld); |
|
169 | 169 | |
170 | 170 | // Finally set the author. |
171 | - $jsonld['author'] = $this->get_author( $post->post_author, $references ); |
|
171 | + $jsonld['author'] = $this->get_author($post->post_author, $references); |
|
172 | 172 | |
173 | 173 | // Return the JSON-LD if filters are disabled by the client. |
174 | - if ( $this->disable_convert_filters ) { |
|
174 | + if ($this->disable_convert_filters) { |
|
175 | 175 | return $jsonld; |
176 | 176 | } |
177 | 177 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @api |
218 | 218 | */ |
219 | - return apply_filters( 'wl_post_jsonld', $jsonld, $post_id, $references ); |
|
219 | + return apply_filters('wl_post_jsonld', $jsonld, $post_id, $references); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -231,18 +231,18 @@ discard block |
||
231 | 231 | * @return string|array A JSON-LD structure. |
232 | 232 | * @since 3.14.0 |
233 | 233 | */ |
234 | - public function get_author( $author_id, &$references ) { |
|
234 | + public function get_author($author_id, &$references) { |
|
235 | 235 | |
236 | 236 | // Get the entity bound to this user. |
237 | - $entity_id = $this->user_service->get_entity( $author_id ); |
|
237 | + $entity_id = $this->user_service->get_entity($author_id); |
|
238 | 238 | |
239 | 239 | // If there's no entity bound return a simple author structure. |
240 | - if ( empty( $entity_id ) || 'publish' !== get_post_status( $entity_id ) ) { |
|
240 | + if (empty($entity_id) || 'publish' !== get_post_status($entity_id)) { |
|
241 | 241 | |
242 | - $author = get_the_author_meta( 'display_name', $author_id ); |
|
243 | - $author_first_name = get_the_author_meta( 'first_name', $author_id ); |
|
244 | - $author_last_name = get_the_author_meta( 'last_name', $author_id ); |
|
245 | - $author_uri = $this->user_service->get_uri( $author_id ); |
|
242 | + $author = get_the_author_meta('display_name', $author_id); |
|
243 | + $author_first_name = get_the_author_meta('first_name', $author_id); |
|
244 | + $author_last_name = get_the_author_meta('last_name', $author_id); |
|
245 | + $author_uri = $this->user_service->get_uri($author_id); |
|
246 | 246 | |
247 | 247 | return array( |
248 | 248 | '@type' => 'Person', |
@@ -250,12 +250,12 @@ discard block |
||
250 | 250 | 'name' => $author, |
251 | 251 | 'givenName' => $author_first_name, |
252 | 252 | 'familyName' => $author_last_name, |
253 | - 'url' => get_author_posts_url( $author_id ), |
|
253 | + 'url' => get_author_posts_url($author_id), |
|
254 | 254 | ); |
255 | 255 | } |
256 | 256 | |
257 | 257 | // Add the author to the references. |
258 | - $author_uri = Wordlift_Entity_Service::get_instance()->get_uri( $entity_id ); |
|
258 | + $author_uri = Wordlift_Entity_Service::get_instance()->get_uri($entity_id); |
|
259 | 259 | $references[] = $entity_id; |
260 | 260 | |
261 | 261 | // Return the JSON-LD for the referenced entity. |
@@ -271,41 +271,41 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @since 3.10.0 |
273 | 273 | */ |
274 | - protected function set_publisher( &$params ) { |
|
274 | + protected function set_publisher(&$params) { |
|
275 | 275 | |
276 | 276 | // If the publisher id isn't set don't do anything. |
277 | 277 | $publisher_id = Wordlift_Configuration_Service::get_instance()->get_publisher_id(); |
278 | - if ( null === $publisher_id ) { |
|
278 | + if (null === $publisher_id) { |
|
279 | 279 | return; |
280 | 280 | } |
281 | 281 | |
282 | 282 | // Get the post instance. |
283 | - $post = get_post( $publisher_id ); |
|
284 | - if ( null === $post ) { |
|
283 | + $post = get_post($publisher_id); |
|
284 | + if (null === $post) { |
|
285 | 285 | // Publisher not found. |
286 | 286 | return; |
287 | 287 | } |
288 | 288 | |
289 | 289 | // Get the item id. |
290 | - $id = Wordlift_Entity_Service::get_instance()->get_uri( $publisher_id ); |
|
290 | + $id = Wordlift_Entity_Service::get_instance()->get_uri($publisher_id); |
|
291 | 291 | |
292 | 292 | // Get the type. |
293 | - $type = $this->entity_type_service->get( $publisher_id ); |
|
293 | + $type = $this->entity_type_service->get($publisher_id); |
|
294 | 294 | |
295 | 295 | // Get the name. |
296 | 296 | $name = $post->post_title; |
297 | 297 | |
298 | 298 | // Set the publisher data. |
299 | 299 | $params['publisher'] = array( |
300 | - '@type' => $this->relative_to_context( $type['uri'] ), |
|
300 | + '@type' => $this->relative_to_context($type['uri']), |
|
301 | 301 | '@id' => $id, |
302 | 302 | 'name' => $name, |
303 | 303 | ); |
304 | 304 | |
305 | 305 | // Add the sameAs values associated with the publisher. |
306 | 306 | $storage_factory = Wordlift_Storage_Factory::get_instance(); |
307 | - $sameas = $storage_factory->post_meta( Wordlift_Schema_Service::FIELD_SAME_AS )->get( $publisher_id ); |
|
308 | - if ( ! empty( $sameas ) ) { |
|
307 | + $sameas = $storage_factory->post_meta(Wordlift_Schema_Service::FIELD_SAME_AS)->get($publisher_id); |
|
308 | + if ( ! empty($sameas)) { |
|
309 | 309 | $params['publisher']['sameAs'] = $sameas; |
310 | 310 | } |
311 | 311 | |
@@ -313,15 +313,15 @@ discard block |
||
313 | 313 | // support the logo property. |
314 | 314 | // |
315 | 315 | // See http://schema.org/logo. |
316 | - if ( 1 !== preg_match( '~Organization$~', $type['uri'] ) ) { |
|
316 | + if (1 !== preg_match('~Organization$~', $type['uri'])) { |
|
317 | 317 | return; |
318 | 318 | } |
319 | 319 | |
320 | 320 | // Get the publisher logo. |
321 | - $publisher_logo = $this->get_publisher_logo( $post->ID ); |
|
321 | + $publisher_logo = $this->get_publisher_logo($post->ID); |
|
322 | 322 | |
323 | 323 | // Bail out if the publisher logo isn't set. |
324 | - if ( false === $publisher_logo ) { |
|
324 | + if (false === $publisher_logo) { |
|
325 | 325 | return; |
326 | 326 | } |
327 | 327 | |
@@ -355,14 +355,14 @@ discard block |
||
355 | 355 | * @since 3.19.2 |
356 | 356 | * @see https://github.com/insideout10/wordlift-plugin/issues/823 related issue. |
357 | 357 | */ |
358 | - private function get_publisher_logo( $post_id ) { |
|
358 | + private function get_publisher_logo($post_id) { |
|
359 | 359 | |
360 | 360 | // Get the featured image for the post. |
361 | - $thumbnail_id = get_post_thumbnail_id( $post_id ); |
|
361 | + $thumbnail_id = get_post_thumbnail_id($post_id); |
|
362 | 362 | |
363 | 363 | // Bail out if thumbnail not available. |
364 | - if ( empty( $thumbnail_id ) || 0 === $thumbnail_id ) { |
|
365 | - $this->log->info( "Featured image not set for post $post_id." ); |
|
364 | + if (empty($thumbnail_id) || 0 === $thumbnail_id) { |
|
365 | + $this->log->info("Featured image not set for post $post_id."); |
|
366 | 366 | |
367 | 367 | return false; |
368 | 368 | } |
@@ -371,24 +371,24 @@ discard block |
||
371 | 371 | $uploads_dir = wp_upload_dir(); |
372 | 372 | |
373 | 373 | // Get the attachment metadata. |
374 | - $metadata = wp_get_attachment_metadata( $thumbnail_id ); |
|
374 | + $metadata = wp_get_attachment_metadata($thumbnail_id); |
|
375 | 375 | |
376 | 376 | // Bail out if the file isn't set. |
377 | - if ( ! isset( $metadata['file'] ) ) { |
|
378 | - $this->log->warn( "Featured image file not found for post $post_id." ); |
|
377 | + if ( ! isset($metadata['file'])) { |
|
378 | + $this->log->warn("Featured image file not found for post $post_id."); |
|
379 | 379 | |
380 | 380 | return false; |
381 | 381 | } |
382 | 382 | |
383 | 383 | // Retrieve the relative filename, e.g. "2018/05/logo_publisher.png" |
384 | - $path = $uploads_dir['basedir'] . DIRECTORY_SEPARATOR . $metadata['file']; |
|
384 | + $path = $uploads_dir['basedir'].DIRECTORY_SEPARATOR.$metadata['file']; |
|
385 | 385 | |
386 | 386 | // Use image src, if local file does not exist. @see https://github.com/insideout10/wordlift-plugin/issues/1149 |
387 | - if ( ! file_exists( $path ) ) { |
|
388 | - $this->log->warn( "Featured image file $path doesn't exist for post $post_id." ); |
|
387 | + if ( ! file_exists($path)) { |
|
388 | + $this->log->warn("Featured image file $path doesn't exist for post $post_id."); |
|
389 | 389 | |
390 | - $attachment_image_src = wp_get_attachment_image_src( $thumbnail_id, '' ); |
|
391 | - if ( $attachment_image_src ) { |
|
390 | + $attachment_image_src = wp_get_attachment_image_src($thumbnail_id, ''); |
|
391 | + if ($attachment_image_src) { |
|
392 | 392 | return array( |
393 | 393 | 'url' => $attachment_image_src[0], |
394 | 394 | 'width' => $attachment_image_src[1], |
@@ -402,27 +402,27 @@ discard block |
||
402 | 402 | } |
403 | 403 | |
404 | 404 | // Try to get the image editor and bail out if the editor cannot be instantiated. |
405 | - $original_file_editor = wp_get_image_editor( $path ); |
|
406 | - if ( is_wp_error( $original_file_editor ) ) { |
|
407 | - $this->log->warn( "Cannot instantiate WP Image Editor on file $path for post $post_id." ); |
|
405 | + $original_file_editor = wp_get_image_editor($path); |
|
406 | + if (is_wp_error($original_file_editor)) { |
|
407 | + $this->log->warn("Cannot instantiate WP Image Editor on file $path for post $post_id."); |
|
408 | 408 | |
409 | 409 | return false; |
410 | 410 | } |
411 | 411 | |
412 | 412 | // Generate the publisher logo filename, we cannot use the `width` and `height` because we're scaling |
413 | 413 | // and we don't actually know the end values. |
414 | - $publisher_logo_path = $original_file_editor->generate_filename( '-publisher-logo' ); |
|
414 | + $publisher_logo_path = $original_file_editor->generate_filename('-publisher-logo'); |
|
415 | 415 | |
416 | 416 | // If the file doesn't exist yet, create it. |
417 | - if ( ! file_exists( $publisher_logo_path ) ) { |
|
418 | - $original_file_editor->resize( 600, 60 ); |
|
419 | - $original_file_editor->save( $publisher_logo_path ); |
|
417 | + if ( ! file_exists($publisher_logo_path)) { |
|
418 | + $original_file_editor->resize(600, 60); |
|
419 | + $original_file_editor->save($publisher_logo_path); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | // Try to get the image editor and bail out if the editor cannot be instantiated. |
423 | - $publisher_logo_editor = wp_get_image_editor( $publisher_logo_path ); |
|
424 | - if ( is_wp_error( $publisher_logo_editor ) ) { |
|
425 | - $this->log->warn( "Cannot instantiate WP Image Editor on file $publisher_logo_path for post $post_id." ); |
|
423 | + $publisher_logo_editor = wp_get_image_editor($publisher_logo_path); |
|
424 | + if (is_wp_error($publisher_logo_editor)) { |
|
425 | + $this->log->warn("Cannot instantiate WP Image Editor on file $publisher_logo_path for post $post_id."); |
|
426 | 426 | |
427 | 427 | return false; |
428 | 428 | } |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | |
433 | 433 | // Finally return the array with data. |
434 | 434 | return array( |
435 | - 'url' => $uploads_dir['baseurl'] . substr( $publisher_logo_path, strlen( $uploads_dir['basedir'] ) ), |
|
435 | + 'url' => $uploads_dir['baseurl'].substr($publisher_logo_path, strlen($uploads_dir['basedir'])), |
|
436 | 436 | 'width' => $size['width'], |
437 | 437 | 'height' => $size['height'], |
438 | 438 | ); |
@@ -638,15 +638,15 @@ discard block |
||
638 | 638 | $that = $this; |
639 | 639 | add_action( |
640 | 640 | 'plugins_loaded', |
641 | - function () use ( $that ) { |
|
642 | - $that->define_admin_hooks( $that ); |
|
643 | - $that->define_public_hooks( $that ); |
|
641 | + function() use ($that) { |
|
642 | + $that->define_admin_hooks($that); |
|
643 | + $that->define_public_hooks($that); |
|
644 | 644 | }, |
645 | 645 | 4 |
646 | 646 | ); |
647 | 647 | |
648 | 648 | // If we're in `WP_CLI` load the related files. |
649 | - if ( class_exists( 'WP_CLI' ) ) { |
|
649 | + if (class_exists('WP_CLI')) { |
|
650 | 650 | $this->load_cli_dependencies(); |
651 | 651 | } |
652 | 652 | |
@@ -686,329 +686,329 @@ discard block |
||
686 | 686 | * The class responsible for orchestrating the actions and filters of the |
687 | 687 | * core plugin. |
688 | 688 | */ |
689 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-loader.php'; |
|
689 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-loader.php'; |
|
690 | 690 | |
691 | 691 | // The class responsible for plugin uninstall. |
692 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-deactivator-feedback.php'; |
|
692 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-deactivator-feedback.php'; |
|
693 | 693 | |
694 | 694 | /** |
695 | 695 | * The class responsible for defining internationalization functionality |
696 | 696 | * of the plugin. |
697 | 697 | */ |
698 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-i18n.php'; |
|
698 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-i18n.php'; |
|
699 | 699 | |
700 | 700 | /** |
701 | 701 | * WordLift's supported languages. |
702 | 702 | */ |
703 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-languages.php'; |
|
703 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-languages.php'; |
|
704 | 704 | |
705 | 705 | /** |
706 | 706 | * WordLift's supported countries. |
707 | 707 | */ |
708 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-countries.php'; |
|
708 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-countries.php'; |
|
709 | 709 | |
710 | 710 | /** |
711 | 711 | * Provide support functions to sanitize data. |
712 | 712 | */ |
713 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-sanitizer.php'; |
|
713 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-sanitizer.php'; |
|
714 | 714 | |
715 | 715 | /** Services. */ |
716 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-log-service.php'; |
|
717 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-http-api.php'; |
|
718 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-redirect-service.php'; |
|
719 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-configuration-service.php'; |
|
720 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-entity-post-type-service.php'; |
|
721 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-entity-type-service.php'; |
|
722 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-entity-link-service.php'; |
|
723 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-relation-service.php'; |
|
724 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-image-service.php'; |
|
716 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-log-service.php'; |
|
717 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-http-api.php'; |
|
718 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-redirect-service.php'; |
|
719 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-configuration-service.php'; |
|
720 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-entity-post-type-service.php'; |
|
721 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-entity-type-service.php'; |
|
722 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-entity-link-service.php'; |
|
723 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-relation-service.php'; |
|
724 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-image-service.php'; |
|
725 | 725 | |
726 | 726 | /** |
727 | 727 | * The Schema service. |
728 | 728 | */ |
729 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-schema-service.php'; |
|
729 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-schema-service.php'; |
|
730 | 730 | |
731 | 731 | /** |
732 | 732 | * The schema:url property service. |
733 | 733 | */ |
734 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-property-service.php'; |
|
735 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-schema-url-property-service.php'; |
|
734 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-property-service.php'; |
|
735 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-schema-url-property-service.php'; |
|
736 | 736 | |
737 | 737 | /** |
738 | 738 | * The UI service. |
739 | 739 | */ |
740 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-ui-service.php'; |
|
740 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-ui-service.php'; |
|
741 | 741 | |
742 | 742 | /** |
743 | 743 | * The Entity Types Taxonomy service. |
744 | 744 | */ |
745 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
745 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-entity-type-taxonomy-service.php'; |
|
746 | 746 | |
747 | 747 | /** |
748 | 748 | * The Entity service. |
749 | 749 | */ |
750 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-entity-uri-service.php'; |
|
751 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-entity-service.php'; |
|
750 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-entity-uri-service.php'; |
|
751 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-entity-service.php'; |
|
752 | 752 | |
753 | 753 | // Add the entity rating service. |
754 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-rating-service.php'; |
|
754 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-rating-service.php'; |
|
755 | 755 | |
756 | 756 | /** |
757 | 757 | * The User service. |
758 | 758 | */ |
759 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-user-service.php'; |
|
759 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-user-service.php'; |
|
760 | 760 | |
761 | 761 | /** |
762 | 762 | * The Timeline service. |
763 | 763 | */ |
764 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-timeline-service.php'; |
|
764 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-timeline-service.php'; |
|
765 | 765 | |
766 | 766 | /** |
767 | 767 | * The Topic Taxonomy service. |
768 | 768 | */ |
769 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
769 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-topic-taxonomy-service.php'; |
|
770 | 770 | |
771 | 771 | /** |
772 | 772 | * The WordLift URI service. |
773 | 773 | */ |
774 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-uri-service.php'; |
|
775 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-property-factory.php'; |
|
776 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-sample-data-service.php'; |
|
774 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-uri-service.php'; |
|
775 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-property-factory.php'; |
|
776 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-sample-data-service.php'; |
|
777 | 777 | |
778 | - require_once plugin_dir_path( __DIR__ ) . 'includes/properties/class-wordlift-property-getter-factory.php'; |
|
779 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-attachment-service.php'; |
|
778 | + require_once plugin_dir_path(__DIR__).'includes/properties/class-wordlift-property-getter-factory.php'; |
|
779 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-attachment-service.php'; |
|
780 | 780 | |
781 | 781 | /** |
782 | 782 | * Load the converters. |
783 | 783 | */ |
784 | - require_once plugin_dir_path( __DIR__ ) . 'includes/intf-wordlift-post-converter.php'; |
|
785 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
786 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
787 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
788 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
789 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-website-jsonld-converter.php'; |
|
784 | + require_once plugin_dir_path(__DIR__).'includes/intf-wordlift-post-converter.php'; |
|
785 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-abstract-post-to-jsonld-converter.php'; |
|
786 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-postid-to-jsonld-converter.php'; |
|
787 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-entity-post-to-jsonld-converter.php'; |
|
788 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-post-to-jsonld-converter.php'; |
|
789 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-website-jsonld-converter.php'; |
|
790 | 790 | |
791 | 791 | /** |
792 | 792 | * Load cache-related files. |
793 | 793 | */ |
794 | - require_once plugin_dir_path( __DIR__ ) . 'includes/cache/require.php'; |
|
794 | + require_once plugin_dir_path(__DIR__).'includes/cache/require.php'; |
|
795 | 795 | |
796 | 796 | /** |
797 | 797 | * Load the content filter. |
798 | 798 | */ |
799 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-content-filter-service.php'; |
|
799 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-content-filter-service.php'; |
|
800 | 800 | |
801 | 801 | /* |
802 | 802 | * Load the excerpt helper. |
803 | 803 | */ |
804 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-post-excerpt-helper.php'; |
|
804 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-post-excerpt-helper.php'; |
|
805 | 805 | |
806 | 806 | /** |
807 | 807 | * Load the JSON-LD service to publish entities using JSON-LD.s |
808 | 808 | * |
809 | 809 | * @since 3.8.0 |
810 | 810 | */ |
811 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-jsonld-service.php'; |
|
811 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-jsonld-service.php'; |
|
812 | 812 | |
813 | 813 | // The Publisher Service and the AJAX adapter. |
814 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-publisher-service.php'; |
|
815 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
814 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-publisher-service.php'; |
|
815 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-publisher-ajax-adapter.php'; |
|
816 | 816 | |
817 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-post-adapter.php'; |
|
817 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-post-adapter.php'; |
|
818 | 818 | |
819 | 819 | /** |
820 | 820 | * Load the WordLift key validation service. |
821 | 821 | */ |
822 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-key-validation-service.php'; |
|
822 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-key-validation-service.php'; |
|
823 | 823 | |
824 | 824 | // Load the `Wordlift_Category_Taxonomy_Service` class definition. |
825 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-category-taxonomy-service.php'; |
|
825 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-category-taxonomy-service.php'; |
|
826 | 826 | |
827 | 827 | // Load the `Wordlift_Entity_Page_Service` class definition. |
828 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-entity-page-service.php'; |
|
828 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-entity-page-service.php'; |
|
829 | 829 | |
830 | 830 | /** Linked Data. */ |
831 | - require_once plugin_dir_path( __DIR__ ) . 'includes/linked-data/storage/class-wordlift-storage.php'; |
|
832 | - require_once plugin_dir_path( __DIR__ ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
833 | - require_once plugin_dir_path( __DIR__ ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
834 | - require_once plugin_dir_path( __DIR__ ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
835 | - require_once plugin_dir_path( __DIR__ ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
836 | - require_once plugin_dir_path( __DIR__ ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
837 | - require_once plugin_dir_path( __DIR__ ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
838 | - require_once plugin_dir_path( __DIR__ ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
839 | - require_once plugin_dir_path( __DIR__ ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
840 | - require_once plugin_dir_path( __DIR__ ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
841 | - require_once plugin_dir_path( __DIR__ ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
831 | + require_once plugin_dir_path(__DIR__).'includes/linked-data/storage/class-wordlift-storage.php'; |
|
832 | + require_once plugin_dir_path(__DIR__).'includes/linked-data/storage/class-wordlift-post-meta-storage.php'; |
|
833 | + require_once plugin_dir_path(__DIR__).'includes/linked-data/storage/class-wordlift-post-property-storage.php'; |
|
834 | + require_once plugin_dir_path(__DIR__).'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php'; |
|
835 | + require_once plugin_dir_path(__DIR__).'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php'; |
|
836 | + require_once plugin_dir_path(__DIR__).'includes/linked-data/storage/class-wordlift-post-author-storage.php'; |
|
837 | + require_once plugin_dir_path(__DIR__).'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php'; |
|
838 | + require_once plugin_dir_path(__DIR__).'includes/linked-data/storage/class-wordlift-post-image-storage.php'; |
|
839 | + require_once plugin_dir_path(__DIR__).'includes/linked-data/storage/class-wordlift-post-related-storage.php'; |
|
840 | + require_once plugin_dir_path(__DIR__).'includes/linked-data/storage/class-wordlift-url-property-storage.php'; |
|
841 | + require_once plugin_dir_path(__DIR__).'includes/linked-data/storage/class-wordlift-storage-factory.php'; |
|
842 | 842 | |
843 | 843 | /** Services. */ |
844 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-google-analytics-export-service.php'; |
|
845 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-api-service.php'; |
|
844 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-google-analytics-export-service.php'; |
|
845 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-api-service.php'; |
|
846 | 846 | |
847 | 847 | /** Adapters. */ |
848 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-tinymce-adapter.php'; |
|
849 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-newrelic-adapter.php'; |
|
850 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
851 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-entity-type-adapter.php'; |
|
852 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-wprocket-adapter.php'; |
|
853 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-nitropack-adapter.php'; |
|
848 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-tinymce-adapter.php'; |
|
849 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-newrelic-adapter.php'; |
|
850 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-sample-data-ajax-adapter.php'; |
|
851 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-entity-type-adapter.php'; |
|
852 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-wprocket-adapter.php'; |
|
853 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-nitropack-adapter.php'; |
|
854 | 854 | |
855 | 855 | /** Autocomplete. */ |
856 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-autocomplete-adapter.php'; |
|
856 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-autocomplete-adapter.php'; |
|
857 | 857 | |
858 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-remote-image-service.php'; |
|
858 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-remote-image-service.php'; |
|
859 | 859 | |
860 | 860 | /** Analytics */ |
861 | - require_once plugin_dir_path( __DIR__ ) . 'includes/analytics/class-wordlift-analytics-connect.php'; |
|
861 | + require_once plugin_dir_path(__DIR__).'includes/analytics/class-wordlift-analytics-connect.php'; |
|
862 | 862 | |
863 | 863 | /** |
864 | 864 | * The class responsible for defining all actions that occur in the admin area. |
865 | 865 | */ |
866 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin.php'; |
|
866 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin.php'; |
|
867 | 867 | |
868 | 868 | /** |
869 | 869 | * The class to customize the entity list admin page. |
870 | 870 | */ |
871 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-entity-list-service.php'; |
|
871 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-entity-list-service.php'; |
|
872 | 872 | |
873 | 873 | /** |
874 | 874 | * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
875 | 875 | */ |
876 | 876 | global $wp_version; |
877 | - if ( version_compare( $wp_version, '5.3', '<' ) ) { |
|
878 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
877 | + if (version_compare($wp_version, '5.3', '<')) { |
|
878 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
879 | 879 | } else { |
880 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
880 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php'; |
|
881 | 881 | } |
882 | 882 | |
883 | 883 | /** |
884 | 884 | * The Notice service. |
885 | 885 | */ |
886 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-notice-service.php'; |
|
886 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-notice-service.php'; |
|
887 | 887 | |
888 | 888 | /** |
889 | 889 | * The PrimaShop adapter. |
890 | 890 | */ |
891 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
891 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-primashop-adapter.php'; |
|
892 | 892 | |
893 | 893 | /** |
894 | 894 | * The WordLift Dashboard service. |
895 | 895 | */ |
896 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-dashboard-service.php'; |
|
896 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-dashboard-service.php'; |
|
897 | 897 | |
898 | 898 | /** |
899 | 899 | * The admin 'Install wizard' page. |
900 | 900 | */ |
901 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin-setup.php'; |
|
901 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin-setup.php'; |
|
902 | 902 | |
903 | 903 | /** |
904 | 904 | * The WordLift entity type list admin page controller. |
905 | 905 | */ |
906 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
906 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin-entity-taxonomy-list-page.php'; |
|
907 | 907 | |
908 | 908 | /** |
909 | 909 | * The WordLift entity type settings admin page controller. |
910 | 910 | */ |
911 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin-entity-type-settings.php'; |
|
911 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin-entity-type-settings.php'; |
|
912 | 912 | |
913 | 913 | /** |
914 | 914 | * The admin 'Download Your Data' page. |
915 | 915 | */ |
916 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin-download-your-data-page.php'; |
|
916 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin-download-your-data-page.php'; |
|
917 | 917 | |
918 | 918 | /** |
919 | 919 | * The admin 'WordLift Settings' page. |
920 | 920 | */ |
921 | - require_once plugin_dir_path( __DIR__ ) . 'admin/elements/intf-wordlift-admin-element.php'; |
|
922 | - require_once plugin_dir_path( __DIR__ ) . 'admin/elements/class-wordlift-admin-input-element.php'; |
|
923 | - require_once plugin_dir_path( __DIR__ ) . 'admin/elements/class-wordlift-admin-radio-input-element.php'; |
|
924 | - require_once plugin_dir_path( __DIR__ ) . 'admin/elements/class-wordlift-admin-select-element.php'; |
|
925 | - require_once plugin_dir_path( __DIR__ ) . 'admin/elements/class-wordlift-admin-select2-element.php'; |
|
926 | - require_once plugin_dir_path( __DIR__ ) . 'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
927 | - require_once plugin_dir_path( __DIR__ ) . 'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
928 | - require_once plugin_dir_path( __DIR__ ) . 'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
929 | - require_once plugin_dir_path( __DIR__ ) . 'admin/elements/class-wordlift-admin-author-element.php'; |
|
930 | - require_once plugin_dir_path( __DIR__ ) . 'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
931 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin-page.php'; |
|
932 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin-settings-page.php'; |
|
933 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
934 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
935 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
921 | + require_once plugin_dir_path(__DIR__).'admin/elements/intf-wordlift-admin-element.php'; |
|
922 | + require_once plugin_dir_path(__DIR__).'admin/elements/class-wordlift-admin-input-element.php'; |
|
923 | + require_once plugin_dir_path(__DIR__).'admin/elements/class-wordlift-admin-radio-input-element.php'; |
|
924 | + require_once plugin_dir_path(__DIR__).'admin/elements/class-wordlift-admin-select-element.php'; |
|
925 | + require_once plugin_dir_path(__DIR__).'admin/elements/class-wordlift-admin-select2-element.php'; |
|
926 | + require_once plugin_dir_path(__DIR__).'admin/elements/class-wordlift-admin-language-select-element.php'; |
|
927 | + require_once plugin_dir_path(__DIR__).'admin/elements/class-wordlift-admin-country-select-element.php'; |
|
928 | + require_once plugin_dir_path(__DIR__).'admin/elements/class-wordlift-admin-tabs-element.php'; |
|
929 | + require_once plugin_dir_path(__DIR__).'admin/elements/class-wordlift-admin-author-element.php'; |
|
930 | + require_once plugin_dir_path(__DIR__).'admin/elements/class-wordlift-admin-publisher-element.php'; |
|
931 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin-page.php'; |
|
932 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin-settings-page.php'; |
|
933 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin-settings-analytics-page.php'; |
|
934 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin-settings-page-action-link.php'; |
|
935 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin-settings-analytics-page-action-link.php'; |
|
936 | 936 | |
937 | 937 | /** Admin Pages */ |
938 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin-user-profile-page.php'; |
|
939 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-entity-type-admin-service.php'; |
|
938 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin-user-profile-page.php'; |
|
939 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-entity-type-admin-service.php'; |
|
940 | 940 | |
941 | 941 | /** |
942 | 942 | * The class responsible for defining all actions that occur in the public-facing |
943 | 943 | * side of the site. |
944 | 944 | */ |
945 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-public.php'; |
|
945 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-public.php'; |
|
946 | 946 | |
947 | 947 | /** |
948 | 948 | * The shortcode abstract class. |
949 | 949 | */ |
950 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-shortcode.php'; |
|
950 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-shortcode.php'; |
|
951 | 951 | |
952 | 952 | /** |
953 | 953 | * The Timeline shortcode. |
954 | 954 | */ |
955 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
955 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-timeline-shortcode.php'; |
|
956 | 956 | |
957 | 957 | /** |
958 | 958 | * The Navigator shortcode. |
959 | 959 | */ |
960 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
960 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-navigator-shortcode.php'; |
|
961 | 961 | |
962 | 962 | /** |
963 | 963 | * The Products Navigator shortcode. |
964 | 964 | */ |
965 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-products-navigator-shortcode.php'; |
|
965 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-products-navigator-shortcode.php'; |
|
966 | 966 | |
967 | 967 | /** |
968 | 968 | * The chord shortcode. |
969 | 969 | */ |
970 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-chord-shortcode.php'; |
|
970 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-chord-shortcode.php'; |
|
971 | 971 | |
972 | 972 | /** |
973 | 973 | * The geomap shortcode. |
974 | 974 | */ |
975 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
975 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-geomap-shortcode.php'; |
|
976 | 976 | |
977 | 977 | /** |
978 | 978 | * The entity cloud shortcode. |
979 | 979 | */ |
980 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
980 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-related-entities-cloud-shortcode.php'; |
|
981 | 981 | |
982 | 982 | /** |
983 | 983 | * The entity glossary shortcode. |
984 | 984 | */ |
985 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-alphabet-service.php'; |
|
986 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-vocabulary-shortcode.php'; |
|
985 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-alphabet-service.php'; |
|
986 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-vocabulary-shortcode.php'; |
|
987 | 987 | |
988 | 988 | /** |
989 | 989 | * Faceted Search shortcode. |
990 | 990 | */ |
991 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-faceted-search-shortcode.php'; |
|
991 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-faceted-search-shortcode.php'; |
|
992 | 992 | |
993 | 993 | /** |
994 | 994 | * The ShareThis service. |
995 | 995 | */ |
996 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-sharethis-service.php'; |
|
996 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-sharethis-service.php'; |
|
997 | 997 | |
998 | 998 | /** |
999 | 999 | * The SEO service. |
1000 | 1000 | */ |
1001 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-seo-service.php'; |
|
1001 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-seo-service.php'; |
|
1002 | 1002 | |
1003 | 1003 | /** |
1004 | 1004 | * The AMP service. |
1005 | 1005 | */ |
1006 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-amp-service.php'; |
|
1006 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-amp-service.php'; |
|
1007 | 1007 | |
1008 | 1008 | /** Widgets */ |
1009 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-widget.php'; |
|
1010 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-related-entities-cloud-widget.php'; |
|
1011 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-context-cards-service.php'; |
|
1009 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-widget.php'; |
|
1010 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-related-entities-cloud-widget.php'; |
|
1011 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-context-cards-service.php'; |
|
1012 | 1012 | |
1013 | 1013 | /* |
1014 | 1014 | * Batch Operations. They're similar to Batch Actions but do not require working on post types. |
@@ -1017,8 +1017,8 @@ discard block |
||
1017 | 1017 | * |
1018 | 1018 | * @since 3.20.0 |
1019 | 1019 | */ |
1020 | - require_once plugin_dir_path( __DIR__ ) . 'includes/batch/intf-wordlift-batch-operation.php'; |
|
1021 | - require_once plugin_dir_path( __DIR__ ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
1020 | + require_once plugin_dir_path(__DIR__).'includes/batch/intf-wordlift-batch-operation.php'; |
|
1021 | + require_once plugin_dir_path(__DIR__).'includes/batch/class-wordlift-batch-operation-ajax-adapter.php'; |
|
1022 | 1022 | |
1023 | 1023 | /* |
1024 | 1024 | * Schema.org Services. |
@@ -1026,10 +1026,10 @@ discard block |
||
1026 | 1026 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
1027 | 1027 | */ |
1028 | 1028 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
1029 | - if ( apply_filters( 'wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES ) ) { |
|
1030 | - require_once plugin_dir_path( __DIR__ ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
1031 | - require_once plugin_dir_path( __DIR__ ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
1032 | - require_once plugin_dir_path( __DIR__ ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
1029 | + if (apply_filters('wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES)) { |
|
1030 | + require_once plugin_dir_path(__DIR__).'includes/schemaorg/class-wordlift-schemaorg-sync-service.php'; |
|
1031 | + require_once plugin_dir_path(__DIR__).'includes/schemaorg/class-wordlift-schemaorg-property-service.php'; |
|
1032 | + require_once plugin_dir_path(__DIR__).'includes/schemaorg/class-wordlift-schemaorg-class-service.php'; |
|
1033 | 1033 | new Wordlift_Schemaorg_Sync_Service(); |
1034 | 1034 | $schemaorg_property_service = Wordlift_Schemaorg_Property_Service::get_instance(); |
1035 | 1035 | new Wordlift_Schemaorg_Class_Service(); |
@@ -1045,13 +1045,13 @@ discard block |
||
1045 | 1045 | |
1046 | 1046 | // Instantiate a global logger. |
1047 | 1047 | global $wl_logger; |
1048 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
1048 | + $wl_logger = Wordlift_Log_Service::get_logger('WordLift'); |
|
1049 | 1049 | |
1050 | 1050 | // Load the `wl-api` end-point. |
1051 | 1051 | new Wordlift_Http_Api(); |
1052 | 1052 | |
1053 | 1053 | // Load the Install Service. |
1054 | - require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-service.php'; |
|
1054 | + require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-service.php'; |
|
1055 | 1055 | $this->install_service = new Wordlift_Install_Service(); |
1056 | 1056 | $this->notice_service = new Wordlift_Notice_Service(); |
1057 | 1057 | $this->user_service = Wordlift_User_Service::get_instance(); |
@@ -1073,21 +1073,21 @@ discard block |
||
1073 | 1073 | add_action( |
1074 | 1074 | 'plugins_loaded', |
1075 | 1075 | // phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable |
1076 | - function () use ( &$that, $schemaorg_property_service ) { |
|
1076 | + function() use (&$that, $schemaorg_property_service) { |
|
1077 | 1077 | |
1078 | 1078 | /** Services. */ |
1079 | 1079 | // Create the configuration service. |
1080 | 1080 | new Wordlift_Api_Service(); |
1081 | 1081 | |
1082 | 1082 | // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
1083 | - $that->entity_link_service = new Wordlift_Entity_Link_Service( $that->entity_post_type_service, Wordlift_Configuration_Service::get_instance()->get_entity_base_path() ); |
|
1083 | + $that->entity_link_service = new Wordlift_Entity_Link_Service($that->entity_post_type_service, Wordlift_Configuration_Service::get_instance()->get_entity_base_path()); |
|
1084 | 1084 | |
1085 | 1085 | $schema_url_property_service = new Wordlift_Schema_Url_Property_Service(); |
1086 | 1086 | |
1087 | 1087 | $that->entity_uri_service = Wordlift_Entity_Uri_Service::get_instance(); |
1088 | 1088 | |
1089 | 1089 | // Create a new instance of the Redirect service. |
1090 | - $that->redirect_service = new Wordlift_Redirect_Service( $that->entity_uri_service ); |
|
1090 | + $that->redirect_service = new Wordlift_Redirect_Service($that->entity_uri_service); |
|
1091 | 1091 | |
1092 | 1092 | // Create a new instance of the Timeline service and Timeline shortcode. |
1093 | 1093 | $that->timeline_service = new Wordlift_Timeline_Service(); |
@@ -1100,30 +1100,30 @@ discard block |
||
1100 | 1100 | // Create an instance of the PrimaShop adapter. |
1101 | 1101 | $that->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
1102 | 1102 | |
1103 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
1103 | + $uri_service = new Wordlift_Uri_Service($GLOBALS['wpdb']); |
|
1104 | 1104 | |
1105 | 1105 | // Create the entity rating service. |
1106 | 1106 | $that->rating_service = Wordlift_Rating_Service::get_instance(); |
1107 | 1107 | |
1108 | 1108 | // Create entity list customization (wp-admin/edit.php). |
1109 | - $that->entity_list_service = new Wordlift_Entity_List_Service( $that->rating_service ); |
|
1109 | + $that->entity_list_service = new Wordlift_Entity_List_Service($that->rating_service); |
|
1110 | 1110 | |
1111 | 1111 | // Create an instance of the Publisher Service and the AJAX Adapter. |
1112 | 1112 | $that->publisher_service = Wordlift_Publisher_Service::get_instance(); |
1113 | - $that->property_factory = new Wordlift_Property_Factory( $schema_url_property_service ); |
|
1114 | - $that->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service ); |
|
1113 | + $that->property_factory = new Wordlift_Property_Factory($schema_url_property_service); |
|
1114 | + $that->property_factory->register(Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service); |
|
1115 | 1115 | |
1116 | 1116 | $attachment_service = Wordlift_Attachment_Service::get_instance(); |
1117 | 1117 | |
1118 | 1118 | // Instantiate the JSON-LD service. |
1119 | 1119 | $property_getter = Wordlift_Property_Getter_Factory::create(); |
1120 | - $that->post_to_jsonld_converter = new Wordlift_Post_To_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service ); |
|
1121 | - $that->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $that->post_to_jsonld_converter ); |
|
1122 | - $that->postid_to_jsonld_converter = new Wordlift_Postid_To_Jsonld_Converter( $that->entity_post_to_jsonld_converter, $that->post_to_jsonld_converter ); |
|
1123 | - $that->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service ); |
|
1120 | + $that->post_to_jsonld_converter = new Wordlift_Post_To_Jsonld_Converter(Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service); |
|
1121 | + $that->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter(Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $that->post_to_jsonld_converter); |
|
1122 | + $that->postid_to_jsonld_converter = new Wordlift_Postid_To_Jsonld_Converter($that->entity_post_to_jsonld_converter, $that->post_to_jsonld_converter); |
|
1123 | + $that->jsonld_website_converter = new Wordlift_Website_Jsonld_Converter(Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service); |
|
1124 | 1124 | |
1125 | - $jsonld_cache = new Ttl_Cache( 'jsonld', 86400 ); |
|
1126 | - $that->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $that->postid_to_jsonld_converter, $jsonld_cache ); |
|
1125 | + $jsonld_cache = new Ttl_Cache('jsonld', 86400); |
|
1126 | + $that->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter($that->postid_to_jsonld_converter, $jsonld_cache); |
|
1127 | 1127 | /* |
1128 | 1128 | * Load the `Wordlift_Term_JsonLd_Adapter`. |
1129 | 1129 | * |
@@ -1131,22 +1131,22 @@ discard block |
||
1131 | 1131 | * |
1132 | 1132 | * @since 3.20.0 |
1133 | 1133 | */ |
1134 | - require_once plugin_dir_path( __DIR__ ) . 'public/class-wordlift-term-jsonld-adapter.php'; |
|
1134 | + require_once plugin_dir_path(__DIR__).'public/class-wordlift-term-jsonld-adapter.php'; |
|
1135 | 1135 | |
1136 | - $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter( $that->entity_uri_service, $that->cached_postid_to_jsonld_converter ); |
|
1137 | - $that->jsonld_service = new Wordlift_Jsonld_Service( Wordlift_Entity_Service::get_instance(), $that->cached_postid_to_jsonld_converter, $that->jsonld_website_converter, $term_jsonld_adapter ); |
|
1136 | + $term_jsonld_adapter = new Wordlift_Term_JsonLd_Adapter($that->entity_uri_service, $that->cached_postid_to_jsonld_converter); |
|
1137 | + $that->jsonld_service = new Wordlift_Jsonld_Service(Wordlift_Entity_Service::get_instance(), $that->cached_postid_to_jsonld_converter, $that->jsonld_website_converter, $term_jsonld_adapter); |
|
1138 | 1138 | |
1139 | 1139 | $jsonld_service = new Jsonld_Service( |
1140 | 1140 | $that->jsonld_service, |
1141 | 1141 | $term_jsonld_adapter, |
1142 | - new Jsonld_User_Service( $that->user_service ) |
|
1142 | + new Jsonld_User_Service($that->user_service) |
|
1143 | 1143 | ); |
1144 | - new Jsonld_Endpoint( $jsonld_service, $that->entity_uri_service ); |
|
1144 | + new Jsonld_Endpoint($jsonld_service, $that->entity_uri_service); |
|
1145 | 1145 | |
1146 | 1146 | // Prints the JSON-LD in the head. |
1147 | - new Jsonld_Adapter( $that->jsonld_service ); |
|
1147 | + new Jsonld_Adapter($that->jsonld_service); |
|
1148 | 1148 | |
1149 | - new Jsonld_By_Id_Endpoint( $that->jsonld_service, $that->entity_uri_service ); |
|
1149 | + new Jsonld_By_Id_Endpoint($that->jsonld_service, $that->entity_uri_service); |
|
1150 | 1150 | |
1151 | 1151 | $that->key_validation_service = new Wordlift_Key_Validation_Service(); |
1152 | 1152 | |
@@ -1154,10 +1154,10 @@ discard block |
||
1154 | 1154 | // Creating Faq Content filter service. |
1155 | 1155 | $that->faq_content_filter_service = new Faq_Content_Filter(); |
1156 | 1156 | $that->sample_data_service = Wordlift_Sample_Data_Service::get_instance(); |
1157 | - $that->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $that->sample_data_service ); |
|
1157 | + $that->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter($that->sample_data_service); |
|
1158 | 1158 | |
1159 | - $that->loader->add_action( 'enqueue_block_editor_assets', $that, 'add_wl_enabled_blocks' ); |
|
1160 | - $that->loader->add_action( 'admin_enqueue_scripts', $that, 'add_wl_enabled_blocks' ); |
|
1159 | + $that->loader->add_action('enqueue_block_editor_assets', $that, 'add_wl_enabled_blocks'); |
|
1160 | + $that->loader->add_action('admin_enqueue_scripts', $that, 'add_wl_enabled_blocks'); |
|
1161 | 1161 | |
1162 | 1162 | /** |
1163 | 1163 | * Filter: wl_feature__enable__blocks. |
@@ -1167,15 +1167,15 @@ discard block |
||
1167 | 1167 | * @return bool |
1168 | 1168 | * @since 3.27.6 |
1169 | 1169 | */ |
1170 | - if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
1170 | + if (apply_filters('wl_feature__enable__blocks', true)) { |
|
1171 | 1171 | // Initialize the short-codes. |
1172 | - new Async_Template_Decorator( new Wordlift_Navigator_Shortcode() ); |
|
1172 | + new Async_Template_Decorator(new Wordlift_Navigator_Shortcode()); |
|
1173 | 1173 | new Wordlift_Chord_Shortcode(); |
1174 | 1174 | new Wordlift_Geomap_Shortcode(); |
1175 | 1175 | new Wordlift_Timeline_Shortcode(); |
1176 | - new Wordlift_Related_Entities_Cloud_Shortcode( Wordlift_Relation_Service::get_instance(), Wordlift_Entity_Service::get_instance() ); |
|
1176 | + new Wordlift_Related_Entities_Cloud_Shortcode(Wordlift_Relation_Service::get_instance(), Wordlift_Entity_Service::get_instance()); |
|
1177 | 1177 | new Wordlift_Vocabulary_Shortcode(); |
1178 | - new Async_Template_Decorator( new Wordlift_Faceted_Search_Shortcode() ); |
|
1178 | + new Async_Template_Decorator(new Wordlift_Faceted_Search_Shortcode()); |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | new Wordlift_Products_Navigator_Shortcode(); |
@@ -1187,16 +1187,16 @@ discard block |
||
1187 | 1187 | new Wordlift_Seo_Service(); |
1188 | 1188 | |
1189 | 1189 | // Initialize the AMP service. |
1190 | - new Wordlift_AMP_Service( $that->jsonld_service ); |
|
1190 | + new Wordlift_AMP_Service($that->jsonld_service); |
|
1191 | 1191 | |
1192 | 1192 | /** Services. */ |
1193 | 1193 | $that->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service(); |
1194 | 1194 | new Wordlift_Image_Service(); |
1195 | 1195 | |
1196 | 1196 | /** Adapters. */ |
1197 | - $that->entity_type_adapter = new Wordlift_Entity_Type_Adapter( Wordlift_Entity_Type_Service::get_instance() ); |
|
1198 | - $that->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $that->publisher_service ); |
|
1199 | - $that->tinymce_adapter = new Wordlift_Tinymce_Adapter( $that ); |
|
1197 | + $that->entity_type_adapter = new Wordlift_Entity_Type_Adapter(Wordlift_Entity_Type_Service::get_instance()); |
|
1198 | + $that->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter($that->publisher_service); |
|
1199 | + $that->tinymce_adapter = new Wordlift_Tinymce_Adapter($that); |
|
1200 | 1200 | |
1201 | 1201 | /* |
1202 | 1202 | * Exclude our public js from WP-Rocket. |
@@ -1220,14 +1220,14 @@ discard block |
||
1220 | 1220 | $that->language_select_element = new Wordlift_Admin_Language_Select_Element(); |
1221 | 1221 | $that->country_select_element = new Wordlift_Admin_Country_Select_Element(); |
1222 | 1222 | $tabs_element = new Wordlift_Admin_Tabs_Element(); |
1223 | - $that->publisher_element = new Wordlift_Admin_Publisher_Element( $that->publisher_service, $tabs_element, $that->select2_element ); |
|
1224 | - $that->author_element = new Wordlift_Admin_Author_Element( $that->publisher_service, $that->select2_element ); |
|
1223 | + $that->publisher_element = new Wordlift_Admin_Publisher_Element($that->publisher_service, $tabs_element, $that->select2_element); |
|
1224 | + $that->author_element = new Wordlift_Admin_Author_Element($that->publisher_service, $that->select2_element); |
|
1225 | 1225 | |
1226 | 1226 | $that->settings_page = Wordlift_Admin_Settings_Page::get_instance(); |
1227 | - $that->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $that->settings_page ); |
|
1227 | + $that->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link($that->settings_page); |
|
1228 | 1228 | |
1229 | - $that->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page( $that->input_element, $that->radio_input_element ); |
|
1230 | - $that->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $that->analytics_settings_page ); |
|
1229 | + $that->analytics_settings_page = new Wordlift_Admin_Settings_Analytics_Page($that->input_element, $that->radio_input_element); |
|
1230 | + $that->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link($that->analytics_settings_page); |
|
1231 | 1231 | $that->analytics_connect = new Wordlift_Analytics_Connect(); |
1232 | 1232 | |
1233 | 1233 | // Pages. |
@@ -1238,9 +1238,9 @@ discard block |
||
1238 | 1238 | * |
1239 | 1239 | * @see https://github.com/insideout10/wordlift-plugin/issues/914 |
1240 | 1240 | */ |
1241 | - if ( apply_filters( 'wl_can_see_classification_box', true ) ) { |
|
1242 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin-post-edit-page.php'; |
|
1243 | - new Wordlift_Admin_Post_Edit_Page( $that ); |
|
1241 | + if (apply_filters('wl_can_see_classification_box', true)) { |
|
1242 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin-post-edit-page.php'; |
|
1243 | + new Wordlift_Admin_Post_Edit_Page($that); |
|
1244 | 1244 | } |
1245 | 1245 | new Wordlift_Entity_Type_Admin_Service(); |
1246 | 1246 | |
@@ -1248,19 +1248,19 @@ discard block |
||
1248 | 1248 | $that->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget(); |
1249 | 1249 | |
1250 | 1250 | // Create an instance of the install wizard. |
1251 | - $that->admin_setup = new Wordlift_Admin_Setup( $that->key_validation_service, Wordlift_Entity_Service::get_instance(), $that->language_select_element, $that->country_select_element ); |
|
1251 | + $that->admin_setup = new Wordlift_Admin_Setup($that->key_validation_service, Wordlift_Entity_Service::get_instance(), $that->language_select_element, $that->country_select_element); |
|
1252 | 1252 | |
1253 | - $that->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $that->entity_post_type_service ); |
|
1253 | + $that->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service($that->entity_post_type_service); |
|
1254 | 1254 | |
1255 | 1255 | // User Profile. |
1256 | - new Wordlift_Admin_User_Profile_Page( $that->author_element, $that->user_service ); |
|
1256 | + new Wordlift_Admin_User_Profile_Page($that->author_element, $that->user_service); |
|
1257 | 1257 | |
1258 | 1258 | $that->entity_page_service = new Wordlift_Entity_Page_Service(); |
1259 | 1259 | |
1260 | 1260 | // Load the debug service if WP is in debug mode. |
1261 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
1262 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-debug-service.php'; |
|
1263 | - new Wordlift_Debug_Service( Wordlift_Entity_Service::get_instance(), $uri_service ); |
|
1261 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
1262 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-debug-service.php'; |
|
1263 | + new Wordlift_Debug_Service(Wordlift_Entity_Service::get_instance(), $uri_service); |
|
1264 | 1264 | } |
1265 | 1265 | |
1266 | 1266 | // Remote Image Service. |
@@ -1273,12 +1273,12 @@ discard block |
||
1273 | 1273 | * |
1274 | 1274 | * @see https://github.com/insideout10/wordlift-plugin/issues/852. |
1275 | 1275 | */ |
1276 | - require_once plugin_dir_path( __DIR__ ) . 'includes/class-wordlift-batch-action.php'; |
|
1277 | - require_once plugin_dir_path( __DIR__ ) . 'includes/mapping/class-wordlift-mapping-service.php'; |
|
1278 | - require_once plugin_dir_path( __DIR__ ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
1276 | + require_once plugin_dir_path(__DIR__).'includes/class-wordlift-batch-action.php'; |
|
1277 | + require_once plugin_dir_path(__DIR__).'includes/mapping/class-wordlift-mapping-service.php'; |
|
1278 | + require_once plugin_dir_path(__DIR__).'includes/mapping/class-wordlift-mapping-ajax-adapter.php'; |
|
1279 | 1279 | |
1280 | 1280 | // Create an instance of the Mapping Service and assign it to the Ajax Adapter. |
1281 | - new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) ); |
|
1281 | + new Wordlift_Mapping_Ajax_Adapter(new Wordlift_Mapping_Service(Wordlift_Entity_Type_Service::get_instance())); |
|
1282 | 1282 | |
1283 | 1283 | /* |
1284 | 1284 | * Load the Mappings JSON-LD post processing. |
@@ -1292,11 +1292,11 @@ discard block |
||
1292 | 1292 | // Taxonomy term rule validator for validating rules for term pages. |
1293 | 1293 | new Taxonomy_Term_Rule_Validator(); |
1294 | 1294 | new Post_Taxonomy_Term_Rule_Validator(); |
1295 | - $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator ); |
|
1296 | - $rule_groups_validator = new Rule_Groups_Validator( $rule_validators_registry ); |
|
1297 | - $mappings_validator = new Mappings_Validator( $mappings_dbo, $rule_groups_validator ); |
|
1295 | + $rule_validators_registry = new Rule_Validators_Registry($default_rule_validator); |
|
1296 | + $rule_groups_validator = new Rule_Groups_Validator($rule_validators_registry); |
|
1297 | + $mappings_validator = new Mappings_Validator($mappings_dbo, $rule_groups_validator); |
|
1298 | 1298 | |
1299 | - new Url_To_Entity_Transform_Function( $that->entity_uri_service ); |
|
1299 | + new Url_To_Entity_Transform_Function($that->entity_uri_service); |
|
1300 | 1300 | new Taxonomy_To_Terms_Transform_Function(); |
1301 | 1301 | new Post_Id_To_Entity_Transform_Function(); |
1302 | 1302 | $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry(); |
@@ -1306,7 +1306,7 @@ discard block |
||
1306 | 1306 | * Intiailize the acf group data formatter. |
1307 | 1307 | */ |
1308 | 1308 | new Acf_Group_Formatter(); |
1309 | - new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry ); |
|
1309 | + new Jsonld_Converter($mappings_validator, $mappings_transform_functions_registry); |
|
1310 | 1310 | |
1311 | 1311 | /** |
1312 | 1312 | * @since 3.26.0 |
@@ -1324,16 +1324,16 @@ discard block |
||
1324 | 1324 | // Call this static method to register FAQ routes to rest api - disabled |
1325 | 1325 | // Faq_Rest_Controller::register_routes(); |
1326 | 1326 | |
1327 | - $that->storage_factory = new Wordlift_Storage_Factory( Wordlift_Entity_Service::get_instance(), $that->user_service, $property_getter ); |
|
1327 | + $that->storage_factory = new Wordlift_Storage_Factory(Wordlift_Entity_Service::get_instance(), $that->user_service, $property_getter); |
|
1328 | 1328 | |
1329 | 1329 | /** WL Autocomplete. */ |
1330 | - $autocomplete_service = new All_Autocomplete_Service( |
|
1330 | + $autocomplete_service = new All_Autocomplete_Service( |
|
1331 | 1331 | array( |
1332 | 1332 | new Local_Autocomplete_Service(), |
1333 | - new Linked_Data_Autocomplete_Service( Entity_Helper::get_instance(), $that->entity_uri_service, Wordlift_Entity_Service::get_instance() ), |
|
1333 | + new Linked_Data_Autocomplete_Service(Entity_Helper::get_instance(), $that->entity_uri_service, Wordlift_Entity_Service::get_instance()), |
|
1334 | 1334 | ) |
1335 | 1335 | ); |
1336 | - $that->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service ); |
|
1336 | + $that->autocomplete_adapter = new Wordlift_Autocomplete_Adapter($autocomplete_service); |
|
1337 | 1337 | |
1338 | 1338 | /** |
1339 | 1339 | * @since 3.27.2 |
@@ -1342,10 +1342,10 @@ discard block |
||
1342 | 1342 | */ |
1343 | 1343 | new Recipe_Maker_Post_Type_Hook(); |
1344 | 1344 | $recipe_maker_validation_service = new Recipe_Maker_Validation_Service(); |
1345 | - new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service ); |
|
1346 | - new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service ); |
|
1347 | - new Recipe_Maker_Jsonld_Swap( $recipe_maker_validation_service, $that->jsonld_service ); |
|
1348 | - new Recipe_Maker_Warning( $recipe_maker_validation_service ); |
|
1345 | + new Recipe_Maker_Jsonld_Hook($attachment_service, $recipe_maker_validation_service); |
|
1346 | + new Recipe_Maker_After_Get_Jsonld_Hook($recipe_maker_validation_service); |
|
1347 | + new Recipe_Maker_Jsonld_Swap($recipe_maker_validation_service, $that->jsonld_service); |
|
1348 | + new Recipe_Maker_Warning($recipe_maker_validation_service); |
|
1349 | 1349 | |
1350 | 1350 | /** |
1351 | 1351 | * Avada Builder compatibility. |
@@ -1360,7 +1360,7 @@ discard block |
||
1360 | 1360 | * @since 3.27.8 |
1361 | 1361 | * @see https://github.com/insideout10/wordlift-plugin/issues/1248 |
1362 | 1362 | */ |
1363 | - new Key_Validation_Notice( $that->key_validation_service, Wordlift_Configuration_Service::get_instance() ); |
|
1363 | + new Key_Validation_Notice($that->key_validation_service, Wordlift_Configuration_Service::get_instance()); |
|
1364 | 1364 | |
1365 | 1365 | /** |
1366 | 1366 | * @since 3.28.0 |
@@ -1372,7 +1372,7 @@ discard block |
||
1372 | 1372 | * @since 3.29.0 |
1373 | 1373 | * @see https://github.com/insideout10/wordlift-plugin/issues/1304 |
1374 | 1374 | */ |
1375 | - new Entity_Rest_Service( Wordlift_Entity_Type_Service::get_instance() ); |
|
1375 | + new Entity_Rest_Service(Wordlift_Entity_Type_Service::get_instance()); |
|
1376 | 1376 | |
1377 | 1377 | /** |
1378 | 1378 | * Expand author in to references. |
@@ -1381,12 +1381,12 @@ discard block |
||
1381 | 1381 | * @see https://github.com/insideout10/wordlift-plugin/issues/1318 |
1382 | 1382 | */ |
1383 | 1383 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
1384 | - if ( apply_filters( 'wl_feature__enable__article-wrapper', false ) ) { |
|
1385 | - new Jsonld_Article_Wrapper( Wordlift_Post_To_Jsonld_Converter::get_instance(), $that->cached_postid_to_jsonld_converter ); |
|
1384 | + if (apply_filters('wl_feature__enable__article-wrapper', false)) { |
|
1385 | + new Jsonld_Article_Wrapper(Wordlift_Post_To_Jsonld_Converter::get_instance(), $that->cached_postid_to_jsonld_converter); |
|
1386 | 1386 | } |
1387 | 1387 | |
1388 | 1388 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
1389 | - if ( apply_filters( 'wl_feature__enable__match-terms', false ) ) { |
|
1389 | + if (apply_filters('wl_feature__enable__match-terms', false)) { |
|
1390 | 1390 | $vocabulary_loader = new Vocabulary_Loader(); |
1391 | 1391 | $vocabulary_loader->init_vocabulary(); |
1392 | 1392 | } |
@@ -1394,7 +1394,7 @@ discard block |
||
1394 | 1394 | /** |
1395 | 1395 | * Added for feature request 1496 (Webhooks) |
1396 | 1396 | */ |
1397 | - if ( apply_filters( 'wl_feature__enable__webhooks', false ) ) { |
|
1397 | + if (apply_filters('wl_feature__enable__webhooks', false)) { |
|
1398 | 1398 | $that->webhook_loader = new Webhooks_Loader(); |
1399 | 1399 | $that->webhook_loader->init(); |
1400 | 1400 | } |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | * @since 3.31.5 |
1424 | 1424 | * Create configuration endpoint for webapp to configure. |
1425 | 1425 | */ |
1426 | - new Config( $that->admin_setup, $that->key_validation_service ); |
|
1426 | + new Config($that->admin_setup, $that->key_validation_service); |
|
1427 | 1427 | /** |
1428 | 1428 | * @since 3.31.7 |
1429 | 1429 | * Remove duplicate videoobject. |
@@ -1435,7 +1435,7 @@ discard block |
||
1435 | 1435 | * @since 3.32.0 |
1436 | 1436 | * Create loader for vocabulary terms. |
1437 | 1437 | */ |
1438 | - $vocabulary_terms_loader = new Vocabulary_Terms_Loader( Wordlift_Entity_Type_Service::get_instance(), $property_getter ); |
|
1438 | + $vocabulary_terms_loader = new Vocabulary_Terms_Loader(Wordlift_Entity_Type_Service::get_instance(), $property_getter); |
|
1439 | 1439 | $vocabulary_terms_loader->init_feature(); |
1440 | 1440 | |
1441 | 1441 | new Entity_Type_Change_Handler( |
@@ -1464,9 +1464,9 @@ discard block |
||
1464 | 1464 | private function set_locale() { |
1465 | 1465 | |
1466 | 1466 | $plugin_i18n = new Wordlift_I18n(); |
1467 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
1467 | + $plugin_i18n->set_domain($this->get_plugin_name()); |
|
1468 | 1468 | |
1469 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
1469 | + $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'); |
|
1470 | 1470 | |
1471 | 1471 | } |
1472 | 1472 | |
@@ -1477,7 +1477,7 @@ discard block |
||
1477 | 1477 | * @since 1.0.0 |
1478 | 1478 | * @access private |
1479 | 1479 | */ |
1480 | - private function define_admin_hooks( $that ) { |
|
1480 | + private function define_admin_hooks($that) { |
|
1481 | 1481 | $plugin_admin = new Wordlift_Admin( |
1482 | 1482 | $that->get_plugin_name(), |
1483 | 1483 | $that->get_version(), |
@@ -1485,51 +1485,51 @@ discard block |
||
1485 | 1485 | $that->user_service |
1486 | 1486 | ); |
1487 | 1487 | |
1488 | - $that->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
1489 | - $that->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 ); |
|
1488 | + $that->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); |
|
1489 | + $that->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11); |
|
1490 | 1490 | |
1491 | 1491 | // Hook the `admin_init` function to the Admin Setup. |
1492 | - Assertions::is_set( $that->admin_setup, '`admin_setup` must be set' ); |
|
1493 | - $that->loader->add_action( 'admin_init', $that->admin_setup, 'admin_init' ); |
|
1492 | + Assertions::is_set($that->admin_setup, '`admin_setup` must be set'); |
|
1493 | + $that->loader->add_action('admin_init', $that->admin_setup, 'admin_init'); |
|
1494 | 1494 | |
1495 | 1495 | // Hook the admin_init to the settings page. |
1496 | - Assertions::is_set( $that->settings_page, '`setting_page` must be set' ); |
|
1497 | - $that->loader->add_action( 'admin_init', $that->settings_page, 'admin_init' ); |
|
1496 | + Assertions::is_set($that->settings_page, '`setting_page` must be set'); |
|
1497 | + $that->loader->add_action('admin_init', $that->settings_page, 'admin_init'); |
|
1498 | 1498 | |
1499 | 1499 | // Hook the admin_init to the analytics settings page. |
1500 | - Assertions::is_set( $that->analytics_settings_page, '`analytics_setting_page` must be set' ); |
|
1501 | - $that->loader->add_action( 'admin_init', $that->analytics_settings_page, 'admin_init' ); |
|
1500 | + Assertions::is_set($that->analytics_settings_page, '`analytics_setting_page` must be set'); |
|
1501 | + $that->loader->add_action('admin_init', $that->analytics_settings_page, 'admin_init'); |
|
1502 | 1502 | |
1503 | 1503 | // Hook the init action to taxonomy services. |
1504 | - $that->loader->add_action( 'init', $that->topic_taxonomy_service, 'init', 0 ); |
|
1505 | - $that->loader->add_action( 'init', $that->entity_types_taxonomy_service, 'init', 0 ); |
|
1504 | + $that->loader->add_action('init', $that->topic_taxonomy_service, 'init', 0); |
|
1505 | + $that->loader->add_action('init', $that->entity_types_taxonomy_service, 'init', 0); |
|
1506 | 1506 | |
1507 | 1507 | // Hook the AJAX wl_timeline action to the Timeline service. |
1508 | - $that->loader->add_action( 'wp_ajax_wl_timeline', $that->timeline_service, 'ajax_timeline' ); |
|
1508 | + $that->loader->add_action('wp_ajax_wl_timeline', $that->timeline_service, 'ajax_timeline'); |
|
1509 | 1509 | |
1510 | 1510 | // Register custom allowed redirect hosts. |
1511 | - $that->loader->add_filter( 'allowed_redirect_hosts', $that->redirect_service, 'allowed_redirect_hosts' ); |
|
1511 | + $that->loader->add_filter('allowed_redirect_hosts', $that->redirect_service, 'allowed_redirect_hosts'); |
|
1512 | 1512 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
1513 | - $that->loader->add_action( 'wp_ajax_wordlift_redirect', $that->redirect_service, 'ajax_redirect' ); |
|
1513 | + $that->loader->add_action('wp_ajax_wordlift_redirect', $that->redirect_service, 'ajax_redirect'); |
|
1514 | 1514 | |
1515 | 1515 | // Hook save_post to the entity service to update custom fields (such as alternate labels). |
1516 | 1516 | // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
1517 | - $that->loader->add_action( 'save_post', Wordlift_Entity_Service::get_instance(), 'save_post', 9, 2 ); |
|
1518 | - $that->loader->add_action( 'save_post', $that->rating_service, 'set_rating_for', 20, 1 ); |
|
1517 | + $that->loader->add_action('save_post', Wordlift_Entity_Service::get_instance(), 'save_post', 9, 2); |
|
1518 | + $that->loader->add_action('save_post', $that->rating_service, 'set_rating_for', 20, 1); |
|
1519 | 1519 | |
1520 | - $that->loader->add_action( 'edit_form_before_permalink', Wordlift_Entity_Service::get_instance(), 'edit_form_before_permalink', 10, 1 ); |
|
1521 | - $that->loader->add_action( 'in_admin_header', $that->rating_service, 'in_admin_header' ); |
|
1520 | + $that->loader->add_action('edit_form_before_permalink', Wordlift_Entity_Service::get_instance(), 'edit_form_before_permalink', 10, 1); |
|
1521 | + $that->loader->add_action('in_admin_header', $that->rating_service, 'in_admin_header'); |
|
1522 | 1522 | |
1523 | 1523 | // Entity listing customization (wp-admin/edit.php) |
1524 | 1524 | // Add custom columns. |
1525 | - $that->loader->add_filter( 'manage_entity_posts_columns', $that->entity_list_service, 'register_custom_columns' ); |
|
1525 | + $that->loader->add_filter('manage_entity_posts_columns', $that->entity_list_service, 'register_custom_columns'); |
|
1526 | 1526 | // no explicit entity as it prevents handling of other post types. |
1527 | - $that->loader->add_filter( 'manage_posts_custom_column', $that->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
1527 | + $that->loader->add_filter('manage_posts_custom_column', $that->entity_list_service, 'render_custom_columns', 10, 2); |
|
1528 | 1528 | // Add 4W selection. |
1529 | - $that->loader->add_action( 'restrict_manage_posts', $that->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
1530 | - $that->loader->add_filter( 'posts_clauses', $that->entity_list_service, 'posts_clauses_classification_scope' ); |
|
1531 | - $that->loader->add_action( 'pre_get_posts', $that->entity_list_service, 'pre_get_posts' ); |
|
1532 | - $that->loader->add_action( 'load-edit.php', $that->entity_list_service, 'load_edit' ); |
|
1529 | + $that->loader->add_action('restrict_manage_posts', $that->entity_list_service, 'restrict_manage_posts_classification_scope'); |
|
1530 | + $that->loader->add_filter('posts_clauses', $that->entity_list_service, 'posts_clauses_classification_scope'); |
|
1531 | + $that->loader->add_action('pre_get_posts', $that->entity_list_service, 'pre_get_posts'); |
|
1532 | + $that->loader->add_action('load-edit.php', $that->entity_list_service, 'load_edit'); |
|
1533 | 1533 | |
1534 | 1534 | /* |
1535 | 1535 | * If `All Entity Types` is disable, use the radio button Walker. |
@@ -1537,18 +1537,18 @@ discard block |
||
1537 | 1537 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
1538 | 1538 | */ |
1539 | 1539 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
1540 | - if ( ! apply_filters( 'wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES ) |
|
1540 | + if ( ! apply_filters('wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES) |
|
1541 | 1541 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
1542 | - && ! apply_filters( 'wl_feature__enable__entity-types-professional', false ) |
|
1542 | + && ! apply_filters('wl_feature__enable__entity-types-professional', false) |
|
1543 | 1543 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
1544 | - && ! apply_filters( 'wl_feature__enable__entity-types-business', false ) |
|
1544 | + && ! apply_filters('wl_feature__enable__entity-types-business', false) |
|
1545 | 1545 | ) { |
1546 | - $that->loader->add_filter( 'wp_terms_checklist_args', $that->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
1546 | + $that->loader->add_filter('wp_terms_checklist_args', $that->entity_types_taxonomy_walker, 'terms_checklist_args'); |
|
1547 | 1547 | } |
1548 | 1548 | |
1549 | 1549 | // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
1550 | 1550 | // entities. |
1551 | - $that->loader->add_filter( 'prima_metabox_entity_header_args', $that->primashop_adapter, 'prima_metabox_entity_header_args', 10 ); |
|
1551 | + $that->loader->add_filter('prima_metabox_entity_header_args', $that->primashop_adapter, 'prima_metabox_entity_header_args', 10); |
|
1552 | 1552 | |
1553 | 1553 | /** |
1554 | 1554 | * Filter: wl_feature__enable__settings-download. |
@@ -1568,20 +1568,20 @@ discard block |
||
1568 | 1568 | ); |
1569 | 1569 | |
1570 | 1570 | // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links. |
1571 | - $that->loader->add_action( 'wp_ajax_wl_download_your_data', $that->download_your_data_page, 'download_your_data', 10 ); |
|
1571 | + $that->loader->add_action('wp_ajax_wl_download_your_data', $that->download_your_data_page, 'download_your_data', 10); |
|
1572 | 1572 | |
1573 | 1573 | // Hook the AJAX wl_jsonld action to the JSON-LD service. |
1574 | - $that->loader->add_action( 'wp_ajax_wl_jsonld', $that->jsonld_service, 'get' ); |
|
1575 | - $that->loader->add_action( 'admin_post_wl_jsonld', $that->jsonld_service, 'get' ); |
|
1576 | - $that->loader->add_action( 'admin_post_nopriv_wl_jsonld', $that->jsonld_service, 'get' ); |
|
1574 | + $that->loader->add_action('wp_ajax_wl_jsonld', $that->jsonld_service, 'get'); |
|
1575 | + $that->loader->add_action('admin_post_wl_jsonld', $that->jsonld_service, 'get'); |
|
1576 | + $that->loader->add_action('admin_post_nopriv_wl_jsonld', $that->jsonld_service, 'get'); |
|
1577 | 1577 | |
1578 | 1578 | // Hook the AJAX wl_validate_key action to the Key Validation service. |
1579 | - $that->loader->add_action( 'wp_ajax_wl_validate_key', $that->key_validation_service, 'validate_key' ); |
|
1579 | + $that->loader->add_action('wp_ajax_wl_validate_key', $that->key_validation_service, 'validate_key'); |
|
1580 | 1580 | |
1581 | 1581 | // Hook the AJAX wl_update_country_options action to the countries. |
1582 | - $that->loader->add_action( 'wp_ajax_wl_update_country_options', $that->country_select_element, 'get_options_html' ); |
|
1582 | + $that->loader->add_action('wp_ajax_wl_update_country_options', $that->country_select_element, 'get_options_html'); |
|
1583 | 1583 | |
1584 | - $that->loader->add_filter( 'admin_post_thumbnail_html', $that->publisher_service, 'add_featured_image_instruction' ); |
|
1584 | + $that->loader->add_filter('admin_post_thumbnail_html', $that->publisher_service, 'add_featured_image_instruction'); |
|
1585 | 1585 | |
1586 | 1586 | // Hook the menu creation on the general wordlift menu creation. |
1587 | 1587 | /** |
@@ -1595,16 +1595,16 @@ discard block |
||
1595 | 1595 | * Since 3.30.0 this feature is registered using registry. |
1596 | 1596 | */ |
1597 | 1597 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
1598 | - if ( apply_filters( 'wl_feature__enable__settings-screen', true ) || Admin_User_Option::is_wordlift_admin() ) { |
|
1599 | - add_action( 'wl_admin_menu', array( $that->settings_page, 'admin_menu' ), 10, 2 ); |
|
1598 | + if (apply_filters('wl_feature__enable__settings-screen', true) || Admin_User_Option::is_wordlift_admin()) { |
|
1599 | + add_action('wl_admin_menu', array($that->settings_page, 'admin_menu'), 10, 2); |
|
1600 | 1600 | } |
1601 | 1601 | |
1602 | 1602 | // Hook key update. |
1603 | - $that->loader->add_action( 'pre_update_option_wl_general_settings', Wordlift_Configuration_Service::get_instance(), 'maybe_update_dataset_uri', 10, 2 ); |
|
1604 | - $that->loader->add_action( 'update_option_wl_general_settings', Wordlift_Configuration_Service::get_instance(), 'update_key', 10, 2 ); |
|
1603 | + $that->loader->add_action('pre_update_option_wl_general_settings', Wordlift_Configuration_Service::get_instance(), 'maybe_update_dataset_uri', 10, 2); |
|
1604 | + $that->loader->add_action('update_option_wl_general_settings', Wordlift_Configuration_Service::get_instance(), 'update_key', 10, 2); |
|
1605 | 1605 | |
1606 | 1606 | // Add additional action links to the WordLift plugin in the plugins page. |
1607 | - $that->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $that->settings_page_action_link, 'action_links', 10, 1 ); |
|
1607 | + $that->loader->add_filter('plugin_action_links_wordlift/wordlift.php', $that->settings_page_action_link, 'action_links', 10, 1); |
|
1608 | 1608 | |
1609 | 1609 | /* |
1610 | 1610 | * Remove the Analytics Settings link from the plugin page. |
@@ -1615,23 +1615,23 @@ discard block |
||
1615 | 1615 | // $that->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $that->analytics_settings_page_action_link, 'action_links', 10, 1 ); |
1616 | 1616 | |
1617 | 1617 | // Hook the AJAX `wl_publisher` action name. |
1618 | - $that->loader->add_action( 'wp_ajax_wl_publisher', $that->publisher_ajax_adapter, 'publisher' ); |
|
1618 | + $that->loader->add_action('wp_ajax_wl_publisher', $that->publisher_ajax_adapter, 'publisher'); |
|
1619 | 1619 | |
1620 | 1620 | // Hook row actions for the entity type list admin. |
1621 | - $that->loader->add_filter( 'wl_entity_type_row_actions', $that->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 ); |
|
1621 | + $that->loader->add_filter('wl_entity_type_row_actions', $that->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2); |
|
1622 | 1622 | |
1623 | 1623 | /** Ajax actions. */ |
1624 | - $that->loader->add_action( 'wp_ajax_wl_google_analytics_export', $that->google_analytics_export_service, 'export' ); |
|
1624 | + $that->loader->add_action('wp_ajax_wl_google_analytics_export', $that->google_analytics_export_service, 'export'); |
|
1625 | 1625 | |
1626 | 1626 | // Hook capabilities manipulation to allow access to entity type admin |
1627 | 1627 | // page on WordPress versions before 4.7. |
1628 | 1628 | global $wp_version; |
1629 | - if ( version_compare( $wp_version, '4.7', '<' ) ) { |
|
1630 | - $that->loader->add_filter( 'map_meta_cap', $that->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 2 ); |
|
1629 | + if (version_compare($wp_version, '4.7', '<')) { |
|
1630 | + $that->loader->add_filter('map_meta_cap', $that->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 2); |
|
1631 | 1631 | } |
1632 | 1632 | |
1633 | 1633 | /** Adapters. */ |
1634 | - $that->loader->add_filter( 'mce_external_plugins', $that->tinymce_adapter, 'mce_external_plugins', 10, 1 ); |
|
1634 | + $that->loader->add_filter('mce_external_plugins', $that->tinymce_adapter, 'mce_external_plugins', 10, 1); |
|
1635 | 1635 | /** |
1636 | 1636 | * Disabling Faq temporarily. |
1637 | 1637 | * Load the tinymce editor button on the tool bar. |
@@ -1642,14 +1642,14 @@ discard block |
||
1642 | 1642 | // $that->loader->add_filter( 'mce_buttons', $that->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 ); |
1643 | 1643 | // $that->loader->add_filter( 'mce_external_plugins', $that->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 ); |
1644 | 1644 | |
1645 | - $that->loader->add_action( 'wp_ajax_wl_sample_data_create', $that->sample_data_ajax_adapter, 'create' ); |
|
1646 | - $that->loader->add_action( 'wp_ajax_wl_sample_data_delete', $that->sample_data_ajax_adapter, 'delete' ); |
|
1645 | + $that->loader->add_action('wp_ajax_wl_sample_data_create', $that->sample_data_ajax_adapter, 'create'); |
|
1646 | + $that->loader->add_action('wp_ajax_wl_sample_data_delete', $that->sample_data_ajax_adapter, 'delete'); |
|
1647 | 1647 | |
1648 | 1648 | /** |
1649 | 1649 | * @since 3.26.0 |
1650 | 1650 | */ |
1651 | 1651 | $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter(); |
1652 | - $that->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' ); |
|
1652 | + $that->loader->add_action('do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box'); |
|
1653 | 1653 | // Adding Rest route for the post excerpt |
1654 | 1654 | Post_Excerpt_Rest_Controller::register_routes(); |
1655 | 1655 | |
@@ -1670,13 +1670,13 @@ discard block |
||
1670 | 1670 | ); |
1671 | 1671 | |
1672 | 1672 | // Hooks to restrict multisite super admin from manipulating entity types. |
1673 | - if ( is_multisite() ) { |
|
1674 | - $that->loader->add_filter( 'map_meta_cap', $that->entity_type_admin_page, 'restrict_super_admin', 10, 2 ); |
|
1673 | + if (is_multisite()) { |
|
1674 | + $that->loader->add_filter('map_meta_cap', $that->entity_type_admin_page, 'restrict_super_admin', 10, 2); |
|
1675 | 1675 | } |
1676 | 1676 | |
1677 | 1677 | $deactivator_feedback = new Wordlift_Deactivator_Feedback(); |
1678 | 1678 | |
1679 | - add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) ); |
|
1679 | + add_action('admin_footer', array($deactivator_feedback, 'render_feedback_popup')); |
|
1680 | 1680 | add_action( |
1681 | 1681 | 'admin_enqueue_scripts', |
1682 | 1682 | array( |
@@ -1699,13 +1699,13 @@ discard block |
||
1699 | 1699 | */ |
1700 | 1700 | add_filter( |
1701 | 1701 | 'allowed_block_types', |
1702 | - function ( $value ) { |
|
1702 | + function($value) { |
|
1703 | 1703 | |
1704 | - if ( true === $value ) { |
|
1704 | + if (true === $value) { |
|
1705 | 1705 | return $value; |
1706 | 1706 | } |
1707 | 1707 | |
1708 | - return array_merge( (array) $value, array( 'wordlift/classification' ) ); |
|
1708 | + return array_merge((array) $value, array('wordlift/classification')); |
|
1709 | 1709 | }, |
1710 | 1710 | PHP_INT_MAX |
1711 | 1711 | ); |
@@ -1718,23 +1718,23 @@ discard block |
||
1718 | 1718 | |
1719 | 1719 | add_action( |
1720 | 1720 | 'admin_notices', |
1721 | - function () { |
|
1722 | - if ( apply_filters( 'wl_feature__enable__notices', true ) ) { |
|
1721 | + function() { |
|
1722 | + if (apply_filters('wl_feature__enable__notices', true)) { |
|
1723 | 1723 | /** |
1724 | 1724 | * Fired when the notice feature is enabled. |
1725 | 1725 | * |
1726 | 1726 | * @since 3.40.4 |
1727 | 1727 | */ |
1728 | - do_action( 'wordlift_admin_notices' ); |
|
1728 | + do_action('wordlift_admin_notices'); |
|
1729 | 1729 | } |
1730 | 1730 | } |
1731 | 1731 | ); |
1732 | 1732 | |
1733 | 1733 | add_action( |
1734 | 1734 | 'admin_init', |
1735 | - function () { |
|
1735 | + function() { |
|
1736 | 1736 | // Only show the notice when the key is set or skipped. |
1737 | - if ( \Wordlift_Configuration_Service::get_instance()->get_key() && ! \Wordlift_Configuration_Service::get_instance()->get_skip_installation_notice() ) { |
|
1737 | + if (\Wordlift_Configuration_Service::get_instance()->get_key() && ! \Wordlift_Configuration_Service::get_instance()->get_skip_installation_notice()) { |
|
1738 | 1738 | $installation_complete_notice = new Installation_Complete_Notice(); |
1739 | 1739 | $installation_complete_notice->init(); |
1740 | 1740 | } |
@@ -1750,57 +1750,57 @@ discard block |
||
1750 | 1750 | * @since 1.0.0 |
1751 | 1751 | * @access private |
1752 | 1752 | */ |
1753 | - private function define_public_hooks( $that ) { |
|
1753 | + private function define_public_hooks($that) { |
|
1754 | 1754 | |
1755 | - $plugin_public = new Wordlift_Public( $that->get_plugin_name(), $that->get_version() ); |
|
1755 | + $plugin_public = new Wordlift_Public($that->get_plugin_name(), $that->get_version()); |
|
1756 | 1756 | |
1757 | 1757 | // Register the entity post type. |
1758 | - $that->loader->add_action( 'init', $that->entity_post_type_service, 'register' ); |
|
1758 | + $that->loader->add_action('init', $that->entity_post_type_service, 'register'); |
|
1759 | 1759 | |
1760 | 1760 | // Bind the link generation and handling hooks to the entity link service. |
1761 | - $that->loader->add_filter( 'post_type_link', $that->entity_link_service, 'post_type_link', 10, 2 ); |
|
1762 | - $that->loader->add_action( 'pre_get_posts', $that->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 ); |
|
1761 | + $that->loader->add_filter('post_type_link', $that->entity_link_service, 'post_type_link', 10, 2); |
|
1762 | + $that->loader->add_action('pre_get_posts', $that->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1); |
|
1763 | 1763 | |
1764 | - $that->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
1765 | - $that->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
1766 | - $that->loader->add_action( 'wp_enqueue_scripts', $that->context_cards_service, 'enqueue_scripts' ); |
|
1764 | + $that->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); |
|
1765 | + $that->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); |
|
1766 | + $that->loader->add_action('wp_enqueue_scripts', $that->context_cards_service, 'enqueue_scripts'); |
|
1767 | 1767 | |
1768 | 1768 | // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html. |
1769 | - $that->loader->add_filter( 'the_content', $that->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' ); |
|
1769 | + $that->loader->add_filter('the_content', $that->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags'); |
|
1770 | 1770 | // Hook the content filter service to add entity links. |
1771 | - if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) { |
|
1771 | + if ( ! defined('WL_DISABLE_CONTENT_FILTER') || ! WL_DISABLE_CONTENT_FILTER) { |
|
1772 | 1772 | // We run before other filters. |
1773 | - $that->loader->add_filter( 'the_content', $that->content_filter_service, 'the_content', 9 ); |
|
1773 | + $that->loader->add_filter('the_content', $that->content_filter_service, 'the_content', 9); |
|
1774 | 1774 | } |
1775 | 1775 | |
1776 | 1776 | // Hook the AJAX wl_timeline action to the Timeline service. |
1777 | - $that->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $that->timeline_service, 'ajax_timeline' ); |
|
1777 | + $that->loader->add_action('wp_ajax_nopriv_wl_timeline', $that->timeline_service, 'ajax_timeline'); |
|
1778 | 1778 | |
1779 | 1779 | // Hook the ShareThis service. |
1780 | - $that->loader->add_filter( 'the_content', $that->sharethis_service, 'the_content', 99 ); |
|
1781 | - $that->loader->add_filter( 'the_excerpt', $that->sharethis_service, 'the_excerpt', 99 ); |
|
1780 | + $that->loader->add_filter('the_content', $that->sharethis_service, 'the_content', 99); |
|
1781 | + $that->loader->add_filter('the_excerpt', $that->sharethis_service, 'the_excerpt', 99); |
|
1782 | 1782 | |
1783 | 1783 | // Hook the AJAX wl_jsonld action to the JSON-LD service. |
1784 | - $that->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $that->jsonld_service, 'get' ); |
|
1784 | + $that->loader->add_action('wp_ajax_nopriv_wl_jsonld', $that->jsonld_service, 'get'); |
|
1785 | 1785 | |
1786 | 1786 | // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service` |
1787 | 1787 | // in order to tweak WP's `WP_Query` to include entities in queries related |
1788 | 1788 | // to categories. |
1789 | - $that->loader->add_action( 'pre_get_posts', $that->category_taxonomy_service, 'pre_get_posts', 10, 1 ); |
|
1789 | + $that->loader->add_action('pre_get_posts', $that->category_taxonomy_service, 'pre_get_posts', 10, 1); |
|
1790 | 1790 | |
1791 | 1791 | /* |
1792 | 1792 | * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service` |
1793 | 1793 | * in order to tweak WP's `WP_Query` to show event related entities in reverse |
1794 | 1794 | * order of start time. |
1795 | 1795 | */ |
1796 | - $that->loader->add_action( 'pre_get_posts', $that->entity_page_service, 'pre_get_posts', 10, 1 ); |
|
1796 | + $that->loader->add_action('pre_get_posts', $that->entity_page_service, 'pre_get_posts', 10, 1); |
|
1797 | 1797 | |
1798 | 1798 | // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done. |
1799 | - $that->loader->add_action( 'save_post', $that->entity_type_adapter, 'save_post', 9, 2 ); |
|
1799 | + $that->loader->add_action('save_post', $that->entity_type_adapter, 'save_post', 9, 2); |
|
1800 | 1800 | |
1801 | 1801 | // Analytics Script Frontend. |
1802 | - if ( apply_filters( 'wl_feature__enable__analytics', true ) && Wordlift_Configuration_Service::get_instance()->is_analytics_enable() ) { |
|
1803 | - $that->loader->add_action( 'wp_enqueue_scripts', $that->analytics_connect, 'enqueue_scripts', 10 ); |
|
1802 | + if (apply_filters('wl_feature__enable__analytics', true) && Wordlift_Configuration_Service::get_instance()->is_analytics_enable()) { |
|
1803 | + $that->loader->add_action('wp_enqueue_scripts', $that->analytics_connect, 'enqueue_scripts', 10); |
|
1804 | 1804 | } |
1805 | 1805 | |
1806 | 1806 | } |
@@ -1865,7 +1865,7 @@ discard block |
||
1865 | 1865 | * @since 3.27.6 |
1866 | 1866 | */ |
1867 | 1867 | // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.NotInFooter,WordPress.WP.EnqueuedResourceParameters.MissingVersion |
1868 | - wp_register_script( 'wl_enabled_blocks', false ); |
|
1868 | + wp_register_script('wl_enabled_blocks', false); |
|
1869 | 1869 | |
1870 | 1870 | $enabled_blocks = array(); |
1871 | 1871 | |
@@ -1875,11 +1875,11 @@ discard block |
||
1875 | 1875 | * @since 3.32.3 |
1876 | 1876 | */ |
1877 | 1877 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
1878 | - if ( apply_filters( 'wl_feature__enable__product-navigator', true ) ) { |
|
1878 | + if (apply_filters('wl_feature__enable__product-navigator', true)) { |
|
1879 | 1879 | $enabled_blocks[] = 'wordlift/products-navigator'; |
1880 | 1880 | } |
1881 | 1881 | |
1882 | - if ( apply_filters( 'wl_feature__enable__blocks', true ) ) { |
|
1882 | + if (apply_filters('wl_feature__enable__blocks', true)) { |
|
1883 | 1883 | // To intimate JS |
1884 | 1884 | $enabled_blocks = array_merge( |
1885 | 1885 | $enabled_blocks, |
@@ -1895,8 +1895,8 @@ discard block |
||
1895 | 1895 | ); |
1896 | 1896 | } |
1897 | 1897 | |
1898 | - wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks ); |
|
1899 | - wp_enqueue_script( 'wl_enabled_blocks' ); |
|
1898 | + wp_localize_script('wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks); |
|
1899 | + wp_enqueue_script('wl_enabled_blocks'); |
|
1900 | 1900 | } |
1901 | 1901 | |
1902 | 1902 | /** |
@@ -1905,8 +1905,8 @@ discard block |
||
1905 | 1905 | public function register_screens() { |
1906 | 1906 | // Hook the menu to the Download Your Data page. |
1907 | 1907 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
1908 | - if ( apply_filters( 'wl_feature__enable__settings-download', true ) ) { |
|
1909 | - Assertions::is_set( $this->download_your_data_page, "`download_your_data_page` can't be null" ); |
|
1908 | + if (apply_filters('wl_feature__enable__settings-download', true)) { |
|
1909 | + Assertions::is_set($this->download_your_data_page, "`download_your_data_page` can't be null"); |
|
1910 | 1910 | add_action( |
1911 | 1911 | 'admin_menu', |
1912 | 1912 | array( |
@@ -1918,7 +1918,7 @@ discard block |
||
1918 | 1918 | ); |
1919 | 1919 | } |
1920 | 1920 | |
1921 | - Assertions::is_set( $this->entity_type_settings_admin_page, "`entity_type_settings_admin_page` can't be null" ); |
|
1921 | + Assertions::is_set($this->entity_type_settings_admin_page, "`entity_type_settings_admin_page` can't be null"); |
|
1922 | 1922 | add_action( |
1923 | 1923 | 'admin_menu', |
1924 | 1924 | array( |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @since 3.8.0 |
44 | 44 | */ |
45 | - public function __construct( $entity_type_service, $user_service, $attachment_service, $property_getter, $schemaorg_property_service, $post_to_jsonld_converter ) { |
|
46 | - parent::__construct( $entity_type_service, $user_service, $attachment_service, $property_getter ); |
|
45 | + public function __construct($entity_type_service, $user_service, $attachment_service, $property_getter, $schemaorg_property_service, $post_to_jsonld_converter) { |
|
46 | + parent::__construct($entity_type_service, $user_service, $attachment_service, $property_getter); |
|
47 | 47 | $this->schemaorg_property_service = $schemaorg_property_service; |
48 | 48 | $this->post_to_jsonld_converter = $post_to_jsonld_converter; |
49 | 49 | } |
@@ -59,28 +59,28 @@ discard block |
||
59 | 59 | * @return array A JSON-LD array. |
60 | 60 | * @since 3.8.0 |
61 | 61 | */ |
62 | - public function convert( $post_id, &$references = array(), &$references_infos = array(), $relations = null ) { |
|
62 | + public function convert($post_id, &$references = array(), &$references_infos = array(), $relations = null) { |
|
63 | 63 | |
64 | 64 | // Get the post instance. |
65 | - $post = get_post( $post_id ); |
|
66 | - if ( null === $post ) { |
|
65 | + $post = get_post($post_id); |
|
66 | + if (null === $post) { |
|
67 | 67 | // Post not found. |
68 | 68 | return null; |
69 | 69 | } |
70 | 70 | |
71 | 71 | // Get the base JSON-LD and the list of entities referenced by this entity. |
72 | - if ( has_term( 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, $post_id ) ) { |
|
73 | - $jsonld = $this->post_to_jsonld_converter->convert( $post_id, $references, $references_infos, $relations ); |
|
72 | + if (has_term('article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, $post_id)) { |
|
73 | + $jsonld = $this->post_to_jsonld_converter->convert($post_id, $references, $references_infos, $relations); |
|
74 | 74 | } else { |
75 | - $jsonld = parent::convert( $post_id, $references, $references_infos, $relations ); |
|
75 | + $jsonld = parent::convert($post_id, $references, $references_infos, $relations); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | // Get the entity name. |
79 | - $jsonld['name'] = html_entity_decode( $post->post_title ); |
|
79 | + $jsonld['name'] = html_entity_decode($post->post_title); |
|
80 | 80 | |
81 | 81 | // 3.13.0, add alternate names. |
82 | - $alternative_labels = Wordlift_Entity_Service::get_instance()->get_alternative_labels( $post_id ); |
|
83 | - if ( 0 < count( $alternative_labels ) ) { |
|
82 | + $alternative_labels = Wordlift_Entity_Service::get_instance()->get_alternative_labels($post_id); |
|
83 | + if (0 < count($alternative_labels)) { |
|
84 | 84 | $jsonld['alternateName'] = $alternative_labels; |
85 | 85 | } |
86 | 86 | |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | // |
89 | 89 | // This allows us to gather the basic properties as defined by the `Thing` entity type. |
90 | 90 | // Get the configured type custom fields. |
91 | - $custom_fields = $this->entity_type_service->get_custom_fields_for_post( $post_id ); |
|
91 | + $custom_fields = $this->entity_type_service->get_custom_fields_for_post($post_id); |
|
92 | 92 | |
93 | - if ( isset( $custom_fields ) ) { |
|
94 | - $this->process_type_custom_fields( $jsonld, $custom_fields, $post, $references, $references_infos ); |
|
93 | + if (isset($custom_fields)) { |
|
94 | + $this->process_type_custom_fields($jsonld, $custom_fields, $post, $references, $references_infos); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /* |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
103 | 103 | */ |
104 | 104 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
105 | - if ( apply_filters( 'wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES ) ) { |
|
106 | - $this->process_post_properties( $jsonld, $post_id ); |
|
105 | + if (apply_filters('wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES)) { |
|
106 | + $this->process_post_properties($jsonld, $post_id); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @api |
122 | 122 | */ |
123 | - $ret_val = apply_filters( |
|
123 | + $ret_val = apply_filters( |
|
124 | 124 | 'wl_entity_jsonld_array', |
125 | 125 | array( |
126 | 126 | 'jsonld' => $jsonld, |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @api |
144 | 144 | */ |
145 | - return apply_filters( 'wl_entity_jsonld', $this->post_process( $jsonld ), $post_id, $references ); |
|
145 | + return apply_filters('wl_entity_jsonld', $this->post_process($jsonld), $post_id, $references); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -153,17 +153,17 @@ discard block |
||
153 | 153 | * |
154 | 154 | * @since 3.20.0 |
155 | 155 | */ |
156 | - private function process_post_properties( &$jsonld, $post_id ) { |
|
156 | + private function process_post_properties(&$jsonld, $post_id) { |
|
157 | 157 | |
158 | 158 | // Get all the props. |
159 | - $props = $this->schemaorg_property_service->get_all( $post_id ); |
|
159 | + $props = $this->schemaorg_property_service->get_all($post_id); |
|
160 | 160 | |
161 | 161 | // Process all the props. |
162 | - foreach ( $props as $name => $instances ) { |
|
162 | + foreach ($props as $name => $instances) { |
|
163 | 163 | |
164 | 164 | // Get the values. |
165 | 165 | $values = array_map( |
166 | - function ( $instance ) { |
|
166 | + function($instance) { |
|
167 | 167 | return $instance['value']; |
168 | 168 | }, |
169 | 169 | $instances |
@@ -172,19 +172,19 @@ discard block |
||
172 | 172 | // We might receive empty values, remove them. |
173 | 173 | $non_empty_values = array_filter( |
174 | 174 | $values, |
175 | - function ( $value ) { |
|
176 | - return ! empty( $value ); |
|
175 | + function($value) { |
|
176 | + return ! empty($value); |
|
177 | 177 | } |
178 | 178 | ); |
179 | 179 | |
180 | 180 | // Skip empty properties. |
181 | - if ( empty( $non_empty_values ) ) { |
|
181 | + if (empty($non_empty_values)) { |
|
182 | 182 | continue; |
183 | 183 | } |
184 | 184 | |
185 | 185 | // @@todo: need to handle maybe Numbers and URLs differently. |
186 | 186 | // Make an array a single value when possible. |
187 | - $jsonld[ $name ] = self::make_one( $non_empty_values ); |
|
187 | + $jsonld[$name] = self::make_one($non_empty_values); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | } |
@@ -198,25 +198,25 @@ discard block |
||
198 | 198 | * @return array The array remapped. |
199 | 199 | * @since 3.8.0 |
200 | 200 | */ |
201 | - public static function post_process( $jsonld ) { |
|
201 | + public static function post_process($jsonld) { |
|
202 | 202 | |
203 | - foreach ( $jsonld as $key => $value ) { |
|
204 | - if ( 'streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key ) { |
|
203 | + foreach ($jsonld as $key => $value) { |
|
204 | + if ('streetAddress' === $key || 'postalCode' === $key || 'addressLocality' === $key || 'addressRegion' === $key || 'addressCountry' === $key || 'postOfficeBoxNumber' === $key) { |
|
205 | 205 | $jsonld['address']['@type'] = 'PostalAddress'; |
206 | - $jsonld['address'][ $key ] = $value; |
|
207 | - unset( $jsonld[ $key ] ); |
|
206 | + $jsonld['address'][$key] = $value; |
|
207 | + unset($jsonld[$key]); |
|
208 | 208 | } |
209 | 209 | |
210 | - if ( 'latitude' === $key || 'longitude' === $key ) { |
|
210 | + if ('latitude' === $key || 'longitude' === $key) { |
|
211 | 211 | $jsonld['geo']['@type'] = 'GeoCoordinates'; |
212 | - $jsonld['geo'][ $key ] = $value; |
|
213 | - unset( $jsonld[ $key ] ); |
|
212 | + $jsonld['geo'][$key] = $value; |
|
213 | + unset($jsonld[$key]); |
|
214 | 214 | } |
215 | 215 | |
216 | - if ( 'calories' === $key ) { |
|
216 | + if ('calories' === $key) { |
|
217 | 217 | $jsonld['nutrition']['@type'] = 'NutritionInformation'; |
218 | - $jsonld['nutrition'][ $key ] = $value; |
|
219 | - unset( $jsonld[ $key ] ); |
|
218 | + $jsonld['nutrition'][$key] = $value; |
|
219 | + unset($jsonld[$key]); |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @since 3.8.0 |
38 | 38 | */ |
39 | - public function __construct( $entity_post_to_jsonld_converter, $post_to_jsonld_converter ) { |
|
39 | + public function __construct($entity_post_to_jsonld_converter, $post_to_jsonld_converter) { |
|
40 | 40 | |
41 | - $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
41 | + $this->log = Wordlift_Log_Service::get_logger(get_class()); |
|
42 | 42 | |
43 | 43 | $this->entity_post_to_jsonld_converter = $entity_post_to_jsonld_converter; |
44 | 44 | $this->post_to_jsonld_converter = $post_to_jsonld_converter; |
@@ -55,17 +55,17 @@ discard block |
||
55 | 55 | * @return array|NULL A JSON-LD array representation of the post with the provided id, or NULL if not found. |
56 | 56 | * @since 3.8.0 |
57 | 57 | */ |
58 | - public function convert( $post_id, &$references = array(), &$references_infos = array(), $relations = null ) { |
|
58 | + public function convert($post_id, &$references = array(), &$references_infos = array(), $relations = null) { |
|
59 | 59 | |
60 | - $this->log->trace( "Converting post $post_id..." ); |
|
60 | + $this->log->trace("Converting post $post_id..."); |
|
61 | 61 | |
62 | 62 | $entity_service = Wordlift_Entity_Service::get_instance(); |
63 | 63 | |
64 | - return $entity_service->is_entity( $post_id ) |
|
64 | + return $entity_service->is_entity($post_id) |
|
65 | 65 | // Entity. |
66 | - ? $this->entity_post_to_jsonld_converter->convert( $post_id, $references, $references_infos, $relations ) |
|
66 | + ? $this->entity_post_to_jsonld_converter->convert($post_id, $references, $references_infos, $relations) |
|
67 | 67 | // Post/Page. |
68 | - : $this->post_to_jsonld_converter->convert( $post_id, $references, $references_infos, $relations ); |
|
68 | + : $this->post_to_jsonld_converter->convert($post_id, $references, $references_infos, $relations); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @since 3.2.0 |
82 | 82 | */ |
83 | 83 | protected function __construct() { |
84 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' ); |
|
84 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Entity_Service'); |
|
85 | 85 | |
86 | 86 | $this->entity_uri_service = Wordlift_Entity_Uri_Service::get_instance(); |
87 | 87 | $this->relation_service = Wordlift_Relation_Service::get_instance(); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public static function get_instance() { |
107 | 107 | |
108 | - if ( ! isset( self::$instance ) ) { |
|
108 | + if ( ! isset(self::$instance)) { |
|
109 | 109 | self::$instance = new self(); |
110 | 110 | } |
111 | 111 | |
@@ -121,22 +121,22 @@ discard block |
||
121 | 121 | * @return bool Return true if the post is an entity otherwise false. |
122 | 122 | * @since 3.1.0 |
123 | 123 | */ |
124 | - public function is_entity( $post_id ) { |
|
124 | + public function is_entity($post_id) { |
|
125 | 125 | |
126 | 126 | // Improve performance by giving for granted that a product is an entity. |
127 | - if ( 'product' === get_post_type( $post_id ) ) { |
|
127 | + if ('product' === get_post_type($post_id)) { |
|
128 | 128 | return true; |
129 | 129 | } |
130 | 130 | |
131 | - $terms = wp_get_object_terms( $post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
131 | + $terms = wp_get_object_terms($post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME); |
|
132 | 132 | |
133 | - if ( is_wp_error( $terms ) ) { |
|
134 | - $this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() ); |
|
133 | + if (is_wp_error($terms)) { |
|
134 | + $this->log->error("Cannot get the terms for post $post_id: ".$terms->get_error_message()); |
|
135 | 135 | |
136 | 136 | return false; |
137 | 137 | } |
138 | 138 | |
139 | - if ( empty( $terms ) ) { |
|
139 | + if (empty($terms)) { |
|
140 | 140 | return false; |
141 | 141 | } |
142 | 142 | |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
149 | 149 | */ |
150 | - foreach ( $terms as $term ) { |
|
151 | - if ( 1 !== preg_match( '~(^|-)article$~', $term->slug ) ) { |
|
150 | + foreach ($terms as $term) { |
|
151 | + if (1 !== preg_match('~(^|-)article$~', $term->slug)) { |
|
152 | 152 | return true; |
153 | 153 | } |
154 | 154 | } |
@@ -167,20 +167,20 @@ discard block |
||
167 | 167 | * @return string Returns a classification scope (e.g. 'what'). |
168 | 168 | * @since 3.5.0 |
169 | 169 | */ |
170 | - public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) { |
|
170 | + public function get_classification_scope_for($post_id, $default = WL_WHAT_RELATION) { |
|
171 | 171 | |
172 | - if ( false === $this->is_entity( $post_id ) ) { |
|
172 | + if (false === $this->is_entity($post_id)) { |
|
173 | 173 | return $default; |
174 | 174 | } |
175 | 175 | |
176 | 176 | // Retrieve the entity type |
177 | - $entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id ); |
|
178 | - $entity_type = str_replace( 'wl-', '', $entity_type_arr['css_class'] ); |
|
177 | + $entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get($post_id); |
|
178 | + $entity_type = str_replace('wl-', '', $entity_type_arr['css_class']); |
|
179 | 179 | // Retrieve classification boxes configuration |
180 | 180 | // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize |
181 | - $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES ); |
|
182 | - foreach ( $classification_boxes as $cb ) { |
|
183 | - if ( in_array( $entity_type, $cb['registeredTypes'], true ) ) { |
|
181 | + $classification_boxes = unserialize(WL_CORE_POST_CLASSIFICATION_BOXES); |
|
182 | + foreach ($classification_boxes as $cb) { |
|
183 | + if (in_array($entity_type, $cb['registeredTypes'], true)) { |
|
184 | 184 | return $cb['id']; |
185 | 185 | } |
186 | 186 | } |
@@ -195,13 +195,13 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @return bool|null Null if it's not an entity, otherwise true if it's used. |
197 | 197 | */ |
198 | - public function is_used( $post_id ) { |
|
198 | + public function is_used($post_id) { |
|
199 | 199 | |
200 | - if ( false === $this->is_entity( $post_id ) ) { |
|
200 | + if (false === $this->is_entity($post_id)) { |
|
201 | 201 | return null; |
202 | 202 | } |
203 | 203 | // Retrieve the post |
204 | - $entity = get_post( $post_id ); |
|
204 | + $entity = get_post($post_id); |
|
205 | 205 | |
206 | 206 | global $wpdb; |
207 | 207 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | ) |
214 | 214 | ); |
215 | 215 | // If there is at least one relation instance for the current entity, then it's used |
216 | - if ( 0 < $relation_instances ) { |
|
216 | + if (0 < $relation_instances) { |
|
217 | 217 | return true; |
218 | 218 | } |
219 | 219 | |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | $wpdb->prepare( |
223 | 223 | "SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s", |
224 | 224 | $entity->ID, |
225 | - wl_get_entity_uri( $entity->ID ) |
|
225 | + wl_get_entity_uri($entity->ID) |
|
226 | 226 | ) |
227 | 227 | ); |
228 | 228 | |
229 | 229 | // If there is at least one meta that refers the current entity uri, then current entity is used |
230 | - if ( 0 < $meta_instances ) { |
|
230 | + if (0 < $meta_instances) { |
|
231 | 231 | return true; |
232 | 232 | } |
233 | 233 | |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | * @since 3.16.3 deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri ); |
247 | 247 | * @since 3.2.0 |
248 | 248 | */ |
249 | - public function get_entity_post_by_uri( $uri ) { |
|
249 | + public function get_entity_post_by_uri($uri) { |
|
250 | 250 | |
251 | - return $this->entity_uri_service->get_entity( $uri ); |
|
251 | + return $this->entity_uri_service->get_entity($uri); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -264,19 +264,19 @@ discard block |
||
264 | 264 | * @param int $post_id Post ID. |
265 | 265 | * @param WP_Post $post Post object. |
266 | 266 | */ |
267 | - public function save_post( $post_id, $post ) { |
|
267 | + public function save_post($post_id, $post) { |
|
268 | 268 | // Avoid doing anything if post is autosave or a revision. |
269 | - if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) { |
|
269 | + if (wp_is_post_autosave($post) || wp_is_post_revision($post)) { |
|
270 | 270 | return; |
271 | 271 | } |
272 | 272 | |
273 | 273 | // We expect a numeric value here. |
274 | - if ( ! isset( $_REQUEST['post_ID'] ) || ! is_numeric( $_REQUEST['post_ID'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
274 | + if ( ! isset($_REQUEST['post_ID']) || ! is_numeric($_REQUEST['post_ID'])) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
275 | 275 | return; |
276 | 276 | } |
277 | 277 | |
278 | 278 | // Get the numeric post ID from the request. |
279 | - $request_post_id = intval( $_REQUEST['post_ID'] ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
279 | + $request_post_id = intval($_REQUEST['post_ID']); //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
280 | 280 | |
281 | 281 | // We're setting the alternative label that have been provided via the UI |
282 | 282 | // (in fact we're using $_REQUEST), while save_post may be also called |
@@ -284,16 +284,16 @@ discard block |
||
284 | 284 | // the $post_id in the save_post call matches the post id set in the request. |
285 | 285 | // |
286 | 286 | // If this is not the current post being saved or if it's not an entity, return. |
287 | - if ( $request_post_id !== $post_id || ! $this->is_entity( $post_id ) ) { |
|
287 | + if ($request_post_id !== $post_id || ! $this->is_entity($post_id)) { |
|
288 | 288 | return; |
289 | 289 | } |
290 | 290 | |
291 | - if ( isset( $_REQUEST['wl_alternative_label'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
292 | - $data = filter_var_array( $_REQUEST, array( 'wl_alternative_label' => array( 'flags' => FILTER_REQUIRE_ARRAY ) ) ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
291 | + if (isset($_REQUEST['wl_alternative_label'])) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
292 | + $data = filter_var_array($_REQUEST, array('wl_alternative_label' => array('flags' => FILTER_REQUIRE_ARRAY))); //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
293 | 293 | // Get the alt labels from the request (or empty array). |
294 | - $alt_labels = isset( $data['wl_alternative_label'] ) ? $data['wl_alternative_label'] : array(); |
|
294 | + $alt_labels = isset($data['wl_alternative_label']) ? $data['wl_alternative_label'] : array(); |
|
295 | 295 | // This is via classic editor, so set the alternative labels. |
296 | - $this->set_alternative_labels( $post_id, $alt_labels ); |
|
296 | + $this->set_alternative_labels($post_id, $alt_labels); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | } |
@@ -306,48 +306,48 @@ discard block |
||
306 | 306 | * |
307 | 307 | * @since 3.2.0 |
308 | 308 | */ |
309 | - public function set_alternative_labels( $post_id, $alt_labels ) { |
|
309 | + public function set_alternative_labels($post_id, $alt_labels) { |
|
310 | 310 | |
311 | 311 | // Bail out if post id is not numeric. We add this check as we found a WP install that was sending a WP_Error |
312 | 312 | // instead of post id. |
313 | - if ( ! is_numeric( $post_id ) ) { |
|
313 | + if ( ! is_numeric($post_id)) { |
|
314 | 314 | return; |
315 | 315 | } |
316 | 316 | |
317 | 317 | // Force $alt_labels to be an array |
318 | - if ( ! is_array( $alt_labels ) ) { |
|
319 | - $alt_labels = array( $alt_labels ); |
|
318 | + if ( ! is_array($alt_labels)) { |
|
319 | + $alt_labels = array($alt_labels); |
|
320 | 320 | } |
321 | 321 | |
322 | - $this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . ' ]' ); |
|
322 | + $this->log->debug("Setting alternative labels [ post id :: $post_id ][ alt labels :: ".implode(',', $alt_labels).' ]'); |
|
323 | 323 | |
324 | 324 | // Delete all the existing alternate labels. |
325 | - delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY ); |
|
325 | + delete_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY); |
|
326 | 326 | |
327 | 327 | // Save only unique synonymns. |
328 | - $alt_labels = array_unique( $alt_labels ); |
|
328 | + $alt_labels = array_unique($alt_labels); |
|
329 | 329 | |
330 | 330 | // Set the alternative labels. |
331 | - foreach ( $alt_labels as $alt_label ) { |
|
331 | + foreach ($alt_labels as $alt_label) { |
|
332 | 332 | |
333 | 333 | // Strip html code from synonym. |
334 | - $alt_label = wp_strip_all_tags( $alt_label ); |
|
334 | + $alt_label = wp_strip_all_tags($alt_label); |
|
335 | 335 | |
336 | - if ( ! empty( $alt_label ) ) { |
|
337 | - add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, (string) $alt_label ); |
|
336 | + if ( ! empty($alt_label)) { |
|
337 | + add_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY, (string) $alt_label); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
341 | 341 | } |
342 | 342 | |
343 | - public function append_alternative_labels( $post_id, $labels_to_append ) { |
|
343 | + public function append_alternative_labels($post_id, $labels_to_append) { |
|
344 | 344 | |
345 | - $merged_labels = $this->get_alternative_labels( $post_id ); |
|
345 | + $merged_labels = $this->get_alternative_labels($post_id); |
|
346 | 346 | |
347 | 347 | // Append new synonyms to the end. |
348 | - $merged_labels = array_merge( $merged_labels, $labels_to_append ); |
|
348 | + $merged_labels = array_merge($merged_labels, $labels_to_append); |
|
349 | 349 | |
350 | - $this->set_alternative_labels( $post_id, $merged_labels ); |
|
350 | + $this->set_alternative_labels($post_id, $merged_labels); |
|
351 | 351 | |
352 | 352 | } |
353 | 353 | |
@@ -359,9 +359,9 @@ discard block |
||
359 | 359 | * @return mixed An array of alternative labels. |
360 | 360 | * @since 3.2.0 |
361 | 361 | */ |
362 | - public function get_alternative_labels( $post_id ) { |
|
362 | + public function get_alternative_labels($post_id) { |
|
363 | 363 | |
364 | - return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY ); |
|
364 | + return get_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |
@@ -373,14 +373,14 @@ discard block |
||
373 | 373 | * @return array An array with the entity title and labels. |
374 | 374 | * @since 3.12.0 |
375 | 375 | */ |
376 | - public function get_labels( $id, $object_type = Object_Type_Enum::POST ) { |
|
377 | - if ( Object_Type_Enum::POST === $object_type ) { |
|
378 | - return array_merge( (array) get_the_title( $id ), $this->get_alternative_labels( $id ) ); |
|
376 | + public function get_labels($id, $object_type = Object_Type_Enum::POST) { |
|
377 | + if (Object_Type_Enum::POST === $object_type) { |
|
378 | + return array_merge((array) get_the_title($id), $this->get_alternative_labels($id)); |
|
379 | 379 | } |
380 | 380 | |
381 | - if ( Object_Type_Enum::TERM === $object_type ) { |
|
382 | - $term = get_term( $id ); |
|
383 | - if ( ! is_a( $term, 'WP_Term' ) ) { |
|
381 | + if (Object_Type_Enum::TERM === $object_type) { |
|
382 | + $term = get_term($id); |
|
383 | + if ( ! is_a($term, 'WP_Term')) { |
|
384 | 384 | return array(); |
385 | 385 | } |
386 | 386 | |
@@ -398,46 +398,46 @@ discard block |
||
398 | 398 | * |
399 | 399 | * @since 3.2.0 |
400 | 400 | */ |
401 | - public function edit_form_before_permalink( $post ) { |
|
401 | + public function edit_form_before_permalink($post) { |
|
402 | 402 | |
403 | 403 | // If it's not an entity, return. |
404 | - if ( ! $this->is_entity( $post->ID ) ) { |
|
404 | + if ( ! $this->is_entity($post->ID)) { |
|
405 | 405 | return; |
406 | 406 | } |
407 | 407 | |
408 | 408 | // If disabled by filter, return. |
409 | 409 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
410 | - if ( ! apply_filters( 'wl_feature__enable__add-synonyms', true ) ) { |
|
410 | + if ( ! apply_filters('wl_feature__enable__add-synonyms', true)) { |
|
411 | 411 | return; |
412 | 412 | } |
413 | 413 | |
414 | 414 | // Print the input template. |
415 | - Wordlift_UI_Service::print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() ); |
|
415 | + Wordlift_UI_Service::print_template('wl-tmpl-alternative-label-input', $this->get_alternative_label_input()); |
|
416 | 416 | |
417 | 417 | // Print all the currently set alternative labels. |
418 | - foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) { |
|
418 | + foreach ($this->get_alternative_labels($post->ID) as $alt_label) { |
|
419 | 419 | |
420 | - echo wp_kses( $this->get_alternative_label_input( $alt_label ), Wordlift_UI_Service::get_template_allowed_html() ); |
|
420 | + echo wp_kses($this->get_alternative_label_input($alt_label), Wordlift_UI_Service::get_template_allowed_html()); |
|
421 | 421 | |
422 | 422 | }; |
423 | 423 | |
424 | 424 | // Print the button. |
425 | - Wordlift_UI_Service::print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) ); |
|
425 | + Wordlift_UI_Service::print_button('wl-add-alternative-labels-button', __('Add more titles', 'wordlift')); |
|
426 | 426 | |
427 | 427 | } |
428 | 428 | |
429 | - public function get_uri( $object_id, $type = Object_Type_Enum::POST ) { |
|
429 | + public function get_uri($object_id, $type = Object_Type_Enum::POST) { |
|
430 | 430 | $content_service = Wordpress_Content_Service::get_instance(); |
431 | - $entity_id = $content_service->get_entity_id( new Wordpress_Content_Id( $object_id, $type ) ); |
|
431 | + $entity_id = $content_service->get_entity_id(new Wordpress_Content_Id($object_id, $type)); |
|
432 | 432 | $dataset_uri = Wordlift_Configuration_Service::get_instance()->get_dataset_uri(); |
433 | 433 | |
434 | - if ( ! isset( $entity_id ) || |
|
435 | - ( ! empty( $dataset_uri ) && 0 !== strpos( $entity_id, $dataset_uri ) ) ) { |
|
436 | - $rel_uri = Entity_Uri_Generator::create_uri( $type, $object_id ); |
|
434 | + if ( ! isset($entity_id) || |
|
435 | + ( ! empty($dataset_uri) && 0 !== strpos($entity_id, $dataset_uri))) { |
|
436 | + $rel_uri = Entity_Uri_Generator::create_uri($type, $object_id); |
|
437 | 437 | try { |
438 | - $content_service->set_entity_id( new Wordpress_Content_Id( $object_id, $type ), $rel_uri ); |
|
439 | - $entity_id = $content_service->get_entity_id( new Wordpress_Content_Id( $object_id, $type ) ); |
|
440 | - } catch ( Exception $e ) { |
|
438 | + $content_service->set_entity_id(new Wordpress_Content_Id($object_id, $type), $rel_uri); |
|
439 | + $entity_id = $content_service->get_entity_id(new Wordpress_Content_Id($object_id, $type)); |
|
440 | + } catch (Exception $e) { |
|
441 | 441 | return null; |
442 | 442 | } |
443 | 443 | } |
@@ -453,9 +453,9 @@ discard block |
||
453 | 453 | * @return string The input HTML code. |
454 | 454 | * @since 3.2.0 |
455 | 455 | */ |
456 | - private function get_alternative_label_input( $value = '' ) { |
|
456 | + private function get_alternative_label_input($value = '') { |
|
457 | 457 | |
458 | - return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), esc_html__( 'Delete', 'wordlift' ) ); |
|
458 | + return sprintf(self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr($value), esc_html__('Delete', 'wordlift')); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | /** |
@@ -468,8 +468,8 @@ discard block |
||
468 | 468 | global $wpdb; |
469 | 469 | |
470 | 470 | // Try to get the count from the transient. |
471 | - $count = get_transient( '_wl_entity_service__count' ); |
|
472 | - if ( false !== $count ) { |
|
471 | + $count = get_transient('_wl_entity_service__count'); |
|
472 | + if (false !== $count) { |
|
473 | 473 | return $count; |
474 | 474 | } |
475 | 475 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | ); |
489 | 489 | |
490 | 490 | // Store the count in cache. |
491 | - set_transient( '_wl_entity_service__count', $count, 900 ); |
|
491 | + set_transient('_wl_entity_service__count', $count, 900); |
|
492 | 492 | |
493 | 493 | return $count; |
494 | 494 | } |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * @return array The arguments for a `get_posts` call. |
503 | 503 | * @since 3.15.0 |
504 | 504 | */ |
505 | - public static function add_criterias( $args ) { |
|
505 | + public static function add_criterias($args) { |
|
506 | 506 | |
507 | 507 | // Build an optimal tax-query. |
508 | 508 | $tax_query = array( |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails. |
546 | 546 | * @since 3.9.0 |
547 | 547 | */ |
548 | - public function create( $name, $type_uri, $logo = null, $status = 'publish' ) { |
|
548 | + public function create($name, $type_uri, $logo = null, $status = 'publish') { |
|
549 | 549 | |
550 | 550 | // Create an entity for the publisher. |
551 | 551 | // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
@@ -559,17 +559,17 @@ discard block |
||
559 | 559 | ); |
560 | 560 | |
561 | 561 | // Return the error if any. |
562 | - if ( is_wp_error( $post_id ) ) { |
|
562 | + if (is_wp_error($post_id)) { |
|
563 | 563 | return $post_id; |
564 | 564 | } |
565 | 565 | |
566 | 566 | // Set the entity logo. |
567 | - if ( $logo && is_numeric( $logo ) ) { |
|
568 | - set_post_thumbnail( $post_id, $logo ); |
|
567 | + if ($logo && is_numeric($logo)) { |
|
568 | + set_post_thumbnail($post_id, $logo); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | // Set the entity type. |
572 | - Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri ); |
|
572 | + Wordlift_Entity_Type_Service::get_instance()->set($post_id, $type_uri); |
|
573 | 573 | |
574 | 574 | return $post_id; |
575 | 575 | } |
@@ -584,9 +584,9 @@ discard block |
||
584 | 584 | * @return array An array of post ids. |
585 | 585 | * @since 3.10.0 |
586 | 586 | */ |
587 | - public function get_related_entities( $id, $post_status = 'publish' ) { |
|
587 | + public function get_related_entities($id, $post_status = 'publish') { |
|
588 | 588 | |
589 | - return $this->relation_service->get_objects( $id, 'ids', null, $post_status ); |
|
589 | + return $this->relation_service->get_objects($id, 'ids', null, $post_status); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
@@ -597,16 +597,16 @@ discard block |
||
597 | 597 | * @return array An array of entity posts. |
598 | 598 | * @since 3.12.2 |
599 | 599 | */ |
600 | - public function get( $params = array() ) { |
|
600 | + public function get($params = array()) { |
|
601 | 601 | |
602 | 602 | // Set the defaults. |
603 | - $defaults = array( 'post_type' => 'entity' ); |
|
603 | + $defaults = array('post_type' => 'entity'); |
|
604 | 604 | |
605 | 605 | // Merge the defaults with the provided parameters. |
606 | - $args = wp_parse_args( $params, $defaults ); |
|
606 | + $args = wp_parse_args($params, $defaults); |
|
607 | 607 | |
608 | 608 | // Call the `get_posts` function. |
609 | - return get_posts( $args ); |
|
609 | + return get_posts($args); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | /** |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | public static function valid_entity_post_types() { |
622 | 622 | |
623 | 623 | // Ignore builtins in the call to avoid getting attachments. |
624 | - $post_types = array( 'post', 'page', self::TYPE_NAME, 'product' ); |
|
624 | + $post_types = array('post', 'page', self::TYPE_NAME, 'product'); |
|
625 | 625 | |
626 | - return apply_filters( 'wl_valid_entity_post_types', $post_types ); |
|
626 | + return apply_filters('wl_valid_entity_post_types', $post_types); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | } |