Reputation: 5741
I have a semi-transparent icon located in the bottom-right of my screen. It's obvious; it's an arrow pointing up, implying that the user can scroll to the top if the page or post is too long.
But I'd like it to have an alt="Scroll to top" attribute when the user hovers over the icon for a few reasons. How can I achieve this? The PHP code where the link is looks like this:
public function plugin_action_links( $action_links )
{
array_unshift( $action_links, "<a href=\"" . STT_OPTIONS_URL . "\">" . __(
'Settings', 'scrollto-top' ) . "</a>" );
return $action_links;
}
If more information is needed, please let me know. I've tried things, but they always break the code. I'm sure I have to put something in the < a href part of this code, but I'm unsure as to the syntax I'd use, or where I'd use it. Any help would be greatly appreciated!
Upvotes: 0
Views: 179
Reputation: 54
thanks Jason, am interesting this like problems in php, please update your code like this
return array_unshift( $action_links, "<a href=\"" . STT_OPTIONS_URL . "\" alt=\"Alt text Here\" title=\"Scroll to top\">" . __('Settings', 'scrollto-top' ) . "</a>" );
Upvotes: 1
Reputation: 24334
You simply add it in the anchor tag.
array_unshift( $action_links, "<a href=\"" . STT_OPTIONS_URL . "\" alt=\"Alt text Here\">" . __(
'Settings', 'scrollto-top' ) . "</a>" );
However if you want this to work cross browser you will need to provide the alt
and title
attribute.
The alt text is alternative text for the image when the image either cant be loaded or the user is using a screen reader. The title text is intended as the tooltip. However not all browsers see it this way so including both should work in all browsers
Upvotes: 2