PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.5.1
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.5.1
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 / admin / taxonomy / class-taxonomy-fields.php

class-taxonomy-fields.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.5.1, at admin/taxonomy/class-taxonomy-fields.php

229 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPSEO plugin file.
4 *
5 * @package WPSEO\Admin
6 */
7
8 /**
9 * Class WPSEO_Taxonomy_Tab.
10 *
11 * Contains the basics for each class extending this one.
12 */
13 class WPSEO_Taxonomy_Fields {
14
15 /**
16 * Returns the taxonomy fields.
17 *
18 * @param string $field_group The field group.
19 *
20 * @return array
21 */
22 public function get( $field_group ) {
23 $fields = [];
24
25 switch ( $field_group ) {
26 case 'content':
27 $fields = $this->get_content_fields();
28 break;
29 case 'settings':
30 $fields = $this->get_settings_fields();
31 break;
32 case 'social':
33 $fields = $this->get_social_fields();
34 break;
35 }
36
37 return $this->filter_hidden_fields( $fields );
38 }
39
40 /**
41 * Returns array with the fields for the general tab.
42 *
43 * @return array
44 */
45 protected function get_content_fields() {
46 $fields = [
47 'title' => [
48 'label' => '',
49 'description' => '',
50 'type' => 'hidden',
51 'options' => '',
52 'hide' => false,
53 ],
54 'desc' => [
55 'label' => '',
56 'description' => '',
57 'type' => 'hidden',
58 'options' => '',
59 'hide' => false,
60 ],
61 'linkdex' => [
62 'label' => '',
63 'description' => '',
64 'type' => 'hidden',
65 'options' => '',
66 'hide' => false,
67 ],
68 'content_score' => [
69 'label' => '',
70 'description' => '',
71 'type' => 'hidden',
72 'options' => '',
73 'hide' => false,
74 ],
75 'focuskw' => [
76 'label' => '',
77 'description' => '',
78 'type' => 'hidden',
79 'options' => '',
80 'hide' => false,
81 ],
82 'is_cornerstone' => [
83 'label' => '',
84 'description' => '',
85 'type' => 'hidden',
86 'options' => '',
87 'hide' => false,
88 ],
89 ];
90
91 /**
92 * Filter: 'wpseo_taxonomy_content_fields' - Adds the possibility to register additional content fields.
93 *
94 * @api array - The additional fields.
95 */
96 $additional_fields = apply_filters( 'wpseo_taxonomy_content_fields', [] );
97
98 return array_merge( $fields, $additional_fields );
99 }
100
101 /**
102 * Returns array with the fields for the settings tab.
103 *
104 * @return array
105 */
106 protected function get_settings_fields() {
107 return [
108 'noindex' => [
109 'label' => '',
110 'description' => '',
111 'type' => 'hidden',
112 'options' => '',
113 'hide' => false,
114 ],
115 'bctitle' => [
116 'label' => '',
117 'description' => '',
118 'type' => 'hidden',
119 'options' => '',
120 'hide' => ( WPSEO_Options::get( 'breadcrumbs-enable' ) !== true ),
121 ],
122 'canonical' => [
123 'label' => '',
124 'description' => '',
125 'type' => 'hidden',
126 'options' => '',
127 'hide' => false,
128 ],
129 ];
130 }
131
132 /**
133 * Returning the fields for the social media tab.
134 *
135 * @return array
136 */
137 protected function get_social_fields() {
138 $fields = [];
139
140 if ( WPSEO_Options::get( 'opengraph', false ) === true ) {
141 $fields = [
142 'opengraph-title' => [
143 'label' => '',
144 'description' => '',
145 'type' => 'hidden',
146 'options' => '',
147 'hide' => false,
148 ],
149 'opengraph-description' => [
150 'label' => '',
151 'description' => '',
152 'type' => 'hidden',
153 'options' => '',
154 'hide' => false,
155 ],
156 'opengraph-image' => [
157 'label' => '',
158 'description' => '',
159 'type' => 'hidden',
160 'options' => '',
161 'hide' => false,
162 ],
163 'opengraph-image-id' => [
164 'label' => '',
165 'description' => '',
166 'type' => 'hidden',
167 'options' => '',
168 'hide' => false,
169 ],
170 ];
171 }
172
173 if ( WPSEO_Options::get( 'twitter', false ) === true ) {
174 $fields = array_merge(
175 $fields,
176 [
177 'twitter-title' => [
178 'label' => '',
179 'description' => '',
180 'type' => 'hidden',
181 'options' => '',
182 'hide' => false,
183 ],
184 'twitter-description' => [
185 'label' => '',
186 'description' => '',
187 'type' => 'hidden',
188 'options' => '',
189 'hide' => false,
190 ],
191 'twitter-image' => [
192 'label' => '',
193 'description' => '',
194 'type' => 'hidden',
195 'options' => '',
196 'hide' => false,
197 ],
198 'twitter-image-id' => [
199 'label' => '',
200 'description' => '',
201 'type' => 'hidden',
202 'options' => '',
203 'hide' => false,
204 ],
205 ]
206 );
207 }
208
209 return $fields;
210 }
211
212 /**
213 * Filter the hidden fields.
214 *
215 * @param array $fields Array with the form fields that has will be filtered.
216 *
217 * @return array
218 */
219 protected function filter_hidden_fields( array $fields ) {
220 foreach ( $fields as $field_name => $field_options ) {
221 if ( ! empty( $field_options['hide'] ) ) {
222 unset( $fields[ $field_name ] );
223 }
224 }
225
226 return $fields;
227 }
228 }
229