Skip to content

Commit ed14c9a

Browse files
committed
fix(metabox): move CSS classes from for to class attr
The label for attribute was polluted with CSS classes which is invalid HTML. Move msls-icon-wrapper and icon type to a proper class attribute.
1 parent 5304510 commit ed14c9a

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

includes/MslsMetaBox.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function render_select(): void {
227227
}
228228

229229
$lis .= sprintf(
230-
'<li><label for="msls_input_%1$s msls-icon-wrapper %5$s">%2$s</label>%3$s%4$s</li>',
230+
'<li><label for="msls_input_%1$s" class="msls-icon-wrapper %5$s">%2$s</label>%3$s%4$s</li>',
231231
esc_attr( $language ),
232232
$icon, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
233233
$selects, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -342,7 +342,7 @@ public function render_input(): void {
342342
}
343343

344344
$items .= sprintf(
345-
'<li class=""><label for="msls_title_%1$s msls-icon-wrapper %7$s">%2$s</label><input type="hidden" id="msls_id_%1$s" name="msls_input_%3$s" value="%4$s"/><input class="msls_title" id="msls_title_%1$s" name="msls_title_%1$s" type="text" value="%5$s"/>%6$s</li>',
345+
'<li class=""><label for="msls_title_%1$s" class="msls-icon-wrapper %7$s">%2$s</label><input type="hidden" id="msls_id_%1$s" name="msls_input_%3$s" value="%4$s"/><input class="msls_title" id="msls_title_%1$s" name="msls_title_%1$s" type="text" value="%5$s"/>%6$s</li>',
346346
$blog->userblog_id,
347347
$icon,
348348
$language,

tests/phpunit/TestMslsMetaBox.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function test_render_select_not_hierarchical(): void {
172172
Functions\expect( 'get_current_blog_id' )->times( 3 )->andReturn( 1 );
173173
Functions\expect( 'get_admin_url' )->twice()->andReturn( 'admin-url-empty' );
174174

175-
$expected = '<ul><li><label for="msls_input_de_DE msls-icon-wrapper flag"><a title="Create a new translation in the de_DE-blog" href="admin-url-empty"><span class="flag-icon flag-icon-de">de_DE</span></a>&nbsp;</label><select name="msls_input_de_DE"><option value="0"></option></select><a class="msls-create-new" href="admin-url-empty" target="_blank" title="Create a new translation in the de_DE-blog"><span class="dashicons dashicons-plus"></span></a></li></ul>';
175+
$expected = '<ul><li><label for="msls_input_de_DE" class="msls-icon-wrapper flag"><a title="Create a new translation in the de_DE-blog" href="admin-url-empty"><span class="flag-icon flag-icon-de">de_DE</span></a>&nbsp;</label><select name="msls_input_de_DE"><option value="0"></option></select><a class="msls-create-new" href="admin-url-empty" target="_blank" title="Create a new translation in the de_DE-blog"><span class="dashicons dashicons-plus"></span></a></li></ul>';
176176
$this->expectOutputString( $expected );
177177

178178
$this->MslsMetaBoxFactory()->render_select();
@@ -205,16 +205,16 @@ public function test_render_select_hierarchical(): void {
205205
Functions\expect( 'get_edit_post_link' )->once()->andReturn( 'edit-post-link' );
206206
Functions\expect( 'get_current_blog_id' )->once()->andReturn( 1 );
207207

208-
$expected = '<ul><li><label for="msls_input_de_DE msls-icon-wrapper flag"><a title="Edit the translation in the de_DE-blog" href="edit-post-link"><span class="flag-icon flag-icon-de">de_DE</span></a>&nbsp;</label><select name="msls_input_region_Code"><option value="0">--some value</option></select></li></ul>';
208+
$expected = '<ul><li><label for="msls_input_de_DE" class="msls-icon-wrapper flag"><a title="Edit the translation in the de_DE-blog" href="edit-post-link"><span class="flag-icon flag-icon-de">de_DE</span></a>&nbsp;</label><select name="msls_input_region_Code"><option value="0">--some value</option></select></li></ul>';
209209
$this->expectOutputString( $expected );
210210

211211
$this->MslsMetaBoxFactory()->render_select();
212212
}
213213

214214
public static function render_input_provider(): array {
215215
return array(
216-
array( array( 'de_DE' => 42 ), 1, 2, 1, 1, 1, '<ul><li class=""><label for="msls_title_ msls-icon-wrapper flag"><a title="Edit the translation in the de_DE-blog" href="edit-post-link"><span class="flag-icon flag-icon-de">de_DE</span></a>&nbsp;</label><input type="hidden" id="msls_id_" name="msls_input_de_DE" value="42"/><input class="msls_title" id="msls_title_" name="msls_title_" type="text" value="Test"/><a class="msls-create-new" href="admin-url-empty" target="_blank" title="Create a new translation in the de_DE-blog" style="display:none"><span class="dashicons dashicons-plus"></span></a></li></ul><input type="hidden" name="msls_post_type" id="msls_post_type" value="page"/><input type="hidden" name="msls_action" id="msls_action" value="suggest_posts"/>' ),
217-
array( array( 'en_US' => 17 ), 0, 3, 2, 0, 2, '<ul><li class=""><label for="msls_title_ msls-icon-wrapper flag"><a title="Create a new translation in the de_DE-blog" href="admin-url-empty"><span class="flag-icon flag-icon-de">de_DE</span></a>&nbsp;</label><input type="hidden" id="msls_id_" name="msls_input_de_DE" value=""/><input class="msls_title" id="msls_title_" name="msls_title_" type="text" value=""/><a class="msls-create-new" href="admin-url-empty" target="_blank" title="Create a new translation in the de_DE-blog"><span class="dashicons dashicons-plus"></span></a></li></ul><input type="hidden" name="msls_post_type" id="msls_post_type" value="page"/><input type="hidden" name="msls_action" id="msls_action" value="suggest_posts"/>' ),
216+
array( array( 'de_DE' => 42 ), 1, 2, 1, 1, 1, '<ul><li class=""><label for="msls_title_" class="msls-icon-wrapper flag"><a title="Edit the translation in the de_DE-blog" href="edit-post-link"><span class="flag-icon flag-icon-de">de_DE</span></a>&nbsp;</label><input type="hidden" id="msls_id_" name="msls_input_de_DE" value="42"/><input class="msls_title" id="msls_title_" name="msls_title_" type="text" value="Test"/><a class="msls-create-new" href="admin-url-empty" target="_blank" title="Create a new translation in the de_DE-blog" style="display:none"><span class="dashicons dashicons-plus"></span></a></li></ul><input type="hidden" name="msls_post_type" id="msls_post_type" value="page"/><input type="hidden" name="msls_action" id="msls_action" value="suggest_posts"/>' ),
217+
array( array( 'en_US' => 17 ), 0, 3, 2, 0, 2, '<ul><li class=""><label for="msls_title_" class="msls-icon-wrapper flag"><a title="Create a new translation in the de_DE-blog" href="admin-url-empty"><span class="flag-icon flag-icon-de">de_DE</span></a>&nbsp;</label><input type="hidden" id="msls_id_" name="msls_input_de_DE" value=""/><input class="msls_title" id="msls_title_" name="msls_title_" type="text" value=""/><a class="msls-create-new" href="admin-url-empty" target="_blank" title="Create a new translation in the de_DE-blog"><span class="dashicons dashicons-plus"></span></a></li></ul><input type="hidden" name="msls_post_type" id="msls_post_type" value="page"/><input type="hidden" name="msls_action" id="msls_action" value="suggest_posts"/>' ),
218218
);
219219
}
220220

0 commit comments

Comments
 (0)