summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-03-05 09:49:15 +0300
committerAndrew Dolgov <[email protected]>2021-03-05 09:49:15 +0300
commit57d244de854c8fa00335285f785a93ca97eef535 (patch)
treebea9d5340a09bd0aac9ebf48cb2bf9f532ef8ac7
initial
-rw-r--r--init.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/init.php b/init.php
new file mode 100644
index 0000000..bb9e840
--- /dev/null
+++ b/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 (with score)"
+ ];
+ }
+
+ function hook_headlines_custom_sort_override($order) {
+ if ($order == "dates_reverse_scored") {
+ return [ "score DESC, updated", true ];
+ } else {
+ return [ "", false ];
+ }
+ }
+
+ function about() {
+ return array(null,
+ "Consider article score while sorting by oldest first",
+ "fox",
+ false,
+ "");
+ }
+
+ function api_version() {
+ return 2;
+ }
+
+}