Skip to content

Commit

Permalink
Merge branch 'release/3.2.22' into v3
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Sep 3, 2019
2 parents 648a449 + a42eb1e commit fe0b34a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,11 @@
# SEOmatic Changelog

## 3.2.22 - 2019.09.03
### Changed
* Cleaned up the `title` parsing to allow for `siteName` only titles more cleanly
* If the source asset file is missing, set `generateNow` to `false` rather than `null`, overriding `generateTransformsBeforePageLoad`
* Maintain the currently selected site between global nav items in the CP sidebar

## 3.2.21 - 2019.08.26
### Changed
* Fixed an issue where SEOmatic would errantly say the environment was disabled
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-seomatic",
"description": "SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.",
"type": "craft-plugin",
"version": "3.2.21",
"version": "3.2.22",
"keywords": [
"craft",
"cms",
Expand Down
20 changes: 15 additions & 5 deletions src/Seomatic.php
Expand Up @@ -287,36 +287,46 @@ public function getCpNavItem()
$subNavs = [];
$navItem = parent::getCpNavItem();
/** @var User $currentUser */
$request = Craft::$app->getRequest();
$siteSuffix = '';
if ($request->getSegment(1) === 'seomatic') {
$segments = $request->getSegments();
$lastSegment = end($segments);
$site = Craft::$app->getSites()->getSiteByHandle($lastSegment);
if ($site !== null) {
$siteSuffix = '/'.$lastSegment;
}
}
$currentUser = Craft::$app->getUser()->getIdentity();
// Only show sub-navs the user has permission to view
if ($currentUser->can('seomatic:dashboard')) {
$subNavs['dashboard'] = [
'label' => 'Dashboard',
'url' => 'seomatic/dashboard',
'url' => 'seomatic/dashboard'.$siteSuffix,
];
}
if ($currentUser->can('seomatic:global-meta')) {
$subNavs['global'] = [
'label' => 'Global SEO',
'url' => 'seomatic/global',
'url' => 'seomatic/global/general'.$siteSuffix,
];
}
if ($currentUser->can('seomatic:content-meta')) {
$subNavs['content'] = [
'label' => 'Content SEO',
'url' => 'seomatic/content',
'url' => 'seomatic/content'.$siteSuffix,
];
}
if ($currentUser->can('seomatic:site-settings')) {
$subNavs['site'] = [
'label' => 'Site Settings',
'url' => 'seomatic/site',
'url' => 'seomatic/site/identity'.$siteSuffix,
];
}
if ($currentUser->can('seomatic:tracking-scripts')) {
$subNavs['tracking'] = [
'label' => 'Tracking Scripts',
'url' => 'seomatic/tracking',
'url' => 'seomatic/tracking/googleAnalytics'.$siteSuffix,
];
}
$editableSettings = true;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/ImageTransform.php
Expand Up @@ -115,7 +115,7 @@ public static function socialTransform(
$generateNow = Seomatic::$environment === EnvironmentHelper::SEOMATIC_DEV_ENV ? null : true;
// Preflight to ensure that the source asset actually exists to avoid Craft hanging
if ($volume !== null && !$volume->fileExists($asset->getPath())) {
$generateNow = null;
$generateNow = false;
}
try {
$url = $assets->getAssetUrl($asset, $transform, $generateNow);
Expand Down
15 changes: 11 additions & 4 deletions src/models/MetaTitle.php
Expand Up @@ -147,6 +147,9 @@ public function prepForRender(&$data): bool
$suffix = '';
break;
}
// Remove potential double spaces
$prefix = preg_replace('/\s+/', ' ', $prefix);;
$suffix = preg_replace('/\s+/', ' ', $suffix);;
$lengthAdjust = mb_strlen($prefix.$suffix);
// Parse the data
$scenario = $this->scenario;
Expand All @@ -158,11 +161,15 @@ public function prepForRender(&$data): bool
if ($truncLen < 0) {
$truncLen = 0;
}
$data = (string)Stringy::create($data)->safeTruncate(
$truncLen,
'…'
);
if (!empty($data)) {
$data = (string)Stringy::create($data)->safeTruncate(
$truncLen,
'…'
);
}
$data = $prefix.$data.$suffix;
// Trim whitespace
$data = trim($data);
// devMode
if (Seomatic::$devMode) {
$data = Seomatic::$settings->devModeTitlePrefix . $data;
Expand Down

0 comments on commit fe0b34a

Please sign in to comment.