diff options
author | Andrew Dolgov <[email protected]> | 2021-01-17 10:47:37 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-01-17 10:47:37 +0300 |
commit | c82457e534a573d5838ccecd9ab94cf7c5b05cc2 (patch) | |
tree | 7973919b6fb4756dccb090d493cf877b690b2055 /plugins | |
parent | bc0d50e892f9fd7bc83d4e745670cd2799b20e5d (diff) |
add plugins/scored_oldest_first
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/scored_oldest_first/init.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/plugins/scored_oldest_first/init.php b/plugins/scored_oldest_first/init.php new file mode 100644 index 000000000..087253de1 --- /dev/null +++ b/plugins/scored_oldest_first/init.php @@ -0,0 +1,35 @@ +<?php +class Scored_Oldest_First extends Plugin { + + function init($host) { + $host->add_hook($host::HOOK_HEADLINES_CUSTOM_SORT_MAP, $this); + $host->add_hook($host::HOOK_HEADLINES_CUSTOM_SORT_OVERRIDE, $this); + } + + function hook_headlines_custom_sort_map() { + return [ + "dates_reverse_scored" => "Oldest first (legacy)" + ]; + } + + function hook_headlines_custom_sort_override($order) { + if ($order == "dates_reverse_scored") { + return [ "score DESC, updated", true ]; + } else { + return [ "", false ]; + } + } + + function about() { + return array(1.0, + "Consider article score while sorting by oldest first", + "fox", + false, + ""); + } + + function api_version() { + return 2; + } + +} |