// Set twitter card
$twitter_card = [
'card' => 'summary',
'description' => function_exists('get_meta_description') ? get_meta_description() : null,
'title' => G\str_replace_last(' - '.CHV\getSetting('website_name'), null, get_doctitle()),
'site' => CHV\getSetting('twitter_account') ? ('@'.CHV\getSetting('twitter_account')) : null,
];
switch (true) {
case G\is_route('image'):
$twitter_card['card'] = 'photo';
break;
case function_exists('get_admin') and G\is_route('album'):
case function_exists('get_user') and G\is_route('user'):
$twitter_card['card'] = 'gallery';
if (G\is_route('album')) {
$twitter_card['creator'] = get_album()['user']['twitter']['username'];
} else {
$twitter_card['creator'] = get_user()['twitter']['username'];
}
$list_output = function_exists('get_list') ? get_list()->output_assoc : null;
if (is_array($list_output) && count($list_output) > 0) {
for ($i = 0; $i < 4; ++$i) {
$twitter_card['image'.$i] = $list_output[$i]['display_url'];
}
}
break;
}
foreach ($twitter_card as $k => $v) {
if (!$v) {
continue;
}
echo '<meta name="twitter:'.$k.'" content="'.$v.'">'."\n";
}