@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! function_exists('insert_if_exists')) { |
|
4 | - function insert_if_exists ($insert, $template = null, $match = null) { |
|
3 | +if (!function_exists('insert_if_exists')) { |
|
4 | + function insert_if_exists($insert, $template = null, $match = null) { |
|
5 | 5 | if (!is_null($insert)) { // if item exists |
6 | 6 | if (is_array($insert)) { // if more than one item is given |
7 | 7 | $ret = ''; // total of all items to return |
@@ -8,7 +8,7 @@ |
||
8 | 8 | |
9 | 9 | class SiteController extends Controller |
10 | 10 | { |
11 | - public function showCreateForm () |
|
11 | + public function showCreateForm() |
|
12 | 12 | { |
13 | 13 | return SEO::make([ |
14 | 14 | 'title' => 'New Site', |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | public $defaults; |
12 | 12 | public static $favicons; |
13 | 13 | |
14 | - public function __construct () { |
|
14 | + public function __construct() { |
|
15 | 15 | $this->defaults = [ |
16 | 16 | 'title' => 'Home', |
17 | 17 | 'title-spacer' => ' – ', |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | ]; |
32 | 32 | } |
33 | 33 | |
34 | - public function generateSEO (array $page) |
|
34 | + public function generateSEO(array $page) |
|
35 | 35 | { |
36 | 36 | SEOTools::metatags() |
37 | 37 | ->setTitleDefault($page['title-description']) |
@@ -66,58 +66,58 @@ discard block |
||
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | - public function setFavicons () { |
|
69 | + public function setFavicons() { |
|
70 | 70 | $favicon_dir = insert_if_exists($this->defaults['icon_dir']); |
71 | 71 | $colors = $this->defaults['colors']; |
72 | - return insert_if_exists (['60x60', '72x72', '114x114', '120x120', '152x152', '180x180'], function ($insert) use ($favicon_dir) { |
|
73 | - return '<link rel="apple-touch-icon" sizes="' . $insert . '" href="' . asset($favicon_dir . '/apple-touch-icon-' . $insert . '.png').'">'; |
|
74 | - }, function ($insert) use ($favicon_dir) { |
|
72 | + return insert_if_exists(['60x60', '72x72', '114x114', '120x120', '152x152', '180x180'], function($insert) use ($favicon_dir) { |
|
73 | + return '<link rel="apple-touch-icon" sizes="'.$insert.'" href="'.asset($favicon_dir.'/apple-touch-icon-'.$insert.'.png').'">'; |
|
74 | + }, function($insert) use ($favicon_dir) { |
|
75 | 75 | return File::exists(public_path($favicon_dir.'/apple-touch-icon-'.$insert.'.png')); |
76 | - }) . |
|
77 | - insert_if_exists (['16x16', '32x32', '96x96', '194x194'], function ($insert) use ($favicon_dir) { |
|
78 | - return '<link rel="icon" type="image/png" href="' . asset($favicon_dir . '/favicon-' . $insert . '.png').'" sizes="'.$insert.'">'; |
|
79 | - }, function ($insert) use ($favicon_dir) { |
|
76 | + }). |
|
77 | + insert_if_exists(['16x16', '32x32', '96x96', '194x194'], function($insert) use ($favicon_dir) { |
|
78 | + return '<link rel="icon" type="image/png" href="'.asset($favicon_dir.'/favicon-'.$insert.'.png').'" sizes="'.$insert.'">'; |
|
79 | + }, function($insert) use ($favicon_dir) { |
|
80 | 80 | return File::exists(public_path($favicon_dir.'/favicon-'.$insert.'.png')); |
81 | - }) . |
|
82 | - insert_if_exists (['192x192'], function ($insert) use ($favicon_dir) { |
|
83 | - return '<link rel="icon" type="image/png" href="' . asset($favicon_dir . '/android-chrome-' . $insert . '.png').'" sizes="'.$insert.'">'; |
|
84 | - }, function ($insert) use ($favicon_dir) { |
|
81 | + }). |
|
82 | + insert_if_exists(['192x192'], function($insert) use ($favicon_dir) { |
|
83 | + return '<link rel="icon" type="image/png" href="'.asset($favicon_dir.'/android-chrome-'.$insert.'.png').'" sizes="'.$insert.'">'; |
|
84 | + }, function($insert) use ($favicon_dir) { |
|
85 | 85 | return File::exists(public_path($favicon_dir.'/android-chrome-'.$insert.'.png')); |
86 | - }) . |
|
87 | - insert_if_exists ($favicon_dir.'/manifest.json', function ($insert) { |
|
88 | - return '<link rel="manifest" href="' . asset($insert) . '">'; |
|
89 | - }, function ($insert) { |
|
86 | + }). |
|
87 | + insert_if_exists($favicon_dir.'/manifest.json', function($insert) { |
|
88 | + return '<link rel="manifest" href="'.asset($insert).'">'; |
|
89 | + }, function($insert) { |
|
90 | 90 | return File::exists(public_path($insert)); |
91 | - }) . |
|
92 | - insert_if_exists ($favicon_dir.'/safari-pinned-tab.svg', function ($insert) use ($colors) { |
|
93 | - return '<link rel="mask-icon" href="'.asset($insert).'" color="' . insert_if_exists($colors['safari_pinned']) . '">'; |
|
94 | - }, function ($insert) { |
|
91 | + }). |
|
92 | + insert_if_exists($favicon_dir.'/safari-pinned-tab.svg', function($insert) use ($colors) { |
|
93 | + return '<link rel="mask-icon" href="'.asset($insert).'" color="'.insert_if_exists($colors['safari_pinned']).'">'; |
|
94 | + }, function($insert) { |
|
95 | 95 | return File::exists(public_path($insert)); |
96 | - }) . |
|
97 | - insert_if_exists ($favicon_dir.'/favicon.ico', function ($insert) { |
|
96 | + }). |
|
97 | + insert_if_exists($favicon_dir.'/favicon.ico', function($insert) { |
|
98 | 98 | return '<link rel="shortcut icon" href="'.asset($insert).'">'; |
99 | - }, function ($insert) { |
|
99 | + }, function($insert) { |
|
100 | 100 | return File::exists(public_path($insert)); |
101 | - }) . |
|
102 | - insert_if_exists ($favicon_dir.'/mstile-144x144.png', function ($insert) { |
|
101 | + }). |
|
102 | + insert_if_exists($favicon_dir.'/mstile-144x144.png', function($insert) { |
|
103 | 103 | return '<meta name="msapplication-TileImage" content="'.asset($insert).'">'; |
104 | - }, function ($insert) { |
|
104 | + }, function($insert) { |
|
105 | 105 | return File::exists(public_path($insert)); |
106 | - }) . |
|
107 | - insert_if_exists ($favicon_dir.'/browserconfig.xml', function ($insert) { |
|
106 | + }). |
|
107 | + insert_if_exists($favicon_dir.'/browserconfig.xml', function($insert) { |
|
108 | 108 | return '<meta name="msapplication-config" content="'.asset($insert).'">'; |
109 | - }, function ($insert) { |
|
109 | + }, function($insert) { |
|
110 | 110 | return File::exists(public_path($insert)); |
111 | - }) . |
|
112 | - insert_if_exists ($colors['ms_tile'], function ($insert) { |
|
111 | + }). |
|
112 | + insert_if_exists($colors['ms_tile'], function($insert) { |
|
113 | 113 | return '<meta name="msapplication-TileColor" content="'.$insert.'">'; |
114 | - }) . |
|
115 | - insert_if_exists ($colors['theme'], function ($insert) { |
|
114 | + }). |
|
115 | + insert_if_exists($colors['theme'], function($insert) { |
|
116 | 116 | return '<meta name="theme-color" content="'.$insert.'">'; |
117 | 117 | }); |
118 | 118 | } |
119 | 119 | |
120 | - public function make (array $details, $view = null) |
|
120 | + public function make(array $details, $view = null) |
|
121 | 121 | { |
122 | 122 | $this->defaults = array_replace($this->defaults, $details); |
123 | 123 | |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | - public function get () |
|
131 | + public function get() |
|
132 | 132 | { |
133 | - return str_replace(PHP_EOL, '', SEOTools::generate()) . $this->setFavicons(); |
|
133 | + return str_replace(PHP_EOL, '', SEOTools::generate()).$this->setFavicons(); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | \ No newline at end of file |