From 9c6374b57e900cb15d05c79bcee6d7b2aa46c368 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 6 Apr 2016 09:41:07 +0300 Subject: [PATCH] Support for rel canonical. --- _include/Page/Common.php | 2 ++ _include/Page/HTML.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/_include/Page/Common.php b/_include/Page/Common.php index 54c285c8..dce53fad 100644 --- a/_include/Page/Common.php +++ b/_include/Page/Common.php @@ -297,6 +297,8 @@ private function parse_page_url ($request_uri) if (S2_USE_HIERARCHY && $parent_num && $page['children_exist'] != $was_end_slash) s2_permanent_redirect($current_path.(!$was_end_slash ? '/' : '')); + $page['canonical_path'] = $current_path.($was_end_slash ? '/' : ''); + $id = $page['id']; $bread_crumbs[] = array( 'title' => $page['title'] diff --git a/_include/Page/HTML.php b/_include/Page/HTML.php index a2d94f4d..5cc235fc 100644 --- a/_include/Page/HTML.php +++ b/_include/Page/HTML.php @@ -112,6 +112,8 @@ public function process_template () $meta_tags[] = ''; if (!empty($page['meta_description'])) $meta_tags[] = ''; + if (!empty($page['canonical_path']) && defined('S2_CANONICAL_URL')) + $meta_tags[] = ''; ($hook = s2_hook('proc_tpl_pre_meta_merge')) ? eval($hook) : null; $replace[''] = implode("\n", $meta_tags);