Skip to content

Commit

Permalink
sort pages by settings key
Browse files Browse the repository at this point in the history
  • Loading branch information
james2doyle committed Jan 8, 2014
1 parent bd2c6f5 commit e347713
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,18 @@ public function on($eventKey, $data = null) {
'title' => $pages[$i]->getTitle(),
'url' => $pages[$i]->getUrl(),
'content' => $pages[$i]->getContent(),
'meta' => $pages[$i]->getMeta()
'meta' => $pages[$i]->getMeta(),
'date' => $pages[$i]->getMeta()['date']
);
}

function build_sorter($key) {
return function ($a, $b) use ($key) {
return strnatcmp($b[$key], $a[$key]);
};
}

usort($this->config['pages'], build_sorter($this->settings['post_key']));
// set the appropriate headers to RSS feeds
header($_SERVER['SERVER_PROTOCOL'].' 200 OK');
header("Content-Type: application/rss+xml; charset=UTF-8");
Expand Down

0 comments on commit e347713

Please sign in to comment.