Created
April 1, 2020 13:48
-
-
Save CrazyBoy49z/326b9ce1f61424368d26f16c3dbd3fa7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$stercseo = $modx->getService('stercseo', 'StercSEO', $modx->getOption('stercseo.core_path', null, $modx->getOption('core_path').'components/stercseo/').'model/stercseo/', array()); | |
if (!($stercseo instanceof StercSEO)) { | |
return; | |
} | |
$resources = $modx->getCollection("modResource"); | |
foreach ($resources as $k => $resource) { | |
$properties = $resource->getProperties('stercseo'); | |
if (!empty($properties)) { | |
$newProperties = [ | |
'index' => $properties['index'], | |
'follow' => $properties['follow'], | |
'sitemap' => $properties['sitemap'], | |
'priority' => $properties['priority'], | |
'changefreq' => $properties['changefreq'] | |
]; | |
} else { | |
$newProperties = [ | |
'index' => $stercseo->getOption('stercseo.index', null, '1'), | |
'follow' => $stercseo->getOption('stercseo.follow', null, '1'), | |
'sitemap' => $stercseo->getOption('stercseo.sitemap', null, '1'), | |
'priority' => $stercseo->getOption('stercseo.priority', null, '0.5'), | |
'changefreq' => $stercseo->getOption('stercseo.changefreq', null, 'weekly') | |
); | |
} | |
$resource->setProperties($newProperties, 'stercseo'); | |
$resource->save(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment