1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
<?php /** * WPSEO plugin file. * * @package WPSEO\Admin */
/** * This class generates the metabox on the edit term page. */ class WPSEO_Taxonomy_Metabox {
/** * @var WP_Term */ private $term;
/** * @var string */ private $taxonomy;
/** * @var WPSEO_Taxonomy_Fields_Presenter */ private $taxonomy_tab_content;
/** * @var WPSEO_Taxonomy_Social_Fields */ private $taxonomy_social_fields;
/** * @var WPSEO_Social_Admin */ private $social_admin;
/** * The constructor. * * @param string $taxonomy The taxonomy. * @param stdClass $term The term. */ public function __construct( $taxonomy, $term ) { $this->term = $term; $this->taxonomy = $taxonomy; $this->taxonomy_tab_content = new WPSEO_Taxonomy_Fields_Presenter( $this->term ); }
/** * Shows the Yoast SEO metabox for the term. */ public function display() {
$content_sections = $this->get_content_sections();
$product_title = 'Yoast SEO'; if ( file_exists( WPSEO_PATH . 'premium/' ) ) { $product_title .= ' Premium'; }
printf( '<div id="wpseo_meta" class="postbox yoast wpseo-taxonomy-metabox-postbox"><h2><span>%1$s</span></h2>', $product_title );
echo '<div class="inside">'; echo '<div id="taxonomy_overall"></div>';
echo '<div class="wpseo-metabox-content">'; echo '<div class="wpseo-metabox-menu"><ul>';
foreach ( $content_sections as $content_section ) { $content_section->display_link(); }
echo '</ul></div>';
foreach ( $content_sections as $content_section ) { $content_section->display_content(); }
echo '</div></div>'; echo '</div>'; }
/** * Returns the relevant metabox sections for the current view. * * @return WPSEO_Metabox_Section[] */ private function get_content_sections() { $content_sections = array();
$content_sections[] = $this->get_seo_meta_section();
$readability_analysis = new WPSEO_Metabox_Analysis_Readability(); if ( $readability_analysis->is_enabled() ) { $content_sections[] = $this->get_readability_meta_section(); }
$content_sections[] = $this->get_social_meta_section(); $content_sections[] = $this->get_settings_meta_section();
return $content_sections; }
/** * Returns the metabox section for the content analysis. * * @return WPSEO_Metabox_Section */ private function get_seo_meta_section() { $taxonomy_content_fields = new WPSEO_Taxonomy_Content_Fields( $this->term ); $content = $this->taxonomy_tab_content->html( $taxonomy_content_fields->get( $this->term ) );
$seo_analysis = new WPSEO_Metabox_Analysis_SEO(); $label = __( 'SEO', 'wordpress-seo' );
if ( $seo_analysis->is_enabled() ) { $label = '<span class="wpseo-score-icon-container" id="wpseo-seo-score-icon"></span>' . $label; }
return new WPSEO_Metabox_Section_React( 'content', $label, $content ); }
/** * Returns the metabox section for the readability analysis. * * @return WPSEO_Metabox_Section */ private function get_readability_meta_section() { return new WPSEO_Metabox_Section_Readability(); }
/** * Returns the metabox section for the settings. * * @return WPSEO_Metabox_Section */ private function get_settings_meta_section() { $taxonomy_settings_fields = new WPSEO_Taxonomy_Settings_Fields( $this->term ); $content = $this->taxonomy_tab_content->html( $taxonomy_settings_fields->get() );
$tab = new WPSEO_Metabox_Form_Tab( 'settings', $content, __( 'Settings', 'wordpress-seo' ), array( 'single' => true, ) );
return new WPSEO_Metabox_Tab_Section( 'settings', '<span class="dashicons dashicons-admin-generic"></span>' . __( 'Settings', 'wordpress-seo' ), array( $tab ) ); }
/** * Returns the metabox section for the social settings. * * @return WPSEO_Metabox_Section */ private function get_social_meta_section() { $this->taxonomy_social_fields = new WPSEO_Taxonomy_Social_Fields( $this->term ); $this->social_admin = new WPSEO_Social_Admin();
$tabs = array(); $tabs[] = $this->create_tab( 'facebook', 'opengraph', 'facebook-alt', __( 'Facebook / Open Graph metadata', 'wordpress-seo' ) ); $tabs[] = $this->create_tab( 'twitter', 'twitter', 'twitter', __( 'Twitter metadata', 'wordpress-seo' ) );
return new WPSEO_Metabox_Tab_Section( 'social', '<span class="dashicons dashicons-share"></span>' . __( 'Social', 'wordpress-seo' ), $tabs ); }
/** * Creates a social network tab. * * @param string $name The name of the tab. * @param string $network The network of the tab. * @param string $icon The icon for the tab. * @param string $label The label for the tab. * * @return WPSEO_Metabox_Form_Tab A WPSEO_Metabox_Form_Tab instance. */ private function create_tab( $name, $network, $icon, $label ) { if ( WPSEO_Options::get( $network ) !== true ) { return new WPSEO_Metabox_Null_Tab(); }
$meta_fields = $this->taxonomy_social_fields->get_by_network( $network );
$tab_settings = new WPSEO_Metabox_Form_Tab( $name, $this->social_admin->get_premium_notice( $network ) . $this->taxonomy_tab_content->html( $meta_fields ), '<span class="screen-reader-text">' . $label . '</span><span class="dashicons dashicons-' . $icon . '"></span>', array( 'single' => $this->has_single_social_tab(), ) );
return $tab_settings; }
/** * Determine whether we only show one social network or two. * * @return bool */ private function has_single_social_tab() { return ( WPSEO_Options::get( 'opengraph' ) === false || WPSEO_Options::get( 'twitter' ) === false ); } }
|