Skip to content

Commit

Permalink
Merge pull request #373 from ministryofjustice/logo-aria-label
Browse files Browse the repository at this point in the history
Logo aria label
  • Loading branch information
brown-a2 authored Sep 13, 2024
2 parents 747408a + f4569e0 commit cb3c49e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
26 changes: 25 additions & 1 deletion inc/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ function hale_customize_register( $wp_customize ) {
'logo_custom_link',
array(
'label' => esc_html__( 'Logo/Site Name custom link', 'hale' ),
'description' => esc_html__( 'Link defaults to homepage if it is not set', 'hale' ),
'description' => esc_html__( 'Link defaults to homepage if it is not set', 'hale' ),
'section' => 'title_tagline',
'type' => 'text',
'active_callback' => function () use ( $wp_customize ) {
Expand All @@ -266,6 +266,30 @@ function hale_customize_register( $wp_customize ) {
)
);

$wp_customize->add_setting(
'logo_aria_label',
array(
'sanitize_callback' => 'hale_sanitize_nohtml',
'default' => get_bloginfo( 'name' ) . " " . __("homepage","hale")
)
);

$wp_customize->add_control(
'logo_aria_label',
array(
'label' => esc_html__( 'Aria label for logo', 'hale' ),
'description' => esc_html__( 'What assistive technology users hear when they inspect the logo', 'hale' ),
'section' => 'title_tagline',
'type' => 'text',
'active_callback' => function () use ( $wp_customize ) {
return (
( $wp_customize->get_setting('logo_has_link')->value() === 'yes' ) &&
( $wp_customize->get_setting('logo_configuration')->value() !== 'no' )
);
},
)
);

/*
* Crown Copyright
*/
Expand Down
3 changes: 2 additions & 1 deletion partials/logo.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
$show_sitename = get_theme_mod( 'logo_configuration' ) == 'name' || get_theme_mod( 'logo_configuration' ) == 'both' ? "yes" : "";
$logo_has_link = get_theme_mod( 'logo_has_link', 'yes' );
$logo_custom_link = get_theme_mod( 'logo_custom_link', '' );
$logo_aria_label = get_theme_mod( 'logo_aria_label', get_bloginfo( 'name' ) . " " . __("homepage","hale") );

if(!empty($logo_custom_link)){
$logo_link = $logo_custom_link;
Expand All @@ -38,7 +39,7 @@
<?php if ( $show_sitename === 'yes' || $show_sitelogo === 'yes' ) { ?>
<div class="govuk-header__logo">
<?php if ( $logo_has_link === 'yes' ) { ?>
<a class="govuk-header__link govuk-header__link--homepage" href="<?php echo esc_url_raw( $logo_link ); ?>" aria-label="<?php bloginfo( 'name' ); ?> homepage">
<a class="govuk-header__link govuk-header__link--homepage" href="<?php echo esc_url_raw( $logo_link ); ?>" aria-label="<?php echo $logo_aria_label; ?>">
<?php
}
if ( has_custom_logo() ) {
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Theme Name: Hale
Text Domain: hale
Version: 4.11.2
Version: 4.12.0
Domain Path: /languages
Description: Theme for Ministry of Justice websites.
Author: Ministry of Justice
Expand Down

0 comments on commit cb3c49e

Please sign in to comment.