@@ -46,32 +46,32 @@ discard block |
||
| 46 | 46 | const DOCUMENTATION_URL = 'https://github.com/nystudio107/craft-seomatic/wiki'; |
| 47 | 47 | |
| 48 | 48 | const PULL_TEXT_FIELDS = [ |
| 49 | - ['fieldName' => 'seoTitle', 'seoField' => 'seoTitle'], |
|
| 50 | - ['fieldName' => 'seoDescription', 'seoField' => 'seoDescription'], |
|
| 51 | - ['fieldName' => 'seoKeywords', 'seoField' => 'seoKeywords'], |
|
| 52 | - ['fieldName' => 'seoImageDescription', 'seoField' => 'seoImageDescription'], |
|
| 53 | - ['fieldName' => 'ogTitle', 'seoField' => 'seoTitle'], |
|
| 54 | - ['fieldName' => 'ogSiteNamePosition', 'seoField' => 'siteNamePosition'], |
|
| 55 | - ['fieldName' => 'ogDescription', 'seoField' => 'seoDescription'], |
|
| 56 | - ['fieldName' => 'ogImageDescription', 'seoField' => 'seoImageDescription'], |
|
| 57 | - ['fieldName' => 'twitterTitle', 'seoField' => 'seoTitle'], |
|
| 58 | - ['fieldName' => 'twitterSiteNamePosition', 'seoField' => 'siteNamePosition'], |
|
| 59 | - ['fieldName' => 'twitterCreator', 'seoField' => 'twitterHandle'], |
|
| 60 | - ['fieldName' => 'twitterDescription', 'seoField' => 'seoDescription'], |
|
| 61 | - ['fieldName' => 'twitterImageDescription', 'seoField' => 'seoImageDescription'], |
|
| 49 | + [ 'fieldName' => 'seoTitle', 'seoField' => 'seoTitle' ], |
|
| 50 | + [ 'fieldName' => 'seoDescription', 'seoField' => 'seoDescription' ], |
|
| 51 | + [ 'fieldName' => 'seoKeywords', 'seoField' => 'seoKeywords' ], |
|
| 52 | + [ 'fieldName' => 'seoImageDescription', 'seoField' => 'seoImageDescription' ], |
|
| 53 | + [ 'fieldName' => 'ogTitle', 'seoField' => 'seoTitle' ], |
|
| 54 | + [ 'fieldName' => 'ogSiteNamePosition', 'seoField' => 'siteNamePosition' ], |
|
| 55 | + [ 'fieldName' => 'ogDescription', 'seoField' => 'seoDescription' ], |
|
| 56 | + [ 'fieldName' => 'ogImageDescription', 'seoField' => 'seoImageDescription' ], |
|
| 57 | + [ 'fieldName' => 'twitterTitle', 'seoField' => 'seoTitle' ], |
|
| 58 | + [ 'fieldName' => 'twitterSiteNamePosition', 'seoField' => 'siteNamePosition' ], |
|
| 59 | + [ 'fieldName' => 'twitterCreator', 'seoField' => 'twitterHandle' ], |
|
| 60 | + [ 'fieldName' => 'twitterDescription', 'seoField' => 'seoDescription' ], |
|
| 61 | + [ 'fieldName' => 'twitterImageDescription', 'seoField' => 'seoImageDescription' ], |
|
| 62 | 62 | ]; |
| 63 | 63 | |
| 64 | 64 | const PULL_ASSET_FIELDS = [ |
| 65 | - ['fieldName' => 'seoImage', 'seoField' => 'seoImage', 'transformName' => 'base'], |
|
| 66 | - ['fieldName' => 'ogImage', 'seoField' => 'seoImage', 'transformName' => 'facebook'], |
|
| 67 | - ['fieldName' => 'twitterImage', 'seoField' => 'seoImage', 'transformName' => 'twitter'], |
|
| 65 | + [ 'fieldName' => 'seoImage', 'seoField' => 'seoImage', 'transformName' => 'base' ], |
|
| 66 | + [ 'fieldName' => 'ogImage', 'seoField' => 'seoImage', 'transformName' => 'facebook' ], |
|
| 67 | + [ 'fieldName' => 'twitterImage', 'seoField' => 'seoImage', 'transformName' => 'twitter' ], |
|
| 68 | 68 | ]; |
| 69 | 69 | |
| 70 | 70 | const SETUP_GRADES = [ |
| 71 | - ['id' => 'data1', 'name' => 'A', 'color' => '#008002'], |
|
| 72 | - ['id' => 'data2', 'name' => 'B', 'color' => '#9ACD31'], |
|
| 73 | - ['id' => 'data4', 'name' => 'C', 'color' => '#FFA500'], |
|
| 74 | - ['id' => 'data5', 'name' => 'D', 'color' => '#8B0100'], |
|
| 71 | + [ 'id' => 'data1', 'name' => 'A', 'color' => '#008002' ], |
|
| 72 | + [ 'id' => 'data2', 'name' => 'B', 'color' => '#9ACD31' ], |
|
| 73 | + [ 'id' => 'data4', 'name' => 'C', 'color' => '#FFA500' ], |
|
| 74 | + [ 'id' => 'data5', 'name' => 'D', 'color' => '#8B0100' ], |
|
| 75 | 75 | ]; |
| 76 | 76 | |
| 77 | 77 | const SEO_SETUP_FIELDS = [ |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public function actionDashboard(string $siteHandle = null, bool $showWelcome = false): Response |
| 114 | 114 | { |
| 115 | - $variables = []; |
|
| 115 | + $variables = [ ]; |
|
| 116 | 116 | // Get the site to edit |
| 117 | 117 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
| 118 | 118 | $pluginName = Seomatic::$settings->pluginName; |
@@ -124,20 +124,20 @@ discard block |
||
| 124 | 124 | } catch (InvalidConfigException $e) { |
| 125 | 125 | Craft::error($e->getMessage(), __METHOD__); |
| 126 | 126 | } |
| 127 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 127 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 128 | 128 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 129 | 129 | true |
| 130 | 130 | ); |
| 131 | 131 | // Enabled sites |
| 132 | 132 | $this->setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 133 | - $variables['controllerHandle'] = 'dashboard'; |
|
| 133 | + $variables[ 'controllerHandle' ] = 'dashboard'; |
|
| 134 | 134 | |
| 135 | 135 | // Basic variables |
| 136 | - $variables['fullPageForm'] = false; |
|
| 137 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 138 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 139 | - $variables['title'] = $templateTitle; |
|
| 140 | - $variables['crumbs'] = [ |
|
| 136 | + $variables[ 'fullPageForm' ] = false; |
|
| 137 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 138 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 139 | + $variables[ 'title' ] = $templateTitle; |
|
| 140 | + $variables[ 'crumbs' ] = [ |
|
| 141 | 141 | [ |
| 142 | 142 | 'label' => $pluginName, |
| 143 | 143 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -147,51 +147,51 @@ discard block |
||
| 147 | 147 | 'url' => UrlHelper::cpUrl('seomatic/dashboard'), |
| 148 | 148 | ], |
| 149 | 149 | ]; |
| 150 | - $variables['selectedSubnavItem'] = 'dashboard'; |
|
| 151 | - $variables['showWelcome'] = $showWelcome; |
|
| 150 | + $variables[ 'selectedSubnavItem' ] = 'dashboard'; |
|
| 151 | + $variables[ 'showWelcome' ] = $showWelcome; |
|
| 152 | 152 | // Calulate the setup grades |
| 153 | - $variables['contentSetupStats'] = []; |
|
| 154 | - $variables['globalSetupStats'] = []; |
|
| 155 | - $variables['setupGrades'] = self::SETUP_GRADES; |
|
| 153 | + $variables[ 'contentSetupStats' ] = [ ]; |
|
| 154 | + $variables[ 'globalSetupStats' ] = [ ]; |
|
| 155 | + $variables[ 'setupGrades' ] = self::SETUP_GRADES; |
|
| 156 | 156 | $numFields = count(self::SEO_SETUP_FIELDS); |
| 157 | 157 | $numGrades = count(self::SETUP_GRADES); |
| 158 | 158 | while ($numGrades--) { |
| 159 | - $variables['contentSetupStats'][] = 0; |
|
| 160 | - $variables['globalSetupStats'][] = 0; |
|
| 159 | + $variables[ 'contentSetupStats' ][ ] = 0; |
|
| 160 | + $variables[ 'globalSetupStats' ][ ] = 0; |
|
| 161 | 161 | } |
| 162 | 162 | $numGrades = count(self::SETUP_GRADES); |
| 163 | 163 | // Content SEO grades |
| 164 | - $variables['metaBundles'] = Seomatic::$plugin->metaBundles->getContentMetaBundlesForSiteId($siteId); |
|
| 164 | + $variables[ 'metaBundles' ] = Seomatic::$plugin->metaBundles->getContentMetaBundlesForSiteId($siteId); |
|
| 165 | 165 | /** @var MetaBundle $metaBundle */ |
| 166 | - foreach ($variables['metaBundles'] as $metaBundle) { |
|
| 166 | + foreach ($variables[ 'metaBundles' ] as $metaBundle) { |
|
| 167 | 167 | $stat = 0; |
| 168 | 168 | foreach (self::SEO_SETUP_FIELDS as $setupField) { |
| 169 | - $stat += intval(!empty($metaBundle->metaGlobalVars[$setupField])); |
|
| 169 | + $stat += intval(!empty($metaBundle->metaGlobalVars[ $setupField ])); |
|
| 170 | 170 | } |
| 171 | 171 | $stat = round($numGrades - (($stat * $numGrades) / $numFields) - 1); |
| 172 | - $variables['contentSetupStats'][$stat]++; |
|
| 172 | + $variables[ 'contentSetupStats' ][ $stat ]++; |
|
| 173 | 173 | } |
| 174 | 174 | // Global SEO grades |
| 175 | 175 | $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($siteId)); |
| 176 | 176 | $stat = 0; |
| 177 | 177 | foreach (self::SEO_SETUP_FIELDS as $setupField) { |
| 178 | - $stat += intval(!empty($metaBundle->metaGlobalVars[$setupField])); |
|
| 178 | + $stat += intval(!empty($metaBundle->metaGlobalVars[ $setupField ])); |
|
| 179 | 179 | } |
| 180 | 180 | $stat = round($numGrades - (($stat * $numGrades) / $numFields) - 1); |
| 181 | - $variables['globalSetupStats'][$stat]++; |
|
| 181 | + $variables[ 'globalSetupStats' ][ $stat ]++; |
|
| 182 | 182 | // Site Settings grades |
| 183 | 183 | $numFields = count(self::SITE_SETUP_FIELDS); |
| 184 | 184 | $numGrades = count(self::SETUP_GRADES); |
| 185 | 185 | while ($numGrades--) { |
| 186 | - $variables['siteSetupStats'][] = 0; |
|
| 186 | + $variables[ 'siteSetupStats' ][ ] = 0; |
|
| 187 | 187 | } |
| 188 | 188 | $numGrades = count(self::SETUP_GRADES); |
| 189 | 189 | $stat = 0; |
| 190 | 190 | foreach (self::SITE_SETUP_FIELDS as $setupField) { |
| 191 | - $stat += intval(!empty($metaBundle->metaSiteVars[$setupField])); |
|
| 191 | + $stat += intval(!empty($metaBundle->metaSiteVars[ $setupField ])); |
|
| 192 | 192 | } |
| 193 | 193 | $stat = round($numGrades - (($stat * $numGrades) / $numFields) - 1); |
| 194 | - $variables['siteSetupStats'][$stat]++; |
|
| 194 | + $variables[ 'siteSetupStats' ][ $stat ]++; |
|
| 195 | 195 | |
| 196 | 196 | // Render the template |
| 197 | 197 | return $this->renderTemplate('seomatic/dashboard/index', $variables); |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | public function actionGlobal(string $subSection = 'general', string $siteHandle = null): Response |
| 211 | 211 | { |
| 212 | - $variables = []; |
|
| 212 | + $variables = [ ]; |
|
| 213 | 213 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
| 214 | 214 | |
| 215 | 215 | $pluginName = Seomatic::$settings->pluginName; |
@@ -221,18 +221,18 @@ discard block |
||
| 221 | 221 | } catch (InvalidConfigException $e) { |
| 222 | 222 | Craft::error($e->getMessage(), __METHOD__); |
| 223 | 223 | } |
| 224 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 224 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 225 | 225 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 226 | 226 | true |
| 227 | 227 | ); |
| 228 | 228 | // Basic variables |
| 229 | - $variables['fullPageForm'] = true; |
|
| 230 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 231 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 232 | - $variables['title'] = $templateTitle; |
|
| 233 | - $variables['subSectionTitle'] = $subSectionTitle; |
|
| 234 | - $variables['docTitle'] = $templateTitle.' - '.$subSectionTitle; |
|
| 235 | - $variables['crumbs'] = [ |
|
| 229 | + $variables[ 'fullPageForm' ] = true; |
|
| 230 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 231 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 232 | + $variables[ 'title' ] = $templateTitle; |
|
| 233 | + $variables[ 'subSectionTitle' ] = $subSectionTitle; |
|
| 234 | + $variables[ 'docTitle' ] = $templateTitle . ' - ' . $subSectionTitle; |
|
| 235 | + $variables[ 'crumbs' ] = [ |
|
| 236 | 236 | [ |
| 237 | 237 | 'label' => $pluginName, |
| 238 | 238 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -243,39 +243,39 @@ discard block |
||
| 243 | 243 | ], |
| 244 | 244 | [ |
| 245 | 245 | 'label' => $subSectionTitle, |
| 246 | - 'url' => UrlHelper::cpUrl('seomatic/global/'.$subSection), |
|
| 246 | + 'url' => UrlHelper::cpUrl('seomatic/global/' . $subSection), |
|
| 247 | 247 | ], |
| 248 | 248 | ]; |
| 249 | - $variables['selectedSubnavItem'] = 'global'; |
|
| 249 | + $variables[ 'selectedSubnavItem' ] = 'global'; |
|
| 250 | 250 | // Pass in the pull fields |
| 251 | 251 | $this->setGlobalFieldSourceVariables($variables); |
| 252 | 252 | // Enabled sites |
| 253 | 253 | $this->setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 254 | - $variables['controllerHandle'] = 'global'.'/'.$subSection; |
|
| 255 | - $variables['currentSubSection'] = $subSection; |
|
| 254 | + $variables[ 'controllerHandle' ] = 'global' . '/' . $subSection; |
|
| 255 | + $variables[ 'currentSubSection' ] = $subSection; |
|
| 256 | 256 | // Meta bundle settings |
| 257 | - $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables['currentSiteId'])); |
|
| 258 | - $variables['globals'] = $metaBundle->metaGlobalVars; |
|
| 259 | - $variables['sitemap'] = $metaBundle->metaSitemapVars; |
|
| 260 | - $variables['settings'] = $metaBundle->metaBundleSettings; |
|
| 257 | + $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables[ 'currentSiteId' ])); |
|
| 258 | + $variables[ 'globals' ] = $metaBundle->metaGlobalVars; |
|
| 259 | + $variables[ 'sitemap' ] = $metaBundle->metaSitemapVars; |
|
| 260 | + $variables[ 'settings' ] = $metaBundle->metaBundleSettings; |
|
| 261 | 261 | // Template container settings |
| 262 | 262 | $templateContainers = $metaBundle->frontendTemplatesContainer->data; |
| 263 | - $variables['robotsTemplate'] = $templateContainers[FrontendTemplates::ROBOTS_TXT_HANDLE]; |
|
| 264 | - $variables['humansTemplate'] = $templateContainers[FrontendTemplates::HUMANS_TXT_HANDLE]; |
|
| 263 | + $variables[ 'robotsTemplate' ] = $templateContainers[ FrontendTemplates::ROBOTS_TXT_HANDLE ]; |
|
| 264 | + $variables[ 'humansTemplate' ] = $templateContainers[ FrontendTemplates::HUMANS_TXT_HANDLE ]; |
|
| 265 | 265 | // Image selectors |
| 266 | 266 | $bundleSettings = $metaBundle->metaBundleSettings; |
| 267 | - $variables['elementType'] = Asset::class; |
|
| 268 | - $variables['seoImageElements'] = $this->assetElementsFromIds($bundleSettings->seoImageIds, $siteId); |
|
| 269 | - $variables['twitterImageElements'] = $this->assetElementsFromIds($bundleSettings->twitterImageIds, $siteId); |
|
| 270 | - $variables['ogImageElements'] = $this->assetElementsFromIds($bundleSettings->ogImageIds, $siteId); |
|
| 267 | + $variables[ 'elementType' ] = Asset::class; |
|
| 268 | + $variables[ 'seoImageElements' ] = $this->assetElementsFromIds($bundleSettings->seoImageIds, $siteId); |
|
| 269 | + $variables[ 'twitterImageElements' ] = $this->assetElementsFromIds($bundleSettings->twitterImageIds, $siteId); |
|
| 270 | + $variables[ 'ogImageElements' ] = $this->assetElementsFromIds($bundleSettings->ogImageIds, $siteId); |
|
| 271 | 271 | // Preview the meta containers |
| 272 | 272 | Seomatic::$plugin->metaContainers->previewMetaContainers( |
| 273 | 273 | MetaBundles::GLOBAL_META_BUNDLE, |
| 274 | - intval($variables['currentSiteId']) |
|
| 274 | + intval($variables[ 'currentSiteId' ]) |
|
| 275 | 275 | ); |
| 276 | 276 | |
| 277 | 277 | // Render the template |
| 278 | - return $this->renderTemplate('seomatic/settings/global/'.$subSection, $variables); |
|
| 278 | + return $this->renderTemplate('seomatic/settings/global/' . $subSection, $variables); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
@@ -305,11 +305,11 @@ discard block |
||
| 305 | 305 | $metaBundle->metaBundleSettings->setAttributes($bundleSettings); |
| 306 | 306 | } |
| 307 | 307 | $templateContainers = $metaBundle->frontendTemplatesContainer->data; |
| 308 | - $robotsContainer = $templateContainers[FrontendTemplates::ROBOTS_TXT_HANDLE]; |
|
| 308 | + $robotsContainer = $templateContainers[ FrontendTemplates::ROBOTS_TXT_HANDLE ]; |
|
| 309 | 309 | if (!empty($robotsContainer) && is_array($robotsTemplate)) { |
| 310 | 310 | $robotsContainer->setAttributes($robotsTemplate); |
| 311 | 311 | } |
| 312 | - $humansContainer = $templateContainers[FrontendTemplates::HUMANS_TXT_HANDLE]; |
|
| 312 | + $humansContainer = $templateContainers[ FrontendTemplates::HUMANS_TXT_HANDLE ]; |
|
| 313 | 313 | if (!empty($humansContainer) && is_array($humansTemplate)) { |
| 314 | 314 | $humansContainer->setAttributes($humansTemplate); |
| 315 | 315 | } |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | */ |
| 335 | 335 | public function actionContent(string $siteHandle = null): Response |
| 336 | 336 | { |
| 337 | - $variables = []; |
|
| 337 | + $variables = [ ]; |
|
| 338 | 338 | // Get the site to edit |
| 339 | 339 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
| 340 | 340 | |
@@ -346,16 +346,16 @@ discard block |
||
| 346 | 346 | } catch (InvalidConfigException $e) { |
| 347 | 347 | Craft::error($e->getMessage(), __METHOD__); |
| 348 | 348 | } |
| 349 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 349 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 350 | 350 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 351 | 351 | true |
| 352 | 352 | ); |
| 353 | 353 | // Basic variables |
| 354 | - $variables['fullPageForm'] = false; |
|
| 355 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 356 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 357 | - $variables['title'] = $templateTitle; |
|
| 358 | - $variables['crumbs'] = [ |
|
| 354 | + $variables[ 'fullPageForm' ] = false; |
|
| 355 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 356 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 357 | + $variables[ 'title' ] = $templateTitle; |
|
| 358 | + $variables[ 'crumbs' ] = [ |
|
| 359 | 359 | [ |
| 360 | 360 | 'label' => $pluginName, |
| 361 | 361 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -366,9 +366,9 @@ discard block |
||
| 366 | 366 | ], |
| 367 | 367 | ]; |
| 368 | 368 | $this->setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 369 | - $variables['controllerHandle'] = 'content'; |
|
| 370 | - $variables['selectedSubnavItem'] = 'content'; |
|
| 371 | - $variables['metaBundles'] = Seomatic::$plugin->metaBundles->getContentMetaBundlesForSiteId($siteId); |
|
| 369 | + $variables[ 'controllerHandle' ] = 'content'; |
|
| 370 | + $variables[ 'selectedSubnavItem' ] = 'content'; |
|
| 371 | + $variables[ 'metaBundles' ] = Seomatic::$plugin->metaBundles->getContentMetaBundlesForSiteId($siteId); |
|
| 372 | 372 | |
| 373 | 373 | // Render the template |
| 374 | 374 | return $this->renderTemplate('seomatic/settings/content/index', $variables); |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | string $sourceHandle, |
| 393 | 393 | string $siteHandle = null |
| 394 | 394 | ): Response { |
| 395 | - $variables = []; |
|
| 395 | + $variables = [ ]; |
|
| 396 | 396 | // @TODO: Let people choose an entry/categorygroup/product as the preview |
| 397 | 397 | // Get the site to edit |
| 398 | 398 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | } catch (InvalidConfigException $e) { |
| 405 | 405 | Craft::error($e->getMessage(), __METHOD__); |
| 406 | 406 | } |
| 407 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 407 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 408 | 408 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 409 | 409 | true |
| 410 | 410 | ); |
@@ -414,22 +414,22 @@ discard block |
||
| 414 | 414 | $metaBundle = Seomatic::$plugin->metaBundles->getMetaBundleBySourceHandle( |
| 415 | 415 | $sourceBundleType, |
| 416 | 416 | $sourceHandle, |
| 417 | - intval($variables['currentSiteId']) |
|
| 417 | + intval($variables[ 'currentSiteId' ]) |
|
| 418 | 418 | ); |
| 419 | - $variables['globals'] = $metaBundle->metaGlobalVars; |
|
| 420 | - $variables['sitemap'] = $metaBundle->metaSitemapVars; |
|
| 421 | - $variables['settings'] = $metaBundle->metaBundleSettings; |
|
| 422 | - $variables['currentSourceHandle'] = $metaBundle->sourceHandle; |
|
| 423 | - $variables['currentSourceBundleType'] = $metaBundle->sourceBundleType; |
|
| 419 | + $variables[ 'globals' ] = $metaBundle->metaGlobalVars; |
|
| 420 | + $variables[ 'sitemap' ] = $metaBundle->metaSitemapVars; |
|
| 421 | + $variables[ 'settings' ] = $metaBundle->metaBundleSettings; |
|
| 422 | + $variables[ 'currentSourceHandle' ] = $metaBundle->sourceHandle; |
|
| 423 | + $variables[ 'currentSourceBundleType' ] = $metaBundle->sourceBundleType; |
|
| 424 | 424 | // Basic variables |
| 425 | 425 | $templateTitle = $metaBundle->sourceName; |
| 426 | 426 | $subSectionTitle = Craft::t('seomatic', ucfirst($subSection)); |
| 427 | - $variables['fullPageForm'] = true; |
|
| 428 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 429 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 430 | - $variables['title'] = $templateTitle; |
|
| 431 | - $variables['subSectionTitle'] = $subSectionTitle; |
|
| 432 | - $variables['crumbs'] = [ |
|
| 427 | + $variables[ 'fullPageForm' ] = true; |
|
| 428 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 429 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 430 | + $variables[ 'title' ] = $templateTitle; |
|
| 431 | + $variables[ 'subSectionTitle' ] = $subSectionTitle; |
|
| 432 | + $variables[ 'crumbs' ] = [ |
|
| 433 | 433 | [ |
| 434 | 434 | 'label' => $pluginName, |
| 435 | 435 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -439,19 +439,19 @@ discard block |
||
| 439 | 439 | 'url' => UrlHelper::cpUrl('seomatic/content'), |
| 440 | 440 | ], |
| 441 | 441 | [ |
| 442 | - 'label' => $metaBundle->sourceName.' · '.$subSectionTitle, |
|
| 442 | + 'label' => $metaBundle->sourceName . ' · ' . $subSectionTitle, |
|
| 443 | 443 | 'url' => UrlHelper::cpUrl("seomatic/content/${subSection}/${sourceBundleType}/${sourceHandle}"), |
| 444 | 444 | ], |
| 445 | 445 | ]; |
| 446 | - $variables['selectedSubnavItem'] = 'content'; |
|
| 447 | - $variables['controllerHandle'] = "edit-content/${subSection}/${sourceBundleType}/${sourceHandle}"; |
|
| 446 | + $variables[ 'selectedSubnavItem' ] = 'content'; |
|
| 447 | + $variables[ 'controllerHandle' ] = "edit-content/${subSection}/${sourceBundleType}/${sourceHandle}"; |
|
| 448 | 448 | // Image selectors |
| 449 | - $variables['currentSubSection'] = $subSection; |
|
| 449 | + $variables[ 'currentSubSection' ] = $subSection; |
|
| 450 | 450 | $bundleSettings = $metaBundle->metaBundleSettings; |
| 451 | - $variables['elementType'] = Asset::class; |
|
| 452 | - $variables['seoImageElements'] = $this->assetElementsFromIds($bundleSettings->seoImageIds, $siteId); |
|
| 453 | - $variables['twitterImageElements'] = $this->assetElementsFromIds($bundleSettings->twitterImageIds, $siteId); |
|
| 454 | - $variables['ogImageElements'] = $this->assetElementsFromIds($bundleSettings->ogImageIds, $siteId); |
|
| 451 | + $variables[ 'elementType' ] = Asset::class; |
|
| 452 | + $variables[ 'seoImageElements' ] = $this->assetElementsFromIds($bundleSettings->seoImageIds, $siteId); |
|
| 453 | + $variables[ 'twitterImageElements' ] = $this->assetElementsFromIds($bundleSettings->twitterImageIds, $siteId); |
|
| 454 | + $variables[ 'ogImageElements' ] = $this->assetElementsFromIds($bundleSettings->ogImageIds, $siteId); |
|
| 455 | 455 | // Pass in the pull fields |
| 456 | 456 | $groupName = "Entry"; |
| 457 | 457 | $this->setContentFieldSourceVariables($sourceBundleType, $sourceHandle, $groupName, $variables); |
@@ -459,11 +459,11 @@ discard block |
||
| 459 | 459 | // Preview the meta containers |
| 460 | 460 | Seomatic::$plugin->metaContainers->previewMetaContainers( |
| 461 | 461 | $uri, |
| 462 | - intval($variables['currentSiteId']) |
|
| 462 | + intval($variables[ 'currentSiteId' ]) |
|
| 463 | 463 | ); |
| 464 | 464 | |
| 465 | 465 | // Render the template |
| 466 | - return $this->renderTemplate('seomatic/settings/content/'.$subSection, $variables); |
|
| 466 | + return $this->renderTemplate('seomatic/settings/content/' . $subSection, $variables); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | */ |
| 533 | 533 | public function actionSite(string $subSection = 'identity', string $siteHandle = null): Response |
| 534 | 534 | { |
| 535 | - $variables = []; |
|
| 535 | + $variables = [ ]; |
|
| 536 | 536 | // Get the site to edit |
| 537 | 537 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
| 538 | 538 | |
@@ -542,24 +542,24 @@ discard block |
||
| 542 | 542 | if ($subSection == "social") { |
| 543 | 543 | $subSectionSuffix = " Media"; |
| 544 | 544 | } |
| 545 | - $subSectionTitle = Craft::t('seomatic', ucfirst($subSection).$subSectionSuffix); |
|
| 545 | + $subSectionTitle = Craft::t('seomatic', ucfirst($subSection) . $subSectionSuffix); |
|
| 546 | 546 | // Asset bundle |
| 547 | 547 | try { |
| 548 | 548 | Seomatic::$view->registerAssetBundle(SeomaticAsset::class); |
| 549 | 549 | } catch (InvalidConfigException $e) { |
| 550 | 550 | Craft::error($e->getMessage(), __METHOD__); |
| 551 | 551 | } |
| 552 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 552 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 553 | 553 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 554 | 554 | true |
| 555 | 555 | ); |
| 556 | 556 | // Basic variables |
| 557 | - $variables['fullPageForm'] = true; |
|
| 558 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 559 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 560 | - $variables['title'] = $templateTitle; |
|
| 561 | - $variables['subSectionTitle'] = $subSectionTitle; |
|
| 562 | - $variables['crumbs'] = [ |
|
| 557 | + $variables[ 'fullPageForm' ] = true; |
|
| 558 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 559 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 560 | + $variables[ 'title' ] = $templateTitle; |
|
| 561 | + $variables[ 'subSectionTitle' ] = $subSectionTitle; |
|
| 562 | + $variables[ 'crumbs' ] = [ |
|
| 563 | 563 | [ |
| 564 | 564 | 'label' => $pluginName, |
| 565 | 565 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -570,24 +570,24 @@ discard block |
||
| 570 | 570 | ], |
| 571 | 571 | [ |
| 572 | 572 | 'label' => $subSectionTitle, |
| 573 | - 'url' => UrlHelper::cpUrl('seomatic/site/'.$subSection), |
|
| 573 | + 'url' => UrlHelper::cpUrl('seomatic/site/' . $subSection), |
|
| 574 | 574 | ], |
| 575 | 575 | ]; |
| 576 | - $variables['selectedSubnavItem'] = 'site'; |
|
| 577 | - $variables['currentSubSection'] = $subSection; |
|
| 576 | + $variables[ 'selectedSubnavItem' ] = 'site'; |
|
| 577 | + $variables[ 'currentSubSection' ] = $subSection; |
|
| 578 | 578 | |
| 579 | 579 | // Enabled sites |
| 580 | 580 | $this->setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 581 | - $variables['controllerHandle'] = 'site'.'/'.$subSection; |
|
| 581 | + $variables[ 'controllerHandle' ] = 'site' . '/' . $subSection; |
|
| 582 | 582 | |
| 583 | 583 | // The site settings for the appropriate meta bundle |
| 584 | - $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables['currentSiteId'])); |
|
| 585 | - $variables['site'] = $metaBundle->metaSiteVars; |
|
| 586 | - $variables['genericImageElements'] = $this->assetElementsFromIds($variables['site']->identity->genericImageIds, $siteId); |
|
| 587 | - $variables['elementType'] = Asset::class; |
|
| 584 | + $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables[ 'currentSiteId' ])); |
|
| 585 | + $variables[ 'site' ] = $metaBundle->metaSiteVars; |
|
| 586 | + $variables[ 'genericImageElements' ] = $this->assetElementsFromIds($variables[ 'site' ]->identity->genericImageIds, $siteId); |
|
| 587 | + $variables[ 'elementType' ] = Asset::class; |
|
| 588 | 588 | |
| 589 | 589 | // Render the template |
| 590 | - return $this->renderTemplate('seomatic/settings/site/'.$subSection, $variables); |
|
| 590 | + return $this->renderTemplate('seomatic/settings/site/' . $subSection, $variables); |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | /** |
@@ -602,26 +602,26 @@ discard block |
||
| 602 | 602 | $siteSettings = $request->getParam('site'); |
| 603 | 603 | |
| 604 | 604 | // Make sure the twitter handle isn't prefixed with an @ |
| 605 | - if (!empty($siteSettings['twitterHandle'])) { |
|
| 606 | - $siteSettings['twitterHandle'] = ltrim($siteSettings['twitterHandle'], '@'); |
|
| 605 | + if (!empty($siteSettings[ 'twitterHandle' ])) { |
|
| 606 | + $siteSettings[ 'twitterHandle' ] = ltrim($siteSettings[ 'twitterHandle' ], '@'); |
|
| 607 | 607 | } |
| 608 | 608 | // Make sure the sameAsLinks are indexed by the handle |
| 609 | - if (!empty($siteSettings['sameAsLinks'])) { |
|
| 610 | - $siteSettings['sameAsLinks'] = ArrayHelper::index($siteSettings['sameAsLinks'], 'handle'); |
|
| 609 | + if (!empty($siteSettings[ 'sameAsLinks' ])) { |
|
| 610 | + $siteSettings[ 'sameAsLinks' ] = ArrayHelper::index($siteSettings[ 'sameAsLinks' ], 'handle'); |
|
| 611 | 611 | } |
| 612 | 612 | // The site settings for the appropriate meta bundle |
| 613 | 613 | $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle($siteId); |
| 614 | 614 | if ($metaBundle) { |
| 615 | 615 | if (is_array($siteSettings)) { |
| 616 | - if (!empty($siteSettings['identity'])) { |
|
| 617 | - $this->normalizeTimes($siteSettings['identity']['localBusinessOpeningHours']); |
|
| 618 | - $metaBundle->metaSiteVars->identity->setAttributes($siteSettings['identity']); |
|
| 619 | - $siteSettings['identity'] = $metaBundle->metaSiteVars->identity; |
|
| 616 | + if (!empty($siteSettings[ 'identity' ])) { |
|
| 617 | + $this->normalizeTimes($siteSettings[ 'identity' ][ 'localBusinessOpeningHours' ]); |
|
| 618 | + $metaBundle->metaSiteVars->identity->setAttributes($siteSettings[ 'identity' ]); |
|
| 619 | + $siteSettings[ 'identity' ] = $metaBundle->metaSiteVars->identity; |
|
| 620 | 620 | } |
| 621 | - if (!empty($siteSettings['creator'])) { |
|
| 622 | - $this->normalizeTimes($siteSettings['creator']['localBusinessOpeningHours']); |
|
| 623 | - $metaBundle->metaSiteVars->creator->setAttributes($siteSettings['creator']); |
|
| 624 | - $siteSettings['creator'] = $metaBundle->metaSiteVars->creator; |
|
| 621 | + if (!empty($siteSettings[ 'creator' ])) { |
|
| 622 | + $this->normalizeTimes($siteSettings[ 'creator' ][ 'localBusinessOpeningHours' ]); |
|
| 623 | + $metaBundle->metaSiteVars->creator->setAttributes($siteSettings[ 'creator' ]); |
|
| 624 | + $siteSettings[ 'creator' ] = $metaBundle->metaSiteVars->creator; |
|
| 625 | 625 | } |
| 626 | 626 | $metaBundle->metaSiteVars->setAttributes($siteSettings); |
| 627 | 627 | } |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | */ |
| 642 | 642 | public function actionPlugin(): Response |
| 643 | 643 | { |
| 644 | - $variables = []; |
|
| 644 | + $variables = [ ]; |
|
| 645 | 645 | $pluginName = Seomatic::$settings->pluginName; |
| 646 | 646 | $templateTitle = Craft::t('seomatic', 'Plugin Settings'); |
| 647 | 647 | // Asset bundle |
@@ -650,16 +650,16 @@ discard block |
||
| 650 | 650 | } catch (InvalidConfigException $e) { |
| 651 | 651 | Craft::error($e->getMessage(), __METHOD__); |
| 652 | 652 | } |
| 653 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 653 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 654 | 654 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 655 | 655 | true |
| 656 | 656 | ); |
| 657 | 657 | // Basic variables |
| 658 | - $variables['fullPageForm'] = true; |
|
| 659 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 660 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 661 | - $variables['title'] = $templateTitle; |
|
| 662 | - $variables['crumbs'] = [ |
|
| 658 | + $variables[ 'fullPageForm' ] = true; |
|
| 659 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 660 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 661 | + $variables[ 'title' ] = $templateTitle; |
|
| 662 | + $variables[ 'crumbs' ] = [ |
|
| 663 | 663 | [ |
| 664 | 664 | 'label' => $pluginName, |
| 665 | 665 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -669,8 +669,8 @@ discard block |
||
| 669 | 669 | 'url' => UrlHelper::cpUrl('seomatic/settings'), |
| 670 | 670 | ], |
| 671 | 671 | ]; |
| 672 | - $variables['selectedSubnavItem'] = 'plugin'; |
|
| 673 | - $variables['settings'] = Seomatic::$settings; |
|
| 672 | + $variables[ 'selectedSubnavItem' ] = 'plugin'; |
|
| 673 | + $variables[ 'settings' ] = Seomatic::$settings; |
|
| 674 | 674 | |
| 675 | 675 | // Render the template |
| 676 | 676 | return $this->renderTemplate('seomatic/settings/plugin/_edit', $variables); |
@@ -689,24 +689,24 @@ discard block |
||
| 689 | 689 | */ |
| 690 | 690 | public function actionTracking(string $subSection = 'googleAnalytics', string $siteHandle = null): Response |
| 691 | 691 | { |
| 692 | - $variables = []; |
|
| 692 | + $variables = [ ]; |
|
| 693 | 693 | // Get the site to edit |
| 694 | 694 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
| 695 | 695 | // Enabled sites |
| 696 | 696 | $this->setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 697 | - $variables['controllerHandle'] = 'tracking'; |
|
| 698 | - $variables['currentSubSection'] = $subSection; |
|
| 697 | + $variables[ 'controllerHandle' ] = 'tracking'; |
|
| 698 | + $variables[ 'currentSubSection' ] = $subSection; |
|
| 699 | 699 | |
| 700 | 700 | // The script meta containers for the global meta bundle |
| 701 | - $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables['currentSiteId'])); |
|
| 702 | - $variables['scripts'] = Seomatic::$plugin->metaBundles->getContainerDataFromBundle( |
|
| 701 | + $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables[ 'currentSiteId' ])); |
|
| 702 | + $variables[ 'scripts' ] = Seomatic::$plugin->metaBundles->getContainerDataFromBundle( |
|
| 703 | 703 | $metaBundle, |
| 704 | 704 | MetaScriptContainer::CONTAINER_TYPE |
| 705 | 705 | ); |
| 706 | 706 | // Plugin and section settings |
| 707 | 707 | $pluginName = Seomatic::$settings->pluginName; |
| 708 | 708 | $templateTitle = Craft::t('seomatic', 'Tracking Scripts'); |
| 709 | - $subSectionTitle = $variables['scripts'][$subSection]->name; |
|
| 709 | + $subSectionTitle = $variables[ 'scripts' ][ $subSection ]->name; |
|
| 710 | 710 | $subSectionTitle = Craft::t('seomatic', $subSectionTitle); |
| 711 | 711 | // Asset bundle |
| 712 | 712 | try { |
@@ -714,17 +714,17 @@ discard block |
||
| 714 | 714 | } catch (InvalidConfigException $e) { |
| 715 | 715 | Craft::error($e->getMessage(), __METHOD__); |
| 716 | 716 | } |
| 717 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 717 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 718 | 718 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 719 | 719 | true |
| 720 | 720 | ); |
| 721 | 721 | // Basic variables |
| 722 | - $variables['fullPageForm'] = true; |
|
| 723 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 724 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 725 | - $variables['title'] = $templateTitle; |
|
| 726 | - $variables['subSectionTitle'] = $subSectionTitle; |
|
| 727 | - $variables['crumbs'] = [ |
|
| 722 | + $variables[ 'fullPageForm' ] = true; |
|
| 723 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 724 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 725 | + $variables[ 'title' ] = $templateTitle; |
|
| 726 | + $variables[ 'subSectionTitle' ] = $subSectionTitle; |
|
| 727 | + $variables[ 'crumbs' ] = [ |
|
| 728 | 728 | [ |
| 729 | 729 | 'label' => $pluginName, |
| 730 | 730 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -735,10 +735,10 @@ discard block |
||
| 735 | 735 | ], |
| 736 | 736 | [ |
| 737 | 737 | 'label' => $subSectionTitle, |
| 738 | - 'url' => UrlHelper::cpUrl('seomatic/tracking/'.$subSection), |
|
| 738 | + 'url' => UrlHelper::cpUrl('seomatic/tracking/' . $subSection), |
|
| 739 | 739 | ], |
| 740 | 740 | ]; |
| 741 | - $variables['selectedSubnavItem'] = 'tracking'; |
|
| 741 | + $variables[ 'selectedSubnavItem' ] = 'tracking'; |
|
| 742 | 742 | |
| 743 | 743 | // Render the template |
| 744 | 744 | return $this->renderTemplate('seomatic/settings/tracking/_edit', $variables); |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | foreach ($scriptData as $key => $value) { |
| 767 | 767 | if (is_array($value)) { |
| 768 | 768 | foreach ($value as $varsKey => $varsValue) { |
| 769 | - $data->$key[$varsKey]['value'] = $varsValue; |
|
| 769 | + $data->$key[ $varsKey ][ 'value' ] = $varsValue; |
|
| 770 | 770 | } |
| 771 | 771 | } else { |
| 772 | 772 | $data->$key = $value; |
@@ -796,17 +796,17 @@ discard block |
||
| 796 | 796 | if (is_string($value)) { |
| 797 | 797 | $value = Json::decode($value); |
| 798 | 798 | } |
| 799 | - $normalized = []; |
|
| 800 | - $times = ['open', 'close']; |
|
| 799 | + $normalized = [ ]; |
|
| 800 | + $times = [ 'open', 'close' ]; |
|
| 801 | 801 | for ($day = 0; $day <= 6; $day++) { |
| 802 | 802 | foreach ($times as $time) { |
| 803 | 803 | if ( |
| 804 | - isset($value[$day][$time]) && |
|
| 805 | - ($date = DateTimeHelper::toDateTime($value[$day][$time])) !== false |
|
| 804 | + isset($value[ $day ][ $time ]) && |
|
| 805 | + ($date = DateTimeHelper::toDateTime($value[ $day ][ $time ])) !== false |
|
| 806 | 806 | ) { |
| 807 | - $normalized[$day][$time] = $date; |
|
| 807 | + $normalized[ $day ][ $time ] = $date; |
|
| 808 | 808 | } else { |
| 809 | - $normalized[$day][$time] = null; |
|
| 809 | + $normalized[ $day ][ $time ] = null; |
|
| 810 | 810 | } |
| 811 | 811 | } |
| 812 | 812 | } |
@@ -829,47 +829,47 @@ discard block |
||
| 829 | 829 | $objectPrefix = 'object.'; |
| 830 | 830 | } |
| 831 | 831 | foreach (self::PULL_TEXT_FIELDS as $fields) { |
| 832 | - $fieldName = $fields['fieldName']; |
|
| 833 | - $source = $bundleSettings[$fieldName.'Source'] ?? ''; |
|
| 834 | - $sourceField = $bundleSettings[$fieldName.'Field'] ?? ''; |
|
| 832 | + $fieldName = $fields[ 'fieldName' ]; |
|
| 833 | + $source = $bundleSettings[ $fieldName . 'Source' ] ?? ''; |
|
| 834 | + $sourceField = $bundleSettings[ $fieldName . 'Field' ] ?? ''; |
|
| 835 | 835 | if (!empty($source)) { |
| 836 | - $seoField = $fields['seoField']; |
|
| 836 | + $seoField = $fields[ 'seoField' ]; |
|
| 837 | 837 | switch ($source) { |
| 838 | 838 | case 'sameAsSeo': |
| 839 | - $globalsSettings[$fieldName] = |
|
| 840 | - '{seomatic.meta.'.$seoField.'}'; |
|
| 839 | + $globalsSettings[ $fieldName ] = |
|
| 840 | + '{seomatic.meta.' . $seoField . '}'; |
|
| 841 | 841 | break; |
| 842 | 842 | |
| 843 | 843 | case 'sameAsSiteTwitter': |
| 844 | - $globalsSettings[$fieldName] = |
|
| 845 | - '{seomatic.site.'.$seoField.'}'; |
|
| 844 | + $globalsSettings[ $fieldName ] = |
|
| 845 | + '{seomatic.site.' . $seoField . '}'; |
|
| 846 | 846 | break; |
| 847 | 847 | |
| 848 | 848 | case 'fromField': |
| 849 | - $globalsSettings[$fieldName] = |
|
| 849 | + $globalsSettings[ $fieldName ] = |
|
| 850 | 850 | '{seomatic.helper.extractTextFromField(' |
| 851 | - .$objectPrefix.$elementName.$sourceField |
|
| 851 | + .$objectPrefix . $elementName . $sourceField |
|
| 852 | 852 | .')}'; |
| 853 | 853 | break; |
| 854 | 854 | |
| 855 | 855 | case 'fromUserField': |
| 856 | - $globalsSettings[$fieldName] = |
|
| 856 | + $globalsSettings[ $fieldName ] = |
|
| 857 | 857 | '{seomatic.helper.extractTextFromField(' |
| 858 | - .$objectPrefix.$elementName.'author.'.$sourceField |
|
| 858 | + .$objectPrefix . $elementName . 'author.' . $sourceField |
|
| 859 | 859 | .')}'; |
| 860 | 860 | break; |
| 861 | 861 | |
| 862 | 862 | case 'summaryFromField': |
| 863 | - $globalsSettings[$fieldName] = |
|
| 863 | + $globalsSettings[ $fieldName ] = |
|
| 864 | 864 | '{seomatic.helper.extractSummary(seomatic.helper.extractTextFromField(' |
| 865 | - .$objectPrefix.$elementName.$sourceField |
|
| 865 | + .$objectPrefix . $elementName . $sourceField |
|
| 866 | 866 | .'))}'; |
| 867 | 867 | break; |
| 868 | 868 | |
| 869 | 869 | case 'keywordsFromField': |
| 870 | - $globalsSettings[$fieldName] = |
|
| 870 | + $globalsSettings[ $fieldName ] = |
|
| 871 | 871 | '{seomatic.helper.extractKeywords(seomatic.helper.extractTextFromField(' |
| 872 | - .$objectPrefix.$elementName.$sourceField |
|
| 872 | + .$objectPrefix . $elementName . $sourceField |
|
| 873 | 873 | .'))}'; |
| 874 | 874 | break; |
| 875 | 875 | |
@@ -896,85 +896,85 @@ discard block |
||
| 896 | 896 | $objectPrefix = 'object.'; |
| 897 | 897 | } |
| 898 | 898 | foreach (self::PULL_ASSET_FIELDS as $fields) { |
| 899 | - $fieldName = $fields['fieldName']; |
|
| 900 | - $source = $bundleSettings[$fieldName.'Source'] ?? ''; |
|
| 901 | - $ids = $bundleSettings[$fieldName.'Ids'] ?? []; |
|
| 902 | - $sourceField = $bundleSettings[$fieldName.'Field'] ?? ''; |
|
| 899 | + $fieldName = $fields[ 'fieldName' ]; |
|
| 900 | + $source = $bundleSettings[ $fieldName . 'Source' ] ?? ''; |
|
| 901 | + $ids = $bundleSettings[ $fieldName . 'Ids' ] ?? [ ]; |
|
| 902 | + $sourceField = $bundleSettings[ $fieldName . 'Field' ] ?? ''; |
|
| 903 | 903 | if (!empty($source)) { |
| 904 | - $transformImage = $bundleSettings[$fieldName.'Transform']; |
|
| 905 | - $seoField = $fields['seoField']; |
|
| 906 | - $transformName = $fields['transformName']; |
|
| 904 | + $transformImage = $bundleSettings[ $fieldName . 'Transform' ]; |
|
| 905 | + $seoField = $fields[ 'seoField' ]; |
|
| 906 | + $transformName = $fields[ 'transformName' ]; |
|
| 907 | 907 | // Special-case Twitter transforms |
| 908 | 908 | if ($transformName == 'twitter') { |
| 909 | 909 | $transformName = 'twitter-summary'; |
| 910 | - if ($globalsSettings['twitterCard'] == 'summary_large_image') { |
|
| 910 | + if ($globalsSettings[ 'twitterCard' ] == 'summary_large_image') { |
|
| 911 | 911 | $transformName = 'twitter-large'; |
| 912 | 912 | } |
| 913 | 913 | } |
| 914 | 914 | if ($transformImage) { |
| 915 | 915 | switch ($source) { |
| 916 | 916 | case 'sameAsSeo': |
| 917 | - $seoSource = $bundleSettings[$seoField.'Source'] ?? ''; |
|
| 918 | - $seoIds = $bundleSettings[$seoField.'Ids'] ?? []; |
|
| 919 | - $seoSourceField = $bundleSettings[$seoField.'Field'] ?? ''; |
|
| 917 | + $seoSource = $bundleSettings[ $seoField . 'Source' ] ?? ''; |
|
| 918 | + $seoIds = $bundleSettings[ $seoField . 'Ids' ] ?? [ ]; |
|
| 919 | + $seoSourceField = $bundleSettings[ $seoField . 'Field' ] ?? ''; |
|
| 920 | 920 | if (!empty($seoSource)) { |
| 921 | 921 | switch ($seoSource) { |
| 922 | 922 | case 'fromField': |
| 923 | 923 | if (!empty($seoSourceField)) { |
| 924 | - $globalsSettings[$fieldName] = '{seomatic.helper.socialTransform(' |
|
| 925 | - .$objectPrefix.$elementName.$seoSourceField.'.one()' |
|
| 926 | - .', "'.$transformName.'"' |
|
| 927 | - .', '.$siteId.')}'; |
|
| 924 | + $globalsSettings[ $fieldName ] = '{seomatic.helper.socialTransform(' |
|
| 925 | + .$objectPrefix . $elementName . $seoSourceField . '.one()' |
|
| 926 | + .', "' . $transformName . '"' |
|
| 927 | + .', ' . $siteId . ')}'; |
|
| 928 | 928 | } |
| 929 | 929 | break; |
| 930 | 930 | case 'fromAsset': |
| 931 | 931 | if (!empty($seoIds)) { |
| 932 | - $globalsSettings[$fieldName] = '{seomatic.helper.socialTransform(' |
|
| 933 | - .$seoIds[0] |
|
| 934 | - .', "'.$transformName.'"' |
|
| 935 | - .', '.$siteId.')}'; |
|
| 932 | + $globalsSettings[ $fieldName ] = '{seomatic.helper.socialTransform(' |
|
| 933 | + .$seoIds[ 0 ] |
|
| 934 | + .', "' . $transformName . '"' |
|
| 935 | + .', ' . $siteId . ')}'; |
|
| 936 | 936 | } |
| 937 | 937 | break; |
| 938 | 938 | default: |
| 939 | - $globalsSettings[$fieldName] = '{seomatic.meta.'.$seoField.'}'; |
|
| 939 | + $globalsSettings[ $fieldName ] = '{seomatic.meta.' . $seoField . '}'; |
|
| 940 | 940 | break; |
| 941 | 941 | } |
| 942 | 942 | } |
| 943 | 943 | break; |
| 944 | 944 | case 'fromField': |
| 945 | 945 | if (!empty($sourceField)) { |
| 946 | - $globalsSettings[$fieldName] = '{seomatic.helper.socialTransform(' |
|
| 947 | - .$objectPrefix.$elementName.$sourceField.'.one()' |
|
| 948 | - .', "'.$transformName.'"' |
|
| 949 | - .', '.$siteId.')}'; |
|
| 946 | + $globalsSettings[ $fieldName ] = '{seomatic.helper.socialTransform(' |
|
| 947 | + .$objectPrefix . $elementName . $sourceField . '.one()' |
|
| 948 | + .', "' . $transformName . '"' |
|
| 949 | + .', ' . $siteId . ')}'; |
|
| 950 | 950 | } |
| 951 | 951 | break; |
| 952 | 952 | case 'fromAsset': |
| 953 | 953 | if (!empty($ids)) { |
| 954 | - $globalsSettings[$fieldName] = '{seomatic.helper.socialTransform(' |
|
| 955 | - .$ids[0] |
|
| 956 | - .', "'.$transformName.'"' |
|
| 957 | - .', '.$siteId.')}'; |
|
| 954 | + $globalsSettings[ $fieldName ] = '{seomatic.helper.socialTransform(' |
|
| 955 | + .$ids[ 0 ] |
|
| 956 | + .', "' . $transformName . '"' |
|
| 957 | + .', ' . $siteId . ')}'; |
|
| 958 | 958 | } |
| 959 | 959 | break; |
| 960 | 960 | } |
| 961 | 961 | } else { |
| 962 | 962 | switch ($source) { |
| 963 | 963 | case 'sameAsSeo': |
| 964 | - $globalsSettings[$fieldName] = '{seomatic.meta.'.$seoField.'}'; |
|
| 964 | + $globalsSettings[ $fieldName ] = '{seomatic.meta.' . $seoField . '}'; |
|
| 965 | 965 | break; |
| 966 | 966 | case 'fromField': |
| 967 | 967 | if (!empty($sourceField)) { |
| 968 | - $globalsSettings[$fieldName] = '{' |
|
| 969 | - .$elementName.$sourceField.'.one().url' |
|
| 968 | + $globalsSettings[ $fieldName ] = '{' |
|
| 969 | + .$elementName . $sourceField . '.one().url' |
|
| 970 | 970 | .'}'; |
| 971 | 971 | } |
| 972 | 972 | break; |
| 973 | 973 | case 'fromAsset': |
| 974 | 974 | if (!empty($ids)) { |
| 975 | - $globalsSettings[$fieldName] = '{{ craft.app.assets.assetById(' |
|
| 976 | - .$ids[0] |
|
| 977 | - .', '.$siteId.').url }}'; |
|
| 975 | + $globalsSettings[ $fieldName ] = '{{ craft.app.assets.assetById(' |
|
| 976 | + .$ids[ 0 ] |
|
| 977 | + .', ' . $siteId . ').url }}'; |
|
| 978 | 978 | } |
| 979 | 979 | break; |
| 980 | 980 | } |
@@ -988,15 +988,15 @@ discard block |
||
| 988 | 988 | */ |
| 989 | 989 | protected function setGlobalFieldSourceVariables(array &$variables) |
| 990 | 990 | { |
| 991 | - $variables['textFieldSources'] = array_merge( |
|
| 992 | - ['globalsGroup' => ['optgroup' => 'Globals Fields']], |
|
| 991 | + $variables[ 'textFieldSources' ] = array_merge( |
|
| 992 | + [ 'globalsGroup' => [ 'optgroup' => 'Globals Fields' ] ], |
|
| 993 | 993 | FieldHelper::fieldsOfTypeFromGlobals( |
| 994 | 994 | FieldHelper::TEXT_FIELD_CLASS_KEY, |
| 995 | 995 | false |
| 996 | 996 | ) |
| 997 | 997 | ); |
| 998 | - $variables['assetFieldSources'] = array_merge( |
|
| 999 | - ['globalsGroup' => ['optgroup' => 'Globals Fields']], |
|
| 998 | + $variables[ 'assetFieldSources' ] = array_merge( |
|
| 999 | + [ 'globalsGroup' => [ 'optgroup' => 'Globals Fields' ] ], |
|
| 1000 | 1000 | FieldHelper::fieldsOfTypeFromGlobals( |
| 1001 | 1001 | FieldHelper::ASSET_FIELD_CLASS_KEY, |
| 1002 | 1002 | false |
@@ -1016,8 +1016,8 @@ discard block |
||
| 1016 | 1016 | string $groupName, |
| 1017 | 1017 | array &$variables |
| 1018 | 1018 | ) { |
| 1019 | - $variables['textFieldSources'] = array_merge( |
|
| 1020 | - ['entryGroup' => ['optgroup' => $groupName.' Fields'], 'title' => 'Title'], |
|
| 1019 | + $variables[ 'textFieldSources' ] = array_merge( |
|
| 1020 | + [ 'entryGroup' => [ 'optgroup' => $groupName . ' Fields' ], 'title' => 'Title' ], |
|
| 1021 | 1021 | FieldHelper::fieldsOfTypeFromSource( |
| 1022 | 1022 | $sourceBundleType, |
| 1023 | 1023 | $sourceHandle, |
@@ -1025,8 +1025,8 @@ discard block |
||
| 1025 | 1025 | false |
| 1026 | 1026 | ) |
| 1027 | 1027 | ); |
| 1028 | - $variables['assetFieldSources'] = array_merge( |
|
| 1029 | - ['entryGroup' => ['optgroup' => $groupName.' Fields']], |
|
| 1028 | + $variables[ 'assetFieldSources' ] = array_merge( |
|
| 1029 | + [ 'entryGroup' => [ 'optgroup' => $groupName . ' Fields' ] ], |
|
| 1030 | 1030 | FieldHelper::fieldsOfTypeFromSource( |
| 1031 | 1031 | $sourceBundleType, |
| 1032 | 1032 | $sourceHandle, |
@@ -1034,15 +1034,15 @@ discard block |
||
| 1034 | 1034 | false |
| 1035 | 1035 | ) |
| 1036 | 1036 | ); |
| 1037 | - $variables['assetVolumeTextFieldSources'] = array_merge( |
|
| 1038 | - ['entryGroup' => ['optgroup' => 'Asset Volume Fields'], 'title' => 'Title'], |
|
| 1037 | + $variables[ 'assetVolumeTextFieldSources' ] = array_merge( |
|
| 1038 | + [ 'entryGroup' => [ 'optgroup' => 'Asset Volume Fields' ], 'title' => 'Title' ], |
|
| 1039 | 1039 | FieldHelper::fieldsOfTypeFromAssetVolumes( |
| 1040 | 1040 | FieldHelper::TEXT_FIELD_CLASS_KEY, |
| 1041 | 1041 | false |
| 1042 | 1042 | ) |
| 1043 | 1043 | ); |
| 1044 | - $variables['userFieldSources'] = array_merge( |
|
| 1045 | - ['entryGroup' => ['optgroup' => 'User Fields']], |
|
| 1044 | + $variables[ 'userFieldSources' ] = array_merge( |
|
| 1045 | + [ 'entryGroup' => [ 'optgroup' => 'User Fields' ] ], |
|
| 1046 | 1046 | FieldHelper::fieldsOfTypeFromUsers( |
| 1047 | 1047 | FieldHelper::TEXT_FIELD_CLASS_KEY, |
| 1048 | 1048 | false |
@@ -1100,43 +1100,43 @@ discard block |
||
| 1100 | 1100 | $sites = Craft::$app->getSites(); |
| 1101 | 1101 | if (Craft::$app->getIsMultiSite()) { |
| 1102 | 1102 | // Set defaults based on the section settings |
| 1103 | - $variables['enabledSiteIds'] = []; |
|
| 1104 | - $variables['siteIds'] = []; |
|
| 1103 | + $variables[ 'enabledSiteIds' ] = [ ]; |
|
| 1104 | + $variables[ 'siteIds' ] = [ ]; |
|
| 1105 | 1105 | |
| 1106 | 1106 | /** @var Site $site */ |
| 1107 | 1107 | foreach ($sites->getEditableSiteIds() as $editableSiteId) { |
| 1108 | - $variables['enabledSiteIds'][] = $editableSiteId; |
|
| 1109 | - $variables['siteIds'][] = $editableSiteId; |
|
| 1108 | + $variables[ 'enabledSiteIds' ][ ] = $editableSiteId; |
|
| 1109 | + $variables[ 'siteIds' ][ ] = $editableSiteId; |
|
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | 1112 | // Make sure the $siteId they are trying to edit is in our array of editable sites |
| 1113 | - if (!in_array($siteId, $variables['enabledSiteIds'])) { |
|
| 1114 | - if (!empty($variables['enabledSiteIds'])) { |
|
| 1115 | - $siteId = reset($variables['enabledSiteIds']); |
|
| 1113 | + if (!in_array($siteId, $variables[ 'enabledSiteIds' ])) { |
|
| 1114 | + if (!empty($variables[ 'enabledSiteIds' ])) { |
|
| 1115 | + $siteId = reset($variables[ 'enabledSiteIds' ]); |
|
| 1116 | 1116 | } else { |
| 1117 | - $this->requirePermission('editSite:'.$siteId); |
|
| 1117 | + $this->requirePermission('editSite:' . $siteId); |
|
| 1118 | 1118 | } |
| 1119 | 1119 | } |
| 1120 | 1120 | } |
| 1121 | 1121 | // Set the currentSiteId and currentSiteHandle |
| 1122 | - $variables['currentSiteId'] = empty($siteId) ? Craft::$app->getSites()->currentSite->id : $siteId; |
|
| 1123 | - $variables['currentSiteHandle'] = empty($siteHandle) |
|
| 1122 | + $variables[ 'currentSiteId' ] = empty($siteId) ? Craft::$app->getSites()->currentSite->id : $siteId; |
|
| 1123 | + $variables[ 'currentSiteHandle' ] = empty($siteHandle) |
|
| 1124 | 1124 | ? Craft::$app->getSites()->currentSite->handle |
| 1125 | 1125 | : $siteHandle; |
| 1126 | 1126 | |
| 1127 | 1127 | // Page title |
| 1128 | - $variables['showSites'] = ( |
|
| 1128 | + $variables[ 'showSites' ] = ( |
|
| 1129 | 1129 | Craft::$app->getIsMultiSite() && |
| 1130 | - count($variables['enabledSiteIds']) |
|
| 1130 | + count($variables[ 'enabledSiteIds' ]) |
|
| 1131 | 1131 | ); |
| 1132 | 1132 | |
| 1133 | - if ($variables['showSites']) { |
|
| 1134 | - $variables['sitesMenuLabel'] = Craft::t( |
|
| 1133 | + if ($variables[ 'showSites' ]) { |
|
| 1134 | + $variables[ 'sitesMenuLabel' ] = Craft::t( |
|
| 1135 | 1135 | 'site', |
| 1136 | - $sites->getSiteById(intval($variables['currentSiteId']))->name |
|
| 1136 | + $sites->getSiteById(intval($variables[ 'currentSiteId' ]))->name |
|
| 1137 | 1137 | ); |
| 1138 | 1138 | } else { |
| 1139 | - $variables['sitesMenuLabel'] = ''; |
|
| 1139 | + $variables[ 'sitesMenuLabel' ] = ''; |
|
| 1140 | 1140 | } |
| 1141 | 1141 | } |
| 1142 | 1142 | |
@@ -1151,10 +1151,10 @@ discard block |
||
| 1151 | 1151 | protected function assetElementsFromIds($assetIds, int $siteId) |
| 1152 | 1152 | { |
| 1153 | 1153 | $elements = Craft::$app->getElements(); |
| 1154 | - $assets = []; |
|
| 1154 | + $assets = [ ]; |
|
| 1155 | 1155 | if (!empty($assetIds)) { |
| 1156 | 1156 | foreach ($assetIds as $assetId) { |
| 1157 | - $assets[] = $elements->getElementById($assetId, Asset::class, $siteId); |
|
| 1157 | + $assets[ ] = $elements->getElementById($assetId, Asset::class, $siteId); |
|
| 1158 | 1158 | } |
| 1159 | 1159 | } |
| 1160 | 1160 | |
@@ -1175,7 +1175,7 @@ discard block |
||
| 1175 | 1175 | if ($siteHandle !== null) { |
| 1176 | 1176 | $site = Craft::$app->getSites()->getSiteByHandle($siteHandle); |
| 1177 | 1177 | if (!$site) { |
| 1178 | - throw new NotFoundHttpException('Invalid site handle: '.$siteHandle); |
|
| 1178 | + throw new NotFoundHttpException('Invalid site handle: ' . $siteHandle); |
|
| 1179 | 1179 | } |
| 1180 | 1180 | $siteId = $site->id; |
| 1181 | 1181 | } else { |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | Craft::t( |
| 185 | 185 | 'seomatic', |
| 186 | 186 | '{name} plugin loaded', |
| 187 | - ['name' => $this->name] |
|
| 187 | + [ 'name' => $this->name ] |
|
| 188 | 188 | ), |
| 189 | 189 | __METHOD__ |
| 190 | 190 | ); |
@@ -203,43 +203,43 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | public function getCpNavItem() |
| 205 | 205 | { |
| 206 | - $subNavs = []; |
|
| 206 | + $subNavs = [ ]; |
|
| 207 | 207 | $navItem = parent::getCpNavItem(); |
| 208 | 208 | /** @var User $currentUser */ |
| 209 | 209 | $currentUser = Craft::$app->getUser()->getIdentity(); |
| 210 | 210 | // Only show sub-navs the user has permission to view |
| 211 | 211 | if ($currentUser->can('seomatic:dashboard')) { |
| 212 | - $subNavs['dashboard'] = [ |
|
| 212 | + $subNavs[ 'dashboard' ] = [ |
|
| 213 | 213 | 'label' => 'Dashboard', |
| 214 | 214 | 'url' => 'seomatic/dashboard', |
| 215 | 215 | ]; |
| 216 | 216 | } |
| 217 | 217 | if ($currentUser->can('seomatic:global-meta')) { |
| 218 | - $subNavs['global'] = [ |
|
| 218 | + $subNavs[ 'global' ] = [ |
|
| 219 | 219 | 'label' => 'Global SEO', |
| 220 | 220 | 'url' => 'seomatic/global', |
| 221 | 221 | ]; |
| 222 | 222 | } |
| 223 | 223 | if ($currentUser->can('seomatic:content-meta')) { |
| 224 | - $subNavs['content'] = [ |
|
| 224 | + $subNavs[ 'content' ] = [ |
|
| 225 | 225 | 'label' => 'Content SEO', |
| 226 | 226 | 'url' => 'seomatic/content', |
| 227 | 227 | ]; |
| 228 | 228 | } |
| 229 | 229 | if ($currentUser->can('seomatic:site-settings')) { |
| 230 | - $subNavs['site'] = [ |
|
| 230 | + $subNavs[ 'site' ] = [ |
|
| 231 | 231 | 'label' => 'Site Settings', |
| 232 | 232 | 'url' => 'seomatic/site', |
| 233 | 233 | ]; |
| 234 | 234 | } |
| 235 | 235 | if ($currentUser->can('seomatic:tracking-scripts')) { |
| 236 | - $subNavs['tracking'] = [ |
|
| 236 | + $subNavs[ 'tracking' ] = [ |
|
| 237 | 237 | 'label' => 'Tracking Scripts', |
| 238 | 238 | 'url' => 'seomatic/tracking', |
| 239 | 239 | ]; |
| 240 | 240 | } |
| 241 | 241 | if ($currentUser->can('seomatic:plugin-settings')) { |
| 242 | - $subNavs['plugin'] = [ |
|
| 242 | + $subNavs[ 'plugin' ] = [ |
|
| 243 | 243 | 'label' => 'Plugin Settings', |
| 244 | 244 | 'url' => 'seomatic/plugin', |
| 245 | 245 | ]; |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | Event::on( |
| 276 | 276 | Plugins::class, |
| 277 | 277 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
| 278 | - function () { |
|
| 278 | + function() { |
|
| 279 | 279 | // Add in our event listeners that are needed for every request |
| 280 | 280 | $this->installGlobalEventListeners(); |
| 281 | 281 | // Only respond to non-console site requests |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | Event::on( |
| 301 | 301 | Plugins::class, |
| 302 | 302 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 303 | - function (PluginEvent $event) { |
|
| 303 | + function(PluginEvent $event) { |
|
| 304 | 304 | if ($event->plugin === $this) { |
| 305 | 305 | // Invalidate our caches after we've been installed |
| 306 | 306 | $this->clearAllCaches(); |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | Event::on( |
| 322 | 322 | Sections::class, |
| 323 | 323 | Sections::EVENT_AFTER_SAVE_SECTION, |
| 324 | - function (SectionEvent $event) { |
|
| 324 | + function(SectionEvent $event) { |
|
| 325 | 325 | Craft::debug( |
| 326 | 326 | 'Sections::EVENT_AFTER_SAVE_SECTION', |
| 327 | 327 | __METHOD__ |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | Event::on( |
| 345 | 345 | Sections::class, |
| 346 | 346 | Sections::EVENT_AFTER_DELETE_SECTION, |
| 347 | - function (SectionEvent $event) { |
|
| 347 | + function(SectionEvent $event) { |
|
| 348 | 348 | Craft::debug( |
| 349 | 349 | 'Sections::EVENT_AFTER_DELETE_SECTION', |
| 350 | 350 | __METHOD__ |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | Event::on( |
| 368 | 368 | Categories::class, |
| 369 | 369 | Categories::EVENT_AFTER_SAVE_GROUP, |
| 370 | - function (CategoryGroupEvent $event) { |
|
| 370 | + function(CategoryGroupEvent $event) { |
|
| 371 | 371 | Craft::debug( |
| 372 | 372 | 'Categories::EVENT_AFTER_SAVE_GROUP', |
| 373 | 373 | __METHOD__ |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | Event::on( |
| 391 | 391 | Categories::class, |
| 392 | 392 | Categories::EVENT_AFTER_DELETE_GROUP, |
| 393 | - function (CategoryGroupEvent $event) { |
|
| 393 | + function(CategoryGroupEvent $event) { |
|
| 394 | 394 | Craft::debug( |
| 395 | 395 | 'Categories::EVENT_AFTER_DELETE_GROUP', |
| 396 | 396 | __METHOD__ |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | Event::on( |
| 414 | 414 | Elements::class, |
| 415 | 415 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
| 416 | - function (ElementEvent $event) { |
|
| 416 | + function(ElementEvent $event) { |
|
| 417 | 417 | Craft::debug( |
| 418 | 418 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
| 419 | 419 | __METHOD__ |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | Event::on( |
| 434 | 434 | Elements::class, |
| 435 | 435 | Elements::EVENT_AFTER_DELETE_ELEMENT, |
| 436 | - function (ElementEvent $event) { |
|
| 436 | + function(ElementEvent $event) { |
|
| 437 | 437 | Craft::debug( |
| 438 | 438 | 'Elements::EVENT_AFTER_DELETE_ELEMENT', |
| 439 | 439 | __METHOD__ |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | Event::on( |
| 464 | 464 | ErrorHandler::class, |
| 465 | 465 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
| 466 | - function (ExceptionEvent $event) { |
|
| 466 | + function(ExceptionEvent $event) { |
|
| 467 | 467 | Craft::debug( |
| 468 | 468 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
| 469 | 469 | __METHOD__ |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | Event::on( |
| 485 | 485 | View::class, |
| 486 | 486 | View::EVENT_BEGIN_BODY, |
| 487 | - function () { |
|
| 487 | + function() { |
|
| 488 | 488 | Craft::debug( |
| 489 | 489 | 'View::EVENT_BEGIN_BODY', |
| 490 | 490 | __METHOD__ |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | Event::on( |
| 500 | 500 | View::class, |
| 501 | 501 | View::EVENT_END_BODY, |
| 502 | - function () { |
|
| 502 | + function() { |
|
| 503 | 503 | Craft::debug( |
| 504 | 504 | 'View::EVENT_END_BODY', |
| 505 | 505 | __METHOD__ |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | Event::on( |
| 515 | 515 | View::class, |
| 516 | 516 | View::EVENT_END_PAGE, |
| 517 | - function () { |
|
| 517 | + function() { |
|
| 518 | 518 | Craft::debug( |
| 519 | 519 | 'View::EVENT_END_PAGE', |
| 520 | 520 | __METHOD__ |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | Event::on( |
| 539 | 539 | UrlManager::class, |
| 540 | 540 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
| 541 | - function (RegisterUrlRulesEvent $event) { |
|
| 541 | + function(RegisterUrlRulesEvent $event) { |
|
| 542 | 542 | Craft::debug( |
| 543 | 543 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
| 544 | 544 | __METHOD__ |
@@ -554,20 +554,20 @@ discard block |
||
| 554 | 554 | Event::on( |
| 555 | 555 | UserPermissions::class, |
| 556 | 556 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
| 557 | - function (RegisterUserPermissionsEvent $event) { |
|
| 557 | + function(RegisterUserPermissionsEvent $event) { |
|
| 558 | 558 | Craft::debug( |
| 559 | 559 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
| 560 | 560 | __METHOD__ |
| 561 | 561 | ); |
| 562 | 562 | // Register our custom permissions |
| 563 | - $event->permissions[Craft::t('seomatic', 'SEOmatic')] = $this->customAdminCpPermissions(); |
|
| 563 | + $event->permissions[ Craft::t('seomatic', 'SEOmatic') ] = $this->customAdminCpPermissions(); |
|
| 564 | 564 | } |
| 565 | 565 | ); |
| 566 | 566 | // Handler: ClearCaches::EVENT_REGISTER_CACHE_OPTIONS |
| 567 | 567 | Event::on( |
| 568 | 568 | ClearCaches::class, |
| 569 | 569 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
| 570 | - function (RegisterCacheOptionsEvent $event) { |
|
| 570 | + function(RegisterCacheOptionsEvent $event) { |
|
| 571 | 571 | Craft::debug( |
| 572 | 572 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
| 573 | 573 | __METHOD__ |
@@ -580,11 +580,11 @@ discard block |
||
| 580 | 580 | } |
| 581 | 581 | ); |
| 582 | 582 | // Entries sidebar |
| 583 | - self::$view->hook('cp.entries.edit.details', function (&$context) { |
|
| 583 | + self::$view->hook('cp.entries.edit.details', function(&$context) { |
|
| 584 | 584 | $html = ''; |
| 585 | 585 | self::$view->registerAssetBundle(SeomaticAsset::class); |
| 586 | 586 | /** @var $entry Entry */ |
| 587 | - $entry = $context['entry']; |
|
| 587 | + $entry = $context[ 'entry' ]; |
|
| 588 | 588 | if (!empty($entry) && !empty($entry->uri)) { |
| 589 | 589 | Seomatic::$plugin->metaContainers->previewMetaContainers($entry->uri, $entry->siteId, true); |
| 590 | 590 | // Render our preview sidebar template |
@@ -600,11 +600,11 @@ discard block |
||
| 600 | 600 | return $html; |
| 601 | 601 | }); |
| 602 | 602 | // Category Groups sidebar |
| 603 | - self::$view->hook('cp.categories.edit.details', function (&$context) { |
|
| 603 | + self::$view->hook('cp.categories.edit.details', function(&$context) { |
|
| 604 | 604 | $html = ''; |
| 605 | 605 | self::$view->registerAssetBundle(SeomaticAsset::class); |
| 606 | 606 | /** @var $category Category */ |
| 607 | - $category = $context['category']; |
|
| 607 | + $category = $context[ 'category' ]; |
|
| 608 | 608 | if (!empty($category) && !empty($category->uri)) { |
| 609 | 609 | Seomatic::$plugin->metaContainers->previewMetaContainers($category->uri, $category->siteId, true); |
| 610 | 610 | // Render our preview sidebar template |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | |
| 647 | 647 | 'seomatic/global' => [ |
| 648 | 648 | 'route' => 'seomatic/settings/global', |
| 649 | - 'defaults' => ['subSection' => 'general'], |
|
| 649 | + 'defaults' => [ 'subSection' => 'general' ], |
|
| 650 | 650 | ], |
| 651 | 651 | 'seomatic/global/<subSection:{handle}>' => |
| 652 | 652 | 'seomatic/settings/global', |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | |
| 666 | 666 | 'seomatic/site' => [ |
| 667 | 667 | 'route' => 'seomatic/settings/site', |
| 668 | - 'defaults' => ['subSection' => 'identity'], |
|
| 668 | + 'defaults' => [ 'subSection' => 'identity' ], |
|
| 669 | 669 | ], |
| 670 | 670 | 'seomatic/site/<subSection:{handle}>' => |
| 671 | 671 | 'seomatic/settings/site', |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | |
| 675 | 675 | 'seomatic/tracking' => [ |
| 676 | 676 | 'route' => 'seomatic/settings/tracking', |
| 677 | - 'defaults' => ['subSection' => 'googleAnalytics'], |
|
| 677 | + 'defaults' => [ 'subSection' => 'googleAnalytics' ], |
|
| 678 | 678 | ], |
| 679 | 679 | 'seomatic/tracking/<subSection:{handle}>' => |
| 680 | 680 | 'seomatic/settings/tracking', |
@@ -698,19 +698,19 @@ discard block |
||
| 698 | 698 | [ |
| 699 | 699 | 'key' => 'seomatic-frontendtemplate-caches', |
| 700 | 700 | 'label' => Craft::t('seomatic', 'SEOmatic frontend template caches'), |
| 701 | - 'action' => [Seomatic::$plugin->frontendTemplates, 'invalidateCaches'], |
|
| 701 | + 'action' => [ Seomatic::$plugin->frontendTemplates, 'invalidateCaches' ], |
|
| 702 | 702 | ], |
| 703 | 703 | // Meta bundle caches |
| 704 | 704 | [ |
| 705 | 705 | 'key' => 'seomatic-metabundle-caches', |
| 706 | 706 | 'label' => Craft::t('seomatic', 'SEOmatic metadata caches'), |
| 707 | - 'action' => [Seomatic::$plugin->metaContainers, 'invalidateCaches'], |
|
| 707 | + 'action' => [ Seomatic::$plugin->metaContainers, 'invalidateCaches' ], |
|
| 708 | 708 | ], |
| 709 | 709 | // Sitemap caches |
| 710 | 710 | [ |
| 711 | 711 | 'key' => 'seomatic-sitemap-caches', |
| 712 | 712 | 'label' => Craft::t('seomatic', 'SEOmatic sitemap caches'), |
| 713 | - 'action' => [Seomatic::$plugin->sitemaps, 'invalidateCaches'], |
|
| 713 | + 'action' => [ Seomatic::$plugin->sitemaps, 'invalidateCaches' ], |
|
| 714 | 714 | ], |
| 715 | 715 | ]; |
| 716 | 716 | } |
@@ -734,9 +734,9 @@ discard block |
||
| 734 | 734 | $metaBundle, |
| 735 | 735 | MetaScriptContainer::CONTAINER_TYPE |
| 736 | 736 | ); |
| 737 | - $scriptsPerms = []; |
|
| 737 | + $scriptsPerms = [ ]; |
|
| 738 | 738 | foreach ($scripts as $scriptHandle => $scriptData) { |
| 739 | - $scriptsPerms["seomatic:tracking-scripts:${scriptHandle}"] = [ |
|
| 739 | + $scriptsPerms[ "seomatic:tracking-scripts:${scriptHandle}" ] = [ |
|
| 740 | 740 | 'label' => Craft::t('seomatic', $scriptData->name), |
| 741 | 741 | ]; |
| 742 | 742 | } |
@@ -83,26 +83,26 @@ |
||
| 83 | 83 | public function rules() |
| 84 | 84 | { |
| 85 | 85 | return [ |
| 86 | - ['pluginName', 'string'], |
|
| 87 | - ['pluginName', 'default', 'value' => 'SEOmatic'], |
|
| 88 | - ['renderEnabled', 'boolean'], |
|
| 89 | - ['environment', 'string'], |
|
| 90 | - ['environment', 'default', 'value' => 'live'], |
|
| 91 | - ['environment', 'in', 'range' => [ |
|
| 86 | + [ 'pluginName', 'string' ], |
|
| 87 | + [ 'pluginName', 'default', 'value' => 'SEOmatic' ], |
|
| 88 | + [ 'renderEnabled', 'boolean' ], |
|
| 89 | + [ 'environment', 'string' ], |
|
| 90 | + [ 'environment', 'default', 'value' => 'live' ], |
|
| 91 | + [ 'environment', 'in', 'range' => [ |
|
| 92 | 92 | 'live', |
| 93 | 93 | 'staging', |
| 94 | 94 | 'local', |
| 95 | - ]], |
|
| 96 | - ['displayPreviewSidebar', 'boolean'], |
|
| 97 | - ['displayAnalysisSidebar', 'boolean'], |
|
| 98 | - ['devModeTitlePrefix', 'string'], |
|
| 99 | - ['devModeTitlePrefix', 'default', 'value' => '[devMode] '], |
|
| 100 | - ['separatorChar', 'string'], |
|
| 101 | - ['separatorChar', 'default', 'value' => '|'], |
|
| 102 | - ['maxTitleLength', 'integer', 'min' => 10], |
|
| 103 | - ['maxTitleLength', 'default', 'value' => 120], |
|
| 104 | - ['maxDescriptionLength', 'integer', 'min' => 10], |
|
| 105 | - ['maxDescriptionLength', 'default', 'value' => 300], |
|
| 95 | + ] ], |
|
| 96 | + [ 'displayPreviewSidebar', 'boolean' ], |
|
| 97 | + [ 'displayAnalysisSidebar', 'boolean' ], |
|
| 98 | + [ 'devModeTitlePrefix', 'string' ], |
|
| 99 | + [ 'devModeTitlePrefix', 'default', 'value' => '[devMode] ' ], |
|
| 100 | + [ 'separatorChar', 'string' ], |
|
| 101 | + [ 'separatorChar', 'default', 'value' => '|' ], |
|
| 102 | + [ 'maxTitleLength', 'integer', 'min' => 10 ], |
|
| 103 | + [ 'maxTitleLength', 'default', 'value' => 120 ], |
|
| 104 | + [ 'maxDescriptionLength', 'integer', 'min' => 10 ], |
|
| 105 | + [ 'maxDescriptionLength', 'default', 'value' => 300 ], |
|
| 106 | 106 | ]; |
| 107 | 107 | } |
| 108 | 108 | } |