mirror of
https://github.com/YunoHost/doc.git
synced 2024-09-03 20:06:26 +02:00
31 lines
785 B
PHP
31 lines
785 B
PHP
|
<?php
|
||
|
namespace Grav\Plugin\Shortcodes;
|
||
|
|
||
|
use Grav\Common\Language\Language;
|
||
|
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||
|
|
||
|
class VersionShortcode extends Shortcode
|
||
|
{
|
||
|
|
||
|
public function init()
|
||
|
{
|
||
|
$this->shortcode->getHandlers()->add('version', function(ShortcodeInterface $sc) {
|
||
|
$lang = $this->getBbCode($sc);
|
||
|
|
||
|
if ($lang) {
|
||
|
$list = explode(',', $lang);
|
||
|
array_walk($list, 'trim');
|
||
|
|
||
|
/** @var Language $language */
|
||
|
$language = $this->grav['language'];
|
||
|
$current = $language->getLanguage();
|
||
|
|
||
|
if (in_array($current, $list, true)) {
|
||
|
return $sc->getContent();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return '';
|
||
|
});
|
||
|
}
|
||
|
}
|