diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6ed140c..bafca85 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,6 @@
dev
-- [ ] add priority on filters for replacement order
-- [ ] add priority on lists of filters for replacement order
- [ ] add auto-find post title in content
+- add priority on filters for replacement order
- split filters into modules
- add autosubmit onadmin menu
- move sort options from blog pref to user pref
diff --git a/inc/lib.epc.filter.php b/inc/lib.epc.filter.php
index 87d19cb..413fce5 100644
--- a/inc/lib.epc.filter.php
+++ b/inc/lib.epc.filter.php
@@ -19,6 +19,7 @@ abstract class epcFilter
private $records = null;
private $properties = [
+ 'priority' => 500,
'name' => 'undefined',
'help' => 'undefined',
'has_list' => false,
diff --git a/inc/lib.epc.filters.php b/inc/lib.epc.filters.php
index 09253bf..82f358f 100644
--- a/inc/lib.epc.filters.php
+++ b/inc/lib.epc.filters.php
@@ -16,12 +16,13 @@ class epcFilterTag extends epcFilter
protected function init(): string
{
$this->setProperties([
- 'name' => __('Tag'),
- 'help' => __('Highlight tags of your blog.'),
- 'htmltag' => 'a',
- 'class' => ['a.epc-tag'],
- 'replace' => '%s',
- 'widget' => '%s'
+ 'priority' => 900,
+ 'name' => __('Tag'),
+ 'help' => __('Highlight tags of your blog.'),
+ 'htmltag' => 'a',
+ 'class' => ['a.epc-tag'],
+ 'replace' => '%s',
+ 'widget' => '%s'
]);
$this->setSettings([
@@ -80,6 +81,7 @@ class epcFilterSearch extends epcFilter
protected function init(): string
{
$this->setProperties([
+ 'priority' => 100,
'name' => __('Search'),
'help' => __('Highlight searched words.'),
'htmltag' => '',
@@ -125,6 +127,7 @@ class epcFilterAcronym extends epcFilter
protected function init(): string
{
$this->setProperties([
+ 'priority' => 700,
'name' => __('Acronym'),
'help' => __('Explain some acronyms. First term of the list is the acornym and second term the explanation.'),
'has_list' => true,
@@ -178,6 +181,7 @@ class epcFilterAbbreviation extends epcFilter
protected function init(): string
{
$this->setProperties([
+ 'priority' => 400,
'name' => __('Abbreviation'),
'help' => __('Explain some abbreviation. First term of the list is the abbreviation and second term the explanation.'),
'has_list' => true,
@@ -231,6 +235,7 @@ class epcFilterDefinition extends epcFilter
protected function init(): string
{
$this->setProperties([
+ 'priority' => 800,
'name' => __('Definition'),
'help' => __('Explain some definition. First term of the list is the sample to define and second term the explanation.'),
'has_list' => true,
@@ -284,6 +289,7 @@ class epcFilterCitation extends epcFilter
protected function init(): string
{
$this->setProperties([
+ 'priority' => 600,
'name' => __('Citation'),
'help' => __('Highlight citation of people. First term of the list is the citation and second term the author.'),
'has_list' => true,
@@ -338,6 +344,7 @@ class epcFilterLink extends epcFilter
protected function init(): string
{
$this->setProperties([
+ 'priority' => 500,
'name' => __('Link'),
'help' => __('Link some words. First term of the list is the term to link and second term the link.'),
'has_list' => true,
@@ -391,6 +398,7 @@ class epcFilterReplace extends epcFilter
protected function init(): string
{
$this->setProperties([
+ 'priority' => 200,
'name' => __('Replace'),
'help' => __('Replace some text. First term of the list is the text to replace and second term the replacement.'),
'has_list' => true,
@@ -431,6 +439,7 @@ class epcFilterUpdate extends epcFilter
protected function init(): string
{
$this->setProperties([
+ 'priority' => 300,
'name' => __('Update'),
'help' => __('Update and show terms. First term of the list is the term to update and second term the new term.'),
'has_list' => true,
@@ -471,6 +480,7 @@ class epcFilterTwitter extends epcFilter
protected function init(): string
{
$this->setProperties([
+ 'priority' => 1000,
'name' => __('Twitter'),
'help' => __('Add link to twitter user page. Every word started with "@" will be considered as twitter user.'),
'htmltag' => 'a',
diff --git a/inc/lib.epc.php b/inc/lib.epc.php
index 6ed2892..3cec725 100644
--- a/inc/lib.epc.php
+++ b/inc/lib.epc.php
@@ -103,7 +103,7 @@ class libEPC
global $core;
if (self::$default_filters === null) {
- $final = [];
+ $final = $sort = [];
$filters = new arrayObject();
try {
@@ -111,12 +111,14 @@ class libEPC
foreach($filters as $filter) {
if ($filter instanceOf epcFilter && !isset($final[$filter->id()])) {
+ $sort[$filter->id()] = $filter->priority;
$final[$filter->id()] = $filter;
}
}
} catch (Exception $e) {
$core->error->add($e->getMessage());
}
+ array_multisort($sort, $final);
self::$default_filters = $final;
}