Skip to content

Commit a27e6a8

Browse files
Coding Standards: Consistently escape URLs in wp-admin/themes.php.
Includes: * Wrapping long lines for better readability. * Bringing some consistency to the placement of `href` and `aria-label` attributes. * Adding missing `aria-label` attributes for Live Preview links. Follow-up to [26726], [52020], [51083]. Props patelketan, sainathpoojary, SergeyBiryukov. Fixes #62405. git-svn-id: https://develop.svn.wordpress.org/trunk@59400 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 1a27422 commit a27e6a8

File tree

1 file changed

+95
-27
lines changed

1 file changed

+95
-27
lines changed

src/wp-admin/themes.php

+95-27
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,9 @@
583583
/* translators: %s: Theme name. */
584584
$details_aria_label = sprintf( _x( 'View Theme Details for %s', 'theme' ), $theme['name'] );
585585
?>
586-
<button type="button" aria-label="<?php echo esc_attr( $details_aria_label ); ?>" class="more-details" id="<?php echo esc_attr( $aria_action ); ?>"><?php _e( 'Theme Details' ); ?></button>
586+
<button type="button" class="more-details" id="<?php echo esc_attr( $aria_action ); ?>"
587+
aria-label="<?php echo esc_attr( $details_aria_label ); ?>"
588+
><?php _e( 'Theme Details' ); ?></button>
587589
<div class="theme-author">
588590
<?php
589591
/* translators: %s: Theme author name. */
@@ -607,30 +609,49 @@
607609
/* translators: %s: Theme name. */
608610
$customize_aria_label = sprintf( _x( 'Customize %s', 'theme' ), $theme['name'] );
609611
?>
610-
<a aria-label="<?php echo esc_attr( $customize_aria_label ); ?>" class="button button-primary customize load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Customize' ); ?></a>
612+
<a class="button button-primary customize load-customize hide-if-no-customize"
613+
href="<?php echo esc_url( $theme['actions']['customize'] ); ?>"
614+
aria-label="<?php echo esc_attr( $customize_aria_label ); ?>"
615+
><?php _e( 'Customize' ); ?></a>
611616
<?php } ?>
612617
<?php } elseif ( $theme['compatibleWP'] && $theme['compatiblePHP'] ) { ?>
613618
<?php
614619
/* translators: %s: Theme name. */
615620
$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
616621
?>
617-
<a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
622+
<a class="button activate"
623+
href="<?php echo esc_url( $theme['actions']['activate'] ); ?>"
624+
aria-label="<?php echo esc_attr( $aria_label ); ?>"
625+
><?php _e( 'Activate' ); ?></a>
626+
618627
<?php
619628
// Only classic themes require the "customize" capability.
620629
if ( current_user_can( 'edit_theme_options' ) && ( $theme['blockTheme'] || current_user_can( 'customize' ) ) ) {
621630
/* translators: %s: Theme name. */
622631
$live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
623632
?>
624-
<a aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>" class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
633+
<a class="button button-primary load-customize hide-if-no-customize"
634+
href="<?php echo esc_url( $theme['actions']['customize'] ); ?>"
635+
aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
636+
><?php _e( 'Live Preview' ); ?></a>
625637
<?php } ?>
626638
<?php } else { ?>
627639
<?php
628640
/* translators: %s: Theme name. */
629641
$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
630642
?>
631-
<a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
632-
<?php if ( ! $theme['blockTheme'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
633-
<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
643+
<a class="button disabled"
644+
aria-label="<?php echo esc_attr( $aria_label ); ?>"
645+
><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
646+
647+
<?php
648+
if ( ! $theme['blockTheme'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
649+
/* translators: %s: Theme name. */
650+
$live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
651+
?>
652+
<a class="button button-primary hide-if-no-customize disabled"
653+
aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
654+
><?php _e( 'Live Preview' ); ?></a>
634655
<?php } ?>
635656
<?php } ?>
636657

@@ -954,7 +975,9 @@ function wp_theme_auto_update_setting_template() {
954975
/* translators: %s: Theme name. */
955976
$details_aria_label = sprintf( _x( 'View Theme Details for %s', 'theme' ), '{{ data.name }}' );
956977
?>
957-
<button type="button" aria-label="<?php echo esc_attr( $details_aria_label ); ?>" class="more-details" id="{{ data.id }}-action"><?php _e( 'Theme Details' ); ?></button>
978+
<button type="button" class="more-details" id="{{ data.id }}-action"
979+
aria-label="<?php echo esc_attr( $details_aria_label ); ?>"
980+
><?php _e( 'Theme Details' ); ?></button>
958981
<div class="theme-author">
959982
<?php
960983
/* translators: %s: Theme author name. */
@@ -978,28 +1001,47 @@ function wp_theme_auto_update_setting_template() {
9781001
/* translators: %s: Theme name. */
9791002
$customize_aria_label = sprintf( _x( 'Customize %s', 'theme' ), '{{ data.name }}' );
9801003
?>
981-
<a aria-label="<?php echo esc_attr( $customize_aria_label ); ?>" class="button button-primary customize load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Customize' ); ?></a>
1004+
<a class="button button-primary customize load-customize hide-if-no-customize"
1005+
href="{{{ data.actions.customize }}}"
1006+
aria-label="<?php echo esc_attr( $customize_aria_label ); ?>"
1007+
><?php _e( 'Customize' ); ?></a>
9821008
<# } #>
9831009
<# } else { #>
9841010
<# if ( data.compatibleWP && data.compatiblePHP ) { #>
9851011
<?php
9861012
/* translators: %s: Theme name. */
9871013
$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
9881014
?>
989-
<a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
1015+
<a class="button activate"
1016+
href="{{{ data.actions.activate }}}"
1017+
aria-label="<?php echo esc_attr( $aria_label ); ?>"
1018+
><?php _e( 'Activate' ); ?></a>
1019+
9901020
<?php
9911021
/* translators: %s: Theme name. */
9921022
$live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
9931023
?>
994-
<a aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>" class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
1024+
<a class="button button-primary load-customize hide-if-no-customize"
1025+
href="{{{ data.actions.customize }}}"
1026+
aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
1027+
><?php _e( 'Live Preview' ); ?></a>
9951028
<# } else { #>
9961029
<?php
9971030
/* translators: %s: Theme name. */
9981031
$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
9991032
?>
1000-
<a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
1033+
<a class="button disabled"
1034+
aria-label="<?php echo esc_attr( $aria_label ); ?>"
1035+
><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
1036+
10011037
<# if ( ! data.blockTheme ) { #>
1002-
<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
1038+
<?php
1039+
/* translators: %s: Theme name. */
1040+
$live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
1041+
?>
1042+
<a class="button button-primary hide-if-no-customize disabled"
1043+
aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
1044+
><?php _e( 'Live Preview' ); ?></a>
10031045
<# } #>
10041046
<# } #>
10051047
<# } #>
@@ -1211,31 +1253,54 @@ function wp_theme_auto_update_setting_template() {
12111253

12121254
<div class="theme-actions">
12131255
<div class="active-theme">
1214-
<a href="{{{ data.actions.customize }}}" class="button button-primary customize load-customize hide-if-no-customize"><?php _e( 'Customize' ); ?></a>
1256+
<a class="button button-primary customize load-customize hide-if-no-customize"
1257+
href="{{{ data.actions.customize }}}"
1258+
><?php _e( 'Customize' ); ?></a>
12151259
<?php echo implode( ' ', $current_theme_actions ); ?>
12161260
</div>
1261+
12171262
<div class="inactive-theme">
12181263
<# if ( data.compatibleWP && data.compatiblePHP ) { #>
1219-
<?php
1220-
/* translators: %s: Theme name. */
1221-
$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
1222-
?>
12231264
<# if ( ! data.blockTheme ) { #>
1224-
<a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
1265+
<?php
1266+
/* translators: %s: Theme name. */
1267+
$live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
1268+
?>
1269+
<a class="button button-primary load-customize hide-if-no-customize"
1270+
href="{{{ data.actions.customize }}}"
1271+
aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
1272+
><?php _e( 'Live Preview' ); ?></a>
12251273
<# } #>
1274+
12261275
<# if ( data.actions.activate ) { #>
1227-
<a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
1276+
<?php
1277+
/* translators: %s: Theme name. */
1278+
$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
1279+
?>
1280+
<a class="button activate"
1281+
href="{{{ data.actions.activate }}}"
1282+
aria-label="<?php echo esc_attr( $aria_label ); ?>"
1283+
><?php _e( 'Activate' ); ?></a>
12281284
<# } #>
12291285
<# } else { #>
1230-
<?php
1231-
/* translators: %s: Theme name. */
1232-
$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
1233-
?>
12341286
<# if ( ! data.blockTheme ) { #>
1235-
<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
1287+
<?php
1288+
/* translators: %s: Theme name. */
1289+
$live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
1290+
?>
1291+
<a class="button button-primary hide-if-no-customize disabled"
1292+
aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
1293+
><?php _e( 'Live Preview' ); ?></a>
12361294
<# } #>
1295+
12371296
<# if ( data.actions.activate ) { #>
1238-
<a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
1297+
<?php
1298+
/* translators: %s: Theme name. */
1299+
$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
1300+
?>
1301+
<a class="button disabled"
1302+
aria-label="<?php echo esc_attr( $aria_label ); ?>"
1303+
><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
12391304
<# } #>
12401305
<# } #>
12411306
</div>
@@ -1245,7 +1310,10 @@ function wp_theme_auto_update_setting_template() {
12451310
/* translators: %s: Theme name. */
12461311
$aria_label = sprintf( _x( 'Delete %s', 'theme' ), '{{ data.name }}' );
12471312
?>
1248-
<a href="{{{ data.actions['delete'] }}}" class="button delete-theme" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Delete' ); ?></a>
1313+
<a class="button delete-theme"
1314+
href="{{{ data.actions['delete'] }}}"
1315+
aria-label="<?php echo esc_attr( $aria_label ); ?>"
1316+
><?php _e( 'Delete' ); ?></a>
12491317
<# } #>
12501318
</div>
12511319
</div>

0 commit comments

Comments
 (0)