|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Typogrify plugin for Craft CMS 3.x |
|
4
|
|
|
* |
|
5
|
|
|
* Typogrify prettifies your web typography by preventing ugly quotes and 'widows' and more |
|
6
|
|
|
* |
|
7
|
|
|
* @link https://nystudio107.com/ |
|
|
|
|
|
|
8
|
|
|
* @copyright Copyright (c) 2017 nystudio107 |
|
|
|
|
|
|
9
|
|
|
*/ |
|
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace nystudio107\typogrify\twigextensions; |
|
12
|
|
|
|
|
13
|
|
|
use nystudio107\typogrify\Typogrify; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
|
|
|
|
|
16
|
|
|
* @author nystudio107 |
|
|
|
|
|
|
17
|
|
|
* @package Typogrify |
|
|
|
|
|
|
18
|
|
|
* @since 1.0.0 |
|
|
|
|
|
|
19
|
|
|
*/ |
|
|
|
|
|
|
20
|
|
|
class TypogrifyTwigExtension extends \Twig_Extension |
|
21
|
|
|
{ |
|
22
|
|
|
// Public Methods |
|
23
|
|
|
// ========================================================================= |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
|
|
|
|
|
26
|
|
|
* @inheritdoc |
|
27
|
|
|
*/ |
|
|
|
|
|
|
28
|
|
|
public function getName() |
|
29
|
|
|
{ |
|
30
|
|
|
return 'Typogrify'; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
|
|
|
|
|
34
|
|
|
* @inheritdoc |
|
35
|
|
|
*/ |
|
|
|
|
|
|
36
|
|
|
public function getFilters() |
|
37
|
|
|
{ |
|
38
|
|
|
$variable = Typogrify::$variable; |
|
39
|
|
|
return [ |
|
40
|
|
|
new \Twig_SimpleFilter('typogrify', [$variable, 'typogrify']), |
|
41
|
|
|
new \Twig_SimpleFilter('typogrifyFeed', [$variable, 'typogrifyFeed']), |
|
42
|
|
|
new \Twig_SimpleFilter('smartypants', [$variable, 'smartypants']), |
|
43
|
|
|
new \Twig_SimpleFilter('truncate', [$variable, 'truncate']), |
|
44
|
|
|
new \Twig_SimpleFilter('truncateOnWord', [$variable, 'truncateOnWord']), |
|
45
|
|
|
new \Twig_SimpleFilter('stringy', [$variable, 'stringy']), |
|
46
|
|
|
new \Twig_SimpleFilter('humanFileSize', [$variable, 'humanFileSize']), |
|
47
|
|
|
new \Twig_SimpleFilter('humanDuration', [$variable, 'humanDuration']), |
|
48
|
|
|
new \Twig_SimpleFilter('humanRelativeTime', [$variable, 'humanRelativeTime']), |
|
49
|
|
|
new \Twig_SimpleFilter('ordinalize', [$variable, 'ordinalize']), |
|
50
|
|
|
new \Twig_SimpleFilter('pluralize', [$variable, 'pluralize']), |
|
51
|
|
|
new \Twig_SimpleFilter('singularize', [$variable, 'singularize']), |
|
52
|
|
|
new \Twig_SimpleFilter('transliterate', [$variable, 'transliterate']), |
|
53
|
|
|
new \Twig_SimpleFilter('wordLimit', [$variable, 'wordLimit']), |
|
54
|
|
|
]; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
|
|
|
|
|
58
|
|
|
* @inheritdoc |
|
59
|
|
|
*/ |
|
|
|
|
|
|
60
|
|
|
public function getFunctions() |
|
61
|
|
|
{ |
|
62
|
|
|
$variable = Typogrify::$variable; |
|
63
|
|
|
return [ |
|
64
|
|
|
new \Twig_SimpleFunction('typogrify', [$variable, 'typogrify']), |
|
65
|
|
|
new \Twig_SimpleFunction('typogrifyFeed', [$variable, 'typogrifyFeed']), |
|
66
|
|
|
new \Twig_SimpleFunction('smartypants', [$variable, 'smartypants']), |
|
67
|
|
|
new \Twig_SimpleFunction('getPhpTypographySettings', [$variable, 'getPhpTypographySettings']), |
|
68
|
|
|
new \Twig_SimpleFunction('truncate', [$variable, 'truncate']), |
|
69
|
|
|
new \Twig_SimpleFunction('truncateOnWord', [$variable, 'truncateOnWord']), |
|
70
|
|
|
new \Twig_SimpleFunction('stringy', [$variable, 'stringy']), |
|
71
|
|
|
new \Twig_SimpleFunction('humanFileSize', [$variable, 'humanFileSize']), |
|
72
|
|
|
new \Twig_SimpleFunction('humanDuration', [$variable, 'humanDuration']), |
|
73
|
|
|
new \Twig_SimpleFunction('humanRelativeTime', [$variable, 'humanRelativeTime']), |
|
74
|
|
|
new \Twig_SimpleFunction('ordinalize', [$variable, 'ordinalize']), |
|
75
|
|
|
new \Twig_SimpleFunction('pluralize', [$variable, 'pluralize']), |
|
76
|
|
|
new \Twig_SimpleFunction('singularize', [$variable, 'singularize']), |
|
77
|
|
|
new \Twig_SimpleFunction('transliterate', [$variable, 'transliterate']), |
|
78
|
|
|
new \Twig_SimpleFunction('wordLimit', [$variable, 'wordLimit']), |
|
79
|
|
|
]; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|