PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
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 / user-meta / framework / custom-meta / author-metadesc.php

author-metadesc.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/user-meta/framework/custom-meta/author-metadesc.php

112 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
4 namespace Yoast\WP\SEO\User_Meta\Framework\Custom_Meta;
5
6 use Yoast\WP\SEO\Helpers\Options_Helper;
7 use Yoast\WP\SEO\User_Meta\Domain\Custom_Meta_Interface;
8
9 /**
10 * The Author_Metadesc custom meta.
11 */
12 class Author_Metadesc implements Custom_Meta_Interface {
13
14 /**
15 * The options helper.
16 *
17 * @var Options_Helper
18 */
19 private $options_helper;
20
21 /**
22 * The constructor.
23 *
24 * @param Options_Helper $options_helper The options helper.
25 */
26 public function __construct( Options_Helper $options_helper ) {
27 $this->options_helper = $options_helper;
28 }
29
30 /**
31 * Returns the priority which the custom meta's form field should be rendered with.
32 *
33 * @return int The priority which the custom meta's form field should be rendered with.
34 */
35 public function get_render_priority(): int {
36 return 200;
37 }
38
39 /**
40 * Returns the db key of the Author_Metadesc custom meta.
41 *
42 * @return string The db key of the Author_Metadesc custom meta.
43 */
44 public function get_key(): string {
45 return 'wpseo_metadesc';
46 }
47
48 /**
49 * Returns the id of the custom meta's form field.
50 *
51 * @return string The id of the custom meta's form field.
52 */
53 public function get_field_id(): string {
54 return 'wpseo_author_metadesc';
55 }
56
57 /**
58 * Returns the meta value.
59 *
60 * @param int $user_id The user ID.
61 *
62 * @return string The meta value.
63 */
64 public function get_value( $user_id ): string {
65 return \get_the_author_meta( $this->get_key(), $user_id );
66 }
67
68 /**
69 * Returns whether the respective global setting is enabled.
70 *
71 * @return bool Whether the respective global setting is enabled.
72 */
73 public function is_setting_enabled(): bool {
74 return ( ! $this->options_helper->get( 'disable-author' ) );
75 }
76
77 /**
78 * Returns whether the custom meta is allowed to be empty.
79 *
80 * @return bool Whether the custom meta is allowed to be empty.
81 */
82 public function is_empty_allowed(): bool {
83 return true;
84 }
85
86 /**
87 * Renders the custom meta's field in the user form.
88 *
89 * @param int $user_id The user ID.
90 *
91 * @return void
92 */
93 public function render_field( $user_id ): void {
94 echo '
95
96 <label for="' . \esc_attr( $this->get_field_id() ) . '">'
97 . \esc_html__( 'Meta description to use for Author page', 'wordpress-seo' )
98 . '</label>';
99
100 echo '
101
102 <textarea
103 rows="5"
104 cols="30"
105 id="' . \esc_attr( $this->get_field_id() ) . '"
106 class="yoast-settings__textarea yoast-settings__textarea--medium"
107 name="' . \esc_attr( $this->get_field_id() ) . '">'
108 . \esc_textarea( $this->get_value( $user_id ) )
109 . '</textarea><br>';
110 }
111 }
112