diff --git a/classes/ComicPressMediaHandling.inc b/classes/ComicPressMediaHandling.inc index 1071585..d3892b1 100644 --- a/classes/ComicPressMediaHandling.inc +++ b/classes/ComicPressMediaHandling.inc @@ -58,13 +58,19 @@ class ComicPressMediaHandling { return $result; } - function _abspath() { return ABSPATH; } + function _abspath() { + return ABSPATH; + } function _expand_filter_callback($matches) { $value = ''; switch (strtolower($matches[1])) { case 'wordpress': - $value = $this->_abspath(); + if ($path = get_option('upload_path')) { + $value = $path; + } else { + $value = $this->_abspath(); + } break; case 'type-folder': $value = $this->type_filter; diff --git a/test/ComicPressMediaHandlingTest.php b/test/ComicPressMediaHandlingTest.php index 358c1c5..4a88e9e 100644 --- a/test/ComicPressMediaHandlingTest.php +++ b/test/ComicPressMediaHandlingTest.php @@ -85,16 +85,21 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase { array('%wordpress%/%type-folder%', vfsStream::url('root') . '/comic'), array('%date-Y%', '2009'), array('%wordpress%/%type-folder%/%date-Y-m-d%*.*', vfsStream::url('root') . '/comic/2009-01-01.*\..*'), + array('%wordpress%/%type-folder%/%date-Y-m-d%*.*', '/wpmupath/comic/2009-01-01.*\..*', '/wpmupath'), ); } /** * @dataProvider providerTestExpandFilter */ - function testExpandFilter($filter, $expected_result) { + function testExpandFilter($filter, $expected_result, $use_option_path = false) { $cpmh = $this->getMock('ComicPressMediaHandling', array('_abspath')); $cpmh->expects($this->any())->method('_abspath')->will($this->returnValue(vfsStream::url('root'))); + if ($use_option_path !== false) { + update_option('upload_path', $use_option_path); + } + $this->assertEquals($expected_result, $cpmh->_expand_filter($filter, 'comic', (object)array('ID' => 1, 'post_date' => '2009-01-01 15:00:00'))); } }