From 9a3dba75dcc24bb2e5f612cfee3cd805f79f4e74 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 20 Jan 2010 07:46:40 -0500 Subject: [PATCH] add support for filters from options --- classes/ComicPressMediaHandling.inc | 4 ++++ test/ComicPressMediaHandlingTest.php | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/classes/ComicPressMediaHandling.inc b/classes/ComicPressMediaHandling.inc index 658ad83..76c1307 100644 --- a/classes/ComicPressMediaHandling.inc +++ b/classes/ComicPressMediaHandling.inc @@ -30,6 +30,10 @@ class ComicPressMediaHandling { if (isset($comic_filename_filters[$filter_to_use])) { return $this->_convert_to_percent_filter($comic_filename_filters[$filter_to_use]); } + $options = get_option('comicpress_options'); + if (isset($options['comic_filename_filters'][$filter_to_use])) { + return $this->_convert_to_percent_filter($options['comic_filename_filters'][$filter_to_use]); + } } } diff --git a/test/ComicPressMediaHandlingTest.php b/test/ComicPressMediaHandlingTest.php index 5d56470..d79578a 100644 --- a/test/ComicPressMediaHandlingTest.php +++ b/test/ComicPressMediaHandlingTest.php @@ -41,7 +41,8 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase { array(null, $default), array('fail', $default), array(array(), $default), - array('test', 'test') + array('test', 'test'), + array('test-from-option', 'test-from-option'), ); } @@ -53,6 +54,12 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase { $comic_filename_filters['test'] = 'test'; + update_option('comicpress_options', array( + 'comic_filename_filters' => array( + 'test-from-option' => 'test-from-option' + ) + )); + $default = str_replace('{date}', $this->cpmh->default_filename_filter, $this->cpmh->default_filter); $cpmh = $this->getMock('ComicPressMediaHandling', array('_convert_to_percent_filter'));