PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.2
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.2
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / presenters / meta-author-presenter.php

meta-author-presenter.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.2, at src/presenters/meta-author-presenter.php

60 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Presenters;
4
5 use WP_User;
6 use Yoast\WP\SEO\Presentations\Indexable_Presentation;
7
8 /**
9 * Presenter class for the meta author tag.
10 */
11 class Meta_Author_Presenter extends Abstract_Indexable_Tag_Presenter {
12
13 /**
14 * The tag key name.
15 *
16 * @var string
17 */
18 protected $key = 'author';
19
20 /**
21 * Returns the author for a post in a meta author tag.
22 *
23 * @return string The meta author tag.
24 */
25 public function present() {
26 $output = parent::present();
27
28 if ( ! empty( $output ) ) {
29 return $output;
30 }
31
32 return '';
33 }
34
35 /**
36 * Get the author's display name.
37 *
38 * @return string The author's display name.
39 */
40 public function get() {
41 if ( $this->presentation->model->object_sub_type !== 'post' ) {
42 return '';
43 }
44
45 $user_data = \get_userdata( $this->presentation->context->post->post_author );
46
47 if ( ! $user_data instanceof WP_User ) {
48 return '';
49 }
50
51 /**
52 * Filter: 'wpseo_meta_author' - Allow developers to filter the article's author meta tag.
53 *
54 * @param string $author_name The article author's display name. Return empty to disable the tag.
55 * @param Indexable_Presentation $presentation The presentation of an indexable.
56 */
57 return \trim( $this->helpers->schema->html->smart_strip_tags( \apply_filters( 'wpseo_meta_author', $user_data->display_name, $this->presentation ) ) );
58 }
59 }
60