add upload-path media option

This commit is contained in:
John Bintz 2010-01-20 06:14:28 -05:00
parent 1f7702ac6c
commit c5500420e9
2 changed files with 7 additions and 1 deletions

View File

@ -96,6 +96,9 @@ class ComicPressMediaHandling {
case 'type-folder': case 'type-folder':
$value = $this->type_folder; $value = $this->type_folder;
break; break;
case 'upload-path':
$value = get_option('upload_path');
break;
default: default:
if (preg_match('#^date-(.*)$#', $matches[1], $date_matches) > 0) { if (preg_match('#^date-(.*)$#', $matches[1], $date_matches) > 0) {
if (isset($this->post_to_use)) { if (isset($this->post_to_use)) {

View File

@ -95,7 +95,8 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase {
array('%test test%', '%test test%'), array('%test test%', '%test test%'),
array('%wordpress%/%type-folder%', vfsStream::url('root') . '/comic'), array('%wordpress%/%type-folder%', vfsStream::url('root') . '/comic'),
array('%date-Y%', '2009'), 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%*.*', vfsStream::url('root') . '/comic/2009-01-01.*\..*'),
array('%wordpress%/%upload-path%/%type-folder%/%date-Y-m-d%*.*', vfsStream::url('root') . '/1/files/comic/2009-01-01.*\..*')
); );
} }
@ -106,6 +107,8 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase {
$cpmh = $this->getMock('ComicPressMediaHandling', array('_abspath')); $cpmh = $this->getMock('ComicPressMediaHandling', array('_abspath'));
$cpmh->expects($this->any())->method('_abspath')->will($this->returnValue(vfsStream::url('root'))); $cpmh->expects($this->any())->method('_abspath')->will($this->returnValue(vfsStream::url('root')));
update_option('upload_path', '1/files');
$this->assertEquals($expected_result, $cpmh->_expand_filter($filter, 'comic', (object)array('ID' => 1, 'post_date' => '2009-01-01 15:00:00'))); $this->assertEquals($expected_result, $cpmh->_expand_filter($filter, 'comic', (object)array('ID' => 1, 'post_date' => '2009-01-01 15:00:00')));
} }