clean up setting meta box info

This commit is contained in:
John Bintz 2009-12-04 22:59:08 -05:00
parent 5a717b627f
commit 9737569e95
5 changed files with 18 additions and 23 deletions

View File

@ -177,7 +177,7 @@ class ComicPressMediaHandling {
$uri = preg_replace_callback('#%([a-z0-9-]+)%#i', array(&$this, '_expand_filter_callback'), $uri); $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; $post_to_use = !is_null($override_post) ? $override_post : $post;
if ($uri = $this->_check_post_meta_data($post_to_use, $type)) { if ($uri = $this->_check_post_meta_data($post_to_use, $type)) {
if ($result = $this->_ensure_valid_url($uri, $type)) { if ($result = $this->_ensure_valid_uri($uri, $type)) {
return $result; return preg_replace('#^/#', '', $result);
} }
} }

View File

@ -17,7 +17,7 @@ class ComicPressPostMediaHandlingMetabox {
$result = array(); $result = array();
if (isset($info['urls'])) { if (isset($info['urls'])) {
if (is_array($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) { foreach ($info['urls'] as $field => $value) {
if (in_array($field, $valid_types)) { if (in_array($field, $valid_types)) {
$result[$field] = strip_tags($value); $result[$field] = strip_tags($value);

View File

@ -1,10 +1,10 @@
<?php <?php
//COMIC CATEGORY -the WordPress ID # of your comic category (default "3") //COMIC CATEGORY -the WordPress ID # of your comic category (default "3")
$comiccat = "3"; $comiccat = "55";
//BLOG CATEGORY - the WordPress ID of your blog category (default "1") //BLOG CATEGORY - the WordPress ID of your blog category (default "1")
$blogcat = "1"; $blogcat = "58";
//COMIC FOLDER - the folder your comics files are located in (default "comics") //COMIC FOLDER - the folder your comics files are located in (default "comics")
$comic_folder = "comics"; $comic_folder = "comics";
@ -29,5 +29,3 @@ $mini_comic_width = "80";
//Minithumb Comic Folder - The folder for your your mini thumbs (default "comics-mini") //Minithumb Comic Folder - The folder for your your mini thumbs (default "comics-mini")
$mini_comic_folder = "comics-mini"; $mini_comic_folder = "comics-mini";
?>

View File

@ -49,14 +49,14 @@ function __comicpress_init() {
} }
if (isset($_REQUEST['cp']['_nonce'])) { 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'])) {
if (isset($_REQUEST['cp']['_action_nonce'])) { if (isset($_REQUEST['cp']['_action_nonce'])) {
if (wp_verify_nonce('comicpress-' . $_REQUEST['cp']['action'], $_REQUEST['cp']['_action_nonce'])) { if (wp_verify_nonce($_REQUEST['cp']['_action_nonce'], 'comicpress-' . $_REQUEST['cp']['action'])) {
$method_name = 'handle_' . str_replace('-', '_', $_REQUEST['cp']['_action_nonce']); $method_name = 'handle_' . str_replace('-', '_', $_REQUEST['cp']['action']);
foreach ($__comicpress_handlable_classes as $class_name) { foreach ($__comicpress_handlable_classes as $class_name) {
if (method_exists($class_name, $method_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. * @param string $filter The $comic_filename_filters to use.
* @return string The absolute URL to the comic file, or false if not found. * @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') { function get_comic_url($type = 'comic', $override_post = null, $filter = 'default') {
if (($result = get_comic_path($folder, $override_post, $filter)) !== false) { foreach (array_unique(array($type, 'comic')) as $which_type) {
return get_bloginfo('wpurl') . '/' . $result; if (($result = get_comic_path($which_type, $override_post, $filter)) !== false) {
} else { return trailingslashit(get_bloginfo('url')) . $result;
if (($result = get_comic_path('comic', $override_post, $filter)) !== false) {
$basecomic = basename($result);
return get_bloginfo('wpurl') . '/' . $result;
} }
} }
return $result; return false;
} }
/** /**

View File

@ -247,8 +247,8 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase {
function providerTestEnsureValidURI() { function providerTestEnsureValidURI() {
return array( return array(
array('', false), array('', false),
array('test', 'wordpress/test'), array('test', 'test'),
array('%type-folder%/test', 'wordpress/comic-dir/test'), array('%type-folder%/test', 'comic-dir/test'),
array('/test', '/test'), array('/test', '/test'),
array('http://file', 'http://file'), array('http://file', 'http://file'),
); );
@ -272,6 +272,6 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase {
$cpmh = $this->getMock('ComicPressMediaHandling', array('_bundle_global_variables')); $cpmh = $this->getMock('ComicPressMediaHandling', array('_bundle_global_variables'));
$cpmh->expects($this->any())->method('_bundle_global_variables')->will($this->returnValue(array('comic' => 'comic-dir'))); $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'));
} }
} }