diff --git a/classes/ComicPressMediaHandling.inc b/classes/ComicPressMediaHandling.inc index 367905d..0f657f8 100644 --- a/classes/ComicPressMediaHandling.inc +++ b/classes/ComicPressMediaHandling.inc @@ -177,7 +177,7 @@ class ComicPressMediaHandling { $uri = preg_replace_callback('#%([a-z0-9-]+)%#i', array(&$this, '_expand_filter_callback'), $uri); - return trailingslashit(get_bloginfo('url')) . $uri; + return $uri; } } } @@ -198,8 +198,8 @@ class ComicPressMediaHandling { $post_to_use = !is_null($override_post) ? $override_post : $post; if ($uri = $this->_check_post_meta_data($post_to_use, $type)) { - if ($result = $this->_ensure_valid_url($uri, $type)) { - return $result; + if ($result = $this->_ensure_valid_uri($uri, $type)) { + return preg_replace('#^/#', '', $result); } } diff --git a/classes/ComicPressPostMediaHandlingMetabox.inc b/classes/ComicPressPostMediaHandlingMetabox.inc index 5ee030b..b4794c8 100644 --- a/classes/ComicPressPostMediaHandlingMetabox.inc +++ b/classes/ComicPressPostMediaHandlingMetabox.inc @@ -17,7 +17,7 @@ class ComicPressPostMediaHandlingMetabox { $result = array(); if (isset($info['urls'])) { if (is_array($info['urls'])) { - $valid_types = $this->_get_valid_types(); + $valid_types = ComicPressPostMediaHandlingMetabox::_get_valid_types(); foreach ($info['urls'] as $field => $value) { if (in_array($field, $valid_types)) { $result[$field] = strip_tags($value); diff --git a/comicpress-config.php b/comicpress-config.php index e21900b..6e1978b 100644 --- a/comicpress-config.php +++ b/comicpress-config.php @@ -1,10 +1,10 @@ \ No newline at end of file diff --git a/functions.php b/functions.php index f5b0793..4ccf03c 100644 --- a/functions.php +++ b/functions.php @@ -49,14 +49,14 @@ function __comicpress_init() { } if (isset($_REQUEST['cp']['_nonce'])) { - if (wp_verify_nonce('comicpress', $_REQUEST['cp']['_nonce'])) { + if (wp_verify_nonce($_REQUEST['cp']['_nonce'], 'comicpress')) { if (isset($_REQUEST['cp']['action'])) { if (isset($_REQUEST['cp']['_action_nonce'])) { - if (wp_verify_nonce('comicpress-' . $_REQUEST['cp']['action'], $_REQUEST['cp']['_action_nonce'])) { - $method_name = 'handle_' . str_replace('-', '_', $_REQUEST['cp']['_action_nonce']); + if (wp_verify_nonce($_REQUEST['cp']['_action_nonce'], 'comicpress-' . $_REQUEST['cp']['action'])) { + $method_name = 'handle_' . str_replace('-', '_', $_REQUEST['cp']['action']); foreach ($__comicpress_handlable_classes as $class_name) { if (method_exists($class_name, $method_name)) { - $class_name->{$method_name}($_REQUEST['cp']); + call_user_func(array($class_name, $method_name), $_REQUEST['cp']); } } } @@ -460,16 +460,13 @@ function get_comic_path($folder = 'comic', $override_post = null, $filter = 'def * @param string $filter The $comic_filename_filters to use. * @return string The absolute URL to the comic file, or false if not found. */ -function get_comic_url($folder = 'comic', $override_post = null, $filter = 'default') { - if (($result = get_comic_path($folder, $override_post, $filter)) !== false) { - return get_bloginfo('wpurl') . '/' . $result; - } else { - if (($result = get_comic_path('comic', $override_post, $filter)) !== false) { - $basecomic = basename($result); - return get_bloginfo('wpurl') . '/' . $result; +function get_comic_url($type = 'comic', $override_post = null, $filter = 'default') { + foreach (array_unique(array($type, 'comic')) as $which_type) { + if (($result = get_comic_path($which_type, $override_post, $filter)) !== false) { + return trailingslashit(get_bloginfo('url')) . $result; } } - return $result; + return false; } /** diff --git a/test/ComicPressMediaHandlingTest.php b/test/ComicPressMediaHandlingTest.php index 6d09695..f0354bd 100644 --- a/test/ComicPressMediaHandlingTest.php +++ b/test/ComicPressMediaHandlingTest.php @@ -247,8 +247,8 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase { function providerTestEnsureValidURI() { return array( array('', false), - array('test', 'wordpress/test'), - array('%type-folder%/test', 'wordpress/comic-dir/test'), + array('test', 'test'), + array('%type-folder%/test', 'comic-dir/test'), array('/test', '/test'), array('http://file', 'http://file'), ); @@ -272,6 +272,6 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase { $cpmh = $this->getMock('ComicPressMediaHandling', array('_bundle_global_variables')); $cpmh->expects($this->any())->method('_bundle_global_variables')->will($this->returnValue(array('comic' => 'comic-dir'))); - $this->assertEquals('wordpress/', $cpmh->_ensure_valid_uri('%type-folder%', 'test')); + $this->assertEquals('', $cpmh->_ensure_valid_uri('%type-folder%', 'test')); } }