add support for filters from options

This commit is contained in:
John Bintz 2010-01-20 07:46:40 -05:00
parent 85c46dbc3a
commit 9a3dba75dc
2 changed files with 12 additions and 1 deletions

View File

@ -30,6 +30,10 @@ class ComicPressMediaHandling {
if (isset($comic_filename_filters[$filter_to_use])) { if (isset($comic_filename_filters[$filter_to_use])) {
return $this->_convert_to_percent_filter($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]);
}
} }
} }

View File

@ -41,7 +41,8 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase {
array(null, $default), array(null, $default),
array('fail', $default), array('fail', $default),
array(array(), $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'; $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); $default = str_replace('{date}', $this->cpmh->default_filename_filter, $this->cpmh->default_filter);
$cpmh = $this->getMock('ComicPressMediaHandling', array('_convert_to_percent_filter')); $cpmh = $this->getMock('ComicPressMediaHandling', array('_convert_to_percent_filter'));