| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPSEO plugin file. |
| 4 |
* |
| 5 |
* @package WPSEO\Frontend\Schema |
| 6 |
*/ |
| 7 |
|
| 8 |
use Yoast\WP\SEO\Config\Schema_IDs; |
| 9 |
use Yoast\WP\SEO\Generators\Schema\Author; |
| 10 |
|
| 11 |
/** |
| 12 |
* Returns schema Person data. |
| 13 |
* |
| 14 |
* @since 10.2 |
| 15 |
* @deprecated 14.0 |
| 16 |
*/ |
| 17 |
class WPSEO_Schema_Author extends WPSEO_Deprecated_Graph_Piece { |
| 18 |
|
| 19 |
/** |
| 20 |
* The hash used for images. |
| 21 |
* |
| 22 |
* @var string |
| 23 |
*/ |
| 24 |
protected $image_hash = Schema_IDs::AUTHOR_LOGO_HASH; |
| 25 |
|
| 26 |
/** |
| 27 |
* The Schema type we use for this class. |
| 28 |
* |
| 29 |
* @var string[] |
| 30 |
*/ |
| 31 |
protected $type = [ 'Person' ]; |
| 32 |
|
| 33 |
/** |
| 34 |
* WPSEO_Schema_Author constructor. |
| 35 |
* |
| 36 |
* @deprecated 14.0 |
| 37 |
* @codeCoverageIgnore |
| 38 |
* |
| 39 |
* @param null $context The context. No longer used but present for BC. |
| 40 |
*/ |
| 41 |
public function __construct( $context = null ) { |
| 42 |
parent::__construct( Author::class ); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Determine whether we should return Person schema. |
| 47 |
* |
| 48 |
* @deprecated 14.0 |
| 49 |
* @codeCoverageIgnore |
| 50 |
* |
| 51 |
* @return bool |
| 52 |
*/ |
| 53 |
public function is_needed() { |
| 54 |
_deprecated_function( __METHOD__, 'WPSEO 14.0', 'Yoast\WP\SEO\Generators\Schema\Author::is_needed' ); |
| 55 |
|
| 56 |
if ( $this->stable->context->indexable->object_type === 'user' ) { |
| 57 |
return true; |
| 58 |
} |
| 59 |
|
| 60 |
// This call to `is_post_author` is why this whole block could not be replaced with a `parent::is_needed()` call. |
| 61 |
if ( $this->is_post_author() ) { |
| 62 |
// If the author is the user the site represents, no need for an extra author block. |
| 63 |
if ( $this->stable->is_needed() ) { |
| 64 |
return (int) $this->stable->context->post->post_author !== $this->stable->context->site_user_id; |
| 65 |
} |
| 66 |
|
| 67 |
return true; |
| 68 |
} |
| 69 |
|
| 70 |
return false; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Gets the Schema type we use for this class. |
| 75 |
* |
| 76 |
* @deprecated 14.0 |
| 77 |
* @codeCoverageIgnore |
| 78 |
* |
| 79 |
* @return string[] The schema type. |
| 80 |
*/ |
| 81 |
public static function get_type() { |
| 82 |
_deprecated_function( __METHOD__, 'WPSEO 14.0' ); |
| 83 |
|
| 84 |
return [ 'Person' ]; |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* Determine whether the current URL is worthy of Article schema. |
| 89 |
* |
| 90 |
* @deprecated 14.0 |
| 91 |
* @codeCoverageIgnore |
| 92 |
* |
| 93 |
* @return bool |
| 94 |
*/ |
| 95 |
protected function is_post_author() { |
| 96 |
_deprecated_function( __METHOD__, 'WPSEO 14.0' ); |
| 97 |
|
| 98 |
return ( |
| 99 |
$this->stable->context->indexable->object_type === 'post' |
| 100 |
&& $this->helpers->schema->article->is_article_post_type( $this->stable->context->indexable->object_sub_type ) |
| 101 |
); |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Determines a User ID for the Person data. |
| 106 |
* |
| 107 |
* @deprecated 14.0 |
| 108 |
* @codeCoverageIgnore |
| 109 |
* |
| 110 |
* @return bool|int User ID or false upon return. |
| 111 |
*/ |
| 112 |
protected function determine_user_id() { |
| 113 |
_deprecated_function( __METHOD__, 'WPSEO 14.0', 'Yoast\WP\SEO\Generators\Schema\Author::determine_user_id' ); |
| 114 |
|
| 115 |
return parent::determine_user_id(); |
| 116 |
} |
| 117 |
} |
| 118 |
|