@@ -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,7 +165,7 @@ 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 | /** |
| 171 | 171 | * Call the `wl_post_jsonld_author` filter. |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $ret_val = apply_filters( |
| 189 | 189 | 'wl_jsonld_author', |
| 190 | 190 | array( |
| 191 | - 'author' => $this->get_author( $post->post_author, $references ), |
|
| 191 | + 'author' => $this->get_author($post->post_author, $references), |
|
| 192 | 192 | 'references' => $references |
| 193 | 193 | ), |
| 194 | 194 | $post_id |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $references = $ret_val['references']; |
| 200 | 200 | |
| 201 | 201 | // Return the JSON-LD if filters are disabled by the client. |
| 202 | - if ( $this->disable_convert_filters ) { |
|
| 202 | + if ($this->disable_convert_filters) { |
|
| 203 | 203 | return $jsonld; |
| 204 | 204 | } |
| 205 | 205 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * |
| 245 | 245 | * @api |
| 246 | 246 | */ |
| 247 | - return apply_filters( 'wl_post_jsonld', $jsonld, $post_id, $references ); |
|
| 247 | + return apply_filters('wl_post_jsonld', $jsonld, $post_id, $references); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -259,18 +259,18 @@ discard block |
||
| 259 | 259 | * @return string|array A JSON-LD structure. |
| 260 | 260 | * @since 3.14.0 |
| 261 | 261 | */ |
| 262 | - public function get_author( $author_id, &$references ) { |
|
| 262 | + public function get_author($author_id, &$references) { |
|
| 263 | 263 | |
| 264 | 264 | // Get the entity bound to this user. |
| 265 | - $entity_id = $this->user_service->get_entity( $author_id ); |
|
| 265 | + $entity_id = $this->user_service->get_entity($author_id); |
|
| 266 | 266 | |
| 267 | 267 | // If there's no entity bound return a simple author structure. |
| 268 | - if ( empty( $entity_id ) || 'publish' !== get_post_status( $entity_id ) ) { |
|
| 268 | + if (empty($entity_id) || 'publish' !== get_post_status($entity_id)) { |
|
| 269 | 269 | |
| 270 | - $author = get_the_author_meta( 'display_name', $author_id ); |
|
| 271 | - $author_first_name = get_the_author_meta( 'first_name', $author_id ); |
|
| 272 | - $author_last_name = get_the_author_meta( 'last_name', $author_id ); |
|
| 273 | - $author_uri = $this->user_service->get_uri( $author_id ); |
|
| 270 | + $author = get_the_author_meta('display_name', $author_id); |
|
| 271 | + $author_first_name = get_the_author_meta('first_name', $author_id); |
|
| 272 | + $author_last_name = get_the_author_meta('last_name', $author_id); |
|
| 273 | + $author_uri = $this->user_service->get_uri($author_id); |
|
| 274 | 274 | |
| 275 | 275 | return array( |
| 276 | 276 | '@type' => 'Person', |
@@ -278,12 +278,12 @@ discard block |
||
| 278 | 278 | 'name' => $author, |
| 279 | 279 | 'givenName' => $author_first_name, |
| 280 | 280 | 'familyName' => $author_last_name, |
| 281 | - 'url' => get_author_posts_url( $author_id ), |
|
| 281 | + 'url' => get_author_posts_url($author_id), |
|
| 282 | 282 | ); |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | // Add the author to the references. |
| 286 | - $author_uri = Wordlift_Entity_Service::get_instance()->get_uri( $entity_id ); |
|
| 286 | + $author_uri = Wordlift_Entity_Service::get_instance()->get_uri($entity_id); |
|
| 287 | 287 | $references[] = $entity_id; |
| 288 | 288 | |
| 289 | 289 | // Return the JSON-LD for the referenced entity. |
@@ -299,41 +299,41 @@ discard block |
||
| 299 | 299 | * |
| 300 | 300 | * @since 3.10.0 |
| 301 | 301 | */ |
| 302 | - protected function set_publisher( &$params ) { |
|
| 302 | + protected function set_publisher(&$params) { |
|
| 303 | 303 | |
| 304 | 304 | // If the publisher id isn't set don't do anything. |
| 305 | 305 | $publisher_id = Wordlift_Configuration_Service::get_instance()->get_publisher_id(); |
| 306 | - if ( empty( $publisher_id ) ) { |
|
| 306 | + if (empty($publisher_id)) { |
|
| 307 | 307 | return; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | // Get the post instance. |
| 311 | - $post = get_post( $publisher_id ); |
|
| 312 | - if ( ! is_a( $post, '\WP_Post' ) ) { |
|
| 311 | + $post = get_post($publisher_id); |
|
| 312 | + if ( ! is_a($post, '\WP_Post')) { |
|
| 313 | 313 | // Publisher not found. |
| 314 | 314 | return; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | // Get the item id. |
| 318 | - $id = Wordlift_Entity_Service::get_instance()->get_uri( $publisher_id ); |
|
| 318 | + $id = Wordlift_Entity_Service::get_instance()->get_uri($publisher_id); |
|
| 319 | 319 | |
| 320 | 320 | // Get the type. |
| 321 | - $type = $this->entity_type_service->get( $publisher_id ); |
|
| 321 | + $type = $this->entity_type_service->get($publisher_id); |
|
| 322 | 322 | |
| 323 | 323 | // Get the name. |
| 324 | 324 | $name = $post->post_title; |
| 325 | 325 | |
| 326 | 326 | // Set the publisher data. |
| 327 | 327 | $params['publisher'] = array( |
| 328 | - '@type' => $this->relative_to_context( $type['uri'] ), |
|
| 328 | + '@type' => $this->relative_to_context($type['uri']), |
|
| 329 | 329 | '@id' => $id, |
| 330 | 330 | 'name' => $name, |
| 331 | 331 | ); |
| 332 | 332 | |
| 333 | 333 | // Add the sameAs values associated with the publisher. |
| 334 | 334 | $storage_factory = Wordlift_Storage_Factory::get_instance(); |
| 335 | - $sameas = $storage_factory->post_meta( Wordlift_Schema_Service::FIELD_SAME_AS )->get( $publisher_id ); |
|
| 336 | - if ( ! empty( $sameas ) ) { |
|
| 335 | + $sameas = $storage_factory->post_meta(Wordlift_Schema_Service::FIELD_SAME_AS)->get($publisher_id); |
|
| 336 | + if ( ! empty($sameas)) { |
|
| 337 | 337 | $params['publisher']['sameAs'] = $sameas; |
| 338 | 338 | } |
| 339 | 339 | |
@@ -341,15 +341,15 @@ discard block |
||
| 341 | 341 | // support the logo property. |
| 342 | 342 | // |
| 343 | 343 | // See http://schema.org/logo. |
| 344 | - if ( 1 !== preg_match( '~Organization$~', $type['uri'] ) ) { |
|
| 344 | + if (1 !== preg_match('~Organization$~', $type['uri'])) { |
|
| 345 | 345 | return; |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | // Get the publisher logo. |
| 349 | - $publisher_logo = $this->get_publisher_logo( $post->ID ); |
|
| 349 | + $publisher_logo = $this->get_publisher_logo($post->ID); |
|
| 350 | 350 | |
| 351 | 351 | // Bail out if the publisher logo isn't set. |
| 352 | - if ( false === $publisher_logo ) { |
|
| 352 | + if (false === $publisher_logo) { |
|
| 353 | 353 | return; |
| 354 | 354 | } |
| 355 | 355 | |
@@ -383,14 +383,14 @@ discard block |
||
| 383 | 383 | * @since 3.19.2 |
| 384 | 384 | * @see https://github.com/insideout10/wordlift-plugin/issues/823 related issue. |
| 385 | 385 | */ |
| 386 | - private function get_publisher_logo( $post_id ) { |
|
| 386 | + private function get_publisher_logo($post_id) { |
|
| 387 | 387 | |
| 388 | 388 | // Get the featured image for the post. |
| 389 | - $thumbnail_id = get_post_thumbnail_id( $post_id ); |
|
| 389 | + $thumbnail_id = get_post_thumbnail_id($post_id); |
|
| 390 | 390 | |
| 391 | 391 | // Bail out if thumbnail not available. |
| 392 | - if ( empty( $thumbnail_id ) || 0 === $thumbnail_id ) { |
|
| 393 | - $this->log->info( "Featured image not set for post $post_id." ); |
|
| 392 | + if (empty($thumbnail_id) || 0 === $thumbnail_id) { |
|
| 393 | + $this->log->info("Featured image not set for post $post_id."); |
|
| 394 | 394 | |
| 395 | 395 | return false; |
| 396 | 396 | } |
@@ -399,24 +399,24 @@ discard block |
||
| 399 | 399 | $uploads_dir = wp_upload_dir(); |
| 400 | 400 | |
| 401 | 401 | // Get the attachment metadata. |
| 402 | - $metadata = wp_get_attachment_metadata( $thumbnail_id ); |
|
| 402 | + $metadata = wp_get_attachment_metadata($thumbnail_id); |
|
| 403 | 403 | |
| 404 | 404 | // Bail out if the file isn't set. |
| 405 | - if ( ! isset( $metadata['file'] ) ) { |
|
| 406 | - $this->log->warn( "Featured image file not found for post $post_id." ); |
|
| 405 | + if ( ! isset($metadata['file'])) { |
|
| 406 | + $this->log->warn("Featured image file not found for post $post_id."); |
|
| 407 | 407 | |
| 408 | 408 | return false; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | // Retrieve the relative filename, e.g. "2018/05/logo_publisher.png" |
| 412 | - $path = $uploads_dir['basedir'] . DIRECTORY_SEPARATOR . $metadata['file']; |
|
| 412 | + $path = $uploads_dir['basedir'].DIRECTORY_SEPARATOR.$metadata['file']; |
|
| 413 | 413 | |
| 414 | 414 | // Use image src, if local file does not exist. @see https://github.com/insideout10/wordlift-plugin/issues/1149 |
| 415 | - if ( ! file_exists( $path ) ) { |
|
| 416 | - $this->log->warn( "Featured image file $path doesn't exist for post $post_id." ); |
|
| 415 | + if ( ! file_exists($path)) { |
|
| 416 | + $this->log->warn("Featured image file $path doesn't exist for post $post_id."); |
|
| 417 | 417 | |
| 418 | - $attachment_image_src = wp_get_attachment_image_src( $thumbnail_id, '' ); |
|
| 419 | - if ( $attachment_image_src ) { |
|
| 418 | + $attachment_image_src = wp_get_attachment_image_src($thumbnail_id, ''); |
|
| 419 | + if ($attachment_image_src) { |
|
| 420 | 420 | return array( |
| 421 | 421 | 'url' => $attachment_image_src[0], |
| 422 | 422 | 'width' => $attachment_image_src[1], |
@@ -430,27 +430,27 @@ discard block |
||
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | // Try to get the image editor and bail out if the editor cannot be instantiated. |
| 433 | - $original_file_editor = wp_get_image_editor( $path ); |
|
| 434 | - if ( is_wp_error( $original_file_editor ) ) { |
|
| 435 | - $this->log->warn( "Cannot instantiate WP Image Editor on file $path for post $post_id." ); |
|
| 433 | + $original_file_editor = wp_get_image_editor($path); |
|
| 434 | + if (is_wp_error($original_file_editor)) { |
|
| 435 | + $this->log->warn("Cannot instantiate WP Image Editor on file $path for post $post_id."); |
|
| 436 | 436 | |
| 437 | 437 | return false; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | // Generate the publisher logo filename, we cannot use the `width` and `height` because we're scaling |
| 441 | 441 | // and we don't actually know the end values. |
| 442 | - $publisher_logo_path = $original_file_editor->generate_filename( '-publisher-logo' ); |
|
| 442 | + $publisher_logo_path = $original_file_editor->generate_filename('-publisher-logo'); |
|
| 443 | 443 | |
| 444 | 444 | // If the file doesn't exist yet, create it. |
| 445 | - if ( ! file_exists( $publisher_logo_path ) ) { |
|
| 446 | - $original_file_editor->resize( 600, 60 ); |
|
| 447 | - $original_file_editor->save( $publisher_logo_path ); |
|
| 445 | + if ( ! file_exists($publisher_logo_path)) { |
|
| 446 | + $original_file_editor->resize(600, 60); |
|
| 447 | + $original_file_editor->save($publisher_logo_path); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | // Try to get the image editor and bail out if the editor cannot be instantiated. |
| 451 | - $publisher_logo_editor = wp_get_image_editor( $publisher_logo_path ); |
|
| 452 | - if ( is_wp_error( $publisher_logo_editor ) ) { |
|
| 453 | - $this->log->warn( "Cannot instantiate WP Image Editor on file $publisher_logo_path for post $post_id." ); |
|
| 451 | + $publisher_logo_editor = wp_get_image_editor($publisher_logo_path); |
|
| 452 | + if (is_wp_error($publisher_logo_editor)) { |
|
| 453 | + $this->log->warn("Cannot instantiate WP Image Editor on file $publisher_logo_path for post $post_id."); |
|
| 454 | 454 | |
| 455 | 455 | return false; |
| 456 | 456 | } |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | |
| 461 | 461 | // Finally return the array with data. |
| 462 | 462 | return array( |
| 463 | - 'url' => $uploads_dir['baseurl'] . substr( $publisher_logo_path, strlen( $uploads_dir['basedir'] ) ), |
|
| 463 | + 'url' => $uploads_dir['baseurl'].substr($publisher_logo_path, strlen($uploads_dir['basedir'])), |
|
| 464 | 464 | 'width' => $size['width'], |
| 465 | 465 | 'height' => $size['height'], |
| 466 | 466 | ); |
@@ -31,26 +31,26 @@ discard block |
||
| 31 | 31 | use Wordlift\Features\Features_Registry; |
| 32 | 32 | use Wordlift\Post\Post_Adapter; |
| 33 | 33 | |
| 34 | -define( 'WORDLIFT_PLUGIN_FILE', __FILE__ ); |
|
| 35 | -define( 'WORDLIFT_VERSION', '3.52.0-0' ); |
|
| 34 | +define('WORDLIFT_PLUGIN_FILE', __FILE__); |
|
| 35 | +define('WORDLIFT_VERSION', '3.52.0-0'); |
|
| 36 | 36 | |
| 37 | 37 | // ## DO NOT REMOVE THIS LINE: WHITELABEL PLACEHOLDER ## |
| 38 | 38 | |
| 39 | -require_once plugin_dir_path( __FILE__ ) . '/libraries/action-scheduler/action-scheduler.php'; |
|
| 40 | -require_once __DIR__ . '/modules/common/load.php'; |
|
| 41 | -require_once __DIR__ . '/modules/app/load.php'; |
|
| 42 | -require_once __DIR__ . '/modules/include-exclude/load.php'; |
|
| 39 | +require_once plugin_dir_path(__FILE__).'/libraries/action-scheduler/action-scheduler.php'; |
|
| 40 | +require_once __DIR__.'/modules/common/load.php'; |
|
| 41 | +require_once __DIR__.'/modules/app/load.php'; |
|
| 42 | +require_once __DIR__.'/modules/include-exclude/load.php'; |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * Filter to disable WLP on any request, defaults to true. |
| 46 | 46 | * |
| 47 | 47 | * @since 3.33.6 |
| 48 | 48 | */ |
| 49 | -if ( ! apply_filters( 'wl_is_enabled', true ) ) { |
|
| 49 | +if ( ! apply_filters('wl_is_enabled', true)) { |
|
| 50 | 50 | return; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | -require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; |
|
| 53 | +require_once plugin_dir_path(__FILE__).'vendor/autoload.php'; |
|
| 54 | 54 | |
| 55 | 55 | /* |
| 56 | 56 | * We introduce the WordLift autoloader, since we start using classes in namespaces, i.e. Wordlift\Http. |
@@ -60,15 +60,15 @@ discard block |
||
| 60 | 60 | wordlift_plugin_autoload_register(); |
| 61 | 61 | |
| 62 | 62 | // Include WordLift constants. |
| 63 | -require_once plugin_dir_path( __FILE__ ) . 'wordlift-constants.php'; |
|
| 63 | +require_once plugin_dir_path(__FILE__).'wordlift-constants.php'; |
|
| 64 | 64 | |
| 65 | 65 | // Load modules. |
| 66 | -require_once plugin_dir_path( __FILE__ ) . 'modules/core/wordlift-core.php'; |
|
| 66 | +require_once plugin_dir_path(__FILE__).'modules/core/wordlift-core.php'; |
|
| 67 | 67 | |
| 68 | -require_once plugin_dir_path( __FILE__ ) . 'deprecations.php'; |
|
| 68 | +require_once plugin_dir_path(__FILE__).'deprecations.php'; |
|
| 69 | 69 | |
| 70 | 70 | // Load early to enable/disable features. |
| 71 | -require_once plugin_dir_path( __FILE__ ) . 'classes/features/index.php'; |
|
| 71 | +require_once plugin_dir_path(__FILE__).'classes/features/index.php'; |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * The code that runs during plugin activation. |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | function activate_wordlift() { |
| 78 | 78 | |
| 79 | - $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' ); |
|
| 79 | + $log = Wordlift_Log_Service::get_logger('activate_wordlift'); |
|
| 80 | 80 | |
| 81 | - $log->info( 'Activating WordLift...' ); |
|
| 81 | + $log->info('Activating WordLift...'); |
|
| 82 | 82 | |
| 83 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 83 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php'; |
|
| 84 | 84 | Wordlift_Activator::activate(); |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | Top_Entities::activate(); |
| 102 | 102 | |
| 103 | - if ( ! wp_next_scheduled( 'wl_daily_cron' ) ) { |
|
| 104 | - wp_schedule_event( time(), 'daily', 'wl_daily_cron' ); |
|
| 103 | + if ( ! wp_next_scheduled('wl_daily_cron')) { |
|
| 104 | + wp_schedule_event(time(), 'daily', 'wl_daily_cron'); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | function deactivate_wordlift() { |
| 114 | 114 | |
| 115 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 115 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php'; |
|
| 116 | 116 | Wordlift_Deactivator::deactivate(); |
| 117 | 117 | Wordlift_Http_Api::deactivate(); |
| 118 | 118 | Ttl_Cache_Cleaner::deactivate(); |
@@ -128,18 +128,18 @@ discard block |
||
| 128 | 128 | Key_Validation_Notice::remove_notification_flag(); |
| 129 | 129 | flush_rewrite_rules(); |
| 130 | 130 | |
| 131 | - wp_clear_scheduled_hook( 'wl_daily_cron' ); |
|
| 131 | + wp_clear_scheduled_hook('wl_daily_cron'); |
|
| 132 | 132 | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | -register_activation_hook( __FILE__, 'activate_wordlift' ); |
|
| 136 | -register_deactivation_hook( __FILE__, 'deactivate_wordlift' ); |
|
| 135 | +register_activation_hook(__FILE__, 'activate_wordlift'); |
|
| 136 | +register_deactivation_hook(__FILE__, 'deactivate_wordlift'); |
|
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | 139 | * The core plugin class that is used to define internationalization, |
| 140 | 140 | * admin-specific hooks, and public-facing site hooks. |
| 141 | 141 | */ |
| 142 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php'; |
|
| 142 | +require plugin_dir_path(__FILE__).'includes/class-wordlift.php'; |
|
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * Begins execution of the plugin. |
@@ -159,12 +159,12 @@ discard block |
||
| 159 | 159 | * @return bool |
| 160 | 160 | * @since 3.27.6 |
| 161 | 161 | */ |
| 162 | - if ( apply_filters( 'wl_feature__enable__widgets', true ) ) { |
|
| 163 | - add_action( 'widgets_init', 'wl_register_chord_widget' ); |
|
| 164 | - add_action( 'widgets_init', 'wl_register_geo_widget' ); |
|
| 165 | - add_action( 'widgets_init', 'wl_register_timeline_widget' ); |
|
| 162 | + if (apply_filters('wl_feature__enable__widgets', true)) { |
|
| 163 | + add_action('widgets_init', 'wl_register_chord_widget'); |
|
| 164 | + add_action('widgets_init', 'wl_register_geo_widget'); |
|
| 165 | + add_action('widgets_init', 'wl_register_timeline_widget'); |
|
| 166 | 166 | } |
| 167 | - add_filter( 'widget_text', 'do_shortcode' ); |
|
| 167 | + add_filter('widget_text', 'do_shortcode'); |
|
| 168 | 168 | |
| 169 | 169 | /** |
| 170 | 170 | * Filter: wl_feature__enable__analysis |
@@ -174,10 +174,10 @@ discard block |
||
| 174 | 174 | * @return bool |
| 175 | 175 | * @since 3.27.6 |
| 176 | 176 | */ |
| 177 | - if ( apply_filters( 'wl_feature__enable__analysis', true ) ) { |
|
| 178 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' ); |
|
| 177 | + if (apply_filters('wl_feature__enable__analysis', true)) { |
|
| 178 | + add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_action'); |
|
| 179 | 179 | } else { |
| 180 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' ); |
|
| 180 | + add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action'); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | $plugin = new Wordlift(); |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | add_action( |
| 196 | 196 | 'plugins_loaded', |
| 197 | - function () { |
|
| 197 | + function() { |
|
| 198 | 198 | // All features from registry should be initialized here. |
| 199 | 199 | $features_registry = Features_Registry::get_instance(); |
| 200 | 200 | $features_registry->initialize_all_features(); |
@@ -205,27 +205,27 @@ discard block |
||
| 205 | 205 | add_action( |
| 206 | 206 | 'plugins_loaded', |
| 207 | 207 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 208 | - function () use ( $plugin ) { |
|
| 208 | + function() use ($plugin) { |
|
| 209 | 209 | |
| 210 | 210 | new Wordlift_Products_Navigator_Shortcode_REST(); |
| 211 | 211 | |
| 212 | 212 | // Register the Dataset module, requires `$api_service`. |
| 213 | - require_once plugin_dir_path( __FILE__ ) . 'classes/dataset/index.php'; |
|
| 214 | - require_once plugin_dir_path( __FILE__ ) . 'classes/shipping-data/index.php'; |
|
| 213 | + require_once plugin_dir_path(__FILE__).'classes/dataset/index.php'; |
|
| 214 | + require_once plugin_dir_path(__FILE__).'classes/shipping-data/index.php'; |
|
| 215 | 215 | |
| 216 | 216 | /* |
| 217 | 217 | * Require the Entity annotation cleanup module. |
| 218 | 218 | * |
| 219 | 219 | * @since 3.34.6 |
| 220 | 220 | */ |
| 221 | - require_once plugin_dir_path( __FILE__ ) . 'classes/cleanup/index.php'; |
|
| 221 | + require_once plugin_dir_path(__FILE__).'classes/cleanup/index.php'; |
|
| 222 | 222 | |
| 223 | 223 | /* |
| 224 | 224 | * Import LOD entities. |
| 225 | 225 | * |
| 226 | 226 | * @since 3.35.0 |
| 227 | 227 | */ |
| 228 | - require_once plugin_dir_path( __FILE__ ) . 'classes/lod-import/index.php'; |
|
| 228 | + require_once plugin_dir_path(__FILE__).'classes/lod-import/index.php'; |
|
| 229 | 229 | |
| 230 | 230 | } |
| 231 | 231 | ); |
@@ -243,31 +243,31 @@ discard block |
||
| 243 | 243 | function wordlift_plugin_autoload_register() { |
| 244 | 244 | |
| 245 | 245 | spl_autoload_register( |
| 246 | - function ( $class_name ) { |
|
| 246 | + function($class_name) { |
|
| 247 | 247 | |
| 248 | 248 | // Bail out if these are not our classes. |
| 249 | - if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) { |
|
| 249 | + if (0 !== strpos($class_name, 'Wordlift\\')) { |
|
| 250 | 250 | return false; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) ); |
|
| 253 | + $class_name_lc = strtolower(str_replace('_', '-', $class_name)); |
|
| 254 | 254 | |
| 255 | - preg_match( '|^wordlift\\\\(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches ); |
|
| 255 | + preg_match('|^wordlift\\\\(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches); |
|
| 256 | 256 | |
| 257 | - $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] ); |
|
| 258 | - $file = 'class-' . $matches[2] . '.php'; |
|
| 257 | + $path = str_replace('\\', DIRECTORY_SEPARATOR, $matches[1]); |
|
| 258 | + $file = 'class-'.$matches[2].'.php'; |
|
| 259 | 259 | |
| 260 | - $full_path = plugin_dir_path( __FILE__ ) . 'classes' . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $file; |
|
| 260 | + $full_path = plugin_dir_path(__FILE__).'classes'.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$file; |
|
| 261 | 261 | |
| 262 | - if ( ! file_exists( $full_path ) ) { |
|
| 262 | + if ( ! file_exists($full_path)) { |
|
| 263 | 263 | return false; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | try { |
| 267 | 267 | require_once $full_path; |
| 268 | - } catch ( Exception $e ) { |
|
| 268 | + } catch (Exception $e) { |
|
| 269 | 269 | // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log |
| 270 | - error_log( "[WordLift] $full_path not found, cannot include." ); |
|
| 270 | + error_log("[WordLift] $full_path not found, cannot include."); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | return true; |
@@ -276,13 +276,13 @@ discard block |
||
| 276 | 276 | |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | -function wl_block_categories( $categories ) { |
|
| 279 | +function wl_block_categories($categories) { |
|
| 280 | 280 | return array_merge( |
| 281 | 281 | $categories, |
| 282 | 282 | array( |
| 283 | 283 | array( |
| 284 | 284 | 'slug' => 'wordlift', |
| 285 | - 'title' => __( 'WordLift', 'wordlift' ), |
|
| 285 | + 'title' => __('WordLift', 'wordlift'), |
|
| 286 | 286 | ), |
| 287 | 287 | ) |
| 288 | 288 | ); |
@@ -292,52 +292,52 @@ discard block |
||
| 292 | 292 | * This function is created temporarily to handle the legacy library, |
| 293 | 293 | * this has to be removed when removing the legacy fields from the ui. |
| 294 | 294 | */ |
| 295 | -function wl_enqueue_leaflet( $in_footer = false ) { |
|
| 295 | +function wl_enqueue_leaflet($in_footer = false) { |
|
| 296 | 296 | // Leaflet. |
| 297 | - wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' ); |
|
| 298 | - wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer ); |
|
| 297 | + wp_enqueue_style('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.css', array(), '1.6.0'); |
|
| 298 | + wp_enqueue_script('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | -add_filter( 'block_categories', 'wl_block_categories', 10 ); |
|
| 301 | +add_filter('block_categories', 'wl_block_categories', 10); |
|
| 302 | 302 | |
| 303 | 303 | // Temporary fix for a typo in WooCommerce Extension. |
| 304 | 304 | add_filter( |
| 305 | 305 | 'wl_feature__enable__dataset', |
| 306 | - function ( $value ) { |
|
| 307 | - return apply_filters( 'wl_features__enable__dataset', $value ); |
|
| 306 | + function($value) { |
|
| 307 | + return apply_filters('wl_features__enable__dataset', $value); |
|
| 308 | 308 | } |
| 309 | 309 | ); |
| 310 | 310 | |
| 311 | -require_once __DIR__ . '/modules/food-kg/load.php'; |
|
| 312 | -require_once __DIR__ . '/modules/gardening-kg/load.php'; |
|
| 313 | -require_once __DIR__ . '/modules/acf4so/load.php'; |
|
| 314 | -require_once __DIR__ . '/modules/dashboard/load.php'; |
|
| 315 | -require_once __DIR__ . '/modules/pods/load.php'; |
|
| 316 | -require_once __DIR__ . '/modules/include-exclude-push-config/load.php'; |
|
| 317 | -require_once __DIR__ . '/modules/super-resolution/load.php'; |
|
| 318 | -require_once __DIR__ . '/modules/redeem-code/load.php'; |
|
| 319 | -require_once __DIR__ . '/modules/raptive-setup/load.php'; |
|
| 320 | -require_once __DIR__ . '/modules/events/load.php'; |
|
| 321 | -require_once __DIR__ . '/modules/plugin-diagnostics/load.php'; |
|
| 322 | -require_once __DIR__ . '/modules/override-url/load.php'; |
|
| 323 | -require_once __DIR__ . '/modules/jsonld-author-filter/load.php'; |
|
| 324 | - |
|
| 325 | -function _wl_update_plugins_raptive_domain( $update, $plugin_data, $plugin_file ) { |
|
| 311 | +require_once __DIR__.'/modules/food-kg/load.php'; |
|
| 312 | +require_once __DIR__.'/modules/gardening-kg/load.php'; |
|
| 313 | +require_once __DIR__.'/modules/acf4so/load.php'; |
|
| 314 | +require_once __DIR__.'/modules/dashboard/load.php'; |
|
| 315 | +require_once __DIR__.'/modules/pods/load.php'; |
|
| 316 | +require_once __DIR__.'/modules/include-exclude-push-config/load.php'; |
|
| 317 | +require_once __DIR__.'/modules/super-resolution/load.php'; |
|
| 318 | +require_once __DIR__.'/modules/redeem-code/load.php'; |
|
| 319 | +require_once __DIR__.'/modules/raptive-setup/load.php'; |
|
| 320 | +require_once __DIR__.'/modules/events/load.php'; |
|
| 321 | +require_once __DIR__.'/modules/plugin-diagnostics/load.php'; |
|
| 322 | +require_once __DIR__.'/modules/override-url/load.php'; |
|
| 323 | +require_once __DIR__.'/modules/jsonld-author-filter/load.php'; |
|
| 324 | + |
|
| 325 | +function _wl_update_plugins_raptive_domain($update, $plugin_data, $plugin_file) { |
|
| 326 | 326 | // Bail out if it's not our plugin. |
| 327 | 327 | $update_uri = $plugin_data['UpdateURI']; |
| 328 | - if ( 'wordlift/wordlift.php' !== $plugin_file || ! isset( $update_uri ) ) { |
|
| 328 | + if ('wordlift/wordlift.php' !== $plugin_file || ! isset($update_uri)) { |
|
| 329 | 329 | return $update; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - $response = wp_remote_get( "$update_uri?nocache=" . time() ); |
|
| 332 | + $response = wp_remote_get("$update_uri?nocache=".time()); |
|
| 333 | 333 | |
| 334 | - if ( is_wp_error( $response ) ) { |
|
| 334 | + if (is_wp_error($response)) { |
|
| 335 | 335 | return $update; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | try { |
| 339 | - return json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 340 | - } catch ( Exception $e ) { |
|
| 339 | + return json_decode(wp_remote_retrieve_body($response)); |
|
| 340 | + } catch (Exception $e) { |
|
| 341 | 341 | return $update; |
| 342 | 342 | } |
| 343 | 343 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter |
| 49 | 49 | * @param $cached_postid_to_jsonld_converter |
| 50 | 50 | */ |
| 51 | - public function __construct( $post_to_jsonld_converter, $cached_postid_to_jsonld_converter ) { |
|
| 51 | + public function __construct($post_to_jsonld_converter, $cached_postid_to_jsonld_converter) { |
|
| 52 | 52 | |
| 53 | 53 | $this->post_to_jsonld_converter = $post_to_jsonld_converter->new_instance_with_filters_disabled(); |
| 54 | 54 | |
@@ -67,16 +67,16 @@ discard block |
||
| 67 | 67 | $this->entity_uri_service = \Wordlift_Entity_Uri_Service::get_instance(); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function after_get_jsonld( $jsonld, $post_id, $context ) { |
|
| 70 | + public function after_get_jsonld($jsonld, $post_id, $context) { |
|
| 71 | 71 | |
| 72 | 72 | // Invalid data structure |
| 73 | - if ( ! is_array( $jsonld ) || ! isset( $jsonld[0] ) || ! is_array( $jsonld[0] ) ) { |
|
| 73 | + if ( ! is_array($jsonld) || ! isset($jsonld[0]) || ! is_array($jsonld[0])) { |
|
| 74 | 74 | return $jsonld; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if ( Jsonld_Context_Enum::PAGE !== $context |
|
| 77 | + if (Jsonld_Context_Enum::PAGE !== $context |
|
| 78 | 78 | // Returns true for "1", "true", "on" and "yes". Returns false otherwise. |
| 79 | - && ! filter_input( INPUT_GET, 'article_wrapper', FILTER_VALIDATE_BOOLEAN ) ) { |
|
| 79 | + && ! filter_input(INPUT_GET, 'article_wrapper', FILTER_VALIDATE_BOOLEAN)) { |
|
| 80 | 80 | return $jsonld; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | // Don't wrap in article if the json-ld is already about an Article (or its descendants). `@type` must be |
| 87 | 87 | // in the schema.org context, i.e. `Article`, not `http://schema.org/Article`. |
| 88 | - if ( ! isset( $post_jsonld['@id'] ) || ! isset( $post_jsonld['@type'] ) || $this->is_article( $post_jsonld['@type'] ) ) { |
|
| 88 | + if ( ! isset($post_jsonld['@id']) || ! isset($post_jsonld['@type']) || $this->is_article($post_jsonld['@type'])) { |
|
| 89 | 89 | return $jsonld; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -93,21 +93,21 @@ discard block |
||
| 93 | 93 | $reference_infos = array(); |
| 94 | 94 | |
| 95 | 95 | // Convert the post as Article. |
| 96 | - $article_jsonld = $this->post_to_jsonld_converter->convert( $post_id, $references, $reference_infos, new Relations() ); |
|
| 96 | + $article_jsonld = $this->post_to_jsonld_converter->convert($post_id, $references, $reference_infos, new Relations()); |
|
| 97 | 97 | |
| 98 | - $article_jsonld['@id'] = $post_jsonld['@id'] . '#article'; |
|
| 98 | + $article_jsonld['@id'] = $post_jsonld['@id'].'#article'; |
|
| 99 | 99 | // Reset the type, since by default the type assigned via the Entity Type taxonomy is used. |
| 100 | 100 | $article_jsonld['@type'] = 'Article'; |
| 101 | - $article_jsonld['about'] = array( '@id' => $post_jsonld['@id'] ); |
|
| 101 | + $article_jsonld['about'] = array('@id' => $post_jsonld['@id']); |
|
| 102 | 102 | |
| 103 | 103 | // Copy over the URLs. |
| 104 | - if ( isset( $post_jsonld['url'] ) ) { |
|
| 104 | + if (isset($post_jsonld['url'])) { |
|
| 105 | 105 | $article_jsonld['url'] = $post_jsonld['url']; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - array_unshift( $jsonld, $article_jsonld ); |
|
| 108 | + array_unshift($jsonld, $article_jsonld); |
|
| 109 | 109 | |
| 110 | - $author_jsonld = $this->get_author_linked_entity( $article_jsonld ); |
|
| 110 | + $author_jsonld = $this->get_author_linked_entity($article_jsonld); |
|
| 111 | 111 | |
| 112 | 112 | |
| 113 | 113 | // Get primary author in case co-authors exist. |
@@ -119,18 +119,18 @@ discard block |
||
| 119 | 119 | * reference : https://schema.org/author |
| 120 | 120 | */ |
| 121 | 121 | |
| 122 | - if ( $author_jsonld && ! $this->is_author_entity_present_in_graph( $jsonld, $primary_author['@id'] ) ) { |
|
| 122 | + if ($author_jsonld && ! $this->is_author_entity_present_in_graph($jsonld, $primary_author['@id'])) { |
|
| 123 | 123 | $jsonld[] = $author_jsonld; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | return $jsonld; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - private function is_article( $schema_types ) { |
|
| 129 | + private function is_article($schema_types) { |
|
| 130 | 130 | |
| 131 | - $array_intersect = array_intersect( self::$article_types, (array) $schema_types ); |
|
| 131 | + $array_intersect = array_intersect(self::$article_types, (array) $schema_types); |
|
| 132 | 132 | |
| 133 | - return ! empty( $array_intersect ); |
|
| 133 | + return ! empty($array_intersect); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -144,32 +144,32 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @since 3.51.4 |
| 146 | 146 | */ |
| 147 | - private function get_primary_author( $author ) { |
|
| 147 | + private function get_primary_author($author) { |
|
| 148 | 148 | |
| 149 | 149 | // Nested array of co-authors. Return the primary author. |
| 150 | - if ( is_array( $author ) && ! empty( $author ) && ! isset( $author['@id'] ) ) { |
|
| 150 | + if (is_array($author) && ! empty($author) && ! isset($author['@id'])) { |
|
| 151 | 151 | return $author[0]; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | return $author; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - private function get_author_linked_entity( $article_jsonld ) { |
|
| 158 | - if ( ! array_key_exists( 'author', $article_jsonld ) ) { |
|
| 157 | + private function get_author_linked_entity($article_jsonld) { |
|
| 158 | + if ( ! array_key_exists('author', $article_jsonld)) { |
|
| 159 | 159 | return false; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - $author = $this->get_primary_author( $article_jsonld['author'] ); |
|
| 162 | + $author = $this->get_primary_author($article_jsonld['author']); |
|
| 163 | 163 | |
| 164 | - if ( count( array_keys( $author ) ) !== 1 || ! array_key_exists( '@id', $author ) ) { |
|
| 164 | + if (count(array_keys($author)) !== 1 || ! array_key_exists('@id', $author)) { |
|
| 165 | 165 | return false; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $author_linked_entity_id = $author['@id']; |
| 169 | 169 | |
| 170 | - $author_entity_post = $this->entity_uri_service->get_entity( $author_linked_entity_id ); |
|
| 170 | + $author_entity_post = $this->entity_uri_service->get_entity($author_linked_entity_id); |
|
| 171 | 171 | |
| 172 | - if ( ! $author_entity_post instanceof \WP_Post ) { |
|
| 172 | + if ( ! $author_entity_post instanceof \WP_Post) { |
|
| 173 | 173 | return false; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -185,10 +185,10 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - private function is_author_entity_present_in_graph( $jsonld, $author_entity_id ) { |
|
| 188 | + private function is_author_entity_present_in_graph($jsonld, $author_entity_id) { |
|
| 189 | 189 | |
| 190 | - foreach ( $jsonld as $item ) { |
|
| 191 | - if ( $item && array_key_exists( '@id', $item ) && $item['@id'] === $author_entity_id ) { |
|
| 190 | + foreach ($jsonld as $item) { |
|
| 191 | + if ($item && array_key_exists('@id', $item) && $item['@id'] === $author_entity_id) { |
|
| 192 | 192 | return true; |
| 193 | 193 | } |
| 194 | 194 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @see https://www.geeklab.info/2010/04/wordpress-pass-variables-by-reference-with-apply_filter/ |
| 20 | 20 | */ |
| 21 | -function _wl_jsonld_author__author_filter( $args_arr, $post_id ) { |
|
| 21 | +function _wl_jsonld_author__author_filter($args_arr, $post_id) { |
|
| 22 | 22 | |
| 23 | 23 | $author = $args_arr['author']; |
| 24 | 24 | $references = $args_arr['references']; |
@@ -26,19 +26,19 @@ discard block |
||
| 26 | 26 | $coauthor_plugin_path = 'co-authors-plus/co-authors-plus.php'; |
| 27 | 27 | |
| 28 | 28 | // If the co-authors plugin is active. |
| 29 | - if ( is_plugin_active( $coauthor_plugin_path ) && function_exists( 'get_coauthors' ) ) { |
|
| 29 | + if (is_plugin_active($coauthor_plugin_path) && function_exists('get_coauthors')) { |
|
| 30 | 30 | |
| 31 | - $coauthors = get_coauthors( $post_id ); |
|
| 31 | + $coauthors = get_coauthors($post_id); |
|
| 32 | 32 | |
| 33 | 33 | // And we have multiple authors on a post. |
| 34 | - if ( count( $coauthors ) > 1 ) { |
|
| 34 | + if (count($coauthors) > 1) { |
|
| 35 | 35 | |
| 36 | 36 | // Clear the existing author. |
| 37 | 37 | $author = array(); |
| 38 | 38 | |
| 39 | 39 | // Build array of authors. |
| 40 | - foreach ( $coauthors as $coauthor ) { |
|
| 41 | - $author[] = Wordlift_Post_To_Jsonld_Converter::get_instance()->get_author( $coauthor->ID, $references ); |
|
| 40 | + foreach ($coauthors as $coauthor) { |
|
| 41 | + $author[] = Wordlift_Post_To_Jsonld_Converter::get_instance()->get_author($coauthor->ID, $references); |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |