Problem/Motivation
We removed theme_link() #1985470: Remove theme_link() as part of a push to stop dedicating theme functions to tiny, single tag chunks of markup because it's overkill and would only get worse if we were to create a Twig template.
For links in particular, there have been many theme functions that are almost identical sort of piling up #1595614: [meta] Remove all the theme functions and templates in core that simply output a link. Replace with #type 'link' render arrays.
theme_more_link() is one of these functions that should not be converted to a Twig template.
Proposed resolution
Create #type 'more_link' that works much as #type 'link', but with a few extra default attributes set. Do not try to recreate the markup of theme_more_link() 1:1 because there is a DIV that has been deemed superfluous in the theme function that might as well be removed here (see comments #52+)
Remaining tasks
Commit patch.
User interface changes
Loss of wrapper divs around "more" links.
API changes
Use #type 'more_link' instead of #theme 'more_link' in renderable arrays.
Here is the current code for theme_more_link():
<?php
function theme_more_link($variables) {
return '<div class="more-link">'. l(t('More'), $variables['url'], array('attributes'=> array('title'=> $variables['title']))) . '</div>';
}
?>
In order to reproduce this with #type = link, we need to make a render array with the following structure:
<?php
$more_link = array(
'#type'=> 'link',
'#href'=> 'admin/content',
'#title'=> t('More'),
'#attributes'=> array(
'#title'=> t('Show more content'),
),
'#theme_wrappers'=> array('container'),
'#wrapper_container_attributes'=> array(
'class'=> array('more-link'),
),
);
?>
Part of #1595614: [meta] Remove all the theme functions and templates in core that simply output a link. Replace with #type 'link' render arrays
Related:
#1939098: Convert theme_more_link() to Twig