diff --git a/CHANGELOG.md b/CHANGELOG.md index 9433a8f..dca1924 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # SEOmatic Changelog +## 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 + +### Changed +* Fixed an issue with the breadcrumbs potentially overlapping URLs improperly +* Truncate locales to 5 characters, to handle custom locales + ## 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/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 715d046..f45d2d6 100644 --- a/releases.json +++ b/releases.json @@ -1,4 +1,15 @@ [ + { + "version": "1.1.55", + "downloadUrl": "https://github.com/nystudio107/seomatic/archive/master.zip", + "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", + "[Fixed] Fixed an issue with the breadcrumbs potentially overlapping URLs improperly", + "[Fixed] Truncate locales to 5 characters, to handle custom locales" + ] + }, { "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..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'] = $locale; + $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'] = craft()->language; + $mainEntityOfPageJSONLD['inLanguage'] = substr(craft()->language, 0, 5); $mainEntityOfPageJSONLD['headline'] = $title; if (isset($meta['seoKeywords'])) $mainEntityOfPageJSONLD['keywords'] = $meta['seoKeywords']; @@ -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); + } } } } @@ -3108,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);