Skip to content

Commit

Permalink
Merge branch 'release/1.1.55'
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Nov 5, 2017
2 parents b4a1d3c + 20cf138 commit d3697a5
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 36 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
2 changes: 1 addition & 1 deletion SeomaticPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getReleaseFeedUrl()

public function getVersion()
{
return '1.1.54';
return '1.1.55';
}

public function getSchemaVersion()
Expand Down
6 changes: 6 additions & 0 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
),
);
56 changes: 28 additions & 28 deletions fieldtypes/Seomatic_MetaFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions releases.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
18 changes: 11 additions & 7 deletions services/SeomaticService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand All @@ -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);
}
}
}
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d3697a5

Please sign in to comment.