[Plugin] Canonical - added support fot category and tags URLs. Added Czech language

This commit is contained in:
Elixcz 2022-09-30 21:24:53 +02:00
parent e4569677c4
commit f50df101eb
No known key found for this signature in database
GPG key ID: 5DEC9DC9750F899A
4 changed files with 50 additions and 9 deletions

View file

@ -0,0 +1,8 @@
{
"plugin-data":
{
"name": "Canonical",
"description": "Použitím kanonických URL adres informujete vyhledávače o adresách s identickým obsahem"
},
"this-plugin-has-no-settings": "Tento plugin nemá nastavení"
}

View file

@ -3,5 +3,6 @@
{
"name": "Canonical",
"description": "Using canonical URLs can help to inform search engines which URLs have identical content."
}
}
},
"this-plugin-has-no-settings": "This plugin has no settings"
}

View file

@ -3,8 +3,8 @@
"email": "",
"website": "https://plugins.bludit.com",
"version": "4.0.0",
"releaseDate": "2021-05-23",
"releaseDate": "2022-09-30",
"license": "MIT",
"compatible": "4.0.0",
"notes": ""
}
}

View file

@ -3,11 +3,43 @@
class pluginCanonical extends Plugin {
public function siteHead() {
if ($GLOBALS['WHERE_AM_I'] === 'home') {
return '<link rel="canonical" href="'.DOMAIN_BASE.'"/>'.PHP_EOL;
} elseif ($GLOBALS['WHERE_AM_I'] === 'page') {
$html = '<!-- Plugin Canonical -->' . PHP_EOL;
if ($GLOBALS['WHERE_AM_I'] === 'home')
{
$html .= '<link rel="canonical" href="'.DOMAIN_BASE.'">'.PHP_EOL;
} elseif ($GLOBALS['WHERE_AM_I'] === 'page')
{
global $page;
return '<link rel="canonical" href="'.$page->permalink().'"/>'.PHP_EOL;
$html .= '<link rel="canonical" href="'.$page->permalink().'">'.PHP_EOL;
} elseif ($GLOBALS['WHERE_AM_I'] === 'category')
{
global $url;
$categoryKey = $url->slug();
$category = new Category( $categoryKey );
$html .= '<link rel="canonical" href="' . $category->permalink() . '">'.PHP_EOL;
} elseif ($GLOBALS['WHERE_AM_I'] === 'tag')
{
global $url;
$tagKey = $url->slug();
$tag = new Tag( $tagKey );
$html .= '<link rel="canonical" href="'.$tag->permalink().'">'.PHP_EOL;
}
$html .= '<!-- /Plugin Canonical -->' . PHP_EOL;
return $html;
}
}
public function form()
{
global $L;
return '<div class="alert alert-info">' . $L->g('This plugin has no settings') . '</div>';
}
}