(2012-12-06, 02:47:49)Carlos Wrote: It seems this can be fixed by inserting this in function generate_sitemap()
Code:global $xml, $page;
...
Any opinions, suggestions? Do you think it should be fixed other way, maybe new different hooks for Sitemap...?
To really solve issues like that I think that the action concept needs to be enhanced:
- pass arguments to actions instead of relying on global variables (not needed here)
- evaluate the return parameter
Then three actions (or rather two actions and one filter) can be used to allow for all eventualities:
Code:
function generate_sitemap() {
# for special purposes, where the whole sitemap is generated by a plugin
$done = exec_action('output-sitemap');
if ($done) { exec_action('save-sitemap'); return; }
...
foreach ($pagesSorted as $page) {
$page = exec_filter('sitemap-additem', $page);
# filter returns null to have page ignored
# filter may adjust any fields, like private and add 'loc', ... (see below)
if ($page) {
# use $page['loc'], $page['lastmod'], $page['changefreq'], $page['priority'], if set
# otherwise set them as now
...
}
}
...
XMLsave($xml, $file);
exec_action('save-sitemap');
}