@@ -4,10 +4,10 @@ discard block |
||
| 4 | 4 | /** |
| 5 | 5 | * CONSTANTS |
| 6 | 6 | */ |
| 7 | -defined('TWITTER_CARD_SUMMARY') OR define('TWITTER_CARD_SUMMARY', "summary"); |
|
| 7 | +defined('TWITTER_CARD_SUMMARY') OR define('TWITTER_CARD_SUMMARY', "summary"); |
|
| 8 | 8 | defined('TWITTER_CARD_SUMMARY_LARGE') OR define('TWITTER_CARD_LARGE', "summary_large_image"); |
| 9 | -defined('TWITTER_CARD_APP') OR define('TWITTER_CARD_APP', "app"); |
|
| 10 | -defined('TWITTER_CARD_PLAYER') OR define('TWITTER_CARD_PLAYER', "player"); |
|
| 9 | +defined('TWITTER_CARD_APP') OR define('TWITTER_CARD_APP', "app"); |
|
| 10 | +defined('TWITTER_CARD_PLAYER') OR define('TWITTER_CARD_PLAYER', "player"); |
|
| 11 | 11 | |
| 12 | 12 | if (!function_exists('og_read_config')) { |
| 13 | 13 | /** |
@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | * @param [type] $config [description] |
| 16 | 16 | * @return [type] [description] |
| 17 | 17 | */ |
| 18 | - function og_read_config($config, $echo=false) { |
|
| 19 | - $ci =& get_instance(); |
|
| 18 | + function og_read_config($config, $echo = false) { |
|
| 19 | + $ci = & get_instance(); |
|
| 20 | 20 | $ci->config->load($config, true); |
| 21 | 21 | if ($ci->config->item($config) == null) return ""; |
| 22 | - $og_vars = array_filter($ci->config->item($config), function ($value, $key) { |
|
| 22 | + $og_vars = array_filter($ci->config->item($config), function($value, $key) { |
|
| 23 | 23 | if (!is_scalar($key)) return false; |
| 24 | 24 | return preg_match("/^og_/", $key, $config); |
| 25 | 25 | }, ARRAY_FILTER_USE_BOTH); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @return [type] [description] |
| 142 | 142 | */ |
| 143 | 143 | function og_image_height($height) { |
| 144 | - return is_int($height) ? "<meta property=\"og:image:height\" content=\"$height\" />" . PHP_EOL : ""; |
|
| 144 | + return is_int($height) ? "<meta property=\"og:image:height\" content=\"$height\" />" . PHP_EOL : ""; |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
@@ -18,22 +18,32 @@ discard block |
||
| 18 | 18 | function og_read_config($config, $echo=false) { |
| 19 | 19 | $ci =& get_instance(); |
| 20 | 20 | $ci->config->load($config, true); |
| 21 | - if ($ci->config->item($config) == null) return ""; |
|
| 21 | + if ($ci->config->item($config) == null) { |
|
| 22 | + return ""; |
|
| 23 | + } |
|
| 22 | 24 | $og_vars = array_filter($ci->config->item($config), function ($value, $key) { |
| 23 | - if (!is_scalar($key)) return false; |
|
| 25 | + if (!is_scalar($key)) { |
|
| 26 | + return false; |
|
| 27 | + } |
|
| 24 | 28 | return preg_match("/^og_/", $key, $config); |
| 25 | 29 | }, ARRAY_FILTER_USE_BOTH); |
| 26 | - if (!is_array($og_vars) || count($og_vars) == 0) return ""; |
|
| 30 | + if (!is_array($og_vars) || count($og_vars) == 0) { |
|
| 31 | + return ""; |
|
| 32 | + } |
|
| 27 | 33 | $og_tags = ""; |
| 28 | 34 | foreach ($og_vars as $key => $value) { |
| 29 | - if (!is_scalar($value)) continue; |
|
| 35 | + if (!is_scalar($value)) { |
|
| 36 | + continue; |
|
| 37 | + } |
|
| 30 | 38 | if ($echo) { |
| 31 | 39 | echo og(substr($key, 3), $value); |
| 32 | 40 | } else { |
| 33 | 41 | $og_tags .= og(substr($key, 3), $value); |
| 34 | 42 | } |
| 35 | 43 | } |
| 36 | - if ($echo) return; |
|
| 44 | + if ($echo) { |
|
| 45 | + return; |
|
| 46 | + } |
|
| 37 | 47 | return $og_tags; |
| 38 | 48 | } |
| 39 | 49 | } |
@@ -46,7 +56,9 @@ discard block |
||
| 46 | 56 | * @return [type] [description] |
| 47 | 57 | */ |
| 48 | 58 | function og($name, $content) { |
| 49 | - if (!is_scalar($name) || !is_scalar($content)) return ""; |
|
| 59 | + if (!is_scalar($name) || !is_scalar($content)) { |
|
| 60 | + return ""; |
|
| 61 | + } |
|
| 50 | 62 | return "<meta property=\"og:$name\" content=\"$content\" />" . PHP_EOL; |
| 51 | 63 | } |
| 52 | 64 | } |
@@ -58,7 +70,9 @@ discard block |
||
| 58 | 70 | * @return [type] [description] |
| 59 | 71 | */ |
| 60 | 72 | function og_title($title) { |
| 61 | - if (!is_scalar($title)) return ""; |
|
| 73 | + if (!is_scalar($title)) { |
|
| 74 | + return ""; |
|
| 75 | + } |
|
| 62 | 76 | return "<meta property=\"og:title\" content=\"$title\" />" . PHP_EOL; |
| 63 | 77 | } |
| 64 | 78 | } |
@@ -70,7 +84,9 @@ discard block |
||
| 70 | 84 | * @return [type] [description] |
| 71 | 85 | */ |
| 72 | 86 | function og_type($type) { |
| 73 | - if (!is_scalar($type)) return ""; |
|
| 87 | + if (!is_scalar($type)) { |
|
| 88 | + return ""; |
|
| 89 | + } |
|
| 74 | 90 | return "<meta property=\"og:type\" content=\"$type\" />" . PHP_EOL; |
| 75 | 91 | } |
| 76 | 92 | } |
@@ -82,7 +98,9 @@ discard block |
||
| 82 | 98 | * @return [type] [description] |
| 83 | 99 | */ |
| 84 | 100 | function og_description($description) { |
| 85 | - if (!is_scalar($description)) return ""; |
|
| 101 | + if (!is_scalar($description)) { |
|
| 102 | + return ""; |
|
| 103 | + } |
|
| 86 | 104 | return "<meta property=\"og:description\" content=\"$description\" />" . PHP_EOL; |
| 87 | 105 | } |
| 88 | 106 | } |
@@ -94,7 +112,9 @@ discard block |
||
| 94 | 112 | * @return [type] [description] |
| 95 | 113 | */ |
| 96 | 114 | function og_url($url) { |
| 97 | - if (!is_scalar($url)) return ""; |
|
| 115 | + if (!is_scalar($url)) { |
|
| 116 | + return ""; |
|
| 117 | + } |
|
| 98 | 118 | return "<meta property=\"og:url\" content=\"$url\" />" . PHP_EOL; |
| 99 | 119 | } |
| 100 | 120 | } |
@@ -106,7 +126,9 @@ discard block |
||
| 106 | 126 | * @return [type] [description] |
| 107 | 127 | */ |
| 108 | 128 | function og_site_name($site_name) { |
| 109 | - if (!is_scalar($site_name)) return ""; |
|
| 129 | + if (!is_scalar($site_name)) { |
|
| 130 | + return ""; |
|
| 131 | + } |
|
| 110 | 132 | return "<meta property=\"og:site_name\" content=\"$site_name\" />" . PHP_EOL; |
| 111 | 133 | } |
| 112 | 134 | } |
@@ -118,7 +140,9 @@ discard block |
||
| 118 | 140 | * @return [type] [description] |
| 119 | 141 | */ |
| 120 | 142 | function og_image($url) { |
| 121 | - if (!is_scalar($url)) return ""; |
|
| 143 | + if (!is_scalar($url)) { |
|
| 144 | + return ""; |
|
| 145 | + } |
|
| 122 | 146 | return "<meta property=\"og:image\" content=\"$url\" />" . PHP_EOL; |
| 123 | 147 | } |
| 124 | 148 | } |
@@ -160,7 +184,9 @@ discard block |
||
| 160 | 184 | |
| 161 | 185 | if (!function_exists('og_determiner')) { |
| 162 | 186 | function og_image_secure_url($url) { |
| 163 | - if (!is_scalar($url)) return ""; |
|
| 187 | + if (!is_scalar($url)) { |
|
| 188 | + return ""; |
|
| 189 | + } |
|
| 164 | 190 | return "<meta property=\"og:image:secure_url\" content=\"$url\" />" . PHP_EOL; |
| 165 | 191 | } |
| 166 | 192 | } |
@@ -172,7 +198,9 @@ discard block |
||
| 172 | 198 | * @return [type] [description] |
| 173 | 199 | */ |
| 174 | 200 | function og_parse_image($image) { |
| 175 | - if (!is_scalar($image)) return ""; |
|
| 201 | + if (!is_scalar($image)) { |
|
| 202 | + return ""; |
|
| 203 | + } |
|
| 176 | 204 | if (is_int(exif_imagetype($image))) { |
| 177 | 205 | $image_size = getimagesize($image); |
| 178 | 206 | if ($image_size && is_int($image_size[0])) { |
@@ -192,7 +220,9 @@ discard block |
||
| 192 | 220 | * @return [type] [description] |
| 193 | 221 | */ |
| 194 | 222 | function og_image_secure_url($url) { |
| 195 | - if (!is_scalar($url)) return ""; |
|
| 223 | + if (!is_scalar($url)) { |
|
| 224 | + return ""; |
|
| 225 | + } |
|
| 196 | 226 | return "<meta property=\"og:image:secure_url\" content=\"$url\" />" . PHP_EOL; |
| 197 | 227 | } |
| 198 | 228 | } |
@@ -204,7 +234,9 @@ discard block |
||
| 204 | 234 | * @return [type] [description] |
| 205 | 235 | */ |
| 206 | 236 | function og_determiner($determiner) { |
| 207 | - if (!is_scalar($determiner)) return ""; |
|
| 237 | + if (!is_scalar($determiner)) { |
|
| 238 | + return ""; |
|
| 239 | + } |
|
| 208 | 240 | return "<meta property=\"og:determiner\" content=\"$determiner\" />" . PHP_EOL; |
| 209 | 241 | } |
| 210 | 242 | } |
@@ -216,7 +248,9 @@ discard block |
||
| 216 | 248 | * @return [type] [description] |
| 217 | 249 | */ |
| 218 | 250 | function og_audio($url) { |
| 219 | - if (!is_scalar($url)) return ""; |
|
| 251 | + if (!is_scalar($url)) { |
|
| 252 | + return ""; |
|
| 253 | + } |
|
| 220 | 254 | return "<meta property=\"og:audio\" content=\"$url\" />" . PHP_EOL; |
| 221 | 255 | } |
| 222 | 256 | } |
@@ -228,7 +262,9 @@ discard block |
||
| 228 | 262 | * @return [type] [description] |
| 229 | 263 | */ |
| 230 | 264 | function og_locale($locale) { |
| 231 | - if (!is_scalar($locale)) return ""; |
|
| 265 | + if (!is_scalar($locale)) { |
|
| 266 | + return ""; |
|
| 267 | + } |
|
| 232 | 268 | return "<meta property=\"og:locale\" content=\"$locale\" />" . PHP_EOL; |
| 233 | 269 | } |
| 234 | 270 | } |
@@ -240,7 +276,9 @@ discard block |
||
| 240 | 276 | * @return [type] [description] |
| 241 | 277 | */ |
| 242 | 278 | function og_twitter_card($card) { |
| 243 | - if (!is_scalar($card)) return ""; |
|
| 279 | + if (!is_scalar($card)) { |
|
| 280 | + return ""; |
|
| 281 | + } |
|
| 244 | 282 | return "<meta name=\"twitter:card\" content=\"$card\"></meta>" . PHP_EOL; |
| 245 | 283 | } |
| 246 | 284 | } |
@@ -252,7 +290,9 @@ discard block |
||
| 252 | 290 | * @return [type] [description] |
| 253 | 291 | */ |
| 254 | 292 | function og_twitter_site($site) { |
| 255 | - if (!is_scalar($site)) return ""; |
|
| 293 | + if (!is_scalar($site)) { |
|
| 294 | + return ""; |
|
| 295 | + } |
|
| 256 | 296 | return "<meta name=\"twitter:site\" content=\"$site\"></meta>" . PHP_EOL; |
| 257 | 297 | } |
| 258 | 298 | } |
@@ -264,7 +304,9 @@ discard block |
||
| 264 | 304 | * @return [type] [description] |
| 265 | 305 | */ |
| 266 | 306 | function og_twitter_creator($creator) { |
| 267 | - if (!is_scalar($creator)) return ""; |
|
| 307 | + if (!is_scalar($creator)) { |
|
| 308 | + return ""; |
|
| 309 | + } |
|
| 268 | 310 | return "<meta name=\"twitter:creator\" content=\"$creator\"></meta>" . PHP_EOL; |
| 269 | 311 | } |
| 270 | 312 | } |