Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/1.1.51'
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Sep 22, 2017
2 parents ec38884 + b23afd2 commit 9fc72db
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 5 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.51 - 2017.09.21
### Added
* Added support for `hreflang="x-default"`
* Added `availabilty` to the default `Offer` Product JSON-LD

### Changed
* Fixed an issue where you could not change the Open Graph or Twitter `title` from a Twig template
* Handle localized elements for breadcrumbs

## 1.1.50 - 2017.08.10
### Added
* Add the ability to override the canonicalUrl from an SEOmatic Meta FieldType
Expand Down
33 changes: 33 additions & 0 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,39 @@ The `email` variable is ordinal-encoded to obfuscate it. For instance, `info@ny

## SEOmatic Helper Twig Variables

SEOmatic populates your templates with the following "helper" variables for that you can use in your templates:

seomaticHelper.twitterUrl
seomaticHelper.facebookUrl
seomaticHelper.googlePlusUrl
seomaticHelper.linkedInUrl
seomaticHelper.youtubeUrl,
seomaticHelper.youtubeChannelUrl
seomaticHelper.instagramUrl
seomaticHelper.pinterestUrl
seomaticHelper.githubUrl
seomaticHelper.vimeoUrl
seomaticHelper.wikipediaUrl
seomaticHelper.ownerGoogleSiteVerification
seomaticHelper.ownerBingSiteVerification
seomaticHelper.ownerGoogleAnalyticsUID
seomaticHelper.ownerGoogleTagManagerID
seomaticHelper.googleAnalyticsSendPageview
seomaticHelper.googleAnalyticsAdvertising
seomaticHelper.googleAnalyticsEcommerce
seomaticHelper.googleAnalyticsEEcommerce
seomaticHelper.googleAnalyticsLinkAttribution
seomaticHelper.googleAnalyticsLinker
seomaticHelper.googleAnalyticsAnonymizeIp
seomaticHelper.ownerCopyrightNotice
seomaticHelper.ownerAddressString
seomaticHelper.ownerAddressHtml
seomaticHelper.ownerMapUrl
seomaticHelper.creatorCopyrightNotice
seomaticHelper.creatorAddressString
seomaticHelper.creatorAddressHtml
seomaticHelper.creatorMapUrl

## Previewing your SEO Meta

There's a lot going on here, so to make it all more easily understood, SEOmatic offers two ways to preview your SEO Meta. You have to **Save** the settings first before you preview them; a "Live Preview" feature is on the wish list for future versions.
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.50';
return '1.1.51';
}

public function getSchemaVersion()
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.51",
"downloadUrl": "https://github.com/nystudio107/seomatic/archive/master.zip",
"date": "2017-09-21T11:00:00-11:00",
"notes": [
"[Fixed] Handle localized elements for breadcrumbs",
"[Added] Added support for `hreflang='x-default'`",
"[Fixed] Fixed an issue where you could not change the Open Graph or Twitter `title` from a Twig template",
"[Added] Added `availabilty` to the default `Offer` Product JSON-LD"
]
},
{
"version": "1.1.50",
"downloadUrl": "https://github.com/nystudio107/seomatic/archive/master.zip",
Expand Down
32 changes: 28 additions & 4 deletions services/SeomaticService.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,22 +620,34 @@ public function getMetaFromElement($element)

foreach ($variants as $variant)
{
if ($variant->getIsAvailable()) {
$availability = "http://schema.org/InStock";
} else {
$availability = "http://schema.org/OutOfStock";
}
$commerceVariant = array(
'seoProductDescription' => $variant->getDescription() . ' - ' . $element->title,
'seoProductPrice' => number_format($variant->getPrice(), 2, '.', ''),
'seoProductCurrency' => craft()->commerce_paymentCurrencies->getPrimaryPaymentCurrency(),
'seoProductSku' => $variant->getSku(),
'seoProductAvailability' => $availability,
);
$commerceVariants[] = $commerceVariant;
}
}
else
{
if ($element->getIsAvailable()) {
$availability = "http://schema.org/InStock";
} else {
$availability = "http://schema.org/OutOfStock";
}
$commerceVariant = array(
'seoProductDescription' => $element->getDescription() . ' - ' . $element->title,
'seoProductPrice' => number_format($element->getPrice(), 2, '.', ''),
'seoProductCurrency' => craft()->commerce_paymentCurrencies->getPrimaryPaymentCurrency(),
'seoProductSku' => $element->getSku(),
'seoProductAvailability' => $availability,
);
$commerceVariants[] = $commerceVariant;
}
Expand Down Expand Up @@ -1217,7 +1229,7 @@ public function getDefaultBreadcrumbs($meta)
$result = array();
$element = null;

$element = craft()->elements->getElementByUri("__home__");
$element = craft()->elements->getElementByUri("__home__", craft()->language, true);
if ($element)
{
$result[$element->title] = $this->getFullyQualifiedUrl($element->url);
Expand Down Expand Up @@ -1247,7 +1259,7 @@ public function getDefaultBreadcrumbs($meta)
foreach ($segments as $segment)
{
$uri .= $segment;
$element = craft()->elements->getElementByUri($uri);
$element = craft()->elements->getElementByUri($uri, craft()->language, true);
if ($element && $element->uri)
{
$result[$element->title] = $this->getFullyQualifiedUrl($element->uri);
Expand Down Expand Up @@ -2374,6 +2386,7 @@ public function getProductJSONLD($meta, $identity, $locale)
"priceCurrency" => $variant['seoProductCurrency'],
"offeredBy" => $identity,
"seller" => $identity,
"availability" => $variant['seoProductAvailability'],
);
$offer = array_filter($offer);
$productJSONLD['offers'] = $offer;
Expand Down Expand Up @@ -2934,10 +2947,21 @@ public function sanitizeMetaVars(&$metaVars)
if ($seomaticSiteMeta['siteSeoTitlePlacement'] == "after")
$titleSuffix = " " . $seomaticSiteMeta['siteSeoTitleSeparator'] . " " . $seomaticSiteMeta['siteSeoName'];

if (isset($seomaticMeta['twitter']['title'])) {
$title = $seomaticMeta['twitter']['title'];
} else {
$title = $seomaticMeta['seoTitle'];
}
if (isset($seomaticMeta['twitter']))
$seomaticMeta['twitter']['title'] = $titlePrefix . $seomaticMeta['seoTitle'] . $titleSuffix;
$seomaticMeta['twitter']['title'] = $titlePrefix . $title . $titleSuffix;

if (isset($seomaticMeta['og']['title'])) {
$title = $seomaticMeta['og']['title'];
} else {
$title = $seomaticMeta['seoTitle'];
}
if (isset($seomaticMeta['og']))
$seomaticMeta['og']['title'] = $titlePrefix . $seomaticMeta['seoTitle'] . $titleSuffix;
$seomaticMeta['og']['title'] = $titlePrefix . $title . $titleSuffix;

/* -- Truncate seoTitle, seoDescription, and seoKeywords to recommended values */

Expand Down
5 changes: 5 additions & 0 deletions templates/_seo_meta.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<link rel="canonical" href="{{ seomaticMeta.canonicalUrl }}" />
{% endif %}
{% set localizedUrls = getLocalizedUrls() %}
{% if localizedUrls |length > 0 %}
<link rel="alternate" href="{{ localizedUrls |first }}" hreflang="x-default" />
{% else %}
<link rel="alternate" href="{{ siteUrl }}" hreflang="x-default" />
{% endif %}
{% if localizedUrls |length > 1 %}
{% for key, value in localizedUrls %}
<link rel="alternate" hreflang="{{ key |lower |replace ('_', '-') }}" href="{{ value }}" />
Expand Down
5 changes: 5 additions & 0 deletions templates/_seo_metaPreview.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<link rel="canonical" href="{{ seomaticMeta.canonicalUrl }}" /> <!-- {% verbatim %}{{ seomaticMeta.canonicalUrl }} (defaults to craft.request.url){% endverbatim %} -->
{% endif %}
{% set localizedUrls = getLocalizedUrls() %}
{% if localizedUrls |length > 0 %}
<link rel="alternate" href="{{ localizedUrls |first }}" hreflang="x-default" />
{% else %}
<link rel="alternate" href="{{ siteUrl }}" hreflang="x-default" />
{% endif %}
{% if localizedUrls |length > 1 %}
{% for key, value in localizedUrls %}
<link rel="alternate" hreflang="{{ key |lower |replace ('_', '-') }}" href="{{ value }}" /> <!-- {% verbatim %}hreflang="{{ key |lower |replace ('_', '-') }}" href="{{ value }}"{% endverbatim %} -->
Expand Down

0 comments on commit 9fc72db

Please sign in to comment.