-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.drupalish.php
39 lines (34 loc) · 1.04 KB
/
functions.drupalish.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
* Create hyperlinks
*
* @param string $text The link text
* @param string $path The URL
* @param array $attributes Everything you want to have inside href-tag
* @return string $l The hyperlink, formatted
* @author Jonas Björk <jonas@jonasbjork.net>
*/
function l( $text, $path, array $attributes = array() ) {
$attr = null;
if ( isset( $attributes['title'] ) && strpos( $attributes['title'], '<' ) !== false ) {
$attributes['title'] = strip_tags( $attibutes['title']);
}
foreach ( $attributes as $a => $v ) {
$attr .= $a . '="' . $v . '" ';
}
return '<a href="' . $path . '" ' . $attr .'>' . $text . '</a>';
}
/**
* Get singular or plural form of an word
*
* @param int $count Number to check
* @param string $singular The word in singular form
* @param string $plural The word in plural form
* @return string $str The word in correct form
* @author Jonas Björk <jonas@jonasbjork.net>
*/
function format_plural( $count = 0, $singular = '', $plural = '' ) {
if ( $count == 1 )
return $singular;
return $plural;
}