Block link with active class I've created couple of blocks from the Drupal UI.

These blocks has unsorted list with links to the other pages. 

They act like a sub menus located into the sidebar region and visible to specific pages.

Here's an example for a block called fruits that have a couple of links:


Apple
Orange
Mango


The Drupal menu system or Superfish module generates active class on the links based on the URL location. How can I do that with these blocks, so let's say a user clicks on the link Apple and when the new page loads, the Apple link will have a active class, so it will look like this:

&lt;li&gt;&lt;a href="/apple" class="active"&gt;Apple&lt;/a&gt;&lt;/li&gt;


I want this, so I can set a CSS for active link.
It needs to be done with PHP. If you use the l() function to generate your links, they will automatically get the active class if you are the page to which the link is linked to.
To do this you would need to enable the PHP filter, but this filter is both recommended against, as well as non-existent in Drupal 8, so it would be better to create a block through code and use that instead of enabling the PHP filter.