From 94bcff40435932189bb2dc838f9fafc4eadfbc38 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Sun, 15 Oct 2017 15:38:27 -0400 Subject: [PATCH 1/7] * Added the ability to disable locales via the `config.php` file, for multi-site reasons Signed-off-by: Andrew Welch --- CHANGELOG.md | 4 ++++ SeomaticPlugin.php | 2 +- config.php | 6 ++++++ releases.json | 8 ++++++++ services/SeomaticService.php | 12 ++++++++---- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9433a8f..8329275 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # SEOmatic Changelog +## 1.1.55 - 2017.10.16 +### Added +* Added the ability to disable locales via the `config.php` file, for multi-site reasons + ## 1.1.54 - 2017.10.10 ### Changed * More intelligent handling of `addTrailingSlashesToUrls` diff --git a/SeomaticPlugin.php b/SeomaticPlugin.php index 453134a..d8ab188 100755 --- a/SeomaticPlugin.php +++ b/SeomaticPlugin.php @@ -26,7 +26,7 @@ public function getReleaseFeedUrl() public function getVersion() { - return '1.1.54'; + return '1.1.55'; } public function getSchemaVersion() diff --git a/config.php b/config.php index cd383d1..4f67be9 100755 --- a/config.php +++ b/config.php @@ -127,4 +127,10 @@ 'seoImageId' => '', ), +/** + * This allows you to exclude locales from SEOmatic's automatic handling of + * hreflang. Useful for some multi-site situations + */ + "excludeLocales" => array( + ), ); \ No newline at end of file diff --git a/releases.json b/releases.json index 715d046..86e2ec2 100644 --- a/releases.json +++ b/releases.json @@ -1,4 +1,12 @@ [ + { + "version": "1.1.55", + "downloadUrl": "https://github.com/nystudio107/seomatic/archive/master.zip", + "date": "2017-10-16T11:00:00-11:00", + "notes": [ + "[Improved] Added the ability to disable locales via the `config.php` file, for multi-site reasons" + ] + }, { "version": "1.1.54", "downloadUrl": "https://github.com/nystudio107/seomatic/archive/master.zip", diff --git a/services/SeomaticService.php b/services/SeomaticService.php index 10982e3..d63633b 100644 --- a/services/SeomaticService.php +++ b/services/SeomaticService.php @@ -3038,6 +3038,7 @@ public function getLocalizedUrls() { $localizedUrls = array(); $requestUri = craft()->request->getRequestUri(); + $excludeLocales = craft()->config->get("excludeLocales", "seomatic"); if (craft()->isLocalized()) { $element = craft()->urlManager->getMatchedElement(); @@ -3065,8 +3066,10 @@ public function getLocalizedUrls() foreach ($locales as $locale) { $localeId = $locale->getId(); - if (isset($unsortedLocalizedUrls[$localeId])) - $localizedUrls[$localeId] = $unsortedLocalizedUrls[$localeId]; + if (!in_array($localeId, $excludeLocales)) { + if (isset($unsortedLocalizedUrls[$localeId])) + $localizedUrls[$localeId] = $unsortedLocalizedUrls[$localeId]; + } } } else @@ -3075,8 +3078,9 @@ public function getLocalizedUrls() foreach ($locales as $locale) { $localeId = $locale->getId(); - $localizedUrls[$localeId] = UrlHelper::getSiteUrl($requestUri, null, null, $localeId); - + if (!in_array($localeId, $excludeLocales)) { + $localizedUrls[$localeId] = UrlHelper::getSiteUrl($requestUri, null, null, $localeId); + } } } } From b72d3c82a60565489fb8c060290f4cc29dce388d Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Fri, 27 Oct 2017 16:04:48 -0400 Subject: [PATCH 2/7] Fixed an issue with the breadcrumbs potentially overlapping URLs improperly Signed-off-by: Andrew Welch --- CHANGELOG.md | 5 ++++- releases.json | 3 ++- services/SeomaticService.php | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8329275..cfb0e06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,12 @@ # SEOmatic Changelog -## 1.1.55 - 2017.10.16 +## 1.1.55 - 2017.10.28 ### Added * Added the ability to disable locales via the `config.php` file, for multi-site reasons +### Changed +* Fixed an issue with the breadcrumbs potentially overlapping URLs improperly + ## 1.1.54 - 2017.10.10 ### Changed * More intelligent handling of `addTrailingSlashesToUrls` diff --git a/releases.json b/releases.json index 86e2ec2..0b84f9d 100644 --- a/releases.json +++ b/releases.json @@ -4,7 +4,8 @@ "downloadUrl": "https://github.com/nystudio107/seomatic/archive/master.zip", "date": "2017-10-16T11:00:00-11:00", "notes": [ - "[Improved] Added the ability to disable locales via the `config.php` file, for multi-site reasons" + "[Improved] Added the ability to disable locales via the `config.php` file, for multi-site reasons", + "[Fixed] Fixed an issue with the breadcrumbs potentially overlapping URLs improperly" ] }, { diff --git a/services/SeomaticService.php b/services/SeomaticService.php index d63633b..eee707e 100644 --- a/services/SeomaticService.php +++ b/services/SeomaticService.php @@ -3112,7 +3112,7 @@ public function getFullyQualifiedUrl($url) } else { $siteUrl = UrlHelper::getSiteUrl('', null, null, craft()->language); // Do this to prevent duplicate locales in the URL, e.g.: https://example.com/en/en/ - $siteUrl = rtrim($siteUrl, '/'); + $siteUrl = rtrim($siteUrl, '/') . '/'; $result = $this->replaceOverlap($siteUrl, $url); if ($result === false) { $result = UrlHelper::getSiteUrl($url, null, null, craft()->language); From b13e875786682c8699d57a2c39c74520667814b7 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Fri, 27 Oct 2017 16:16:06 -0400 Subject: [PATCH 3/7] Added paranoid checking for deleted source fields in the FieldType Signed-off-by: Andrew Welch --- CHANGELOG.md | 1 + fieldtypes/Seomatic_MetaFieldType.php | 56 +++++++++++++-------------- releases.json | 1 + 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfb0e06..a78ffc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 1.1.55 - 2017.10.28 ### Added * Added the ability to disable locales via the `config.php` file, for multi-site reasons +* Added paranoid checking for deleted source fields in the FieldType ### Changed * Fixed an issue with the breadcrumbs potentially overlapping URLs improperly diff --git a/fieldtypes/Seomatic_MetaFieldType.php b/fieldtypes/Seomatic_MetaFieldType.php index 29f00c9..664913e 100755 --- a/fieldtypes/Seomatic_MetaFieldType.php +++ b/fieldtypes/Seomatic_MetaFieldType.php @@ -145,48 +145,48 @@ public function getInputHtml($name, $value) { $field = craft()->fields->getFieldById($fieldLayout->fieldId); - switch ($field->type) - { - case "PlainText": - case "RichText": - case "RedactorI": - case "PreparseField_Preparse": - $fieldList[$field->handle] = $field->name; - $fieldData[$field->handle] = craft()->seomatic->truncateStringOnWord( + if (!empty($field->handle) && !empty($fieldList[$field->handle])) { + switch ($field->type) { + case "PlainText": + case "RichText": + case "RedactorI": + case "PreparseField_Preparse": + $fieldList[$field->handle] = $field->name; + $fieldData[$field->handle] = craft()->seomatic->truncateStringOnWord( strip_tags($this->element->content[$field->handle]), 200); - break; + break; - case "Neo": - $fieldList[$field->handle] = $field->name; - $fieldData[$field->handle] = craft()->seomatic->truncateStringOnWord( + case "Neo": + $fieldList[$field->handle] = $field->name; + $fieldData[$field->handle] = craft()->seomatic->truncateStringOnWord( craft()->seomatic->extractTextFromNeo($this->element[$field->handle]), 200); - break; + break; - case "Matrix": - $fieldList[$field->handle] = $field->name; - $fieldData[$field->handle] = craft()->seomatic->truncateStringOnWord( + case "Matrix": + $fieldList[$field->handle] = $field->name; + $fieldData[$field->handle] = craft()->seomatic->truncateStringOnWord( craft()->seomatic->extractTextFromMatrix($this->element[$field->handle]), 200); - break; + break; - case "Tags": - $fieldList[$field->handle] = $field->name; - $fieldData[$field->handle] = craft()->seomatic->truncateStringOnWord( + case "Tags": + $fieldList[$field->handle] = $field->name; + $fieldData[$field->handle] = craft()->seomatic->truncateStringOnWord( craft()->seomatic->extractTextFromTags($this->element[$field->handle]), 200); - break; + break; - case "FocusPoint_FocusPoint": - case "Assets": - $imageFieldList[$field->handle] = $field->name; - $img = $this->element[$field->handle]->first(); - if ($img) - { + case "FocusPoint_FocusPoint": + case "Assets": + $imageFieldList[$field->handle] = $field->name; + $img = $this->element[$field->handle]->first(); + if ($img) { $fieldImage[$field->handle] = $img->url; } - break; + break; + } } } $variables['fieldList'] = $fieldList; diff --git a/releases.json b/releases.json index 0b84f9d..8fc414a 100644 --- a/releases.json +++ b/releases.json @@ -5,6 +5,7 @@ "date": "2017-10-16T11:00:00-11:00", "notes": [ "[Improved] Added the ability to disable locales via the `config.php` file, for multi-site reasons", + "[Improved] Added paranoid checking for deleted source fields in the FieldType", "[Fixed] Fixed an issue with the breadcrumbs potentially overlapping URLs improperly" ] }, From efb6fa2c376268b54cc168daef309f7ecd731f1d Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Thu, 2 Nov 2017 21:07:43 -0400 Subject: [PATCH 4/7] Truncate locales to 4 characters, to handle custom locales Signed-off-by: Andrew Welch --- CHANGELOG.md | 1 + releases.json | 3 ++- services/SeomaticService.php | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a78ffc3..f98d492 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Changed * Fixed an issue with the breadcrumbs potentially overlapping URLs improperly +* Truncate locales to 4 characters, to handle custom locales ## 1.1.54 - 2017.10.10 ### Changed diff --git a/releases.json b/releases.json index 8fc414a..d61b009 100644 --- a/releases.json +++ b/releases.json @@ -6,7 +6,8 @@ "notes": [ "[Improved] Added the ability to disable locales via the `config.php` file, for multi-site reasons", "[Improved] Added paranoid checking for deleted source fields in the FieldType", - "[Fixed] Fixed an issue with the breadcrumbs potentially overlapping URLs improperly" + "[Fixed] Fixed an issue with the breadcrumbs potentially overlapping URLs improperly", + "[Fixed] Truncate locales to 4 characters, to handle custom locales" ] }, { diff --git a/services/SeomaticService.php b/services/SeomaticService.php index eee707e..540be55 100644 --- a/services/SeomaticService.php +++ b/services/SeomaticService.php @@ -962,7 +962,7 @@ public function setSocialForMeta(&$meta, $siteMeta, $social, $helper, $identity, if ($locale == "en") $openGraph['locale'] = 'en_US'; else - $openGraph['locale'] = $locale; + $openGraph['locale'] = substr($locale, 0, 4); if (strlen($openGraph['locale']) == 2) $openGraph['locale'] = $openGraph['locale'] . "_" . strtoupper($openGraph['locale']); @@ -2297,7 +2297,7 @@ public function getMainEntityOfPageJSONLD($meta, $identity, $locale, $isMainEnti { case "CreativeWork": { - $mainEntityOfPageJSONLD['inLanguage'] = craft()->language; + $mainEntityOfPageJSONLD['inLanguage'] = substr(craft()->language, 0, 4); $mainEntityOfPageJSONLD['headline'] = $title; if (isset($meta['seoKeywords'])) $mainEntityOfPageJSONLD['keywords'] = $meta['seoKeywords']; From 2e474d52903ff803526da8c7921b0e456586a21c Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Sun, 5 Nov 2017 14:22:31 -0500 Subject: [PATCH 5/7] Locales should be 5 characters, not 4 Signed-off-by: Andrew Welch --- services/SeomaticService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/SeomaticService.php b/services/SeomaticService.php index 540be55..606a59b 100644 --- a/services/SeomaticService.php +++ b/services/SeomaticService.php @@ -962,7 +962,7 @@ public function setSocialForMeta(&$meta, $siteMeta, $social, $helper, $identity, if ($locale == "en") $openGraph['locale'] = 'en_US'; else - $openGraph['locale'] = substr($locale, 0, 4); + $openGraph['locale'] = substr($locale, 0, 5); if (strlen($openGraph['locale']) == 2) $openGraph['locale'] = $openGraph['locale'] . "_" . strtoupper($openGraph['locale']); @@ -2297,7 +2297,7 @@ public function getMainEntityOfPageJSONLD($meta, $identity, $locale, $isMainEnti { case "CreativeWork": { - $mainEntityOfPageJSONLD['inLanguage'] = substr(craft()->language, 0, 4); + $mainEntityOfPageJSONLD['inLanguage'] = substr(craft()->language, 0, 5); $mainEntityOfPageJSONLD['headline'] = $title; if (isset($meta['seoKeywords'])) $mainEntityOfPageJSONLD['keywords'] = $meta['seoKeywords']; From 10503afc61401eddb92891c649ddd7591cbae63e Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Sun, 5 Nov 2017 14:23:34 -0500 Subject: [PATCH 6/7] Locales should be 5 characters, not 4 Signed-off-by: Andrew Welch --- CHANGELOG.md | 2 +- releases.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f98d492..3dbd97f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ ### Changed * Fixed an issue with the breadcrumbs potentially overlapping URLs improperly -* Truncate locales to 4 characters, to handle custom locales +* Truncate locales to 5 characters, to handle custom locales ## 1.1.54 - 2017.10.10 ### Changed diff --git a/releases.json b/releases.json index d61b009..0ea114a 100644 --- a/releases.json +++ b/releases.json @@ -7,7 +7,7 @@ "[Improved] Added the ability to disable locales via the `config.php` file, for multi-site reasons", "[Improved] Added paranoid checking for deleted source fields in the FieldType", "[Fixed] Fixed an issue with the breadcrumbs potentially overlapping URLs improperly", - "[Fixed] Truncate locales to 4 characters, to handle custom locales" + "[Fixed] Truncate locales to 5 characters, to handle custom locales" ] }, { From 20cf138bc253758ab7e6f31ce45460b9d7f98bad Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Sun, 5 Nov 2017 14:24:34 -0500 Subject: [PATCH 7/7] Locales should be 5 characters, not 4 Signed-off-by: Andrew Welch --- CHANGELOG.md | 2 +- releases.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dbd97f..dca1924 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # SEOmatic Changelog -## 1.1.55 - 2017.10.28 +## 1.1.55 - 2017.11.05 ### Added * Added the ability to disable locales via the `config.php` file, for multi-site reasons * Added paranoid checking for deleted source fields in the FieldType diff --git a/releases.json b/releases.json index 0ea114a..f45d2d6 100644 --- a/releases.json +++ b/releases.json @@ -2,7 +2,7 @@ { "version": "1.1.55", "downloadUrl": "https://github.com/nystudio107/seomatic/archive/master.zip", - "date": "2017-10-16T11:00:00-11:00", + "date": "2017-11-05T11:00:00-11:00", "notes": [ "[Improved] Added the ability to disable locales via the `config.php` file, for multi-site reasons", "[Improved] Added paranoid checking for deleted source fields in the FieldType",