Skip to content

Commit

Permalink
include screen-reader-text option in icon helper
Browse files Browse the repository at this point in the history
  • Loading branch information
billerickson committed May 7, 2019
1 parent 597716e commit a4ea5b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions inc/helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function ea_icon( $atts = array() ) {
'group' => 'utility',
'size' => 16,
'class' => false,
'title' => false,
), $atts );

if( empty( $atts['icon'] ) )
Expand All @@ -143,5 +144,8 @@ function ea_icon( $atts = array() ) {
$svg = preg_replace( "/([\n\t]+)/", ' ', $svg ); // Remove newlines & tabs.
$svg = preg_replace( '/>\s*</', '><', $svg ); // Remove white space between SVG tags.

if( !empty( $atts['title'] ) )
$svg .= '<span class="screen-reader-text">' . esc_html( $atts['title'] ) . '</span>';

return $svg;
}
2 changes: 1 addition & 1 deletion searchform.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
<span class="screen-reader-text">Search for</span>
<input type="search" class="search-field" placeholder="Search&hellip;" value="<?php echo get_search_query(); ?>" name="s" title="Search for" />
</label>
<button type="submit" class="search-submit"><?php echo ea_icon( 'search' );?><span class="screen-reader-text">Submit</span></button>
<button type="submit" class="search-submit"><?php echo ea_icon( array( 'icon' => 'search', 'title' => 'Submit' ) );?></button>
</form>

0 comments on commit a4ea5b9

Please sign in to comment.