| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Helpers\Schema; |
| 4 |
|
| 5 |
/** |
| 6 |
* Class Article_Helper. |
| 7 |
*/ |
| 8 |
class Article_Helper { |
| 9 |
|
| 10 |
/** |
| 11 |
* Determines whether a given post type should have Article schema. |
| 12 |
* |
| 13 |
* @param string|null $post_type Post type to check. |
| 14 |
* |
| 15 |
* @return bool True if it has Article schema, false if not. |
| 16 |
*/ |
| 17 |
public function is_article_post_type( $post_type = null ) { |
| 18 |
if ( \is_null( $post_type ) ) { |
| 19 |
$post_type = \get_post_type(); |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Filter: 'wpseo_schema_article_post_types' - Allow changing for which post types we output Article schema. |
| 24 |
* |
| 25 |
* @deprecated 17.6 - Just enable support for authors for the desired post type. |
| 26 |
* |
| 27 |
* @api string[] $post_types The post types for which we output Article. |
| 28 |
*/ |
| 29 |
\apply_filters_deprecated( 'wpseo_schema_article_post_types', [ [ 'post' ] ], 'WPSEO 17.6', '', 'Every post type supporting authors will automatically have the Article schema enabled.' ); |
| 30 |
|
| 31 |
return $this->is_author_supported( $post_type ); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Checks whether author is supported for the passed object sub type. |
| 36 |
* |
| 37 |
* @param string $object_sub_type The sub type of the object to check author support for. |
| 38 |
* |
| 39 |
* @return bool True if author is supported for the passed object sub type. |
| 40 |
*/ |
| 41 |
public function is_author_supported( $object_sub_type ) { |
| 42 |
return \post_type_supports( $object_sub_type, 'author' ); |
| 43 |
} |
| 44 |
} |
| 45 |
|