Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sitemap: useless actions sitemap-additem and save-sitemap
#6
(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');
}
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply


Messages In This Thread
RE: Sitemap: useless actions sitemap-additem and save-sitemap - by mvlcek - 2012-12-06, 03:25:48



Users browsing this thread: 1 Guest(s)